Beispiel #1
0
        public static int AddNewPerk()
        {
            Perk perk = new Perk();

            perk.ID   = GenerateNewID(perkIDList);
            perk.name = "Perk " + perk.ID;
            perkIDList.Add(perk.ID);
            perkList.Add(perk);
            UpdatePerkNameList();
            SetDirtyPerk();
            return(perkList.Count - 1);
        }
Beispiel #2
0
        public static int ClonePerk(int listID)
        {
            Perk perk = perkList[listID].Clone();

            perk.ID = GenerateNewID(perkIDList);
            perkIDList.Add(perk.ID);
            perk.name += " (Clone)";
            perkList.Insert(listID + 1, perk);
            UpdatePerkNameList();
            SetDirtyPerk();
            return(listID + 1);
        }
Beispiel #3
0
 private void ModifyTowerModifier(PerkTowerModifier towerModifier, Perk perk)
 {
     towerModifier.HP            += perk.HP;
     towerModifier.HPRegen       += perk.HPRegen;
     towerModifier.HPStagger     += perk.HPStagger;
     towerModifier.shield        += perk.shield;
     towerModifier.shieldRegen   += perk.shieldRegen;
     towerModifier.shieldStagger += perk.shieldStagger;
     towerModifier.buildCost     += perk.buildCost;
     towerModifier.upgradeCost   += perk.upgradeCost;
     ModifyUnitStats(towerModifier.stats, perk.stats);
 }
Beispiel #4
0
        public Perk Clone()
        {
            Perk perk = new Perk();

            perk.ID              = ID;
            perk.name            = name;
            perk.icon            = icon;
            perk.iconUnavailable = iconUnavailable;

            perk.repeatable     = repeatable;
            perk.purchased      = purchased;
            perk.purchasedCount = purchasedCount;

            perk.type = type;

            //perk.cost=cost;
            perk.cost         = new List <int>(cost);
            perk.minLevel     = minLevel;
            perk.minWave      = minWave;
            perk.minPerkPoint = minPerkPoint;
            //perk.prereq=prereq;
            perk.prereq = new List <int>(prereq);

            //perk.itemIDList=itemIDList;
            perk.itemIDList = new List <int>(itemIDList);
            perk.itemID     = itemID;
            perk.value      = value;
            perk.valueAlt   = valueAlt;
            //perk.valueRscList=valueRscList;
            perk.valueRscList = new List <float>(valueRscList);
            perk.stats        = stats.Clone();
            perk.effects      = effects.Clone();

            perk.HP            = HP;
            perk.HPRegen       = HPRegen;
            perk.HPStagger     = HPStagger;
            perk.shield        = shield;
            perk.shieldRegen   = shieldRegen;
            perk.shieldStagger = shieldStagger;
            perk.buildCost     = buildCost;
            perk.upgradeCost   = upgradeCost;

            perk.abCost      = abCost;
            perk.abCooldown  = abCooldown;
            perk.abAOERadius = abAOERadius;

            perk.desp = desp;

            return(perk);
        }
Beispiel #5
0
        Vector2 DrawPerkConfigurator(float startX, float startY, Perk perk)
        {
            float cachedX = startX;
            float cachedY = startY;

            EditorUtilities.DrawSprite(new Rect(startX, startY, 60, 60), perk.icon);
            startX += 65;

            cont = new GUIContent("Name:", "The ability name to be displayed in game");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY / 2, width, height), cont);
            perk.name = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width - 5, height), perk.name);

            cont = new GUIContent("Icon:", "The ability icon to be displayed in game, must be a sprite");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.icon = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width - 5, height), perk.icon, typeof(Sprite), false);

            cont = new GUIContent("Disable Perk:", "Disable Perk");
            EditorGUI.LabelField(new Rect(startX + 295, startY, width, height), cont);
            perk.disablePerk = EditorGUI.Toggle(new Rect(startX + 295 + spaceX, startY, 185, height), perk.disablePerk);

            startX -= 65;
            startY += 30 + spaceY / 2; cachedY = startY;

            cont = new GUIContent("Min level required:", "Minimum level to reach before the perk becoming available. (level are specified in GameControl of each scene)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.levelUnlock = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), perk.levelUnlock);

            float temp = cachedY;

            cachedY = startY + 15; startY = temp;
            startX  = cachedX + 310;

            GUIStyle style = new GUIStyle("TextArea");

            style.wordWrap = true;
            cont           = new GUIContent("Perk description (to be used in runtime): ", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
            perk.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 50), perk.desp, style);


            startX = cachedX; startY = cachedY;

            Vector2 v2        = DrawPerkType(startX, startY, perk);
            float   maxHeight = v2.y + 40;

            return(new Vector2(Mathf.Max(startX + 280, v2.x), Mathf.Max(maxHeight, startY + 170)));
        }
        public Perk Clone()
        {
            Perk perk = new Perk();

            perk.ID          = ID;
            perk.name        = name;
            perk.icon        = icon;
            perk.type        = type;
            perk.levelUnlock = levelUnlock;

            perk.itemIDList = new List <int>(itemIDList);
            perk.desp       = desp;
            perk.perkLevel  = new List <PerkLevel>();
            for (int i = 0; i < perkLevel.Count; i++)
            {
                perk.perkLevel.Add(perkLevel[i].Clone());
            }
            return(perk);
        }
Beispiel #7
0
        void UpdateDisplay()
        {
            lbPerkPoint.text = "Points: " + PerkManager.GetPerkPoint();

            Perk perk = PerkManager.GetPerk(perkItemList[selectID].perkID);

            lbPerkName.text = perk.name;
            lbPerkDesp.text = perk.desp;

            if (perk.purchased)
            {
                lbPerkReq.text = "";
                rscRootObj.SetActive(false);

                butPurchase.label.text          = "Purchased";
                butPurchase.button.interactable = false;
                return;
            }

            butPurchase.label.text = "Purchase";

            string text = perk.IsAvailable();

            if (text == "")
            {
                List <int> cost = perk.GetCost();
                for (int i = 0; i < rscItemList.Count; i++)
                {
                    rscItemList[i].label.text = cost[i].ToString();
                }

                lbPerkReq.text = "";
                rscRootObj.SetActive(true);
                butPurchase.button.interactable = true;
            }
            else
            {
                lbPerkReq.text = text;
                rscRootObj.SetActive(false);
                butPurchase.button.interactable = false;
            }
        }
Beispiel #8
0
        public int purchasedCount = 0;  //for repeatable perk
        #endregion


        public Perk Clone()             //return ObjectCopier.Clone(this);
        {
            Perk clone = new Perk();    //(Perk)base.Clone();

            base.Clone(this, clone);
            clone.type            = type;
            clone.groupID         = groupID;
            clone.hideInInspector = hideInInspector;

            clone.autoUnlockOnLevel = autoUnlockOnLevel;
            clone.autoUnlockOnWave  = autoUnlockOnWave;

            clone.cost         = cost;
            clone.costRsc      = new List <float>(costRsc);
            clone.minLevel     = minLevel;
            clone.minWave      = minWave;
            clone.minPerkCount = minPerkCount;
            clone.prereq       = new List <int>(prereq);
            clone.repeatable   = repeatable;


            clone.effType = effType;

            clone.newTowerPID   = newTowerPID;
            clone.newAbilityPID = newAbilityPID;

            clone.replaceTowerPID   = replaceTowerPID;
            clone.replaceAbilityPID = replaceAbilityPID;

            clone.applyToAll     = applyToAll;
            clone.towerPIDList   = new List <int>(towerPIDList);
            clone.abilityPIDList = new List <int>(abilityPIDList);
            clone.perkPIDList    = new List <int>(perkPIDList);
            clone.effectPIDList  = new List <int>(effectPIDList);

            clone.effect   = effect.Clone();
            clone.costMul  = costMul;
            clone.gain     = gain;
            clone.gainList = new List <float>(gainList);

            return(clone);
        }
Beispiel #9
0
        private int _NewItem(int idx = -1)
        {
            Perk item = null;

            if (idx < 0)
            {
                item = new Perk(); item.effect.Reset();
            }
            if (idx >= 0)
            {
                item = PerkDB.GetList()[idx].Clone();
            }

            item.prefabID = TDE.GenerateNewID(PerkDB.GetPrefabIDList());

            PerkDB.GetList().Add(item);
            PerkDB.UpdateLabel();

            return(PerkDB.GetList().Count - 1);
        }
Beispiel #10
0
        Vector2 DrawPerkConfigurator(float startX, float startY, Perk item)
        {
            float maxX = startX;

            startY = TDE.DrawBasicInfo(startX, startY, item);


            int type = (int)item.type;                contL = TDE.SetupContL(perkTypeLabel, perkTypeTooltip);

            TDE.Label(startX, startY += spaceY + 5, width, height, "Perk Type:", "Specify what the perk do");
            type      = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), type, contL);
            item.type = (_PerkType)type;

            showTypeDesp = EditorGUI.ToggleLeft(new Rect(startX + spaceX + width + 2, startY, width, 20), "Show Description", showTypeDesp);
            if (showTypeDesp)
            {
                EditorGUI.HelpBox(new Rect(startX, startY += spaceY, width + spaceX, 40), perkTypeTooltip[(int)item.type], MessageType.Info);
                startY += 45 - height;
            }

            startY += 10;


            startY = DrawBasicSetting(startX, startY, item) + 10;


            startY = DrawEffectSetting(startX, startY, item);


            startY += spaceY;

            GUIStyle style = new GUIStyle("TextArea");        style.wordWrap = true;

            cont = new GUIContent("Perk description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY, 400, 20), cont);
            item.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), item.desp, style);

            return(new Vector2(maxX, startY + 170));
        }
Beispiel #11
0
        private void ModifyAbilityModifier(PerkAbilityModifier abilityModifier, Perk perk)
        {
            abilityModifier.cost      += perk.abCost;
            abilityModifier.cooldown  += perk.abCooldown;
            abilityModifier.aoeRadius += perk.abAOERadius;

            abilityModifier.effects.damageMin  += perk.effects.damageMin;
            abilityModifier.effects.damageMax  += perk.effects.damageMax;
            abilityModifier.effects.stunChance += perk.effects.stunChance;

            abilityModifier.effects.slow.duration       += perk.effects.duration;
            abilityModifier.effects.slow.slowMultiplier += perk.effects.slow.slowMultiplier;

            abilityModifier.effects.dot.duration += perk.effects.duration;
            abilityModifier.effects.dot.interval += perk.effects.dot.interval;
            abilityModifier.effects.dot.value    += perk.effects.dot.value;

            abilityModifier.effects.damageBuff   += perk.effects.damageBuff;
            abilityModifier.effects.rangeBuff    += perk.effects.rangeBuff;
            abilityModifier.effects.cooldownBuff += perk.effects.cooldownBuff;
            abilityModifier.effects.HPGainMin    += perk.effects.HPGainMin;
            abilityModifier.effects.HPGainMax    += perk.effects.HPGainMax;
        }
		private void ModifyFPSWeaponModifier(PerkFPSWeaponModifier weaponModifier, Perk perk){ ModifyUnitStats(weaponModifier.stats, perk.stats); }
		private void ModifyTowerModifier(PerkTowerModifier towerModifier, Perk perk){
			towerModifier.HP+=perk.HP;
			towerModifier.HPRegen+=perk.HPRegen;
			towerModifier.HPStagger+=perk.HPStagger;
			towerModifier.shield+=perk.shield;
			towerModifier.shieldRegen+=perk.shieldRegen;
			towerModifier.shieldStagger+=perk.shieldStagger;
			towerModifier.buildCost+=perk.buildCost;
			towerModifier.upgradeCost+=perk.upgradeCost;
			ModifyUnitStats(towerModifier.stats, perk.stats);
		}
		private void ModifyAbilityModifier(PerkAbilityModifier abilityModifier, Perk perk){
			abilityModifier.cost=perk.abCost;
			abilityModifier.cooldown=perk.abCooldown;
			abilityModifier.aoeRadius=perk.abAOERadius;
			
			abilityModifier.effects.damageMin+=perk.effects.damageMin;
			abilityModifier.effects.damageMax+=perk.effects.damageMax;
			abilityModifier.effects.stunChance+=perk.effects.stunChance;
			
			abilityModifier.effects.slow.duration+=perk.effects.duration;
			abilityModifier.effects.slow.slowMultiplier+=perk.effects.slow.slowMultiplier;
			
			abilityModifier.effects.dot.duration+=perk.effects.duration;
			abilityModifier.effects.dot.interval+=perk.effects.dot.interval;
			abilityModifier.effects.dot.value+=perk.effects.dot.value;
			
			abilityModifier.effects.damageBuff+=perk.effects.damageBuff;
			abilityModifier.effects.rangeBuff+=perk.effects.rangeBuff;
			abilityModifier.effects.cooldownBuff+=perk.effects.cooldownBuff;
			abilityModifier.effects.HPGainMin+=perk.effects.HPGainMin;
			abilityModifier.effects.HPGainMax+=perk.effects.HPGainMax;
		}
		//for initiating perk which add new tower & ability,
		//let everything else (UI) settle in first before adding the new element 
		IEnumerator DelayPurchasePerk(Perk perk){
			yield return null;
			_PurchasePerk(perk, false);
		}
		public string _PurchasePerk(Perk perk, bool useRsc=true){
			string text=perk.Purchase(useRsc);
			if(text!="") return text;
			
			if(onPerkPurchasedE!=null) onPerkPurchasedE(perk);
			
			//process the prereq for other perk
			for(int i=0; i<perkList.Count; i++){
				Perk perkTemp=perkList[i];
				if(perkTemp.purchased || perkTemp.prereq.Count==0) continue;
				perkTemp.prereq.Remove(perk.ID);
			}
			
			
			perkPoint+=1;
			if(onPerkPointE!=null) onPerkPointE(perkPoint);
			
			if(perk.type==_PerkType.NewTower){ 
				List<UnitTower> towerList=TowerDB.Load();
				for(int i=0; i<towerList.Count; i++){
					if(towerList[i].prefabID==perk.itemIDList[0]){
						unlockedTower.Add(towerList[i]);
						BuildManager.AddNewTower(towerList[i]);
					}
				}
			}
			else if(perk.type==_PerkType.NewAbility){
				List<Ability> abilityList=AbilityDB.Load();
				for(int i=0; i<abilityList.Count; i++){
					if(abilityList[i].ID==perk.itemIDList[0]){
						unlockedAbility.Add(abilityList[i]);
						AbilityManager.AddNewAbility(abilityList[i]);
					}
				}
			}
			else if(perk.type==_PerkType.NewFPSWeapon){
				List<FPSWeapon> FPSWeaponList=FPSWeaponDB.Load();
				for(int i=0; i<FPSWeaponList.Count; i++){
					if(FPSWeaponList[i].prefabID==perk.itemIDList[0]){
						unlockedWeapon.Add(FPSWeaponList[i]);
						FPSControl.AddNewWeapon(FPSWeaponList[i]);
					}
				}
			}
			
			else if(perk.type==_PerkType.GainLife){ GameControl.GainLife((int)Random.Range(perk.value, perk.valueAlt)); }
			else if(perk.type==_PerkType.LifeCap){ lifeCap+=(int)perk.value; GameControl.GainLife(0); }
			else if(perk.type==_PerkType.LifeRegen){ lifeRegen+=perk.value; }
			else if(perk.type==_PerkType.LifeWaveClearedBonus){ lifeWaveClearedBonus+=(int)perk.value; }
			
			else if(perk.type==_PerkType.GainRsc){ 
				List<int> valueList=new List<int>();
				for(int i=0; i<perk.valueRscList.Count; i++) valueList.Add((int)perk.valueRscList[i]);
				ResourceManager.GainResource(valueList, null, false);	//dont pass multiplier and dont use multiplier
			}
			else if(perk.type==_PerkType.RscRegen){ 
				for(int i=0; i<perk.valueRscList.Count; i++) rscRegen[i]+=perk.valueRscList[i];
			}
			else if(perk.type==_PerkType.RscGain){ 
				for(int i=0; i<perk.valueRscList.Count; i++) rscGain[i]+=perk.valueRscList[i];
			}
			else if(perk.type==_PerkType.RscCreepKilledGain){ 
				for(int i=0; i<perk.valueRscList.Count; i++) rscCreepKilledGain[i]+=perk.valueRscList[i];
			}
			else if(perk.type==_PerkType.RscWaveClearedGain){ 
				for(int i=0; i<perk.valueRscList.Count; i++) rscWaveClearedGain[i]+=perk.valueRscList[i];
			}
			else if(perk.type==_PerkType.RscResourceTowerGain){ 
				for(int i=0; i<perk.valueRscList.Count; i++) rscRscTowerGain[i]+=perk.valueRscList[i];
			}
			
			else if(perk.type==_PerkType.Tower){ ModifyTowerModifier(globalTowerModifier, perk); }
			else if(perk.type==_PerkType.TowerSpecific){ 
				for(int i=0; i<perk.itemIDList.Count; i++){
					int ID=TowerModifierExist(perk.itemIDList[i]);
					if(ID==-1){
						PerkTowerModifier towerModifier=new PerkTowerModifier();
						towerModifier.prefabID=perk.itemIDList[i];
						towerModifierList.Add(towerModifier);
						ID=towerModifierList.Count-1;
					}
					ModifyTowerModifierInList(ID, perk);
				}
			}
			else if(perk.type==_PerkType.Ability){ ModifyAbilityModifier(globalAbilityModifier, perk); }
			else if(perk.type==_PerkType.AbilitySpecific){ 
				for(int i=0; i<perk.itemIDList.Count; i++){
					int ID=AbilityModifierExist(perk.itemIDList[i]);
					if(ID==-1){
						PerkAbilityModifier abilityModifier=new PerkAbilityModifier();
						abilityModifier.abilityID=perk.itemIDList[i];
						abilityModifierList.Add(abilityModifier);
						ID=abilityModifierList.Count-1;
					}
					ModifyAbilityModifierInList(ID, perk);
				}
			}
			else if(perk.type==_PerkType.FPSWeapon){ ModifyFPSWeaponModifier(globalFPSWeaponModifier, perk); }
			else if(perk.type==_PerkType.FPSWeaponSpecific){ 
				for(int i=0; i<perk.itemIDList.Count; i++){
					int ID=FPSWeaponModifierExist(perk.itemIDList[i]);
					if(ID==-1){
						PerkFPSWeaponModifier weaponModifier=new PerkFPSWeaponModifier();
						weaponModifier.prefabID=perk.itemIDList[i];
						FPSWeaponModifierList.Add(weaponModifier);
						ID=FPSWeaponModifierList.Count-1;
					}
					ModifyFPSWeaponModifierInList(ID, perk);
				}
			}
			
			else if(perk.type==_PerkType.EnergyRegen){ energyRegen+=perk.value; }
			else if(perk.type==_PerkType.EnergyIncreaseCap){ energyCap+=perk.value; }
			else if(perk.type==_PerkType.EnergyCreepKilledBonus){ energyCreepKilledBonus+=perk.value; }
			else if(perk.type==_PerkType.EnergyWaveClearedBonus){ energyWaveClearedBonus+=perk.value; }
			
			return "";
		}
		Vector2 DrawFPSWeaponStat(float startX, float startY, Perk perk){
			startY+=5;
			
			Vector2 v2=DrawUnitStat(startX, startY+5, perk.stats, true);
			//startY=v2.x+spaceY;
			
			return new Vector2(startX, v2.y);
		}
Beispiel #18
0
        protected float DrawEffectSetting(float startX, float startY, Perk item)
        {
            //TDE.Label(startX, startY, spaceX*2, height, "Perk Effect Attribute", "", TDE.headerS);	startY+=spaceY;
            string text = "Perk Effect Attribute ";          //+ (!foldStats ? "(show)" : "(hide)");

            foldStats = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldStats, text, TDE.foldoutS);
            if (!foldStats)
            {
                return(startY + spaceY);
            }

            startY += spaceY; startX += 12;

            if (item.type == _PerkType.NewTower)
            {
                TDE.Label(startX, startY, width, height, "New Tower:", "The new tower to be added to game");
                item.newTowerPID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.newTowerPID, TowerDB.label);

                TDE.Label(startX, startY += spaceY, width, height, " - Replacing:", "OPTIONAL - exiting tower that will be replaced");
                item.replaceTowerPID      = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.replaceTowerPID, TowerDB.label);
            }

            else if (item.type == _PerkType.NewAbility)
            {
                TDE.Label(startX, startY, width, height, "New Ability:", "The new ability to be added to game");
                item.newAbilityPID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.newAbilityPID, AbilityDB.label);

                TDE.Label(startX, startY += spaceY, width, height, " - Replacing:", "OPTIONAL - exiting ability that will be replaced");
                item.replaceAbilityPID    = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.replaceAbilityPID, AbilityDB.label);
            }

            else if (item.UseGainValue() || item.UseGainList())
            {
                startY = DrawEffectTypeSetting(startX, startY, item);

                string txtType = item.IsMultiplier() ? "Multiplier:" : "Modifier:";
                if (!item.SupportModNMul())
                {
                    txtType = "Gain:";
                }

                if (item.UseGainValue())
                {
                    string txt = item.UseGainList() ? "Global " : "";

                    TDE.Label(startX, startY, width, height, txt + txtType);                  //"Gain Value:", "");
                    item.gain = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.gain);
                    startY   += spaceY;
                }

                if (item.UseGainList())
                {
                    if (item.gainList.Count < RscDB.GetCount())
                    {
                        item.gainList.Add(0);
                    }
                    if (item.gainList.Count > RscDB.GetCount())
                    {
                        item.gainList.Remove(item.gainList.Count - 1);
                    }

                    for (int i = 0; i < item.gainList.Count; i++)
                    {
                        TDE.DrawSprite(new Rect(startX, startY, height, height), RscDB.GetIcon(i));
                        TDE.Label(startX + height, startY, width - height, height, " - " + RscDB.GetName(i));                   //" - "+txtType, "");
                        item.gainList[i] = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.gainList[i]);
                        if (i < item.gainList.Count - 1)
                        {
                            startY += spaceY;
                        }
                    }
                }
                else
                {
                    startY -= spaceY;
                }
            }

            else if (item.UseStats())
            {
                string textItem = "";
                if (item.type == _PerkType.ModifyTower)
                {
                    textItem = "towers";
                }
                if (item.type == _PerkType.ModifyAbility)
                {
                    textItem = "abilities";
                }
                if (item.type == _PerkType.ModifyEffect)
                {
                    textItem = "effects";
                }

                TDE.Label(startX, startY, width, height, "Apply To All:", "Check to apply to all " + textItem);
                item.applyToAll = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.applyToAll);

                if (!item.applyToAll)
                {
                    startY += spaceY;
                    if (item.type == _PerkType.ModifyTower)
                    {
                        TDE.Label(startX, startY, width, height, "Target Tower:", "The target towers which this perk should be applied to");
                        for (int i = 0; i < item.towerPIDList.Count; i++)
                        {
                            if (item.towerPIDList[i] < 0)
                            {
                                item.towerPIDList.RemoveAt(i); i -= 1; continue;
                            }

                            int index = TowerDB.GetPrefabIndex(item.towerPIDList[i]);
                            index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, TowerDB.label);
                            int prefabID = TowerDB.GetItem(index).prefabID;
                            if (prefabID != item.prefabID && !item.towerPIDList.Contains(prefabID))
                            {
                                item.towerPIDList[i] = prefabID;
                            }

                            if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                            {
                                item.towerPIDList.RemoveAt(i); i -= 1;
                            }

                            startY += spaceY;
                        }

                        int newIdx = -1;
                        newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, TowerDB.label);
                        if (newIdx >= 0 && !item.towerPIDList.Contains(TowerDB.GetItem(newIdx).prefabID))
                        {
                            item.towerPIDList.Add(TowerDB.GetItem(newIdx).prefabID);
                        }
                    }
                    if (item.type == _PerkType.ModifyAbility)
                    {
                        TDE.Label(startX, startY, width, height, "Target Ability:", "The target abilities which this perk should be applied to");
                        for (int i = 0; i < item.abilityPIDList.Count; i++)
                        {
                            int index = AbilityDB.GetPrefabIndex(item.abilityPIDList[i]);
                            index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, AbilityDB.label);
                            int prefabID = AbilityDB.GetItem(index).prefabID;
                            if (prefabID != item.prefabID && !item.abilityPIDList.Contains(prefabID))
                            {
                                item.abilityPIDList[i] = prefabID;
                            }

                            if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                            {
                                item.abilityPIDList.RemoveAt(i); i -= 1;
                            }

                            startY += spaceY;
                        }

                        int newIdx = -1;
                        newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, AbilityDB.label);
                        if (newIdx >= 0 && !item.abilityPIDList.Contains(AbilityDB.GetItem(newIdx).prefabID))
                        {
                            item.abilityPIDList.Add(AbilityDB.GetItem(newIdx).prefabID);
                        }
                    }
                    if (item.type == _PerkType.ModifyEffect)
                    {
                        TDE.Label(startX, startY, width, height, "Target Effect:", "The target effects which this perk should be applied to");
                        for (int i = 0; i < item.effectPIDList.Count; i++)
                        {
                            int index = EffectDB.GetPrefabIndex(item.effectPIDList[i]);
                            index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, EffectDB.label);
                            int prefabID = EffectDB.GetItem(index).prefabID;

                            if (prefabID != item.prefabID && !item.effectPIDList.Contains(prefabID))
                            {
                                item.effectPIDList[i] = prefabID;
                            }

                            if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                            {
                                item.effectPIDList.RemoveAt(i); i -= 1;
                            }

                            startY += spaceY;
                        }

                        int newIdx = -1;
                        newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, EffectDB.label);
                        if (newIdx >= 0 && !item.effectPIDList.Contains(EffectDB.GetItem(newIdx).prefabID))
                        {
                            item.effectPIDList.Add(EffectDB.GetItem(newIdx).prefabID);
                        }
                    }
                }

                startY += spaceY + 10;

                startY = DrawEffectTypeSetting(startX, startY, item) - spaceY;

                startY += spaceY;

                _EType eType = _EType.PerkT;

                if (item.type == _PerkType.ModifyAbility)
                {
                    eType = _EType.PerkA;

                    TDE.Label(startX, startY, width, height, "Use Limit:", "Modify the use limit of the ability");
                    if (item.effType == Perk._EffType.Multiplier)
                    {
                        TDE.Label(startX + spaceX, startY, widthS, height, "-");
                    }
                    else
                    {
                        item.gain = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.gain);
                    }

                    TDE.Label(startX, startY += spaceY, width, height, "Cost:", "Modify/Multiply the activation cost of the ability");
                    item.costMul              = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.costMul);
                    startY += spaceY;
                }
                else if (item.type == _PerkType.ModifyEffect)
                {
                    eType = _EType.PerkE;

                    TDE.Label(startX, startY, width, height, "Duration:", "Modify the duration of the effect");
                    item.effect.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.effect.duration);

                    TDE.Label(startX, startY += spaceY + 5, width, height, "Stun:", "Check to enable the effec to stun. This will only override the default value if it's set to true");
                    item.effect.stun          = EditorGUI.Toggle(new Rect(startX + spaceX, startY, height, height), item.effect.stun);
                    startY += spaceY;
                }

                startY = DrawStats(startX - 12, startY, item.effect.stats, eType) - spaceY;
            }

            else if (item.IsForPerk())
            {
                TDE.Label(startX, startY, width, height, "Apply To All:", "Check to apply to all perk");
                item.applyToAll = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.applyToAll);

                if (!item.applyToAll)
                {
                    TDE.Label(startX, startY += spaceY, width, height, "Target Perk:", "The target perk which this perk affect should be applied to");
                    for (int i = 0; i < item.perkPIDList.Count; i++)
                    {
                        int index = PerkDB.GetPrefabIndex(item.perkPIDList[i]);
                        index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, PerkDB.label);
                        int prefabID = PerkDB.GetItem(index).prefabID;
                        if (prefabID != item.prefabID && !item.perkPIDList.Contains(prefabID))
                        {
                            item.perkPIDList[i] = prefabID;
                        }

                        if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                        {
                            item.perkPIDList.RemoveAt(i); i -= 1;
                        }

                        startY += spaceY;
                    }

                    int newID = -1;
                    newID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newID, PerkDB.label);
                    if (newID >= 0 && !item.perkPIDList.Contains(newID))
                    {
                        item.perkPIDList.Add(newID);
                    }
                    startY += spaceY + 10;
                }

                TDE.Label(startX, startY, width, height, "Perk Rsc Multiplier:", "Modify/Multiply the purchase cost of the ability");
                item.costMul = EditorGUI.FloatField(new Rect(startX + spaceX + 25, startY, widthS, height), item.costMul);

                if (item.gainList.Count < RscDB.GetCount())
                {
                    item.gainList.Add(0);
                }
                if (item.gainList.Count > RscDB.GetCount())
                {
                    item.gainList.Remove(item.gainList.Count - 1);
                }

                for (int i = 0; i < item.gainList.Count; i++)
                {
                    TDE.DrawSprite(new Rect(startX, startY += spaceY, height, height), RscDB.GetIcon(i));
                    TDE.Label(startX + height, startY, width - height, height, " - " + RscDB.GetName(i) + ":", "");
                    item.gainList[i] = EditorGUI.FloatField(new Rect(startX + spaceX + 25, startY, widthS, height), item.gainList[i]);
                }
            }

            return(startY + spaceY);
        }
		Vector2 DrawItemIDFPSWeapon(float startX, float startY, Perk perk, int limit=1){
			string[] fpsWeaponNameList=EditorDBManager.GetFPSWeaponNameList();
			List<FPSWeapon> fpsWeaponList=EditorDBManager.GetFPSWeaponList();
			
			if(perk.itemIDList.Count==0) perk.itemIDList.Add(-1);
			while(perk.itemIDList.Count>limit) perk.itemIDList.RemoveAt(perk.itemIDList.Count-1);
			
			for(int i=0; i<perk.itemIDList.Count; i++){
				int ID=perk.itemIDList[i];
				
				if(ID>=0){
					for(int n=0; n<fpsWeaponList.Count; n++){ 
						if(fpsWeaponList[n].prefabID==ID){ ID=n+1;	break; }
					}
				}
				
				cont=new GUIContent(" - Ability:", "The ability to add to game when the perk is unlocked");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				ID = EditorGUI.Popup(new Rect(startX+spaceX-30, startY, width, 15), ID, fpsWeaponNameList);
				if(ID>0 && !perk.itemIDList.Contains(fpsWeaponList[ID-1].prefabID)) perk.itemIDList[i]=fpsWeaponList[ID-1].prefabID;
				else if(ID==0) perk.itemIDList[i]=-1;
				
				//if the list is full, extend it
				if(i==perk.itemIDList.Count-1 && ID>=0 && perk.itemIDList.Count<limit) perk.itemIDList.Add(-1);
				
				//if one of the element in the list is empty, shrink it
				if(i<perk.itemIDList.Count-1 && perk.itemIDList[i]==-1){ perk.itemIDList.RemoveAt(i); i-=1; }
			}
			
			return new Vector2(startX, startY);
		}
Beispiel #20
0
 void DrawValue(float startX, float startY, Perk perk, int level, GUIContent cont = null)
 {
     EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
     perk.perkLevel[level].value = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), perk.perkLevel[level].value);
 }
		Vector2 DrawPerkType(float startX, float startY, Perk perk){
			int type=(int)perk.type;
			cont=new GUIContent("Perk Type:", "What the perk does");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			contL=new GUIContent[perkTypeLabel.Length];
			for(int i=0; i<contL.Length; i++) contL[i]=new GUIContent(perkTypeLabel[i], perkTypeTooltip[i]);
			type = EditorGUI.Popup(new Rect(startX+spaceX-20, startY, width, 15), new GUIContent(""), type, contL);
			perk.type=(_PerkType)type;
			
			_PerkType perkType=perk.type;
			
			
			startX+=10;
			
			
			if(perkType==_PerkType.NewTower){
				DrawItemIDTower(startX, startY, perk);
			}
			else if(perkType==_PerkType.NewAbility){
				DrawItemIDAbility(startX, startY, perk);
			}
			else if(perkType==_PerkType.NewFPSWeapon){
				DrawItemIDFPSWeapon(startX, startY, perk);
			}
			
			
			else if(perkType==_PerkType.GainLife){
				GUIContent cont1=new GUIContent(" - Min value:", "Minimum value");
				GUIContent cont2=new GUIContent(" - Max value:", "Maximum value");
				DrawValueMinMax(startX, startY, perk, cont1, cont2);
			}
			else if(perkType==_PerkType.LifeCap){
				cont=new GUIContent(" - Increase Value:", "value used to modify the existing maximum life capacity");
				DrawValue(startX, startY, perk, cont);
			}
			else if(perkType==_PerkType.LifeRegen){
				cont=new GUIContent(" - Increase Value:", "value used to modify the existing life regeneration rate");
				DrawValue(startX, startY, perk, cont);
			}
			else if(perkType==_PerkType.LifeWaveClearedBonus){
				GUIContent cont1=new GUIContent(" - Min value:", "Minimum value");
				GUIContent cont2=new GUIContent(" - Max value:", "Maximum value");
				DrawValueMinMax(startX, startY, perk, cont1, cont2);
			}
			
			
			
			
			else if(IsPerkTypeUsesRsc(perkType)){
				if(perkType==_PerkType.GainRsc) cont=new GUIContent(" - Gain:", "The resource to be gain upon purchasing this perk");
				else if(perkType==_PerkType.RscRegen) cont=new GUIContent(" - Rate modifier:", "The resource to be gain upon purchasing this perk");
				else if(perkType==_PerkType.RscGain) cont=new GUIContent(" - Gain multiplier:", "The resource to be gain upon purchasing this perk");
				else if(perkType==_PerkType.RscCreepKilledGain) cont=new GUIContent(" - Gain multiplier:", "The resource to be gain upon purchasing this perk");
				else if(perkType==_PerkType.RscWaveClearedGain) cont=new GUIContent(" - Gain multiplier:", "The resource to be gain upon purchasing this perk");
				else if(perkType==_PerkType.RscResourceTowerGain) cont=new GUIContent(" - Gain multiplier:", "The resource to be gain upon purchasing this perk");
				
				List<Rsc> rscList=EditorDBManager.GetRscList();
				while(perk.valueRscList.Count<rscList.Count) perk.valueRscList.Add(0);
				while(perk.valueRscList.Count<rscList.Count) perk.valueRscList.RemoveAt(perk.valueRscList.Count-1);
				
				//cont=new GUIContent("Gain:", "The resource to be gain upon purchasing this perk");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				int count=0;	startY+=spaceY; 	float cachedX=startX;
				for(int i=0; i<rscList.Count; i++){
					EditorUtilities.DrawSprite(new Rect(startX+15, startY-1, 20, 20), rscList[i].icon);
					perk.valueRscList[i]=EditorGUI.FloatField(new Rect(startX+35, startY, 40, height), perk.valueRscList[i]);
					count+=1; 	startX+=75;
					if(count==3){ startY+=spaceY; startX=cachedX; }
				}
				startX=cachedX;	startY+=5;
			}
			
			
			
			
			//~ if(IsPerkTypeUsesUnitStats(perkType)){
			if(perkType==_PerkType.Tower || perkType==_PerkType.TowerSpecific){
				Vector2 v2;
				if(perkType==_PerkType.TowerSpecific){
					v2=DrawItemIDTower(startX, startY, perk, 5);	startY=v2.y;
				}
				v2=DrawTowerStat(startX, startY, perk);		startY=v2.y;
			}
			
			if(perkType==_PerkType.Ability || perkType==_PerkType.AbilitySpecific){
				if(perkType==_PerkType.AbilitySpecific){
					DrawItemIDAbility(startX, startY, perk);	startY+=spaceY;
				}
				Vector2 v2=DrawAbilityStat(startX, startY, perk);		startY=v2.y;
			}
			
			if(perkType==_PerkType.FPSWeapon || perkType==_PerkType.FPSWeaponSpecific){
				if(perkType==_PerkType.FPSWeaponSpecific){
					DrawItemIDFPSWeapon(startX, startY, perk);	startY+=spaceY;
				}
				Vector2 v2=DrawFPSWeaponStat(startX, startY, perk);		startY=v2.y;
			}
			
			
			
			else if(perkType==_PerkType.EnergyRegen){
				cont=new GUIContent(" - Increase Value:", "value used to modify the existing energy regeneration rate");
				DrawValue(startX, startY, perk, cont);
			}
			else if(perkType==_PerkType.EnergyIncreaseCap){
				cont=new GUIContent(" - Increase Value:", "value used to modify the existing maximum energy capacity");
				DrawValue(startX, startY, perk, cont);
			}
			else if(perkType==_PerkType.EnergyCreepKilledBonus){
				GUIContent cont1=new GUIContent(" - Min value:", "Minimum value");
				GUIContent cont2=new GUIContent(" - Max value:", "Maximum value");
				DrawValueMinMax(startX, startY, perk, cont1, cont2);
			}
			else if(perkType==_PerkType.EnergyWaveClearedBonus){
				GUIContent cont1=new GUIContent(" - Min value:", "Minimum value");
				GUIContent cont2=new GUIContent(" - Max value:", "Maximum value");
				DrawValueMinMax(startX, startY, perk, cont1, cont2);
			}
			
			return new Vector2(startX, startY);
		}
		void DrawValueMinMax(float startX, float startY, Perk perk, GUIContent cont1=null, GUIContent cont2=null){
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont1);
			perk.value=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.value);
				
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont2);
			perk.valueAlt=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.valueAlt);
		}
		Vector2 DrawTowerStat(float startX, float startY, Perk perk){
			startY+=5;
			
			foldGeneralParameter=EditorGUI.Foldout(new Rect(startX, startY+=spaceY, width, height), foldGeneralParameter, "Show General Stats");
			
			if(foldGeneralParameter){
				startX+=15;
				
				cont=new GUIContent("HP:", "HP multiplier of the tower. Takes value from 0 and above with 0.2 being 20% increment");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				perk.HP=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.HP);
				cont=new GUIContent("HP Regen:", "HP rgeneration multiplier of the tower. Takes value from 0 and above with 0.2 being 20% increment");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				perk.HPRegen=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.HPRegen);
				cont=new GUIContent("HP Stagger:", "HP stagger duration multiplier of the tower. Takes value from 0-1 with 0.2 being 20% decrease in duration");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				perk.HPStagger=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.HPStagger);
				
				cont=new GUIContent("Shield:", "Shield multiplier of the tower. Takes value from 0 and above with 0.2 being 20% increment");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				perk.shield=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.shield);
				cont=new GUIContent("Shield Regen:", "Shield rgeneration multiplier of the tower. Takes value from 0 and above with 0.2 being 20% increment");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				perk.shieldRegen=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.shieldRegen);
				cont=new GUIContent("Shield Stagger:", "Shield stagger duration multiplier of the tower. Takes value from 0-1 with 0.2 being 20% decrease in duration");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				perk.shieldStagger=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.shieldStagger);
				
				cont=new GUIContent("Build Cost:", "Build cost multiplier of the tower. Takes value from 0-1 with 0.2 being 20% decrease in cost");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				perk.buildCost=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.buildCost);
				cont=new GUIContent("Upgrade Cost:", "Upgrade cost multiplier of the tower. Takes value from 0-1 with 0.2 being 20% decrease in cost");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
				perk.upgradeCost=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.upgradeCost);
				
				startX-=15;
			}
			
			Vector2 v2=DrawUnitStat(startX, startY+5, perk.stats, false);
			startY=v2.y;
			
			return new Vector2(startX, startY);
		}
Beispiel #24
0
        private static void RefreshRsc()
        {
            for (int i = 0; i < towerList.Count; i++)
            {
                UnitTower tower = towerList[i];
                for (int n = 0; n < tower.stats.Count; n++)
                {
                    UnitStat stat = tower.stats[n];

                    while (stat.cost.Count < rscList.Count)
                    {
                        stat.cost.Add(0);
                    }
                    while (stat.cost.Count > rscList.Count)
                    {
                        stat.cost.RemoveAt(stat.cost.Count - 1);
                    }

                    while (stat.rscGain.Count < rscList.Count)
                    {
                        stat.rscGain.Add(0);
                    }
                    while (stat.rscGain.Count > rscList.Count)
                    {
                        stat.rscGain.RemoveAt(stat.rscGain.Count - 1);
                    }
                }
            }

            for (int i = 0; i < creepList.Count; i++)
            {
                UnitCreep creep = creepList[i];

                while (creep.valueRscMin.Count < rscList.Count)
                {
                    creep.valueRscMin.Add(0);
                }
                while (creep.valueRscMin.Count > rscList.Count)
                {
                    creep.valueRscMin.RemoveAt(creep.valueRscMin.Count - 1);
                }

                while (creep.valueRscMax.Count < rscList.Count)
                {
                    creep.valueRscMax.Add(0);
                }
                while (creep.valueRscMax.Count > rscList.Count)
                {
                    creep.valueRscMax.RemoveAt(creep.valueRscMax.Count - 1);
                }
            }

            for (int i = 0; i < perkList.Count; i++)
            {
                Perk perk = perkList[i];
                while (perk.cost.Count < rscList.Count)
                {
                    perk.cost.Add(0);
                }
                while (perk.cost.Count > rscList.Count)
                {
                    perk.cost.RemoveAt(perk.cost.Count - 1);
                }
            }
        }
Beispiel #25
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (instance == null)
            {
                Awake(); return;
            }

            GUI.changed = false;

            Undo.RecordObject(instance, "PerkManager");

            EditorGUILayout.Space();

            cont = new GUIContent("Game Scene:", "Check to to indicate if the scene is not an actual game scene\nIntend if the a perk menu scene, purchased perk wont take effect ");
            instance.inGameScene = EditorGUILayout.Toggle(cont, instance.inGameScene);

            cont = new GUIContent("Carry Over:", "Check to have carry the progress made in previous level to this level, the progress made in this level will be carry over to the next level.\n\nIf this is the first level, the specified setting value is used instead");
            instance.carryOver = EditorGUILayout.Toggle(cont, instance.carryOver);

            EditorGUILayout.Space();


            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();

            EditorGUIUtility.labelWidth += 35;
            cont = new GUIContent("Use RscManager For Cost:", "Check use the resources in RscManager for perk cost");
            instance.useRscManagerForCost = EditorGUILayout.Toggle(cont, instance.useRscManagerForCost);
            EditorGUIUtility.labelWidth  -= 35;

            cont = new GUIContent("Resource:", "The resource used  to cast perk");
            if (instance.useRscManagerForCost)
            {
                EditorGUILayout.LabelField("Resource:", "-");
            }
            else
            {
                instance.rsc = EditorGUILayout.IntField(cont, instance.rsc);
            }

            GUILayout.EndVertical();

            if (!instance.useRscManagerForCost)
            {
                Sprite icon = PerkDB.GetRscIcon();
                icon = (Sprite)EditorGUILayout.ObjectField(icon, typeof(Sprite), true, GUILayout.Width(40), GUILayout.Height(40));
                PerkDB.SetRscIcon(icon);
            }

            GUILayout.EndHorizontal();


            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showList = EditorGUILayout.Foldout(showList, "Show Perk List");
            EditorGUILayout.EndHorizontal();
            if (showList)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailablePrefabIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.unavailablePrefabIDList = PerkDB.GetPrefabIDList();
                }
                EditorGUILayout.Space();
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();


                List <Perk> perkList = PerkDB.GetList();
                for (int i = 0; i < perkList.Count; i++)
                {
                    if (perkList[i].hideInInspector)
                    {
                        continue;
                    }

                    Perk perk = perkList[i];

                    GUILayout.BeginHorizontal();

                    EditorGUILayout.Space();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    TDE.DrawSprite(GUILayoutUtility.GetLastRect(), perk.icon, perk.desp, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(perk.name, GUILayout.ExpandWidth(false));

                    GUILayout.BeginHorizontal();

                    float cachedL = EditorGUIUtility.labelWidth;      EditorGUIUtility.labelWidth = 80;
                    float cachedF = EditorGUIUtility.fieldWidth;      EditorGUIUtility.fieldWidth = 10;

                    EditorGUI.BeginChangeCheck();
                    bool flag = !instance.unavailablePrefabIDList.Contains(perk.prefabID) ? true : false;
                    flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the perk in this level"), flag);

                    if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                    {
                        if (!flag && !instance.unavailablePrefabIDList.Contains(perk.prefabID))
                        {
                            instance.unavailablePrefabIDList.Add(perk.prefabID);
                            instance.purchasedPrefabIDList.Remove(perk.prefabID);
                        }
                        else if (flag)
                        {
                            instance.unavailablePrefabIDList.Remove(perk.prefabID);
                        }
                    }

                    if (!instance.unavailablePrefabIDList.Contains(perk.prefabID))
                    {
                        EditorGUI.BeginChangeCheck();
                        flag = instance.purchasedPrefabIDList.Contains(perk.prefabID);
                        flag = EditorGUILayout.Toggle(new GUIContent(" - purchased: ", "check to set the perk as purchased right from the start"), flag);

                        if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                        {
                            if (flag)
                            {
                                instance.purchasedPrefabIDList.Add(perk.prefabID);
                            }
                            else
                            {
                                instance.purchasedPrefabIDList.Remove(perk.prefabID);
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField(" - purchased: ", "- ");
                    }

                    EditorGUIUtility.labelWidth = cachedL;    EditorGUIUtility.fieldWidth = cachedF;

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();

            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Beispiel #26
0
 public static string PurchasePerk(Perk perk, bool useRsc = true)
 {
     return(instance._PurchasePerk(perk, useRsc));
 }
Beispiel #27
0
        Vector2 DrawPerkType(float startX, float startY, Perk perk)
        {
            // type
            int type = (int)perk.type;

            cont = new GUIContent("Perk Type:", "What the perk does");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            contL = new GUIContent[perkTypeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(perkTypeLabel[i], perkTypeTooltip[i]);
            }
            type      = EditorGUI.Popup(new Rect(startX + spaceX - 20, startY, width, 15), new GUIContent(""), type, contL);
            perk.type = (_PerkType)type;
            _PerkType perkType = perk.type;
            Vector2   v2;

            if (perkType == _PerkType.TowerSpecific)
            {
                v2 = DrawItemIDTower(startX, startY, perk, 3); startY = v2.y;
            }
            if (perkType == _PerkType.AbilitySpecific)
            {
                DrawItemIDAbility(startX, startY, perk); startY += spaceY;
            }
            // level
            perk.level = Mathf.Clamp(perk.level, 0, perk.perkLevel.Count - 1);
            int level = perk.level;

            cont = new GUIContent("Perk Level:", "Level of perk");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            contL = new GUIContent[perk.perkLevel.Count];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent((i + 1).ToString(), "");
            }
            level      = EditorGUI.Popup(new Rect(startX + spaceX - 20, startY, 50, 15), new GUIContent(""), level, contL);
            perk.level = level;
            if (GUI.Button(new Rect(startX + spaceX + 40, startY, 40, 15), "-1"))
            {
                if (perk.perkLevel.Count > 1)
                {
                    perk.perkLevel.RemoveAt(perk.perkLevel.Count - 1);
                }
            }
            if (GUI.Button(new Rect(startX + spaceX + 90, startY, 40, 15), "+1"))
            {
                perk.perkLevel.Add(perk.perkLevel[perk.perkLevel.Count - 1].Clone());
            }

            // Detail level

            startY      += spaceY * 2;
            minimiseStat = EditorGUI.Foldout(new Rect(startX, startY, width, height), minimiseStat, "Show Stats");

            float offsetDetail = 220;
            float maxHeight    = startY;
            float maxWidth     = startX + offsetDetail * (perk.perkLevel.Count - 1);

            if (!minimiseStat)
            {
                startY += spaceY;
                startX += 15;
                for (int i = 0; i < perk.perkLevel.Count; i++)
                {
                    EditorGUI.LabelField(new Rect(startX + offsetDetail * i, startY, width, height), "Level " + (i + 1) + " Stats");
                    float _height = DrawLevelDetail(startX + offsetDetail * i, startY, perk, i).y;
                    if (_height > maxHeight)
                    {
                        maxHeight = _height;
                    }
                }
            }

            return(new Vector2(maxWidth, maxHeight));
        }
Beispiel #28
0
 private void ModifyTowerModifierInList(int ID, Perk perk)
 {
     ModifyTowerModifier(towerModifierList[ID], perk);
 }
Beispiel #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="startX"></param>
        /// <param name="startY"></param>
        /// <param name="perk"></param>
        /// <param name="level"></param>
        /// <returns></returns>
        Vector2 DrawLevelDetail(float startX, float startY, Perk perk, int level)
        {
            _PerkType perkType = perk.type;

            // cost
            cont = new GUIContent("Upgrage Cost:", "The resource required to build/upgrade to this level");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.perkLevel[level].cost = EditorGUI.IntField(new Rect(startX + 100, startY, 85, height), perk.perkLevel[level].cost);
            // stats level
            startX += 10;

            if (perkType == _PerkType.GainLife)
            {
                GUIContent cont1 = new GUIContent(" - Min value:", "Minimum value");
                GUIContent cont2 = new GUIContent(" - Max value:", "Maximum value");
                DrawValueMinMax(startX, startY, perk, level, cont1, cont2);
                startY += spaceY;
            }
            else if (perkType == _PerkType.LifeCap)
            {
                cont = new GUIContent(" - Increase Value:", "value used to modify the existing maximum life capacity");
                DrawValue(startX, startY, perk, level, cont);
            }
            else if (perkType == _PerkType.LifeRegen)
            {
                cont = new GUIContent(" - Increase Value:", "value used to modify the existing life regeneration rate");
                DrawValue(startX, startY, perk, level, cont);
            }
            else if (perkType == _PerkType.LifeWaveClearedBonus)
            {
                GUIContent cont1 = new GUIContent(" - Min value:", "Minimum value");
                GUIContent cont2 = new GUIContent(" - Max value:", "Maximum value");
                DrawValueMinMax(startX, startY, perk, level, cont1, cont2);
                startY += spaceY;
            }
            else if (IsPerkTypeUsesRsc(perkType))
            {
                if (perkType == _PerkType.RscCap)
                {
                    cont = new GUIContent(" - Gain:", "The resource to be gain upon purchasing this perk");
                }
                else if (perkType == _PerkType.RscRegen)
                {
                    cont = new GUIContent(" - Rate modifier:", "The resource to be gain upon purchasing this perk");
                }
                else if (perkType == _PerkType.RscGain)
                {
                    cont = new GUIContent(" - Gain multiplier:", "The resource to be gain upon purchasing this perk");
                }
                else if (perkType == _PerkType.RscCreepKilledGain)
                {
                    cont = new GUIContent(" - Gain multiplier:", "The resource to be gain upon purchasing this perk");
                }
                else if (perkType == _PerkType.RscWaveClearedGain)
                {
                    cont = new GUIContent(" - Gain multiplier:", "The resource to be gain upon purchasing this perk");
                }
                else if (perkType == _PerkType.RscResourceTowerGain)
                {
                    cont = new GUIContent(" - Gain multiplier:", "The resource to be gain upon purchasing this perk");
                }

                //cont=new GUIContent("Gain:", "The resource to be gain upon purchasing this perk");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                startY += spaceY; float cachedX = startX;

                EditorUtilities.DrawSprite(new Rect(startX + 15, startY - 1, 20, 20), EditorDBManager.iconRsc);
                perk.perkLevel[level].valueRsc = EditorGUI.FloatField(new Rect(startX + 35, startY, 40, height), perk.perkLevel[level].valueRsc);

                startX = cachedX; startY += 5;
            }

            //~ if(IsPerkTypeUsesUnitStats(perkType)){
            if (perkType == _PerkType.Tower || perkType == _PerkType.TowerSpecific)
            {
                Vector2 v2;
                v2 = DrawTowerStat(startX, startY, perk, level); startY = v2.y;
            }

            if (perkType == _PerkType.Ability || perkType == _PerkType.AbilitySpecific)
            {
                Vector2 v2 = DrawAbilityStat(startX, startY, perk, level); startY = v2.y;
            }

            else if (perkType == _PerkType.EnergyRegen)
            {
                cont = new GUIContent(" - Increase Value:", "value used to modify the existing energy regeneration rate");
                DrawValue(startX, startY, perk, level, cont);
            }
            else if (perkType == _PerkType.EnergyIncreaseCap)
            {
                cont = new GUIContent(" - Increase Value:", "value used to modify the existing maximum energy capacity");
                DrawValue(startX, startY, perk, level, cont);
            }
            else if (perkType == _PerkType.EnergyCreepKilledBonus)
            {
                GUIContent cont1 = new GUIContent(" - Min value:", "Minimum value");
                GUIContent cont2 = new GUIContent(" - Max value:", "Maximum value");
                DrawValueMinMax(startX, startY, perk, level, cont1, cont2);
                startY += spaceY;
            }
            else if (perkType == _PerkType.EnergyWaveClearedBonus)
            {
                GUIContent cont1 = new GUIContent(" - Min value:", "Minimum value");
                GUIContent cont2 = new GUIContent(" - Max value:", "Maximum value");
                DrawValueMinMax(startX, startY, perk, level, cont1, cont2);
                startY += spaceY;
            }
            // des level

            startY += spaceY;
            GUIStyle style = new GUIStyle("TextArea");

            style.wordWrap = true;
            cont           = new GUIContent("Level Description:", "Level Description");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.perkLevel[level].desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 175, 75), perk.perkLevel[level].desp, style);
            startY += 75;
            //
            return(new Vector2(startX, startY));
        }
Beispiel #30
0
		public static void OnPerkPurchased(Perk perk){
			if(onPerkPurchasedE!=null) onPerkPurchasedE(perk);
		}
Beispiel #31
0
        Vector2 DrawAbilityStat(float startX, float startY, Perk perk, int level)
        {
            startY += 5;

            //~ if(perk.itemIDList[0]==-1) return;

            //~ Ability ability=null;
            //~ List<Ability> abilityList=EditorDBManager.GetAbilityList();
            //~ for(int i=0; i<abilityList.Count; i++){ if(abilityList[i].ID==perk.itemIDList[0]) ability=abilityList[i]; }

            cont = new GUIContent("Cost:", "Multiplier to the ability energy cost. Takes value from 0-1 with 0.3 being decrease energy cost by 30%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.perkLevel[level].abCost = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), perk.perkLevel[level].abCost);
            cont = new GUIContent("Cooldown:", "Multiplier to the ability cooldown duration. Takes value from 0-1 with 0.3 being decrease cooldown duration by 30%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.perkLevel[level].abCooldown              = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), perk.perkLevel[level].abCooldown);
            cont = new GUIContent("AOE Radius:", "Multiplier to the ability AOE radius. Takes value from 0 and above with 0.3 being increment of 30%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.perkLevel[level].abAOERadius             = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), perk.perkLevel[level].abAOERadius);


            startY += 5;

            cont = new GUIContent("Duration:", "Duration multiplier. Takes value from 0 and above with 0.3 being increase duration by 30%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.perkLevel[level].effects.duration        = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), perk.perkLevel[level].effects.duration);
            perk.perkLevel[level].effects.dot.duration    = perk.perkLevel[level].effects.duration;
            perk.perkLevel[level].effects.slow.duration   = perk.perkLevel[level].effects.duration;

            startY += 5;

            cont = new GUIContent("Damage:", "Damage multiplier. Takes value from 0 and above with 0.3 being increase existing effect damage by 30%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.perkLevel[level].effects.damageMin       = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), perk.perkLevel[level].effects.damageMin);

            cont = new GUIContent("Stun Chance:", "Duration modifier. Takes value from 0 and above with 0.3 being increase stun chance by 30%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.perkLevel[level].effects.stunChance      = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), perk.perkLevel[level].effects.stunChance);

            startY += 5;

            cont = new GUIContent("Slow", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); startY -= spaceY;

            cont = new GUIContent("         - Multiplier:", "Move speed multiplier. Takes value from 0-1 with with 0.3 being decrese default speed by 30%");
            EditorGUI.LabelField(new Rect(startX, startY     += spaceY, width, height), cont);
            perk.perkLevel[level].effects.slow.slowMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), perk.perkLevel[level].effects.slow.slowMultiplier);


            startY += 5;

            cont = new GUIContent("Dot", "Damage over time");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); startY -= spaceY;

            cont = new GUIContent("        - Damage:", "Damage multiplier to DOT. Takes value from 0 and above with with 0.3 being increase the tick damage by 30%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.perkLevel[level].effects.dot.value       = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), perk.perkLevel[level].effects.dot.value);

            startY += 5;

            cont = new GUIContent("DamageBuff:", "Damage buff modifer. Takes value from 0 and above with 0.3 being increase existing damage by 30%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.perkLevel[level].effects.damageBuff      = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), perk.perkLevel[level].effects.damageBuff);

            cont = new GUIContent("RangeBuff:", "Range buff modifer. Takes value from 0 and above with 0.3 being increase existing range by 30%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.perkLevel[level].effects.rangeBuff       = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), perk.perkLevel[level].effects.rangeBuff);

            cont = new GUIContent("CDBuff:", "Cooldown buff modifer. Takes value from 0 and above with 0.3 being reduce existing cooldown by 30%");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.perkLevel[level].effects.cooldownBuff    = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), perk.perkLevel[level].effects.cooldownBuff);

            cont = new GUIContent("HPGain:", "HP Gain multiplier. Takes value from 0 and above with 0.3 being increase existing effect HP gain value by 30%.");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perk.perkLevel[level].effects.HPGainMin       = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), perk.perkLevel[level].effects.HPGainMin);


            return(new Vector2(startX, startY));
        }
Beispiel #32
0
        protected float DrawBasicSetting(float startX, float startY, Perk item)
        {
            //TDE.Label(startX, startY+=spaceY, width, height, "General Setting", "", TDE.headerS);
            string textF = "General Setting ";          //+(!foldBasicSetting ? "(show)" : "(hide)");

            foldBasicSetting = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldBasicSetting, textF, TDE.foldoutS);
            if (!foldBasicSetting)
            {
                return(startY);
            }

            startX += 12;

            //~ TDE.Label(startX, startY+=spaceY, width, height, "Gained on Wave:", "");	CheckColor(item.autoUnlockOnWave, -1);
            //~ item.autoUnlockOnWave=EditorGUI.IntField(new Rect(startX+spaceX, startY, widthS, height), item.autoUnlockOnWave);	ResetColor();

            //~ startY+=10;

            TDE.Label(startX, startY += spaceY, width, height, "Cost:", "The cost of PerkManager resource required for the perk\nUsed when 'Use RscManager For Cost' is disabled in PerkManager");
            item.cost = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.cost);

            TDE.Label(startX, startY += spaceY, width, height, "Cost (Rsc):", "The cost of RscManager resource required for the perk\nUsed when 'Use RscManager For Cost' is enabled in PerkManager");
            //~ while(item.costRsc.Count<RscDB.GetCount()) item.costRsc.Add(0);
            //~ while(item.costRsc.Count>RscDB.GetCount()) item.costRsc.RemoveAt(item.costRsc.Count-1);

            RscManager.MatchRscList(item.costRsc, 0);

            float cachedX = startX;

            for (int i = 0; i < RscDB.GetCount(); i++)
            {
                if (i > 0 && i % 3 == 0)
                {
                    startX = cachedX; startY += spaceY;
                }
                if (i > 0)
                {
                    startX += widthS + 2;
                }
                TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i));
                item.costRsc[i] = EditorGUI.FloatField(new Rect(startX + spaceX + height, startY, widthS - height, height), item.costRsc[i]);
            }
            startX = cachedX;

            //TDE.Label(startX, startY+=spaceY, width, height, "Repeatabe:", "");
            //item.repeatable=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), item.repeatable);
            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "AutoUnlockOnWave:", "If given a value, the perk will automatically be purchased for the player upon completing the specified wave");  CheckColor(item.autoUnlockOnWave, 0);
            item.autoUnlockOnWave     = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.autoUnlockOnWave);       ResetColor();

            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "Min Level:", "The minimum level required before the perk becomes available\n\nThis is value of 'Level ID' in GameControl");   CheckColor(item.minLevel, 0);
            item.minLevel             = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.minLevel);       ResetColor();

            TDE.Label(startX, startY += spaceY, width, height, "Min Wave:", "The minimum wave required before the perk becomes available");   CheckColor(item.minWave, 0);
            item.minWave              = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.minWave); ResetColor();

            TDE.Label(startX, startY += spaceY, width, height, "Min Perk Count:", "The minimum number of perk purchased required before the perk becomes available"); CheckColor(item.minPerkCount, 0);
            item.minPerkCount         = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.minPerkCount);       ResetColor();


            TDE.Label(startX, startY += spaceY, width, height, "Prereq Perk:", "Perk(s) required to be purchased before the perk becomes available");
            for (int i = 0; i < item.prereq.Count; i++)
            {
                TDE.Label(startX + spaceX - 20, startY, widthS, height, "-");

                int index = PerkDB.GetPrefabIndex(item.prereq[i]);
                if (index < 0)
                {
                    item.prereq.RemoveAt(i); i -= 1; continue;
                }

                index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, PerkDB.label);

                int prefabID = PerkDB.GetItem(index).prefabID;
                if (prefabID != item.prefabID && !item.prereq.Contains(prefabID))
                {
                    item.prereq[i] = prefabID;
                }

                if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                {
                    item.prereq.RemoveAt(i); i -= 1;
                }

                startY += spaceY;
            }

            int newID = -1;           CheckColor(item.prereq.Count, 0);

            newID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newID, PerkDB.label);
            if (newID >= 0 && !item.prereq.Contains(newID))
            {
                item.prereq.Add(newID);
            }
            startY += 10;
            ResetColor();

            return(startY);
        }
Beispiel #33
0
 private void ModifyAbilityModifierInList(int ID, Perk perk)
 {
     ModifyAbilityModifier(abilityModifierList[ID], perk);
 }
		public static string PurchasePerk(Perk perk, bool useRsc=true){ return instance._PurchasePerk(perk, useRsc); }
Beispiel #35
0
 private void ModifyFPSWeaponModifierInList(int ID, Perk perk)
 {
     ModifyUnitStats(FPSWeaponModifierList[ID].stats, perk.stats);
 }
		private void ModifyTowerModifierInList(int ID, Perk perk){ ModifyTowerModifier(towerModifierList[ID], perk); }
		Vector2 DrawPerkConfigurator(float startX, float startY, Perk perk){
			
			float cachedX=startX;
			float cachedY=startY;
			
			EditorUtilities.DrawSprite(new Rect(startX, startY, 60, 60), perk.icon);
			startX+=65;
			
			cont=new GUIContent("Name:", "The ability name to be displayed in game");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY/2, width, height), cont);
			perk.name=EditorGUI.TextField(new Rect(startX+spaceX-65, startY, width-5, height), perk.name);
			
			cont=new GUIContent("Icon:", "The ability icon to be displayed in game, must be a sprite");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.icon=(Sprite)EditorGUI.ObjectField(new Rect(startX+spaceX-65, startY, width-5, height), perk.icon, typeof(Sprite), false);
			
			startX-=65;
			startY+=10+spaceY/2;	cachedY=startY;
			
			cont=new GUIContent("Repeatable:", "Check if the ability can be repeatably purchase. For perk that offer straight, one off bonus such as life and resource");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.repeatable=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), perk.repeatable);
			
			
			cont=new GUIContent("Prerequisite Perk:", "Perks that needs to be purchased before this perk is unlocked and become available");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			
			int listID=0;
			string[] perkNameList=EditorDBManager.GetPerkNameList();
			for(int i=0; i<perk.prereq.Count; i++){
				listID=GetListIDFromPerkID(perk.prereq[i])+1;
				listID=EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), listID, perkNameList);
				if(listID>0){
					int ID=GetPerkIDFromListID(listID-1);
					if(ID!=perk.ID && !perk.prereq.Contains(ID)) perk.prereq[i]=ID;
				}
				else{
					perk.prereq.RemoveAt(i);
					i-=1;
				}
				startY+=spaceY;
			}
			listID=0;
			listID = EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), listID, perkNameList);
			if(listID>0){
				int ID=GetPerkIDFromListID(listID-1);
				if(ID!=perk.ID && !perk.prereq.Contains(ID)) perk.prereq.Add(ID);
			}
			
			
			cont=new GUIContent("Min level required:", "Minimum level to reach before the perk becoming available. (level are specified in GameControl of each scene)");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.minLevel=EditorGUI.IntField(new Rect(startX+spaceX, startY, 40, height), perk.minLevel);
			
			cont=new GUIContent("Min wave required:", "Minimum wave to reach before the perk becoming available");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.minWave=EditorGUI.IntField(new Rect(startX+spaceX, startY, 40, height), perk.minWave);
			
			cont=new GUIContent("Min PerkPoint req:", "Minimum perk point to have before the perk becoming available");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.minPerkPoint=EditorGUI.IntField(new Rect(startX+spaceX, startY, 40, height), perk.minPerkPoint);
			
			
			List<Rsc> rscList=EditorDBManager.GetRscList();
			
			while(perk.cost.Count<rscList.Count) perk.cost.Add(0);
			while(perk.cost.Count>rscList.Count) perk.cost.RemoveAt(perk.cost.Count-1);
			
				cont=new GUIContent("Purchase Cost:", "The resource required to build/upgrade to this level");
				EditorGUI.LabelField(new Rect(startX, startY+=spaceY+3, width, height), cont);
				int count=0;	startX+=spaceX;		float cachedX2=startX;
				for(int i=0; i<perk.cost.Count; i++){
					EditorUtilities.DrawSprite(new Rect(startX, startY-1, 20, 20), rscList[i].icon);
					perk.cost[i]=EditorGUI.IntField(new Rect(startX+20, startY, 40, height), perk.cost[i]);
					count+=1; 	startX+=75;
					if(count==2){ startY+=spaceY; startX=cachedX2; }
				}
			
			//startX=cachedX;	//startY+=4;
			
			float temp=cachedY;
			cachedY=startY+15;	startY=temp;	
			startX=cachedX+310;
			
			Vector2 v2=DrawPerkType(startX, startY, perk);  float maxHeight=v2.y+40;
			
			
			startX=cachedX;	startY=cachedY;
			
			GUIStyle style=new GUIStyle("TextArea");
			style.wordWrap=true;
			cont=new GUIContent("Perk description (to be used in runtime): ", "");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, 400, 20), cont);
			perk.desp=EditorGUI.TextArea(new Rect(startX, startY+spaceY-3, 270, 150), perk.desp, style);
				
				
			return new Vector2(startX+280, Mathf.Max(maxHeight, startY+170));
		}
		private void ModifyAbilityModifierInList(int ID, Perk perk){ ModifyAbilityModifier(abilityModifierList[ID], perk);}
Beispiel #39
0
        public bool _PurchasePerk(Perk perk)
        {
            if (perk.IsAvailable() == false)
            {
                return(false);
            }

            if (perk.type == _PerkType.GainLife)
            {
                GameControl.GainLife((int)Random.Range(perk.perkLevel[perk.level].value, perk.perkLevel[perk.level].valueAlt));
            }
            else if (perk.type == _PerkType.LifeCap)
            {
                lifeCap += (int)perk.perkLevel[perk.level].value; GameControl.GainLife(0);
            }
            else if (perk.type == _PerkType.LifeRegen)
            {
                lifeRegen += perk.perkLevel[perk.level].value;
            }
            else if (perk.type == _PerkType.LifeWaveClearedBonus)
            {
                lifeWaveClearedBonus += (int)perk.perkLevel[perk.level].value;
            }

            else if (perk.type == _PerkType.RscCap)
            {
                int _value = (int)perk.perkLevel[perk.level].valueRsc;
                ResourceManager.GainResource(_value, 0, false); //dont pass multiplier and dont use multiplier
            }
            else if (perk.type == _PerkType.RscRegen)
            {
                rscRegen += perk.perkLevel[perk.level].valueRsc;
            }
            else if (perk.type == _PerkType.RscGain)
            {
                rscGain += perk.perkLevel[perk.level].valueRsc;
            }
            else if (perk.type == _PerkType.RscCreepKilledGain)
            {
                rscCreepKilledGain += perk.perkLevel[perk.level].valueRsc;
            }
            else if (perk.type == _PerkType.RscWaveClearedGain)
            {
                rscWaveClearedGain += perk.perkLevel[perk.level].valueRsc;
            }
            else if (perk.type == _PerkType.RscResourceTowerGain)
            {
                rscRscTowerGain += perk.perkLevel[perk.level].valueRsc;
            }

            else if (perk.type == _PerkType.Tower)
            {
                ModifyTowerModifier(globalTowerModifier, perk);
            }
            else if (perk.type == _PerkType.TowerSpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = TowerModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkTowerModifier towerModifier = new PerkTowerModifier();
                        towerModifier.prefabID = perk.itemIDList[i];
                        towerModifierList.Add(towerModifier);
                        ID = towerModifierList.Count - 1;
                    }
                    ModifyTowerModifierInList(ID, perk);
                }
            }
            else if (perk.type == _PerkType.Ability)
            {
                ModifyAbilityModifier(globalAbilityModifier, perk);
            }
            else if (perk.type == _PerkType.AbilitySpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = AbilityModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkAbilityModifier abilityModifier = new PerkAbilityModifier();
                        abilityModifier.abilityID = perk.itemIDList[i];
                        abilityModifierList.Add(abilityModifier);
                        ID = abilityModifierList.Count - 1;
                    }
                    ModifyAbilityModifierInList(ID, perk);
                }
            }

            else if (perk.type == _PerkType.EnergyRegen)
            {
                energyRegen += perk.perkLevel[perk.level].value;
            }
            else if (perk.type == _PerkType.EnergyIncreaseCap)
            {
                energyCap += perk.perkLevel[perk.level].value;
            }
            else if (perk.type == _PerkType.EnergyCreepKilledBonus)
            {
                energyCreepKilledBonus += perk.perkLevel[perk.level].value;
            }
            else if (perk.type == _PerkType.EnergyWaveClearedBonus)
            {
                energyWaveClearedBonus += perk.perkLevel[perk.level].value;
            }

            return(true);
        }
		private void ModifyFPSWeaponModifierInList(int ID, Perk perk){ ModifyUnitStats(FPSWeaponModifierList[ID].stats, perk.stats); }
		void OnPerkPurchased(Perk perk){ if(perkPurchasedSound!=null) _PlaySound(perkPurchasedSound); }
        public Perk Clone()
        {
            Perk perk=new Perk();
            perk.ID=ID;
            perk.name=name;
            perk.icon=icon;
            perk.iconUnavailable=iconUnavailable;

            perk.repeatable=repeatable;
            perk.purchased=purchased;

            perk.type=type;

            //perk.cost=cost;
            perk.cost=new List<int>(cost);
            perk.minLevel=minLevel;
            perk.minWave=minWave;
            perk.minPerkPoint=minPerkPoint;
            //perk.prereq=prereq;
            perk.prereq=new List<int>(prereq);

            //perk.itemIDList=itemIDList;
            perk.itemIDList=new List<int>(itemIDList);
            perk.itemID=itemID;
            perk.value=value;
            perk.valueAlt=valueAlt;
            //perk.valueRscList=valueRscList;
            perk.valueRscList=new List<float>(valueRscList);
            perk.stats=stats;

            perk.HP=HP;
            perk.HPRegen=HPRegen;
            perk.HPStagger=HPStagger;
            perk.shield=shield;
            perk.shieldRegen=shieldRegen;
            perk.shieldStagger=shieldStagger;
            perk.buildCost=buildCost;
            perk.upgradeCost=upgradeCost;

            perk.abCost=abCost;
            perk.abCooldown=abCooldown;
            perk.abAOERadius=abAOERadius;

            perk.desp=desp;

            return perk;
        }
Beispiel #43
0
        public override void OnInspectorGUI()
        {
            GUI.changed = false;

            EditorGUILayout.Space();

            cont = new GUIContent("Persistant Progress", "Check to use persistantProgress\nThe progress done in this level will be carried to next\nEnable this will cause all the level to use the perk enabled in this instance, perk enabled/disable in subsequent PerkManager instance will be ignored");
            instance.persistantProgress = EditorGUILayout.Toggle(cont, instance.persistantProgress);

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showPerkList = EditorGUILayout.Foldout(showPerkList, "Show Perk List");
            EditorGUILayout.EndHorizontal();
            if (showPerkList)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailableIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.purchasedIDList = new List <int>();

                    instance.unavailableIDList = new List <int>();
                    for (int i = 0; i < perkList.Count; i++)
                    {
                        instance.unavailableIDList.Add(perkList[i].ID);
                    }
                }
                EditorGUILayout.EndHorizontal();


                for (int i = 0; i < perkList.Count; i++)
                {
                    Perk perk = perkList[i];


                    GUILayout.BeginHorizontal();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    Rect rect = GUILayoutUtility.GetLastRect();
                    EditorUtilities.DrawSprite(rect, perk.icon, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(perk.name, GUILayout.ExpandWidth(false));

                    GUILayout.BeginHorizontal();
                    bool flag = !instance.unavailableIDList.Contains(perk.ID) ? true : false;
                    if (Application.isPlaying)
                    {
                        flag = !flag;                                                                           //switch it around in runtime
                    }
                    EditorGUILayout.LabelField(new GUIContent(" - enabled: ", "check to enable the perk in this level"), GUILayout.Width(70));
                    flag = EditorGUILayout.Toggle(flag);

                    if (!Application.isPlaying)
                    {
                        if (flag)
                        {
                            instance.unavailableIDList.Remove(perk.ID);
                        }
                        else
                        {
                            if (!instance.unavailableIDList.Contains(perk.ID))
                            {
                                instance.unavailableIDList.Add(perk.ID);
                                instance.purchasedIDList.Remove(perk.ID);
                            }
                        }
                    }

                    if (!instance.unavailableIDList.Contains(perk.ID))
                    {
                        flag = instance.purchasedIDList.Contains(perk.ID);
                        EditorGUILayout.LabelField(new GUIContent("- purchased:", "Check to set the perk as purchased right from the start"), GUILayout.Width(75));
                        flag = EditorGUILayout.Toggle(flag);
                        if (!flag)
                        {
                            instance.purchasedIDList.Remove(perk.ID);
                        }
                        else if (!instance.purchasedIDList.Contains(perk.ID))
                        {
                            instance.purchasedIDList.Add(perk.ID);
                        }
                    }

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();

            if (GUILayout.Button("Open PerkEditor"))
            {
                PerkEditorWindow.Init();
            }
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showDefaultFlag = EditorGUILayout.Foldout(showDefaultFlag, "Show default editor");
            EditorGUILayout.EndHorizontal();
            if (showDefaultFlag)
            {
                DrawDefaultInspector();
            }


            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Beispiel #44
0
        public string _PurchasePerk(Perk perk, bool useRsc = true)
        {
            string text = perk.Purchase(useRsc);

            if (text != "")
            {
                return(text);
            }

            if (!purchasedIDList.Contains(perk.ID))
            {
                purchasedIDList.Add(perk.ID);
            }
            SavePurchasedPerk();

            TDTK.OnPerkPurchased(perk);

            //process the prereq for other perk
            for (int i = 0; i < perkList.Count; i++)
            {
                Perk perkTemp = perkList[i];
                if (perkTemp.purchased || perkTemp.prereq.Count == 0)
                {
                    continue;
                }
                perkTemp.prereq.Remove(perk.ID);
            }


            perkPoint += 1;
            TDTK.OnPerkPoint();

            if (perk.type == _PerkType.NewTower)
            {
                UnitTower tower = TDTK.GetDBTower(perk.itemIDList[0]);
                unlockedTowerList.Add(tower);
                BuildManager.AddNewTower(tower);
            }
            else if (perk.type == _PerkType.NewAbility)
            {
                Ability ability = TDTK.GetDBAbility(perk.itemIDList[0]);
                unlockedAbilityList.Add(ability);
                AbilityManager.AddNewAbility(ability);
            }
            else if (perk.type == _PerkType.NewFPSWeapon)
            {
                FPSWeapon weapon = TDTK.GetDBFpsWeapon(perk.itemIDList[0]);
                unlockedWeaponList.Add(weapon);
                FPSControl.AddNewWeapon(weapon);
            }

            else if (perk.type == _PerkType.GainLife)
            {
                GameControl.GainLife((int)Random.Range(perk.value, perk.valueAlt));
            }
            else if (perk.type == _PerkType.LifeCap)
            {
                lifeCap += (int)perk.value; GameControl.GainLife(0);
            }
            else if (perk.type == _PerkType.LifeRegen)
            {
                lifeRegen += perk.value;
            }
            else if (perk.type == _PerkType.LifeWaveClearedBonus)
            {
                lifeWaveClearedBonus += (int)perk.value;
            }

            else if (perk.type == _PerkType.GainRsc)
            {
                List <int> valueList = new List <int>();
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    valueList.Add((int)perk.valueRscList[i]);
                }
                ResourceManager.GainResource(valueList, null, false);                   //dont pass multiplier and dont use multiplier
            }
            else if (perk.type == _PerkType.RscRegen)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscRegen[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscCreepKilledGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscCreepKilledGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscWaveClearedGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscWaveClearedGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscResourceTowerGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscRscTowerGain[i] += perk.valueRscList[i];
                }
            }

            else if (perk.type == _PerkType.Tower)
            {
                ModifyTowerModifier(globalTowerModifier, perk);
            }
            else if (perk.type == _PerkType.TowerSpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = TowerModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkTowerModifier towerModifier = new PerkTowerModifier();
                        towerModifier.prefabID = perk.itemIDList[i];
                        towerModifierList.Add(towerModifier);
                        ID = towerModifierList.Count - 1;
                    }
                    ModifyTowerModifierInList(ID, perk);
                }
            }
            else if (perk.type == _PerkType.Ability)
            {
                ModifyAbilityModifier(globalAbilityModifier, perk);
            }
            else if (perk.type == _PerkType.AbilitySpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = AbilityModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkAbilityModifier abilityModifier = new PerkAbilityModifier();
                        abilityModifier.abilityID = perk.itemIDList[i];
                        abilityModifierList.Add(abilityModifier);
                        ID = abilityModifierList.Count - 1;
                    }
                    ModifyAbilityModifierInList(ID, perk);
                }
            }
            else if (perk.type == _PerkType.FPSWeapon)
            {
                ModifyFPSWeaponModifier(globalFPSWeaponModifier, perk);
            }
            else if (perk.type == _PerkType.FPSWeaponSpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = FPSWeaponModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkFPSWeaponModifier weaponModifier = new PerkFPSWeaponModifier();
                        weaponModifier.prefabID = perk.itemIDList[i];
                        FPSWeaponModifierList.Add(weaponModifier);
                        ID = FPSWeaponModifierList.Count - 1;
                    }
                    ModifyFPSWeaponModifierInList(ID, perk);
                }
            }

            else if (perk.type == _PerkType.EnergyRegen)
            {
                energyRegen += perk.value;
            }
            else if (perk.type == _PerkType.EnergyIncreaseCap)
            {
                energyCap += perk.value;
            }
            else if (perk.type == _PerkType.EnergyCreepKilledBonus)
            {
                energyCreepKilledBonus += perk.value;
            }
            else if (perk.type == _PerkType.EnergyWaveClearedBonus)
            {
                energyWaveClearedBonus += perk.value;
            }

            return("");
        }
Beispiel #45
0
        //madeby ays and perkid nonstatic
        public string _RemovePerk(string perkName)
        {
            Perk perk=new Perk();
            string text = "not removed";
            for(int i=0; i<perkList.Count; i++)
            {
                if(perkList[i].name==perkName)
                {
                    Debug.Log("Perkmaneger : perklist i is "+i+" perkName is"+perkName+" perktype is "+perkList[i].type);
                    text=perkList[i].Removed();
                    perk=perkList[i];
                }
            }
            perkPoint -= 1;
            if(onPerkPointE!=null) onPerkPointE(perkPoint);

            if(perk.type==_PerkType.NewTower){
                List<UnitTower> towerList=TowerDB.Load();
                for(int i=0; i<towerList.Count; i++){
                    if(towerList[i].prefabID==perk.itemIDList[0]){
                        //unlockedTower.Add(towerList[i]);
                        //BuildManager.AddNewTower(towerList[i]);
                        BuildManager.RemoveTower(towerList[i]);
                    }
                }
            }

            return text;
        }
Beispiel #46
0
        Vector2 DrawPerkList(float startX, float startY, List <Perk> perkList)
        {
            float width = 260;

            if (minimiseList)
            {
                width = 60;
            }


            if (!minimiseList)
            {
                if (GUI.Button(new Rect(startX + 180, startY - 20, 40, 18), "up"))
                {
                    if (selectID > 0)
                    {
                        Perk perk = perkList[selectID];
                        perkList[selectID]     = perkList[selectID - 1];
                        perkList[selectID - 1] = perk;
                        selectID -= 1;

                        if (selectID * 35 < scrollPos1.y)
                        {
                            scrollPos1.y = selectID * 35;
                        }
                    }
                }
                if (GUI.Button(new Rect(startX + 222, startY - 20, 40, 18), "down"))
                {
                    if (selectID < perkList.Count - 1)
                    {
                        Perk perk = perkList[selectID];
                        perkList[selectID]     = perkList[selectID + 1];
                        perkList[selectID + 1] = perk;
                        selectID += 1;

                        if (listVisibleRect.height - 35 < selectID * 35)
                        {
                            scrollPos1.y = (selectID + 1) * 35 - listVisibleRect.height + 5;
                        }
                    }
                }
            }


            listVisibleRect = new Rect(startX, startY, width + 15, window.position.height - startY - 5);
            listContentRect = new Rect(startX, startY, width, perkList.Count * 35 + 5);

            GUI.color = new Color(.8f, .8f, .8f, 1f);
            GUI.Box(listVisibleRect, "");
            GUI.color = Color.white;

            scrollPos1 = GUI.BeginScrollView(listVisibleRect, scrollPos1, listContentRect);


            startY += 5; startX += 5;

            for (int i = 0; i < perkList.Count; i++)
            {
                EditorUtilities.DrawSprite(new Rect(startX, startY + (i * 35), 30, 30), perkList[i].icon);

                if (minimiseList)
                {
                    if (selectID == i)
                    {
                        GUI.color = new Color(0, 1f, 1f, 1f);
                    }
                    if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 30, 30), ""))
                    {
                        SelectPerk(i);
                    }
                    GUI.color = Color.white;

                    continue;
                }



                if (selectID == i)
                {
                    GUI.color = new Color(0, 1f, 1f, 1f);
                }
                if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 150, 30), perkList[i].name))
                {
                    SelectPerk(i);
                }
                GUI.color = Color.white;

                if (deleteID == i)
                {
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "cancel"))
                    {
                        deleteID = -1;
                    }

                    GUI.color = Color.red;
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35) + 15, 60, 15), "confirm"))
                    {
                        if (selectID >= deleteID)
                        {
                            SelectPerk(Mathf.Max(0, selectID - 1));
                        }
                        perkList.RemoveAt(deleteID);
                        deleteID = -1;
                    }
                    GUI.color = Color.white;
                }
                else
                {
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "remove"))
                    {
                        deleteID = i;
                    }
                }
            }

            GUI.EndScrollView();

            return(new Vector2(startX + width, startY));
        }
		Vector2 DrawAbilityStat(float startX, float startY, Perk perk){
			startY+=5;
			
			//~ if(perk.itemIDList[0]==-1) return;
			
			//~ Ability ability=null; 
			//~ List<Ability> abilityList=EditorDBManager.GetAbilityList();
			//~ for(int i=0; i<abilityList.Count; i++){ if(abilityList[i].ID==perk.itemIDList[0]) ability=abilityList[i]; }
			
			cont=new GUIContent("Cost:", "Multiplier to the ability energy cost. Takes value from 0-1 with 0.3 being decrease energy cost by 30%");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.abCost=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.abCost);
			cont=new GUIContent("Cooldown:", "Multiplier to the ability cooldown duration. Takes value from 0-1 with 0.3 being decrease cooldown duration by 30%");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.abCooldown=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.abCooldown);
			cont=new GUIContent("AOE Radius:", "Multiplier to the ability AOE radius. Takes value from 0 and above with 0.3 being increment of 30%");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.abAOERadius=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.abAOERadius);
			
			
			startY+=5;
			
			cont=new GUIContent("Duration:", "Duration multiplier. Takes value from 0 and above with 0.3 being increase duration by 30%");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.effects.duration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.effects.duration);
			perk.effects.dot.duration=perk.effects.duration;
			perk.effects.slow.duration=perk.effects.duration;

			startY+=5;
			
			cont=new GUIContent("Damage:", "Damage multiplier. Takes value from 0 and above with 0.3 being increase existing effect damage by 30%");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.effects.damageMin=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.effects.damageMin);
			
			cont=new GUIContent("Stun Chance:", "Duration modifier. Takes value from 0 and above with 0.3 being increase stun chance by 30%");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.effects.stunChance=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.effects.stunChance);
			
			startY+=5;
			
			cont=new GUIContent("Slow", "");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=spaceY;
			
			cont=new GUIContent("         - Multiplier:", "Move speed multiplier. Takes value from 0-1 with with 0.3 being decrese default speed by 30%");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.effects.slow.slowMultiplier=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.effects.slow.slowMultiplier);
			
			
			startY+=5;
			
			cont=new GUIContent("Dot", "Damage over time");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);	startY-=spaceY;
			
			cont=new GUIContent("        - Damage:", "Damage multiplier to DOT. Takes value from 0 and above with with 0.3 being increase the tick damage by 30%");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.effects.dot.value=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.effects.dot.value);
			
			startY+=5;
			
			cont=new GUIContent("DamageBuff:", "Damage buff modifer. Takes value from 0 and above with 0.3 being increase existing damage by 30%");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.effects.damageBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.effects.damageBuff);
			
			cont=new GUIContent("RangeBuff:", "Range buff modifer. Takes value from 0 and above with 0.3 being increase existing range by 30%");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.effects.rangeBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.effects.rangeBuff);
			
			cont=new GUIContent("CDBuff:", "Cooldown buff modifer. Takes value from 0 and above with 0.3 being reduce existing cooldown by 30%");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.effects.cooldownBuff=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.effects.cooldownBuff);
			
			cont=new GUIContent("HPGain:", "HP Gain multiplier. Takes value from 0 and above with 0.3 being increase existing effect HP gain value by 30%.");
			EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
			perk.effects.HPGainMin=EditorGUI.FloatField(new Rect(startX+spaceX, startY, 40, height), perk.effects.HPGainMin);
			
			
			return new Vector2(startX, startY);
		}
		public static int AddNewPerk(){
			Perk perk=new Perk();
			perk.ID=GenerateNewID(perkIDList);
			perk.name="Perk "+perk.ID;
			perkIDList.Add(perk.ID);
			perkList.Add(perk);
			UpdatePerkNameList();
			SetDirtyPerk();
			return perkList.Count-1;
		}
Beispiel #49
0
 public static bool PurchasePerk(Perk perk)
 {
     return(instance._PurchasePerk(perk));
 }
Beispiel #50
0
 private void ModifyFPSWeaponModifier(PerkFPSWeaponModifier weaponModifier, Perk perk)
 {
     ModifyUnitStats(weaponModifier.stats, perk.stats);
 }
Beispiel #51
0
        void DrawPerkList()
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showPerkList = EditorGUILayout.Foldout(showPerkList, "Show Perk List");
            EditorGUILayout.EndHorizontal();

            if (showPerkList)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailableIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.purchasedIDList   = new List <int>();
                    instance.unavailableIDList = new List <int>();
                    for (int i = 0; i < perkDB.perkList.Count; i++)
                    {
                        instance.unavailableIDList.Add(perkDB.perkList[i].ID);
                    }
                }
                EditorGUILayout.EndHorizontal();


                for (int i = 0; i < perkDB.perkList.Count; i++)
                {
                    Perk perk = perkDB.perkList[i];

                    GUILayout.BeginHorizontal();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    Rect rect = GUILayoutUtility.GetLastRect();
                    TDEditor.DrawSprite(rect, perk.icon, perk.desp, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(perk.name, GUILayout.ExpandWidth(false));

                    GUILayout.BeginHorizontal();

                    EditorGUI.BeginChangeCheck();
                    bool flag = !instance.unavailableIDList.Contains(perk.ID) ? true : false;
                    EditorGUILayout.LabelField(new GUIContent(" - enabled: ", "check to enable the perk in this level"), GUILayout.Width(70));
                    flag = EditorGUILayout.Toggle(flag);

                    if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                    {
                        if (!flag && !instance.unavailableIDList.Contains(perk.ID))
                        {
                            instance.unavailableIDList.Add(perk.ID);
                        }
                        else if (flag)
                        {
                            instance.unavailableIDList.Remove(perk.ID);
                        }
                    }

                    if (!instance.unavailableIDList.Contains(perk.ID))
                    {
                        flag = instance.purchasedIDList.Contains(perk.ID);
                        EditorGUILayout.LabelField(new GUIContent(" - purchased: ", "check to set the perk as purchased right from the start"), GUILayout.Width(70));
                        flag = EditorGUILayout.Toggle(flag);

                        if (!Application.isPlaying)
                        {
                            if (flag)
                            {
                                instance.purchasedIDList.Add(perk.ID);
                            }
                            else
                            {
                                instance.purchasedIDList.Remove(perk.ID);
                            }
                        }
                    }

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }
        }