Exemplo n.º 1
0
        public void SetState(TreeFSMState newState)
        {
            CancelTimingCoroutine();

            if (!treeState.CurrentState.Equals(newState))
            {
                treeState.Update.CurrentState(newState).FinishAndSend();

                switch (newState)
                {
                case TreeFSMState.HEALTHY:
                    harvestableInterface.ResetResourceCount();
                    flammable.Send(new Flammable.Update().SetCanBeIgnited(true));
                    break;

                case TreeFSMState.STUMP:
                    flammable.Send(new Flammable.Update().SetCanBeIgnited(false));
                    timingCoroutine = StartCoroutine(RegrowAfter(SimulationSettings.TreeStumpRegrowthTimeSecs));
                    break;

                case TreeFSMState.BURNING:
                    timingCoroutine = StartCoroutine(BurnAfter(SimulationSettings.TreeBurningTimeSecs));
                    break;

                case TreeFSMState.BURNT:
                    flammableInterface.SelfExtinguish(flammable, false);
                    timingCoroutine = StartCoroutine(RegrowAfter(SimulationSettings.BurntTreeRegrowthTimeSecs));
                    break;
                }
            }
        }
Exemplo n.º 2
0
 public override void Enter()
 {
     flammableInterface.SelfExtinguish(flammable, false);
     if (regrowingCoroutine == null)
     {
         regrowingCoroutine = parentBehaviour.StartCoroutine(TimerUtils.WaitAndPerform(SimulationSettings.BurntTreeRegrowthTimeSecs, Regrow));
     }
 }
Exemplo n.º 3
0
 private void Die()
 {
     playerInfo.Send(new PlayerInfo.Update().SetIsAlive(false));
     health.Send(new Health.Update().SetCanBeChanged(false));
     flammableInterface.SelfExtinguish(flammable, false);
     spells.Send(new Spells.Update().SetCooldowns(new Map <SpellType, float> {
         { SpellType.LIGHTNING, 0f }, { SpellType.RAIN, 0f }
     }).SetCanCastSpells(false));
 }
Exemplo n.º 4
0
 private void UpdateHQFlammablility(int healthValue)
 {
     if (healthValue <= 0)
     {
         flammableBehaviour.SelfExtinguish(health, false);
     }
     else
     {
         var canBeIgnited = healthValue > 0;
         flammableBehaviour.SelfSetCanBeIgnited(health, canBeIgnited);
     }
 }
        public void EvaluateAndSetFlammability(Health.Update update)
        {
            if (barracksInfo == null)
            {
                Debug.LogError("barracksInfo is null in BarracksStateMachine.");
                return;
            }

            if (flammableBehaviour == null)
            {
                Debug.LogError("flammableBehaviour is null in BarracksStateMachine.");
                return;
            }

            if (update.currentHealth.Value <= 0)
            {
                flammableBehaviour.SelfExtinguish(health, false);
            }
            else
            {
                var canBeIgnited = update.currentHealth.Value > 0;
                flammableBehaviour.SelfSetCanBeIgnited(barracksInfo, canBeIgnited);
            }
        }