Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace bidloCodVZdanii
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Renderer renderer = new Renderer();
  14.             Map map = new Map();
  15.             Fish1 fish1 = new Fish1(5,2,1000,'@');
  16.             Fish2 fish2 = new Fish2(6,2, 1000, '$');
  17.             Fish3 fish3 = new Fish3(7,2, 1000, '*');
  18.  
  19.             Console.CursorVisible = false;
  20.             while (true)
  21.             {
  22.                
  23.                 Console.Clear();
  24.                 renderer.WriteMap();
  25.             }
  26.  
  27.            
  28.         }
  29.     }
  30.     class Fish
  31.     {
  32.         public int PozitionX;
  33.         public int PozitionY;
  34.         public int Hp;
  35.         public char Simvol;
  36.         protected Random random = new Random();
  37.         public Fish(int pozitionX, int pozitionY, int hp, char simvol)
  38.         {
  39.             PozitionX = pozitionX;
  40.             PozitionY = pozitionY;
  41.             Hp = hp;
  42.             Simvol = simvol;
  43.         }
  44.     }
  45.     class Fish1 : Fish
  46.     {
  47.         public Fish1(int pozitionX, int pozitionY, int hp, char simvol): base(pozitionX, pozitionY, hp, simvol)
  48.         {
  49.            
  50.         }
  51.         public void Demeanor()
  52.         {
  53.             Pozition pozition = new Pozition(PozitionX, PozitionY);
  54.  
  55.             switch (random.Next(1, 9))
  56.             {
  57.                 case 1:
  58.                     pozition.MoveDown();
  59.                     break;
  60.                 case 2:
  61.                     pozition.MoveDownLeft();
  62.                     break;
  63.                 case 3:
  64.                     pozition.MoveDownRight();
  65.                     break;
  66.                 case 4:
  67.                     pozition.MoveLeft();
  68.                     break;
  69.                 case 5:
  70.                     pozition.MoveUP();
  71.                     break;
  72.                 case 6:
  73.                     pozition.MoveUPLeft();
  74.                     break;
  75.                 case 7:
  76.                     pozition.MoveUPRight();
  77.                     break;
  78.                 case 8:
  79.                     pozition.MoveRight();
  80.                     break;
  81.  
  82.             }
  83.         }
  84.     }
  85.     class Fish2 : Fish
  86.     {
  87.         public Fish2(int pozitionX, int pozitionY, int hp, char simvol) : base(pozitionX, pozitionY, hp, simvol)
  88.         {
  89.  
  90.         }
  91.         public void Demeanor()
  92.         {
  93.             Pozition pozition = new Pozition(PozitionX, PozitionY);
  94.             switch (random.Next(1, 5))
  95.             {
  96.                 case 1:
  97.                     pozition.MoveDown();
  98.                     break;
  99.                 case 2:
  100.                     pozition.MoveLeft();
  101.                     break;
  102.                 case 3:
  103.                     pozition.MoveRight();
  104.                     break;
  105.                 case 4:
  106.                     pozition.MoveUP();
  107.                     break;
  108.             }
  109.         }
  110.     }
  111.     class Fish3 : Fish
  112.     {
  113.         public Fish3(int pozitionX, int pozitionY, int hp, char simvol) : base(pozitionX, pozitionY, hp, simvol)
  114.         {
  115.  
  116.         }
  117.         public void Demeanor()
  118.         {
  119.             Pozition pozition = new Pozition(PozitionX, PozitionY);
  120.             switch (random.Next(1, 5))
  121.             {
  122.                 case 1:
  123.                     pozition.MoveDownLeft();
  124.                     break;
  125.                 case 2:
  126.                     pozition.MoveDownRight();
  127.                     break;
  128.                 case 3:
  129.                     pozition.MoveUPLeft();
  130.                     break;
  131.                 case 4:
  132.                     pozition.MoveUPRight();
  133.                     break;
  134.             }
  135.         }
  136.     }
  137.  
  138.     class Pozition
  139.     {
  140.         public int PozitionX { get; protected set; }
  141.         public int PozitionY { get; protected set; }
  142.         private Map _map = new Map();
  143.  
  144.         public Pozition(int pozitionX, int pozitionY)
  145.         {
  146.             PozitionX = pozitionX;
  147.             PozitionY = pozitionY;
  148.            
  149.         }
  150.  
  151.         public void MoveUP()
  152.         {
  153.             if (_map.GetMap[PozitionX, PozitionY - 1] != '#')
  154.             {
  155.                 PozitionY--;
  156.             }
  157.         }
  158.  
  159.         public void MoveDown()
  160.         {
  161.             if (_map.GetMap[PozitionX, PozitionY + 1] != '#')
  162.             {
  163.                 PozitionY++;
  164.             }
  165.            
  166.         }
  167.  
  168.         public void MoveRight()
  169.         {
  170.             if (_map.GetMap[PozitionX + 1, PozitionY] != '#')
  171.             {
  172.                 PozitionX++;
  173.             }
  174.            
  175.         }
  176.  
  177.         public void MoveLeft()
  178.         {
  179.             if (_map.GetMap[PozitionX - 1, PozitionY - 1] != '#')
  180.             {
  181.                 PozitionX--;
  182.             }
  183.         }
  184.         public void MoveUPRight()
  185.         {
  186.             if (_map.GetMap[PozitionX + 1, PozitionY - 1] != '#')
  187.             {
  188.                 PozitionY--;
  189.                 PozitionX++;
  190.             }
  191.         }
  192.         public void MoveUPLeft()
  193.         {
  194.             if (_map.GetMap[PozitionX - 1, PozitionY - 1] != '#')
  195.             {
  196.                 PozitionY--;
  197.                 PozitionX--;
  198.             }
  199.         }
  200.         public void MoveDownRight()
  201.         {
  202.             if (_map.GetMap[PozitionX + 1, PozitionY + 1] != '#')
  203.             {
  204.                 PozitionY++;
  205.                 PozitionX++;
  206.             }
  207.  
  208.         }
  209.         public void MoveDownLeft()
  210.         {
  211.             if (_map.GetMap[PozitionX - 1, PozitionY + 1] != '#')
  212.             {
  213.                 PozitionY++;
  214.                 PozitionX--;
  215.             }
  216.  
  217.         }
  218.     }
  219.     class Map
  220.     {
  221.         private char[,] _map =
  222.         {
  223.                 {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' },
  224.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  225.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  226.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  227.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  228.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  229.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  230.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  231.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  232.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  233.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  234.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  235.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  236.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  237.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  238.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  239.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  240.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  241.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  242.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  243.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  244.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  245.                 {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
  246.                 {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' },
  247.         };
  248.         public char[,] GetMap
  249.         {
  250.             get
  251.             {
  252.                 return _map;
  253.             }
  254.         }
  255.         public int LengthMap
  256.         {
  257.             get
  258.             {
  259.                 return _map.GetLength(0);
  260.             }
  261.         }
  262.         public int HeightMap
  263.         {
  264.             get
  265.             {
  266.                 return _map.GetLength(1);
  267.             }
  268.         }
  269.  
  270.  
  271.  
  272.     }
  273.     class Renderer
  274.     {
  275.         public void WriteMap()
  276.         {
  277.             Map map = new Map();
  278.             Console.SetCursorPosition(0, 0);
  279.             for (int i = 0; i < map.LengthMap; i++)
  280.             {
  281.                 for (int j = 0; j < map.HeightMap; j++)
  282.                 {
  283.                     Console.Write(map.GetMap[i, j]);
  284.                 }
  285.                 Console.WriteLine();
  286.             }
  287.         }
  288.     }
  289. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement