Ejemplo n.º 1
0
        public virtual void TryToAttack(Vector dir)
        {
            this.facing = dir;

            if (!this.canAttack || this.Stamina.GetCurrent() < 30)
            {
                return;
            }

            this.canAttack          = false;
            this.isRestoringStamina = false;

            this.currentAnimation = new Animation(new List <char>()
            {
                '!'
            }, 10, this, () =>
            {
                var attack    = new Attack(AttackType.Melee, this.position, this.facing, 25, this, Attack.LW_ATTACK);
                this.Stamina -= 30;
                if (this.staminaTimer != null)
                {
                    TimersContainer.Remove(this.staminaTimer);
                    this.staminaTimer = null;
                }
                this.staminaTimer = new Timer("restStam", attack.ticks + 15,
                                              () => { this.isRestoringStamina = true; });
                new Timer("restCanAttack", attack.ticks - 3,
                          () => { this.canAttack = true; });
                this.currentAnimation = null;
            });
        }
Ejemplo n.º 2
0
 public void Logic()
 {
     this.ticks++;
     if (this.ticks >= finalTick)
     {
         if (onFinish != null)
         {
             onFinish();
             onFinish = null;
         }
         TimersContainer.Remove(this);
     }
 }