예제 #1
0
        public bool handleActorAttack(DamageInfo damageInfo)
        {
            for (int i = 0; i < actors.Count; i++)
            {
                victim = actors.ElementAt(i);
                if (victim.Equals(damageInfo.attacker))
                    continue;
                else if (victim.hitBox.Intersects(damageInfo.attackRect))
                {
                    victim.velocity += damageInfo.attacker.sightVector * 20;
                    victim.onHurt(damageInfo);
                    Recoil recoil = new Recoil(victim.animationList, victim);
                    if (!victim.animationList.has(recoil))
                        victim.animationList.pushFront(recoil);
                    if (victim.health <= 0)
                    {
                        victim.onKill(damageInfo);
                        actors.Remove(victim);
                    }
                    return true;
                }
            }

            return false;
            
        }
        private void Actor_Hurt(Object sender, EventArgs e)
        {
            SoundManager.Instance.playSound("hurt1");
            Actor hurtActor = (Actor)sender;
            Recoil recoil = new Recoil(actionLists[hurtActor], hurtActor);
            if (!actionLists[hurtActor].has(recoil))
                actionLists[hurtActor].pushFront(recoil);

        }
 private void Actor_Light_Attack(Object sender, EventArgs e)
 {
     Actor inputtingActor = (Actor)sender;
     //Punch punch = new Punch(actionLists[inputtingActor], inputtingActor);
     Attack attack = new Attack(actionLists[inputtingActor], inputtingActor);
     Recoil recoil = new Recoil(actionLists[inputtingActor], inputtingActor);
     if (!actionLists[inputtingActor].has(attack) && !actionLists[inputtingActor].has(recoil))
     {
         actionLists[inputtingActor].pushFront(attack);
     }
 }