Esempio n. 1
0
    public void SaveGame()
    {
        string                      sceneName         = SceneLoader.instance.GetSceneName();
        PlayerData                  playerData        = new PlayerData(playerLife, playerScore, playerHealth);
        CollectiblesData            collectiblesData  = new CollectiblesData(collectedKeys);
        List <MovingObjectSaveData> movingObjectsData = new List <MovingObjectSaveData>();

        ObjectMovement[] movingObjects = GameObject.FindObjectsOfType <ObjectMovement>();
        for (int i = 0; i < movingObjects.Length; i++)
        {
            MovingObjectSaveData movingObjectSave = new MovingObjectSaveData(
                movingObjects[i].transform.position,
                movingObjects[i].moveRange,
                movingObjects[i].moveMultiplier,
                movingObjects[i].moveSpeed,
                movingObjects[i].startPos,
                movingObjects[i].moveDir,
                movingObjects[i].endPos
                );
            movingObjectsData.Add(movingObjectSave);
        }

        SceneData dataToSave = new SceneData(
            playerData,
            collectiblesData,
            movingObjectsData
            );

        string filePath = Application.persistentDataPath + "/savedSceneData_" + sessionId + "_" + sceneName + ".ideaprj1sav"; //savedSceneData_123456_Scene1.ideaprj1sav    savedSceneData_123456_Scene2.ideaprj1sav

        SaveData(dataToSave, filePath);

        SaveData(sceneName, Application.persistentDataPath + "/initialData.ideaprj1sav");
        SaveData(sessionId, Application.persistentDataPath + "/initialDataId.ideaprj1sav");
    }
Esempio n. 2
0
        private void createItems()
        {
            CollectiblesData collectiblesData = getCollectiblesData();

            if (collectiblesData == null)
            {
                Log.LogError(this, "CollectiblesData could not be found");
                return;
            }
            List <string> sortedKeys = getSortedKeys(collectiblesData.CollectibleTotals);
            bool          flag       = false;

            for (int i = 0; i < sortedKeys.Count; i++)
            {
                GameObject gameObject = createItem(sortedKeys[i], collectiblesData.CollectibleTotals[sortedKeys[i]], inventoryItemPrefab);
                if (gameObject.GetComponent <ExchangeScreenInventoryItem>().ExchangeItem.CanExchange())
                {
                    totalValidCollectibles++;
                }
                if (collectiblesData.CollectibleTotals[sortedKeys[i]] > 0)
                {
                    flag = true;
                }
            }
            EmptyPanel.SetActive(!flag);
            if (this.ItemsCreated != null)
            {
                this.ItemsCreated();
            }
        }
Esempio n. 3
0
 public SceneData(PlayerData aPlayerData, CollectiblesData aCollectiblesData, List <MovingObjectSaveData> aMovingObjectDataList)
 {
     this.playerData       = aPlayerData;
     this.collectiblesData = aCollectiblesData;
     movingObjectSaveData  = aMovingObjectDataList;
 }
Esempio n. 4
0
 private void initializeCollectibleData()
 {
     collectiblesData = dataEntityCollection.GetComponent <CollectiblesData>(dataEntityCollection.LocalPlayerHandle);
 }