Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace bidloCodVZdanii
- {
- class Program
- {
- static void Main(string[] args)
- {
- Renderer renderer = new Renderer();
- Map map = new Map();
- Fish1 fish1 = new Fish1(5,2,1000,'@');
- Fish2 fish2 = new Fish2(6,2, 1000, '$');
- Fish3 fish3 = new Fish3(7,2, 1000, '*');
- Console.CursorVisible = false;
- while (true)
- {
- Console.Clear();
- renderer.WriteMap();
- }
- }
- }
- class Fish
- {
- public int PozitionX;
- public int PozitionY;
- public int Hp;
- public char Simvol;
- protected Random random = new Random();
- public Fish(int pozitionX, int pozitionY, int hp, char simvol)
- {
- PozitionX = pozitionX;
- PozitionY = pozitionY;
- Hp = hp;
- Simvol = simvol;
- }
- }
- class Fish1 : Fish
- {
- public Fish1(int pozitionX, int pozitionY, int hp, char simvol): base(pozitionX, pozitionY, hp, simvol)
- {
- }
- public void Demeanor()
- {
- Pozition pozition = new Pozition(PozitionX, PozitionY);
- switch (random.Next(1, 9))
- {
- case 1:
- pozition.MoveDown();
- break;
- case 2:
- pozition.MoveDownLeft();
- break;
- case 3:
- pozition.MoveDownRight();
- break;
- case 4:
- pozition.MoveLeft();
- break;
- case 5:
- pozition.MoveUP();
- break;
- case 6:
- pozition.MoveUPLeft();
- break;
- case 7:
- pozition.MoveUPRight();
- break;
- case 8:
- pozition.MoveRight();
- break;
- }
- }
- }
- class Fish2 : Fish
- {
- public Fish2(int pozitionX, int pozitionY, int hp, char simvol) : base(pozitionX, pozitionY, hp, simvol)
- {
- }
- public void Demeanor()
- {
- Pozition pozition = new Pozition(PozitionX, PozitionY);
- switch (random.Next(1, 5))
- {
- case 1:
- pozition.MoveDown();
- break;
- case 2:
- pozition.MoveLeft();
- break;
- case 3:
- pozition.MoveRight();
- break;
- case 4:
- pozition.MoveUP();
- break;
- }
- }
- }
- class Fish3 : Fish
- {
- public Fish3(int pozitionX, int pozitionY, int hp, char simvol) : base(pozitionX, pozitionY, hp, simvol)
- {
- }
- public void Demeanor()
- {
- Pozition pozition = new Pozition(PozitionX, PozitionY);
- switch (random.Next(1, 5))
- {
- case 1:
- pozition.MoveDownLeft();
- break;
- case 2:
- pozition.MoveDownRight();
- break;
- case 3:
- pozition.MoveUPLeft();
- break;
- case 4:
- pozition.MoveUPRight();
- break;
- }
- }
- }
- class Pozition
- {
- public int PozitionX { get; protected set; }
- public int PozitionY { get; protected set; }
- private Map _map = new Map();
- public Pozition(int pozitionX, int pozitionY)
- {
- PozitionX = pozitionX;
- PozitionY = pozitionY;
- }
- public void MoveUP()
- {
- if (_map.GetMap[PozitionX, PozitionY - 1] != '#')
- {
- PozitionY--;
- }
- }
- public void MoveDown()
- {
- if (_map.GetMap[PozitionX, PozitionY + 1] != '#')
- {
- PozitionY++;
- }
- }
- public void MoveRight()
- {
- if (_map.GetMap[PozitionX + 1, PozitionY] != '#')
- {
- PozitionX++;
- }
- }
- public void MoveLeft()
- {
- if (_map.GetMap[PozitionX - 1, PozitionY - 1] != '#')
- {
- PozitionX--;
- }
- }
- public void MoveUPRight()
- {
- if (_map.GetMap[PozitionX + 1, PozitionY - 1] != '#')
- {
- PozitionY--;
- PozitionX++;
- }
- }
- public void MoveUPLeft()
- {
- if (_map.GetMap[PozitionX - 1, PozitionY - 1] != '#')
- {
- PozitionY--;
- PozitionX--;
- }
- }
- public void MoveDownRight()
- {
- if (_map.GetMap[PozitionX + 1, PozitionY + 1] != '#')
- {
- PozitionY++;
- PozitionX++;
- }
- }
- public void MoveDownLeft()
- {
- if (_map.GetMap[PozitionX - 1, PozitionY + 1] != '#')
- {
- PozitionY++;
- PozitionX--;
- }
- }
- }
- class Map
- {
- private char[,] _map =
- {
- {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' },
- };
- public char[,] GetMap
- {
- get
- {
- return _map;
- }
- }
- public int LengthMap
- {
- get
- {
- return _map.GetLength(0);
- }
- }
- public int HeightMap
- {
- get
- {
- return _map.GetLength(1);
- }
- }
- }
- class Renderer
- {
- public void WriteMap()
- {
- Map map = new Map();
- Console.SetCursorPosition(0, 0);
- for (int i = 0; i < map.LengthMap; i++)
- {
- for (int j = 0; j < map.HeightMap; j++)
- {
- Console.Write(map.GetMap[i, j]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement