Esempio n. 1
0
        public void Apply(Behaviour behaviour, GameObject caster)
        {
            if (!behaviour.IsIgnoresImmunity &&
                Behaviours.Any(element => (element.StatusImmunity & behaviour.StatusFlags) > 0) ||
                CombatEncounter.Active == null && behaviour.IsPreventsMovement())
            {
                AnyBehaviourImmune?.Invoke(gameObject, behaviour);
                return;
            }

            BeforeBehaviourApplied(behaviour);

            var applied = Behaviours.FirstOrDefault(b => b.Id == behaviour.Id);

            if (applied != null)
            {
                ReApply(applied, behaviour);
                return;
            }

            Behaviours.Add(behaviour);
            Behaviours = Behaviours.OrderBy(b => b.RemainingDuration).ToList();

            behaviour.Removed += OnBehaviourRemoved;
            behaviour.Apply(caster, gameObject);

            AnyBehaviourApplied?.Invoke(behaviour);
            BehaviourApplied?.Invoke(behaviour);
        }
Esempio n. 2
0
        private void OnAnyCombatTeamTurnStarted(CombatEncounter combat)
        {
            if (combat.ActingTeamId != gameObject.GetComponent <UnitComponent>().TeamId)
            {
                return;
            }

            foreach (var behaviour in Behaviours.OrderBy(b => b.IsHarmful).ToList())
            {
                behaviour.MaybeExpire();

                if (behaviour.IsApplied)
                {
                    behaviour.Tick();
                }
            }
        }