public bool CanTrain(int amountToTrain) { bool hasEnoughResources = false; List <ResourceAmount> resourceAmounts = new List <ResourceAmount>(); for (int i = 0; i < resourceCosts.Count; i++) { ResourceAmount currentAmount = Resource.Instance.GetResourceAmount(resourceCosts[i].resourceType); ResourceAmount cost = resourceCosts[i]; if (currentAmount.resourceAmount >= (cost.resourceAmount * amountToTrain)) { resourceAmounts.Add(currentAmount); } } if (resourceAmounts.Count >= resourceCosts.Count) { hasEnoughResources = true; // resourceAmounts has the same order as resourceCosts for (int i = 0; i < resourceCosts.Count; i++) { resourceAmounts[i].resourceAmount -= (resourceCosts[i].resourceAmount * amountToTrain); } availabilityState = Troop.AvailabilityState.Training; GameEvents.TrainingStarted(this); GameEvents.OnTimePassed += CheckTrainingTime; } return(hasEnoughResources); }
public bool StartResearching() { bool hasEnoughResources = false; List <ResourceAmount> resourceAmounts = new List <ResourceAmount>(); for (int i = 0; i < resourceCosts.Count; i++) { ResourceAmount currentAmount = Resource.Instance.GetResourceAmount(resourceCosts[i].resourceType); ResourceAmount cost = resourceCosts[i]; if (currentAmount.resourceAmount >= cost.resourceAmount) { resourceAmounts.Add(currentAmount); } } if (resourceAmounts.Count >= resourceCosts.Count) { hasEnoughResources = true; // resourceAmounts has the same order as resourceCosts for (int i = 0; i < resourceCosts.Count; i++) { resourceAmounts[i].resourceAmount -= resourceCosts[i].resourceAmount; } availabilityState = AvailabilityState.Researching; GameEvents.TechResearchStarted(this); //GameEvents.OnTurnPassed += NewTurn; GameEvents.OnTimePassed += CheckTime; } return(hasEnoughResources); }
public void TechUnlock() { availabilityState = AvailabilityState.Unlocked; GameEvents.TechUnlocked(this); GameEvents.OnTechResearchCompleted -= CheckRequirements; Debug.Log("Tech unlocked " + this.techName); }
public void TroopUnlock() { availabilityState = AvailabilityState.Unlocked; GameEvents.TroopUnlocked(this); GameEvents.OnBuildingCompleted -= CheckTrainingRequirements; Debug.Log("Troop unlocked " + troopName); }
public void HuntUnlock() { availabilityState = AvailabilityState.Unlocked; GameEvents.HuntUnlocked(this); GameEvents.OnTechResearchCompleted -= CheckHuntRequirements; Debug.Log("Hunt unlocked " + huntName); }
public void Train() { GameEvents.TrainingCompleted(this); GameEvents.OnTimePassed -= CheckTrainingTime; availabilityState = AvailabilityState.Unlocked; Debug.Log("Troops were trained " + troopName); }
public void Learn() { GameEvents.TechResearchCompleted(this); GameEvents.OnTimePassed -= CheckTime; availabilityState = AvailabilityState.Learned; Debug.Log("Tech was learned " + this.techName); //GameEvents.OnTurnPassed -= NewTurn; }
public void HuntComplete() { GameEvents.HuntCompleted(this); GameEvents.HuntQuestCompleted(huntName); GameEvents.OnTimePassed -= CheckHuntingTime; availabilityState = AvailabilityState.Completed; Debug.Log(string.Format("Hunt was finished {0}", huntName)); }
public bool CanHunt() { bool canHunt = false; switch (requiredTroopType) { case Troop.TroopType.Infantry: if (MilitaryManager.Instance.infantryAmount >= neededArmyAmount) { canHunt = true; } break; case Troop.TroopType.Cavalry: if (MilitaryManager.Instance.cavalryAmount >= neededArmyAmount) { canHunt = true; } break; case Troop.TroopType.Spear: if (MilitaryManager.Instance.spearAmount >= neededArmyAmount) { canHunt = true; } break; case Troop.TroopType.Archer: if (MilitaryManager.Instance.archerAmount >= neededArmyAmount) { canHunt = true; } break; case Troop.TroopType.Magic: if (MilitaryManager.Instance.mageAmount >= neededArmyAmount) { canHunt = true; } break; default: break; } availabilityState = AvailabilityState.Hunting; GameEvents.OnTimePassed += CheckHuntingTime; return(canHunt); }