| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class GameInitializer : MonoBehaviour
- {
- public TeamCohesionManager cohesionManager;
- public PositionGridManager gridManager;
- public PartyUIManager uiManager;
-
- [Header("Respawn Settings")]
- public bool saveInitialCheckpoint = true;
- public float checkpointDelay = 2f;
- void Start()
- {
- CharacterInGroup starter = new CharacterInGroup
- {
- characterName = "Aryn",
- characterType = CharacterInGroup.CharacterType.Warrior,
- personality = CharacterInGroup.PersonalityType.Loyal,
- race = CharacterInGroup.RaceType.Human,
- age = 32,
- isMale = true,
- // Attributs
- strength = 12,
- constitution = 8,
- intelligence = 6,
- agility = 4,
- // Position sur la grille
- gridX = 2,
- gridY = 4,
- // Points de vie
- maxHP = 100,
- currentHP = 100,
- // Mana
- maxMana = 20,
- currentMana = 20,
- // Fatigue
- maxFatigue = 100,
- currentFatigue = 100,
- // Progression
- level = 1,
- experience = 0
- };
- starter.learnedSkills.Add(new LearnedSkill { skillName = "Coup puissant", skillLevel = 1 });
- starter.learnedSkills.Add(new LearnedSkill { skillName = "Frappe tourbillonnante", skillLevel = 1 });
- starter.learnedSkills.Add(new LearnedSkill { skillName = "Boule de Feu", skillLevel = 1 });
- cohesionManager.groupMembers = new List<CharacterInGroup> { starter };
- gridManager.characters = new List<CharacterInGroup> { starter };
- Debug.Log("Héros initial ajouté : " + starter.characterName);
-
- // Save initial checkpoint after setup
- if (saveInitialCheckpoint)
- {
- StartCoroutine(SaveInitialCheckpointDelayed());
- }
- }
-
- /// <summary>
- /// Save initial checkpoint after a short delay to ensure everything is initialized
- /// </summary>
- private IEnumerator SaveInitialCheckpointDelayed()
- {
- yield return new WaitForSeconds(checkpointDelay);
-
- // Find CheckpointSystem in scene
- var checkpointSystemObj = GameObject.Find("CheckpointSystem");
- if (checkpointSystemObj != null)
- {
- checkpointSystemObj.SendMessage("SaveCheckpoint", SendMessageOptions.DontRequireReceiver);
- Debug.Log("[GameInitializer] Initial checkpoint saved");
- }
- else
- {
- Debug.LogWarning("[GameInitializer] CheckpointSystem not found, cannot save initial checkpoint");
- }
- }
- }
|