Ejemplo n.º 1
0
    public void UpdateSaveSlot(int thisLevel)
    {
        //Same as in initialization, want to update this every time the game is saved
        for (int _p = 0; _p < GameManager.PARTYSIZE; _p++)
        {
            PC.Add(new SaveCharacterClass(GameManager.PARTY.PC[_p]));
        }
        for (int _i = 0; _i < 20; _i++)
        {
            if (GameManager.PARTY.bagInventory[_i] != null)
            {
                bagInventory[_i] = new SaveItemClass(GameManager.PARTY.bagInventory[_i]);
            }
        }
        wealth = GameManager.PARTY.wealth;
        light  = GameManager.PARTY.light;
        currentDungeonLevel = UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex;
        xCoord      = (int)GameManager.PARTY.transform.position.x;
        yCoord      = (int)GameManager.PARTY.transform.position.z;
        face_xCoord = GameManager.PARTY.FaceMe.transform.position.x;
        face_yCoord = GameManager.PARTY.FaceMe.transform.position.y;
        face_zCoord = GameManager.PARTY.FaceMe.transform.position.z;
        facing      = GameManager.PARTY.facing;

        //Save data for this level only
        List <GameObject> chestlist = new List <GameObject>(); List <GameObject> lootList = new List <GameObject>(); List <GameObject> doorList = new List <GameObject>();
        List <GameObject> spawnerList = new List <GameObject>();

        FindAllChildrenWithTag(GameManager.GAME.Levels[thisLevel].transform, "Chest", chestlist);   //Make a list of chests
        FindAllChildrenWithTag(GameManager.GAME.Levels[thisLevel].transform, "GridNode", lootList); //Make a list of loot
        FindAllChildrenWithTag(GameManager.GAME.Levels[thisLevel].transform, "MapDoor", doorList);  //Make a list of doors
        foreach (GameObject _spawnr in GameObject.FindGameObjectsWithTag("Spawner"))
        {
            spawnerList.Add(_spawnr);                                                                         //Make a list of spawners
        }
        if (chestlist.Count > 0)
        {
            for (int _i = 0; _i < chestlist.Count; _i++)
            {
                Levels[thisLevel].chest[_i] = new SaveChestClass(chestlist[_i].GetComponent <Hello_I_am_a_chest>().inventory);                                                              //Save the chests to the save slot
            }
        }
        if (lootList.Count > 0)
        {
            for (int _i = 0; _i < lootList.Count; _i++)
            {
                Levels[thisLevel].loot[_i] = new SaveLootClass(lootList[_i].GetComponent <GridNode>().inventory); //Save the loot to the save slot\
                Levels[thisLevel].trap[_i] = new SaveTrapClass(lootList[_i].GetComponent <GridNode>());           //Save trap data
            }
        }
        if (doorList.Count > 0)
        {
            for (int _i = 0; _i < doorList.Count; _i++)
            {
                Levels[thisLevel].door[_i] = new SaveDoorClass(doorList[_i].GetComponent <Hello_I_am_a_Door>());
            }
        }
        if (spawnerList.Count > 0)
        {
            for (int _i = 0; _i < spawnerList.Count; _i++)
            {
                Levels[thisLevel].SpawnTimer[_i] = spawnerList[_i].GetComponent <Spawner>().timer;
                if (spawnerList[_i].transform.childCount > 0)
                {
                    for (int _p = 0; _p < spawnerList[_i].transform.childCount; _p++)
                    {
                        SaveMobLogicClass _thisOne = new SaveMobLogicClass(spawnerList[_i].transform.GetChild(_p).GetComponent <MobLogic>());
                        spawnerList[_i].transform.GetChild(_p).GetComponent <MobLogic>().mob_data.xCoord = spawnerList[_i].transform.GetChild(_p).transform.localPosition.x;
                        spawnerList[_i].transform.GetChild(_p).GetComponent <MobLogic>().mob_data.yCoord = spawnerList[_i].transform.GetChild(_p).transform.localPosition.z;
                        Levels[thisLevel].Spawn[_i].InsertKiddo(_p, _thisOne, spawnerList[_i].transform.GetChild(_p).transform.localPosition.x, spawnerList[_i].transform.GetChild(_p).transform.localPosition.z);
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    public SaveSlot()
    {
        //Load Party members into SaveSlot
        for (int _p = 0; _p < GameManager.PARTYSIZE; _p++)
        {
            PC.Add(new SaveCharacterClass(GameManager.PARTY.PC[_p]));
        }

        //Load party baggage into SaveSlot
        for (int _i = 0; _i < 20; _i++)
        {
            if (GameManager.PARTY.bagInventory[_i] != null)
            {
                bagInventory[_i] = new SaveItemClass(GameManager.PARTY.bagInventory[_i]);
            }
        }

        //Load Party variables into SaveSlot
        wealth = GameManager.PARTY.wealth;
        light  = GameManager.PARTY.light;
        currentDungeonLevel = UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex;
        xCoord      = (int)GameManager.PARTY.transform.position.x;
        yCoord      = (int)GameManager.PARTY.transform.position.z;
        face_xCoord = GameManager.PARTY.FaceMe.transform.position.x;
        face_yCoord = GameManager.PARTY.FaceMe.transform.position.y;
        face_zCoord = GameManager.PARTY.FaceMe.transform.position.z;
        facing      = GameManager.PARTY.facing;

        //Initialize Level List by grabbing data from all levels in the GameManager.GAME.Levels array
        List <GameObject> chestlist = new List <GameObject>(); List <GameObject> lootList = new List <GameObject>(); List <GameObject> doorList = new List <GameObject>();//Need these lists later
        List <GameObject> spawnerList = new List <GameObject>();

        for (int _l = 0; _l < GameManager.GAME.Levels.Length; _l++)
        {
            Levels.Add(new SaveLevelClass());                                                    //start by adding an entry to the list

            chestlist.Clear(); lootList.Clear();                                                 //make sure the lists are empty.

            FindAllChildrenWithTag(GameManager.GAME.Levels[_l].transform, "Chest", chestlist);   //Make a list of chests
            FindAllChildrenWithTag(GameManager.GAME.Levels[_l].transform, "GridNode", lootList); //Make a list of loot
            FindAllChildrenWithTag(GameManager.GAME.Levels[_l].transform, "MapDoor", doorList);  //Make a list of doors
            foreach (GameObject _spawnr in GameObject.FindGameObjectsWithTag("Spawner"))
            {
                spawnerList.Add(_spawnr);                                                                          //Make a list of spawners
            }
            if (chestlist.Count > 0)
            {
                foreach (GameObject _ch in chestlist)
                {
                    Levels[_l].chest.Add(new SaveChestClass(_ch.GetComponent <Hello_I_am_a_chest>().inventory));                                                       //Save the chests to the save slot
                }
            }
            if (lootList.Count > 0)
            {
                foreach (GameObject _lt in lootList)
                {
                    Levels[_l].loot.Add(new SaveLootClass(_lt.GetComponent <GridNode>().inventory)); //Save the loot to the save slot
                    Levels[_l].trap.Add(new SaveTrapClass(_lt.GetComponent <GridNode>()));           //Save the trap data from Gridnodes
                }
            }
            if (doorList.Count > 0)
            {
                foreach (GameObject _dr in doorList)
                {
                    Levels[_l].door.Add(new SaveDoorClass(_dr.GetComponent <Hello_I_am_a_Door>()));
                }
            }
            if (spawnerList.Count > 0)
            {
                foreach (GameObject _sp in spawnerList)
                {
                    Levels[_l].SpawnTimer.Add(_sp.GetComponent <Spawner>().timer);

                    _sp.GetComponent <Spawner>().InitialSpawn(); //Kick off initial spawn of spawners
                    Levels[_l].Spawn.Add(new SaveLevelClass.SpawnChildren(_sp.GetComponent <Spawner>()));
                }
            }
        }
    }