Esempio n. 1
0
        // Cette histoire d'identifiant c'est un peu relou pour rien.
        // Retiens que le système ne marche pas dans certains cas comme : "Si je change le contenu du coffre, l'identifiant change aussi"
        // Donc c'est baisé
        private void Awake()
        {
#if UNITY_EDITOR
            if (!UnityEditor.EditorApplication.isPlaying)
            {
                if (Time.frameCount != 0 && Time.renderedFrameCount != 0)//not loading scene
                {
                    base.Awake();
                    if (chestPanel == null) // Ouch
                        chestPanel = GameObject.Find("CanvasInteract/Parent/PanelTreasure");
                    if (objectName == null) // Ouch
                        objectName = GameObject.Find("CanvasInteract/Parent/PanelTreasure/PopupTreasure/ObjectIcon/ObjectName").GetComponent<TextMeshProUGUI>();
                    if (objectDescription == null) // Ouch
                        objectDescription = GameObject.Find("CanvasInteract/Parent/PanelTreasure/PopupObjectDescription/TextObjectDescription").GetComponent<TextMeshProUGUI>();
                    if (chestAnimator == null)
                        chestAnimator = GetComponent<Animator>();

                    if (chestDatabase == null)
                        chestDatabase = AssetDatabase.LoadAssetAtPath<GameVariableDatabase>(UnityEditor.AssetDatabase.GUIDToAssetPath(UnityEditor.AssetDatabase.FindAssets("VariableDatabaseChest")[0]));
                    
                    if (chestDatabase.CheckExist(chestID) == true)
                    {
                        Debug.Log("Je créer un nouvel identifiant dans la base de données");
                        chestID = "Chest_" + UnityEngine.SceneManagement.SceneManager.GetActiveScene().name + "_" + chestDatabase.GameVariables.Count;
                        chestDatabase.AddGameVariable(chestID, 0);
                    }
                    else
                    {
                        CreateChestID();
                    }
                }
            }

#endif
        }
Esempio n. 2
0
 // On sauvegarde les valeurs à sauver 
 public void SavePartyData(PlayerDatabase database, GameVariableDatabase variableDatabase, GameVariableDatabase chestDatabase)
 {
     characterSavesData.Clear();
     for (int i = 0; i < characterStatControllers.Count; i++)
     {
         characterSavesData.Add(new CharacterSave(database.GetPlayerData(characterStatControllers[i].CharacterData).name, characterEquipement[i].GetWeaponTotalExp(), characterEquipement[i].GetArmors()));
     }
     gameVariables = variableDatabase.SaveVariables();
     chestVariable = chestDatabase.SaveVariables();
 }
Esempio n. 3
0
        // On utilise les valeurs qu'on a sauver pour re générer les joueurs 
        // Bon le Load c'est un peu n'importe quoi ça fait beaucoup de chose, à refactor peut etre
        public void LoadPartyData(PlayerDatabase database, GameVariableDatabase variableDatabase, GameVariableDatabase chestDatabase, ItemDatabase itemDatabase)
        {
            variableDatabase.LoadVariable(gameVariables);
            chestDatabase.LoadVariable(chestVariable);
            characterStatControllers.Clear();
            characterGrowths.Clear();
            characterEquipement.Clear();
            for (int i = 0; i < characterSavesData.Count; i++)
            {
                PlayerData playerData = database.GetPlayerData(characterSavesData[i].playerDataID);
                characterStatControllers.Add(new CharacterStatController(playerData.CharacterData));
                characterGrowths.Add(new CharacterGrowthController(playerData.CharacterGrowth, characterStatControllers[i]));

                // Convertit les string du json en ArmorData
                List<ArmorData> res = new List<ArmorData>(characterSavesData[i].armorEquipped.Count);
                for (int j = 0; j < characterSavesData[i].armorEquipped.Count; j++)
                {
                    res.Add((ArmorData) itemDatabase.GetItemData(characterSavesData[i].armorEquipped[j]));
                }
                characterEquipement.Add(new CharacterEquipementController(playerData.WeaponEquipped, res, playerData.WeaponLevels, characterSavesData[i].playerExperience, characterStatControllers[i], characterGrowths[i]));

            }
            partyInitialized = new PartyInitialized();
        }