Exemplo n.º 1
0
        public static List <Perk> Load()
        {
            GameObject obj = Resources.Load("DB_UnitedSolution/PerkDB", typeof(GameObject)) as GameObject;

                        #if UNITY_EDITOR
            if (obj == null)
            {
                obj = CreatePrefab();
            }
                        #endif

            PerkDB instance = obj.GetComponent <PerkDB>();
            return(instance.perkList);
        }
Exemplo n.º 2
0
        public static List <Perk> LoadClone()
        {
            GameObject obj      = Resources.Load("DB_UnitedSolution/PerkDB", typeof(GameObject)) as GameObject;
            PerkDB     instance = obj.GetComponent <PerkDB>();

            List <Perk> newList = new List <Perk>();

            if (instance != null)
            {
                for (int i = 0; i < instance.perkList.Count; i++)
                {
                    newList.Add(instance.perkList[i].Clone());
                }
            }

            return(newList);
        }
Exemplo n.º 3
0
        private static void LoadPerk()
        {
            perkDBPrefab = PerkDB.LoadDB();
            perkList     = perkDBPrefab.perkList;

            for (int i = 0; i < perkList.Count; i++)
            {
                //perkList[i].ID=i;
                if (perkList[i] != null)
                {
                    perkIDList.Add(perkList[i].ID);
                }
                else
                {
                    perkList.RemoveAt(i);
                    i -= 1;
                }
            }

            UpdatePerkNameList();
        }
Exemplo n.º 4
0
        public void Init()
        {
            if (init)
            {
                return;
            }

            init = true;

            if (instance != null)
            {
                Destroy(gameObject);
                return;
            }

            instance = this;

            //load your custom/saved purchasedIDList here if you are doing a persistent perk system

            List <Perk> dbList = PerkDB.Load();

            for (int i = 0; i < dbList.Count; i++)
            {
                if (!unavailableIDList.Contains(dbList[i].ID))
                {
                    Perk perk = dbList[i].Clone();
                    perkList.Add(perk);
                }
            }

            globalTowerModifier     = new PerkTowerModifier();
            globalAbilityModifier   = new PerkAbilityModifier();
            globalFPSWeaponModifier = new PerkFPSWeaponModifier();

            emptyTowerModifier     = new PerkTowerModifier();
            emptyAbilityModifier   = new PerkAbilityModifier();
            emptyFPSWeaponModifier = new PerkFPSWeaponModifier();

            int rscCount = ResourceManager.GetResourceCount();

            for (int i = 0; i < rscCount; i++)
            {
                rscRegen.Add(0);
                rscGain.Add(0);
                rscCreepKilledGain.Add(0);
                rscWaveClearedGain.Add(0);
                rscRscTowerGain.Add(0);
            }

            for (int i = 0; i < perkList.Count; i++)
            {
                if (purchasedIDList.Contains(perkList[i].ID))
                {
                    if (perkList[i].type == _PerkType.NewTower || perkList[i].type == _PerkType.NewAbility || perkList[i].type == _PerkType.NewFPSWeapon)
                    {
                        StartCoroutine(DelayPurchasePerk(perkList[i]));
                    }
                    else
                    {
                        _PurchasePerk(perkList[i], false);                      //dont use rsc since these are pre-purchased perk
                    }
                }
            }

            if (persistantProgress)
            {
                transform.parent = null;
                DontDestroyOnLoad(gameObject);
            }
        }