Beispiel #1
0
        public static List <int> GetUnitAbilityXIDList(int prefabID)
        {
            List <int> abilityXIDList = new List <int>();

            for (int i = 0; i < globalUnitModifier.abilityXIDList.Count; i++)
            {
                abilityXIDList.Add(globalUnitModifier.abilityXIDList[i]);
            }

            PerkUnitModifier unitModifier = GetUnitModifier(prefabID);

            for (int i = 0; i < unitModifier.abilityXIDList.Count; i++)
            {
                abilityXIDList.Add(unitModifier.abilityXIDList[i]);
            }

            return(abilityXIDList);
        }
Beispiel #2
0
 private void ModifyUnitModifier(PerkUnitModifier unitModifier, Perk perk)
 {
     ModifyUnitStats(unitModifier.stats, perk.stats);
 }
Beispiel #3
0
        public string _PurchasePerk(Perk perk, bool useCurrency = true)
        {
            string text = perk.Purchase(useCurrency);

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

            SavePerkProgress();

            TBTK.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.prefabID);
            }

            perkPoint += 1;
            TBTK.OnPerkPoint(perkPoint);

            if (perk.type == _PerkType.NewUnitAbility)
            {
                if (perk.addAbilityToAllUnit)
                {
                    AbilityManagerUnit.PerkUnlockNewAbility(null, perk.newUnitAbilityID, perk.subUnitAbilityID);
                    globalUnitModifier.abilityIDList.Add(perk.newUnitAbilityID);
                    globalUnitModifier.abilityXIDList.Add(perk.subUnitAbilityID);
                }
                else
                {
                    AbilityManagerUnit.PerkUnlockNewAbility(perk.newABUnitIDList, perk.newUnitAbilityID, perk.subUnitAbilityID);
                    for (int i = 0; i < perk.newABUnitIDList.Count; i++)
                    {
                        int index = UnitModifierExist(perk.newABUnitIDList[i]);
                        if (index == -1)
                        {
                            PerkUnitModifier unitModifier = new PerkUnitModifier();
                            unitModifier.prefabID = perk.newABUnitIDList[i];
                            unitModifierList.Add(unitModifier);
                            index = unitModifierList.Count - 1;
                        }
                        unitModifierList[index].abilityIDList.Add(perk.newUnitAbilityID);
                        unitModifierList[index].abilityXIDList.Add(perk.subUnitAbilityID);
                    }
                }
            }
            else if (perk.type == _PerkType.NewFactionAbility)
            {
                AbilityManagerFaction.PerkUnlockNewAbility(perk.newFacAbilityID, perk.subFacAbilityID);
                factionAbilityIDList.Add(perk.newFacAbilityID);
                factionAbilityXIDList.Add(perk.subFacAbilityID);
            }
            else if (perk.type == _PerkType.Unit)
            {
                for (int i = 0; i < perk.unitIDList.Count; i++)
                {
                    int index = UnitModifierExist(perk.unitIDList[i]);
                    if (index == -1)
                    {
                        PerkUnitModifier unitModifier = new PerkUnitModifier();
                        unitModifier.prefabID = perk.unitIDList[i];
                        unitModifierList.Add(unitModifier);
                        index = unitModifierList.Count - 1;
                    }
                    ModifyUnitModifierInList(index, perk);
                }
            }
            else if (perk.type == _PerkType.Unit_All)
            {
                ModifyUnitModifier(globalUnitModifier, perk);
            }
            else if (perk.type == _PerkType.UnitAbility)
            {
                for (int i = 0; i < perk.unitAbilityIDList.Count; i++)
                {
                    int index = UnitAbilityModifierExist(perk.unitAbilityIDList[i]);
                    if (index == -1)
                    {
                        PerkAbilityModifier abilityModifier = new PerkAbilityModifier();
                        abilityModifier.prefabID = perk.unitAbilityIDList[i];
                        unitAbilityModifierList.Add(abilityModifier);
                        index = unitAbilityModifierList.Count - 1;
                    }
                    ModifyUnitAbilityModifierInList(index, perk);
                }
            }
            else if (perk.type == _PerkType.UnitAbility_All)
            {
                ModifyUnitAbilityModifier(globalUnitAbilityModifier, perk);
            }
            else if (perk.type == _PerkType.FactionAbility)
            {
                for (int i = 0; i < perk.facAbilityIDList.Count; i++)
                {
                    int index = FactionAbilityModifierExist(perk.facAbilityIDList[i]);
                    if (index == -1)
                    {
                        PerkAbilityModifier abilityModifier = new PerkAbilityModifier();
                        abilityModifier.prefabID = perk.facAbilityIDList[i];
                        factionAbilityModifierList.Add(abilityModifier);
                        index = factionAbilityModifierList.Count - 1;
                    }
                    ModifyFactionAbilityModifierInList(index, perk);
                }
            }
            else if (perk.type == _PerkType.FactionAbility_All)
            {
                ModifyFactionAbilityModifier(globalFactionAbilityModifier, perk);
            }


            return("");
        }