Пример #1
0
 private static char DrawCell(Cell cell)
 {
     var picture = '0';
     switch (cell.Type)
     {
         case CellType.Hidden:
             picture = '░';
             break;
         case CellType.Water:
             picture = '▒';
             break;
         case CellType.WithGold:
             picture = '☼';
             break;
         case CellType.Empty:
             picture = ' ';
             break;
         case CellType.Character1:
             picture = '☺';
             break;
         case CellType.Character2:
             picture = '☻';
             break;
         case CellType.Ship:
             picture = '⌂';
             break;
     }
     return picture;
 }
Пример #2
0
 private static Image DrawCell(Cell cell)
 {
     Image picture = Resources.Empty;
     switch (cell.Type)
     {
         case CellType.Hidden:
             picture = Resources.Smoke;
             break;
         case CellType.Water:
             picture = Resources.Water;
             break;
         case CellType.WithGold:
             picture = Resources.Gold;
             break;
         case CellType.Character1:
             picture = Resources.Pirate1;
             break;
         case CellType.Character2:
             picture = Resources.Pirate2;
             break;
         case CellType.Ship:
             picture = Resources.Ship;
             break;
     }
     return picture;
 }
Пример #3
0
 private void InitMap()
 {
     for (var i = 0; i < YSize; i++)
     {
         _map[0, i] = new Cell(CellType.Water);
         _map[XSize - 1, i] = new Cell(CellType.Water);
     }
     for (var i = 0; i < XSize; i++)
     {
         _map[i, 0] = new Cell(CellType.Water);
         _map[i, YSize - 1] = new Cell(CellType.Water);
     }
     for (var i = 1; i < (XSize - 1); i++)
         for (var j = 1; j < (YSize - 1); j++)
             _map[i, j] = new Cell();
 }
Пример #4
0
 private void SetCharacterOnMap(int x, int y, int charId)
 {
     CellType cellTypEnum;
     Enum.TryParse("Character" + (charId + 1).ToString(), false, out cellTypEnum);
     _map[x, y] = new Cell(cellTypEnum);
 }
Пример #5
0
 private void GenerateCell(int x, int y)
 {
     var rnd = new Random();
     if (rnd.Next(6) == 0 && _goldMapCapacity > 0)
     {
         _goldMapCapacity--;
         _map[x, y] = new Cell(CellType.WithGold);
     }
     else
     {
         _map[x, y] = new Cell(CellType.Empty);
     }
 }
Пример #6
0
        private void CheckActionsOnThatCell(Character ch, Point futureCoordinates)
        {
            int x = futureCoordinates.X, y = futureCoordinates.Y;
            if (_map[x, y].Type == CellType.Hidden)
                GenerateCell(x, y);
            if (_map[x, y].Type == CellType.WithGold)
            {
                if (!ch.WithGold)
                {
                    ch.WithGold = true;
                    _map[x, y] = new Cell(CellType.Empty);
                }
                return;
            }
            if (_map[x, y].Type == CellType.Ship && ch.WithGold)
            {
                ch.WithGold = false;
                ch.TakeGold();
                return;
            }

            if (_map[x, y].Type == CellType.Character1 || _map[x, y].Type == CellType.Character2)
            {
                var enemy= _ships.Select(ship => ship.Crew[0]).First(cah => cah.X == x && cah.Y == y);
                _ships.Select(ship=>ship).First(ship=>ship.Crew.Contains(enemy)).KillCharacter(enemy);
                _map[x, y] = enemy.CurrentCell;
                enemy.CurrentCell=new Cell(CellType.Ship);

            }
        }