public override void Update() { if (StateEnemy is Pterodactyl) { Pterodactyl p = StateEnemy as Pterodactyl; try { Point playerCoords = new Point(0, 0); foreach (WorldObject obj in World.Instance.objects) { if (obj is Ostrich) { Ostrich o = obj as Ostrich; playerCoords = o.coords; } } double x = (p.coords.x - playerCoords.x); double y = (p.coords.y - playerCoords.y); p.angle = Math.Atan(x / y); if (x < 0) { p.angle += 180; } p.imagePath = "Images/Enemy/pterodactyl_charge.png"; } catch (InvalidOperationException op) { Trace.WriteLine(op.Message); } } }
public void TestDie() { Ostrich o = new Ostrich(); o.coords = new Point(500, 500); o.Die(); Assert.AreEqual(new List <WorldObject> { }, World.Instance.objects); }
public void TestMoveUp() { Entity e = new Ostrich(); e.coords = new Point(500, 500); // set initial speed, angle, and position e.Update(); Point testPoint = new Point(450, 500); Assert.AreEqual(testPoint, e.coords); }
public void TestCollisions() { Ostrich a = new Ostrich(); a.coords = new Point(500, 500); Buzzard b = new Buzzard(); b.coords = new Point(510, 510); a.hitbox = new Hitbox(50, 50); b.hitbox = new Hitbox(50, 50); World.Instance.objects.Add(a); World.Instance.objects.Add(b); Assert.AreEqual(b.hitbox, a.hitbox.CheckCollisions()); }
public void TestNoCollision() { Ostrich a = new Ostrich(); a.coords = new Point(500, 500); Buzzard b = new Buzzard(); b.coords = new Point(600, 600); a.hitbox = new Hitbox(50, 50); b.hitbox = new Hitbox(50, 50); World.Instance.objects.Add(a); World.Instance.objects.Add(b); Assert.IsTrue(a.hitbox.CheckCollisions() == null); }
// Constructor for the flapstate public FlapState(Ostrich ostrich) { this.ostrich = ostrich; this.stateMachine = ostrich.stateMachine; }
public SpawnState(Ostrich ostrich) { this.ostrich = ostrich; this.stateMachine = ostrich.stateMachine; }