public bool CollidesWith(Player player)
 {
     if (GetDistance(player.Location) < 75) {
         return true;
     }
     else {
         return false;
     }
 }
        public void ChasePlayer(Player player)
        {
            if (Location.X >= player.Location.X)
                Location = new Point(Location.X - 1, Location.Y);

            if (Location.X <= player.Location.X)
                Location = new Point(Location.X + 1, Location.Y);

            if (Location.Y >= player.Location.Y)
                Location = new Point(Location.X, Location.Y - 1);

            if (Location.Y <= player.Location.Y)
                Location = new Point(Location.X, Location.Y + 1);
        }
Example #3
0
 public void ChasePlayer(Player player, string axis)
 {
     bool continueX = true;
     bool continueY = true;
     if (smartMovingEnabled)
     {
         if (smartmovingDirection.Contains("up") || smartmovingDirection.Contains("down"))
         {
             continueY = false;
         }
         if (smartmovingDirection.Contains("left") || smartmovingDirection.Contains("right"))
         {
             continueX = false;
         }
     }
     if (axis == "x" && continueX)
     {
             if (Location.X >= player.Location.X)
             {
                     Location = new Point(Location.X - 1 - movingSpeed, Location.Y);
             }
             if (Location.X <= player.Location.X)
             {
                     Location = new Point(Location.X + 1 + movingSpeed, Location.Y);
             }
     }
     else if (axis == "y" && continueY)
     {
             if (Location.Y >= player.Location.Y)
             {
                     Location = new Point(Location.X, Location.Y - 1 - movingSpeed);
             }
             if (Location.Y <= player.Location.Y)
             {
                     Location = new Point(Location.X, Location.Y + 1 + movingSpeed);
             }
     }
 }
Example #4
0
        private void BuildGameField(out List<GameObject> gameObjects, out Player player)
        {
            // Maak een test begin veld
            Debug.WriteLine("BuildGameField: Start");
            gameObjects = new List<GameObject>();
            gameObjects.Add(new MovingExplodingObstacle(new Point(100, 100), 40, 40));
            gameObjects.Add(new MovingExplodingObstacle(new Point(200, 100), 40, 40));
            gameObjects.Add(new MovingExplodingObstacle(new Point(300, 100), 40, 40));
            gameObjects.Add(new SlowingObstacle(new Point(300, 100), 40, 40));
            gameObjects.Add(new SlowingObstacle(new Point(300, 100), 40, 40));
            gameObjects.Add(new ExplodingObstacle(new Point(50, 0), 40, 40));

            player = new Player(new Point(0, 5), 40, 40);
            Debug.WriteLine("BuildGameField: End");
        }