예제 #1
0
		private void ChooseInitialCardsForNextFaction() {
			++cardChoosingFactionIdx;
			if (cardChoosingFactionIdx < factionList.Count) {
				Debug.LogWarning("Choosing cards for faction " + cardChoosingFactionIdx);
				if(factionList[cardChoosingFactionIdx].isPlayerFaction){
					// Debug.LogWarning("deck size = " + factionList[cardChoosingFactionIdx].allUnitList.Select(unit => unit.reserveAbilityIDList.Count).Sum());
					numAbilitiesChosen = 0;
					abilitySelections = new List<Unit.AbilitySelection>();
					for (int i = 0; i < abilitySelectionButtons.Count; ++i)
					{
						// Debug.LogWarning("Choosing card  " + i);
						Unit.AbilitySelection abilitySelection = Unit.DrawCard(factionList[cardChoosingFactionIdx].allUnitList);
						abilitySelections.Add(abilitySelection);
						if (abilitySelection != null){
							// Debug.LogWarning("selection  " + abilitySelection.abilityId + " " + abilitySelection.cardOwner.unitName);
							UnitAbility ability=AbilityManagerUnit.GetAbilityBasedOnID(abilitySelection.abilityId);
							abilitySelectionButtons[i].Init();
							// Debug.LogWarning("ability = " + ability.name);
							// Debug.LogWarning(abilitySelectionButtons[i]);
							// Debug.LogWarning(abilitySelectionButtons[i].imgIcon);
							// Debug.LogWarning(abilitySelectionButtons[i].label);
							abilitySelectionButtons[i].imgIcon.sprite= ability.icon;
							abilitySelectionButtons[i].label.text = ability.GetCost().ToString();
							abilitySelectionButtons[i].SetActive(true);	
						}
					}
					chooseInitialCardsUI.gameObject.SetActive(true);
				} else {
					ChooseInitialCardsForNextFaction();
				}				
			} else {
				chooseInitialCardsUI.gameObject.SetActive(false);
				GameControl.OnFinishedCardChoice();
			}
		}
예제 #2
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("");
        }
예제 #3
0
        public void Init()
        {
            instance = this;

            unitAbilityDBList = UnitAbilityDB.LoadClone();
        }
예제 #4
0
        void Awake()
        {
            instance = this;

            TBData.ClearEndData();

            SettingDB settingDB = InitSetting();

            if (enableCover)
            {
                CoverSystem.SetFullCoverDodgeBonus(fullCoverBonus);
                CoverSystem.SetHalfCoverDodgeBonus(halfCoverBonus);
                CoverSystem.SetExposedCritChanceBonus(exposedCritBonus);
            }

            //get the instance of each component and initiate them, the order in which these component matters

            PerkManager perkManager = (PerkManager)FindObjectOfType(typeof(PerkManager));

            if (perkManager != null)
            {
                perkManager.Init();
            }

            AbilityManagerUnit abManagerUnit = (AbilityManagerUnit)FindObjectOfType(typeof(AbilityManagerUnit));

            if (abManagerUnit != null)
            {
                abManagerUnit.Init();
            }

            AbilityManagerFaction abManagerFac = (AbilityManagerFaction)FindObjectOfType(typeof(AbilityManagerFaction));

            if (abManagerFac != null)
            {
                abManagerFac.Init();
            }

            TurnControl turnControl = (TurnControl)FindObjectOfType(typeof(TurnControl));

            turnControl.Init();

            if (settingDB != null)
            {
                turnControl.turnMode  = settingDB.turnMode;
                turnControl.moveOrder = settingDB.moveOrder;
            }

            GridManager gridManager = (GridManager)FindObjectOfType(typeof(GridManager));

            if (settingDB != null)
            {
                gridManager.generateGridOnStart = settingDB.generateGridOnStart;
            }
            gridManager.Init();

            FactionManager factionManager = (FactionManager)FindObjectOfType(typeof(FactionManager));

            if (settingDB != null)
            {
                factionManager.generateUnitOnStart = settingDB.generateUnitOnStart;
            }
            factionManager.Init();

            CollectibleManager collectibleManager = (CollectibleManager)FindObjectOfType(typeof(CollectibleManager));

            if (settingDB != null)
            {
                collectibleManager.generateCollectibleOnStart = settingDB.generateCollectibleOnStart;
            }
            collectibleManager.Init();

            GridManager.SetupGridForFogOfWar();

            OverlayManager overlayManager = (OverlayManager)FindObjectOfType(typeof(OverlayManager));

            overlayManager.Init();

            defaultShootObject = Resources.Load("ScenePrefab/DefaultShootObject", typeof(GameObject)) as GameObject;

            gamePhase = _GamePhase.Initialization;
        }