コード例 #1
0
ファイル: Peach.cs プロジェクト: Afro-Drive/Momotaro
 public override void HitChara(Character chara)
 {
     if ((chara is Human ||
          chara is Dog ||
          chara is Bird ||
          chara is Monkey) &&
         isDeadFlag == false)
     {
         sound.PlaySE("momo");
         isDeadFlag = true;
         mediator.ChangeHp(1);
     }
 }
コード例 #2
0
        public override void HitChara(Character other)
        {
            if (invincible == false)
            {
                if (other is Enemy || other is ShotEnemyBullet || other is Boss || other is BossBullet || other is BossBulletZ)
                {
                    sound.PlaySE("dmg");
                    Direction dir = this.CheckDirection(other);

                    mediator.ChangeHp(-1);
                    damageShow     = new CountDownTimer(0.2f);
                    invincibleTime = new CountDownTimer(2f);
                    invincible     = true;

                    if (dir == Direction.Right)
                    {
                        rightDamage = true;
                    }
                    else if (dir == Direction.Left)
                    {
                        leftDamage = true;
                    }
                    else if (dir == Direction.Top)
                    {
                        velocity.Y -= 8f;
                        velocity.Y  = (velocity.X < -8f) ? (velocity.Y) : (-8f);
                    }
                    else if (dir == Direction.Bottom)
                    {
                        velocity.Y += 8f;
                        velocity.Y  = (velocity.X < 8f) ? (velocity.Y) : (8f);
                        Console.WriteLine("bottom");
                    }
                }
            }
        }