Exemplo n.º 1
0
        // TODO remove
        private StatsDifference NewDifferenceWithMyFoodValue(int value)
        {
            var result = new StatsDifference();

            result.SetMyFood(value);
            return(result);
        }
Exemplo n.º 2
0
    private void Update()
    {
        StatsDifference effect = Effect.Effect;

        foreach (var indicator in new KeyValuePair <StateIndicator, StateItemType>[] {
            new KeyValuePair <StateIndicator, StateItemType> (MyEnergy, StateItemType.MyEnergy),
            new KeyValuePair <StateIndicator, StateItemType> (MyMaxEnergy, StateItemType.MyMaxEnergy),
            new KeyValuePair <StateIndicator, StateItemType> (MyFood, StateItemType.MyFood),
            new KeyValuePair <StateIndicator, StateItemType> (MyHappiness, StateItemType.MyHappiness),
            new KeyValuePair <StateIndicator, StateItemType> (MyHealth, StateItemType.MyHealth),
            new KeyValuePair <StateIndicator, StateItemType> (FamilyFood, StateItemType.FamilyFood),
            new KeyValuePair <StateIndicator, StateItemType> (FamilyHappiness, StateItemType.FamilyHappiness),
            new KeyValuePair <StateIndicator, StateItemType> (FamilyHealth, StateItemType.FamilyHealth)
        })
        {
            // TODO display values push down?
            indicator.Key.UpdateValue(
                State.State.GetStateItemValue <float>(indicator.Value.ToString()),
                Mathf.CeilToInt(State.State.GetStateItemValue <float>(indicator.Value.ToString())),
                effect.GetStat(indicator.Value.ToString()));

            // TODO special indicator for MyEnergy
            MyEnergy.UpdateValue(State.State.GetStateItemValue <float>(StateItemType.MyEnergy.ToString()), Mathf.CeilToInt(State.State.GetStateItemValue <float>(StateItemType.MyEnergy.ToString())), effect.GetStat(StateItemType.MyEnergy.ToString()), State.State.GetStateItemValue <float>(StateItemType.MyMaxEnergy.ToString()));
        }
    }
Exemplo n.º 3
0
    void Update()
    {
        StatsDifference effect = Effect.Effect;

        Money.text                     = State.State.GetStateItemValue <int>(StateItemType.Money.ToString()) + EffectSuffixCreator.Create(effect.GetStat(StateItemType.Money.ToString()));
        MoneyPerWorkshift.text         = Mathf.FloorToInt(State.State.GetStateItemValue <int>(StateItemType.MySalary.ToString())) + EffectSuffixCreator.Create(effect.GetStat(StateItemType.MySalary.ToString()));
        MoneyPerPartnersWorkshift.text = Mathf.FloorToInt(State.State.GetStateItemValue <int>(StateItemType.PartnerSalary.ToString())) + EffectSuffixCreator.Create(effect.GetStat(StateItemType.PartnerSalary.ToString()));
        FoodSupplies.text              = Mathf.FloorToInt(State.State.GetStateItemValue <int>(StateItemType.FoodSupplies.ToString())) + EffectSuffixCreator.Create(effect.GetStat(StateItemType.FoodSupplies.ToString()));
        Age.text = Mathf.FloorToInt(State.State.GetStateItemValue <float>(StateItemType.Age.ToString())).ToString();
    }
Exemplo n.º 4
0
 private void UpdateStatsOneTime(StatsDifference difference, StateAction action)
 {
     foreach (var item in _items.Values)
     {
         if (ShouldItemBeUpdated(item))
         {
             item.ApplyDifferenceByAction(difference, action);
         }
     }
 }
Exemplo n.º 5
0
        public override void ApplyDifferenceByAction(StatsDifference difference, StateAction action, float multiplier = 1)
        {
            base.ApplyDifferenceByAction(difference, action, multiplier);

            // TODO aaaaargh ugly comparison of objects to find out if it's after-action difference!
            // maybe create methods UpdateBeforeAction and UpdateAfterAction in StateItem and make default implementation the same, just override it in money case
            if (action.IsWorkAction() && difference == action.GetEffectAfter())
            {
                Value += action.IsPartnersAction() ? _getPartnerSalary() : _getPlayerSalary();
            }
        }
Exemplo n.º 6
0
 public void Plus(StatsDifference difference)
 {
     MyEnergy                  += difference.MyEnergy;
     MyMaxEnergy               += difference.MyMaxEnergy;
     MyFood                    += difference.MyFood;
     MyHappiness               += difference.MyHappiness;
     MyHealth                  += difference.MyHealth;
     FamilyFood                += difference.FamilyFood;
     FamilyHappiness           += difference.FamilyHappiness;
     FamilyHealth              += difference.FamilyHealth;
     Money                     += difference.Money;
     FoodSupplies              += difference.FoodSupplies;
     MoneyPerWorkshift         += difference.MoneyPerWorkshift;
     MoneyPerPartnersWorkshift += difference.MoneyPerPartnersWorkshift;
 }
Exemplo n.º 7
0
    private StatsDifference CreateSummaryEffect(StateAction action)
    {
        StatsDifference result = new StatsDifference();

        var differences = new[] { action.GetEffectBefore(), action.GetEffectDuring(), action.GetEffectAfter() };

        foreach (StatsDifference difference in differences)
        {
            result.Plus(difference);
        }

        if (action.GetName() == PlayerActionType.GoToWork.ToString())
        {
            result.SetMoney(State.State.GetStateItemValue <int>(StateItemType.MySalary.ToString()));
        }

        if (action.GetName() == PlayerActionType.PartnerGoesToWork.ToString())
        {
            result.SetMoney(State.State.GetStateItemValue <int>(StateItemType.PartnerSalary.ToString()));
        }

        return(result);
    }
Exemplo n.º 8
0
 public void ResetDifference()
 {
     m_Effect       = new StatsDifference();
     m_TimeToFinish = 0;
 }
Exemplo n.º 9
0
 protected override int GetDifferenceValue(StatsDifference difference)
 {
     return(difference.GetStat(GetName()));
 }
Exemplo n.º 10
0
 public override bool DifferenceHasZeroEffect(StatsDifference difference)
 {
     return(GetDifferenceValue(difference) == 0);
 }
Exemplo n.º 11
0
 public override void ApplyDifferenceByAction(StatsDifference difference, StateAction action, float multiplier = 1)
 {
     Value += GetDifferenceValue(difference);
 }
Exemplo n.º 12
0
 public virtual bool DifferenceHasZeroEffect(StatsDifference difference)
 {
     return(true);
 }
Exemplo n.º 13
0
 public virtual void ApplyDifferenceByAction(StatsDifference difference, StateAction action, float multiplier = 1)
 {
     ApplyDifferenceByActionCalled++;
 }
Exemplo n.º 14
0
 protected abstract T GetDifferenceValue(StatsDifference difference);
Exemplo n.º 15
0
 public abstract bool DifferenceHasZeroEffect(StatsDifference difference);
Exemplo n.º 16
0
 public abstract void ApplyDifferenceByAction(StatsDifference difference, StateAction action, float multiplier = 1);