Exemplo n.º 1
0
        public void Execute(long currentTimeMs, List <Actor> touchedActors)
        {
            DefaultCharacter currentCharacter = (DefaultCharacter)character;

            if (currentCharacter == null)
            {
                return;
            }

            if ((currentTimeMs - timeLastExecuted) < cooldown)
            {
                return;
            }

            bool isFacingRight = physics.IsFacingRight();

            if (currentCharacter.InvTreasure == null)
            {
                foreach (Actor actor in touchedActors)
                {
                    Treasure treasure = actor as Treasure;
                    if (treasure != null)
                    {
                        treasure.CharacterCollect(character);
                    }

                    AmmoCrate ammoCrate = actor as AmmoCrate;
                    if (ammoCrate != null)
                    {
                        ammoCrate.CharacterCollect(character);
                    }

                    Trap trap = actor as Trap;
                    if (trap != null)
                    {
                        trap.CharacterCollect(character);
                    }
                }
            }


            timeLastExecuted = currentTimeMs;
        }