Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        public void TestDie()
        {
            Ostrich o = new Ostrich();

            o.coords = new Point(500, 500);
            o.Die();
            Assert.AreEqual(new List <WorldObject> {
            }, World.Instance.objects);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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());
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 // Constructor for the flapstate
 public FlapState(Ostrich ostrich)
 {
     this.ostrich      = ostrich;
     this.stateMachine = ostrich.stateMachine;
 }
Esempio n. 7
0
 public SpawnState(Ostrich ostrich)
 {
     this.ostrich      = ostrich;
     this.stateMachine = ostrich.stateMachine;
 }