// Handles the Start event public void Start() { if (triggerType == TriggerType.Create || triggerType == TriggerType.CreateDestroy) { stats.Stat(statName).Add((decimal)amount); } }
public void Start() { var stat = Stats.Stat("vegetables-harvested"); if (stat != null) { stat.OnChange += OnVegetablesHarvestedChange; } }
/// <summary> /// Determins if all tech and stat requirements are met for this building /// </summary> /// <param name="statManager"></param> /// <param name="techManager"></param> /// <returns>True if requirements met, false otherwise</returns> public bool RequirementsMet(StatManager statManager, TechManager techManager) { foreach (var requirement in statRequirements) { var statname = requirement.name; var stat = statManager.Stat(statname); if (!requirement.IsSatisfied((float)stat.Value)) { return(false); } } foreach (var tech in techRequirements) { if (!techManager.TechResearched(tech)) { return(false); } } return(true); }
/// <summary> /// Withdraws the given reservation from this reservoir /// </summary> /// <param name="res"></param> /// <exception cref="System.ArgumentException">Thrown when an invalid reservation is passed</exception> /// <returns>True on success, false if the reservation is not fulfillable</returns> public bool WithdrawReservation(ResourceReservation res) { if (res.source != this.gameObject) { Debug.Log(res); throw new ArgumentException("Reservation not for this Reservoir"); } if (res.Released || res.Cancelled) { Debug.Log(res); throw new ArgumentException("Invalid reservation!"); } if (amount >= res.amount) { amount -= res.amount; res.Released = true; reservations.Remove(res); if (!String.IsNullOrEmpty(harvestStat)) { IGameStat stat = statManager.Stat(harvestStat); if (stat != null) { stat.Add(res.amount); } else { Debug.Log("Unable to resolve stat " + harvestStat); } } return(true); } else { return(false); } }