Exemplo n.º 1
0
 public void FillInGameField()
 {
     for (int n = 0; n < Height; n++)
     {
         for (int j = 0; j < Width; j++)
         {
             if (field[n, j] == "T")
             {
                 gameField[n, j] = new Teleport(n, j);
             }
             else if (field[n, j] == "#")
             {
                 gameField[n, j] = new BreakPoint(n, j);
             }
             else if (field[n, j] == "@")
             {
                 gameField[n, j] = new Prize(n, j);
                 Prizes++;
             }
             else if (field[n, j] == " ")
             {
                 gameField[n, j] = new EmptyCell(n, j);
             }
             else if (field[n, j] == "%")
             {
                 gameField[n, j] = new Trap(n, j);
             }
             else if (field[n, j] == "M")
             {
                 gameField[n, j] = new MedHelp(n, j);
             }
             else if (field[n, j] == "*")
             {
                 gameField[n, j] = new Death(n, j);
             }
             else if (field[n, j] == "O")
             {
                 gameField[n, j] = new Enemy(n, j);
             }
             else if (field[n, j] == "I")
             {
                 gameField[n, j] = player;
             }
         }
     }
 }
Exemplo n.º 2
0
        public void MoveEnemys()
        {
            int index = 1;
            int count = 0;

            while (true)
            {
                lock (locker)
                {
                    Console.CursorVisible = false;
                    foreach (var c in gameField)
                    {
                        if (c is Enemy)
                        {
                            int X = c.Y;
                            int Y = c.X;
                            c.X += index;
                            if (gameField[c.X, c.Y] is Player)
                            {
                                player.NullLives();
                                break;
                            }
                            gameField[c.X, c.Y] = c;
                            gameField[Y, X]     = new EmptyCell(X, Y);
                            DrawCell(c.Y, c.X);
                            DrawCell(X, Y);
                            break;
                        }
                    }
                }
                count += index;
                if (count == 4 || count == 0)
                {
                    index *= -1;
                }
                Thread.Sleep(300);
            }
        }
Exemplo n.º 3
0
 public bool MovePlayer(int x, int y)
 {
     lock (locker)
     {
         int X = player.X;
         int Y = player.Y;
         if (gameField[player.Y + y, player.X + x] is EmptyCell)
         {
             player.Move(x, y);
             gameField[player.Y, player.X] = player;
             gameField[Y, X] = new EmptyCell(X, Y);
             return(true);
         }
         else if (gameField[player.Y + y, player.X + x].GetType() == typeof(Trap))
         {
             player.Move(x, y);
             player.MinusLives();
             gameField[player.Y, player.X] = player;
             gameField[Y, X] = new EmptyCell(X, Y);
         }
         else if (gameField[player.Y + y, player.X + x].GetType() == typeof(Enemy))
         {
             player.Move(x, y);
             player.NullLives();
             gameField[player.Y, player.X] = player;
             gameField[Y, X] = new EmptyCell(X, Y);
         }
         else if (gameField[Y + y, X + x].GetType() == typeof(Prize))
         {
             player.Move(x, y);
             gameField[player.Y, player.X] = player;
             gameField[Y, X] = new EmptyCell(X, Y);
             MinusPrizes();
             return(false);
         }
         else if (gameField[Y + y, X + x].GetType() == typeof(MedHelp))
         {
             player.Move(x, y);
             gameField[player.Y, player.X] = player;
             player.PlusLives();
             gameField[Y, X] = new EmptyCell(X, Y);
             return(false);
         }
         else if (gameField[Y + y, X + x].GetType() == typeof(Death))
         {
             player.Move(x, y);
             gameField[player.Y, player.X] = player;
             player.NullLives();
             gameField[Y, X] = new EmptyCell(X, Y);
             return(false);
         }
         else if (gameField[Y + y, X + x].GetType() == typeof(Teleport))
         {
             if (player.X + x == 3 && player.Y + y == 2)
             {
                 player.Teleport(Width - 3, 4);
                 player.Move(x, y);
                 gameField[player.Y, player.X] = player;
             }
             else if (player.Y + y == 4 && player.X + x == Width - 3)
             {
                 player.Teleport(3, 2);
                 player.Move(x, y);
                 gameField[player.Y, player.X] = player;
             }
             gameField[Y, X] = new EmptyCell(X, Y);
             return(true);
         }
         else if (gameField[Y + y, X + x].GetType() == typeof(BreakPoint))
         {
             return(false);
         }
         return(false);
     }
 }