GameInitializer.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. public class GameInitializer : MonoBehaviour
  5. {
  6. public TeamCohesionManager cohesionManager;
  7. public PositionGridManager gridManager;
  8. public PartyUIManager uiManager;
  9. [Header("Respawn Settings")]
  10. public bool saveInitialCheckpoint = true;
  11. public float checkpointDelay = 2f;
  12. void Start()
  13. {
  14. CharacterInGroup starter = new CharacterInGroup
  15. {
  16. characterName = "Aryn",
  17. characterType = CharacterInGroup.CharacterType.Warrior,
  18. personality = CharacterInGroup.PersonalityType.Loyal,
  19. race = CharacterInGroup.RaceType.Human,
  20. age = 32,
  21. isMale = true,
  22. // Attributs
  23. strength = 12,
  24. constitution = 8,
  25. intelligence = 6,
  26. agility = 4,
  27. // Position sur la grille
  28. gridX = 2,
  29. gridY = 4,
  30. // Points de vie
  31. maxHP = 100,
  32. currentHP = 100,
  33. // Mana
  34. maxMana = 20,
  35. currentMana = 20,
  36. // Fatigue
  37. maxFatigue = 100,
  38. currentFatigue = 100,
  39. // Progression
  40. level = 1,
  41. experience = 0
  42. };
  43. starter.learnedSkills.Add(new LearnedSkill { skillName = "Coup puissant", skillLevel = 1 });
  44. starter.learnedSkills.Add(new LearnedSkill { skillName = "Frappe tourbillonnante", skillLevel = 1 });
  45. starter.learnedSkills.Add(new LearnedSkill { skillName = "Boule de Feu", skillLevel = 1 });
  46. cohesionManager.groupMembers = new List<CharacterInGroup> { starter };
  47. gridManager.characters = new List<CharacterInGroup> { starter };
  48. Debug.Log("Héros initial ajouté : " + starter.characterName);
  49. // Save initial checkpoint after setup
  50. if (saveInitialCheckpoint)
  51. {
  52. StartCoroutine(SaveInitialCheckpointDelayed());
  53. }
  54. }
  55. /// <summary>
  56. /// Save initial checkpoint after a short delay to ensure everything is initialized
  57. /// </summary>
  58. private IEnumerator SaveInitialCheckpointDelayed()
  59. {
  60. yield return new WaitForSeconds(checkpointDelay);
  61. // Find CheckpointSystem in scene
  62. var checkpointSystemObj = GameObject.Find("CheckpointSystem");
  63. if (checkpointSystemObj != null)
  64. {
  65. checkpointSystemObj.SendMessage("SaveCheckpoint", SendMessageOptions.DontRequireReceiver);
  66. Debug.Log("[GameInitializer] Initial checkpoint saved");
  67. }
  68. else
  69. {
  70. Debug.LogWarning("[GameInitializer] CheckpointSystem not found, cannot save initial checkpoint");
  71. }
  72. }
  73. }