Esempio n. 1
0
        protected void CollideWith(CollidableObject obj)
        {
            if (obj == null)
            {
                return;
            }
            if (obj is Enemy)
            {
                Enemy enemy = (Enemy)obj;
                if (IsCollide(enemy))
                {
                    HP -= enemy.Attack;
                    OnCollide(enemy);
                }

                else if (obj is EnemyBullet)
                {
                    EnemyBullet enemybullet = (EnemyBullet)obj;
                    if (IsCollide(enemybullet))
                    {
                        //HPはEnemyBulletで。
                        //attackがEnemy依存で全部0ダメージになる
                        OnCollide(enemybullet);
                    }
                }
            }
        }
Esempio n. 2
0
        protected int distance(CollidableObject obj)
        {
            int t = (int)obj.Position.X - (int)Position.X;
            int s = (int)obj.Position.Y - (int)Position.Y;

            return((int)Math.Sqrt(t * t + s * s));
        }
Esempio n. 3
0
 public override void OnCollide(CollidableObject obj)
 {
     if (obj is Enemy)
     {
         HitEffect effect = new HitEffect();
         effect.Scale = new asd.Vector2DF(40, 40);
         Layer.AddObject(effect);
         effect.Position = Position;
         effect.Play();
         asd.Engine.Sound.SetVolume(asd.Engine.Sound.Play(ColSound), 0.05f);
     }
     base.OnCollide(obj);
 }
Esempio n. 4
0
 protected override void CollideWith(CollidableObject obj)
 {
     base.CollideWith(obj);
     if (obj is EnemyBullet)
     {
         EnemyBullet bullet = (EnemyBullet)obj;
         if (IsCollide(bullet))
         {
             OnCollide(bullet);
             bullet.Dispose();
             Dispose();
         }
     }
 }
Esempio n. 5
0
        protected virtual void CollideWith(CollidableObject obj)
        {
            if (obj == null)
            {
                return;
            }

            if (obj is Enemy)
            {
                Enemy enemy = (Enemy)obj;
                if (IsCollide(enemy))
                {
                    OnCollide(enemy);
                    enemy.HP -= Attack;
                    Dispose();
                }
            }
        }
Esempio n. 6
0
        protected void CollideWith(CollidableObject obj)
        {
            if (obj == null)
            {
                return;
            }

            if (obj is Unit)
            {
                Unit unit = (Unit)obj;
                if (IsCollide(unit))
                {
                    OnCollide(unit);
                    Dispose();
                    unit.HP -= Attack;
                }
            }
        }
Esempio n. 7
0
 public override void OnCollide(CollidableObject obj)
 {
     if (obj is Enemy)
     {
         HitEffectEnemy effect = new HitEffectEnemy();
         effect.Scale = new asd.Vector2DF(4, 4);
         Layer.AddObject(effect);
         effect.Position = Position;
         effect.Play();
         asd.Engine.Sound.SetVolume(asd.Engine.Sound.Play(ColSound), 0.2f);
     }
     else if (obj is EnemyBullet)
     {
         HitEffectEnemy effect = new HitEffectEnemy();
         effect.Scale = new asd.Vector2DF(4, 4);
         Layer.AddObject(effect);
         effect.Position = Position;
         effect.Play();
         //弾との衝突音はEnemyBulletで
     }
     base.OnCollide(obj);
 }
Esempio n. 8
0
 public virtual void OnCollide(CollidableObject obj)
 {
 }
Esempio n. 9
0
 public bool IsCollide(CollidableObject o)
 {
     return((o.Position - Position).Length < Radius + o.Radius - 5);
 }
Esempio n. 10
0
 public override void OnCollide(CollidableObject obj)
 {
     asd.Engine.Sound.SetVolume(asd.Engine.Sound.Play(ColSound), 0.1f);
     base.OnUpdate();
 }