Exemplo n.º 1
0
        //Attack has its own method so that it can raise the event EnemyAttack and allow any listeners (renderer)
        //to respond to it. It also has a sleep that is the duration of the attack animation so that the player
        //can't move until the animation is finished. It is short so doesn't interrupt gameplay.
        private void Attack()
        {
            EnemyAttackEventArgs args = new EnemyAttackEventArgs();

            args.Position = position;
            OnEnemyAttack(args);
            recentlyAttacked = true;
            Thread.Sleep((1000 / 240) * 60);
            player.TakeDamage();
        }
Exemplo n.º 2
0
 //Method called by the EnemyAttack delegate for when the attack event is called. Controls the
 //enemyAttackBool as well as passes along the position of the attacking enemy so
 //only the attacking one actually animates instead of all of them.
 void EnemyAttacked(object sender, EnemyAttackEventArgs e)
 {
     enemyAttackBool     = true;
     this.attackingEnemy = e.Position;
 }
Exemplo n.º 3
0
        protected virtual void OnEnemyAttack(EnemyAttackEventArgs e)
        {
            EventHandler <EnemyAttackEventArgs> handler = EnemyAttack;

            handler?.Invoke(this, e);
        }