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); } } } }
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)); }
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); }
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(); } } }
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(); } } }
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; } } }
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); }
public virtual void OnCollide(CollidableObject obj) { }
public bool IsCollide(CollidableObject o) { return((o.Position - Position).Length < Radius + o.Radius - 5); }
public override void OnCollide(CollidableObject obj) { asd.Engine.Sound.SetVolume(asd.Engine.Sound.Play(ColSound), 0.1f); base.OnUpdate(); }