public SaveMobLogicClass GetKiddoLogic(int n)
        {
            SaveMobLogicClass _result = null;

            if (children[n] != null)
            {
                _result = children[n];
            }
            return(_result);
        }
Example #2
0
 public void LoadMob(SaveMobLogicClass mob)
 {
     mob_data              = new Mob.MobInstance(mob_template);
     mob_data.xCoord       = mob.xCoord; mob_data.yCoord = mob.yCoord;
     mob_data.mob_HP       = mob.mob_HP;
     mob_data.mob_Poisoned = mob.mob_Poisoned;
     mob_data.mob_Cursed   = mob.mob_Cursed;
     mob_data.mob_Blinded  = mob.mob_Blinded;
     mob_data.mob_Slowed   = mob.mob_Slowed;
     mob_data.mob_Weakened = mob.mob_Weakened;
     mob_data.mob_Stoned   = mob.mob_Stoned;
     mob_data.mob_Frog     = mob.mob_Frog;
     moveTarget            = transform.parent.GetComponent <Spawner>().Waypoint_List[mob.wp_index].gameObject;
     //mob_data.UpdateCoords(transform.position.x, transform.position.z);
 }
 public void InsertKiddo(int index, SaveMobLogicClass mob, float x, float y)
 {
     this.children[index].xCoord = x;
     this.children[index].yCoord = y;
     this.children[index]        = mob;
 }
Example #4
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);
                    }
                }
            }
        }
    }