PhotoShaman

pingpong

Jul 24th, 2016
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 36.39 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. using System.Threading;
  7.  
  8.  
  9. namespace ConsoleApplication65
  10. {
  11.     class Program
  12.     {
  13.         private static int x, y, timeStart, xBox, yBox, xPBox, yPBox, color,
  14.                             ballPosX, ballPosY, playerPos, botPos, playerSize, botSize, playerResult, botResult;
  15.         private static bool StartOpen, FolderOpen, DrawingOpen, Drawing, SaveOrLoadOpen, Exit, SaveDrawing,
  16.                             Image1Save = false, Image2Save = false, Image3Save = false, Kitty = false, ToUpDate = true,
  17.                             ballDirectionUp = true, ballDirectionRight = true;
  18.         private static int[,] image, AnimationSettins1, AnimationSettins2;
  19.         private static int[,] DrawingSaveMain = new int[18, 52];
  20.         private static int[,] DrawingSave1, DrawingSave2, DrawingSave3 = new int[18, 52];
  21.  
  22.         static Random randomGenerator = new Random();
  23.  
  24.         static void Main()
  25.         {
  26.             Settings();
  27.             //LoadingDraw();
  28.             OperatingSystem();
  29.         }
  30.  
  31.         private static void Settings()
  32.         {
  33.             timeStart = TimeCheck();
  34.             StartOpen = false;
  35.             FolderOpen = false;
  36.             DrawingOpen = false;
  37.             Exit = false;
  38.             color = 1;
  39.  
  40.             Console.SetWindowSize(120, 30);
  41.             Console.BufferHeight = Console.WindowHeight;
  42.             Console.BufferWidth = Console.WindowWidth;
  43.             Console.Title = "Doors OS";
  44.  
  45.             x = 2;
  46.             y = Console.WindowHeight - 5;
  47.  
  48.             ResetDrawingSaveMain();
  49.         }
  50.  
  51.         private static void ResetDrawingSaveMain()
  52.         {
  53.             for (int i = 0; i <= 17; i++)
  54.             {
  55.                 for (int j = 0; j <= 50; j++)
  56.                 {
  57.                     DrawingSaveMain[i, j] = 15;
  58.                 }
  59.                 DrawingSaveMain[i, 51] = 0;
  60.             }
  61.         }
  62.  
  63.         private static int TimeCheck()
  64.         {
  65.             int timeReturn;
  66.             string curTimeShort = DateTime.Now.ToString("mm");
  67.             timeReturn = Convert.ToInt32(curTimeShort);
  68.             return timeReturn;
  69.         }
  70.  
  71.         private static void LoadingAnimationSettings()
  72.         {
  73.             AnimationSettins1 = new int[,]
  74.                 {
  75.                 {1,1,10,5,45,7,0},
  76.                 {0,2,10,5,65,7,0},
  77.                 {0,3,10,5,45,17,0},
  78.                 {0,4,10,5,65,17,200},
  79.                 {1,1,10,5,47,8,0},
  80.                 {0,2,10,5,63,8,0},
  81.                 {0,3,10,5,47,16,0},
  82.                 {0,4,10,5,63,16,300},
  83.                 {1,1,10,5,50,10,0},
  84.                 {0,2,10,5,60,10,0},
  85.                 {0,3,10,5,50,15,0},
  86.                 {0,4,10,5,60,15,300},
  87.                 {1,1,10,10,50,5,0},
  88.                 {0,2,10,10,60,5,0},
  89.                 {0,3,10,10,50,15,0},
  90.                 {0,4,10,10,60,15,300},
  91.                 {1,1,10,10,50,5,0},
  92.                 {0,2,10,10,60,5,0},
  93.                 {0,4,10,10,60,15,0},
  94.                 {0,3,15,15,50,10,200},
  95.                 {1,3,20,20,50,5,200},
  96.                 {0,5,2,1,65,15,0}
  97.                 };
  98.             AnimationSettins2 = new int[,]
  99.                 {
  100.                 {1,34,13,100},
  101.                 {2,46,13,100},
  102.                 {2,56,13,100},
  103.                 {3,66,13,100},
  104.                 {4,76,13,100},
  105.                 {2,88,13,100},
  106.                 {4,98,13,2000}
  107.                 };
  108.         }
  109.  
  110.         private static void LoadingDraw()
  111.         {
  112.             Console.CursorVisible = false;
  113.  
  114.             LoadingAnimationSettings();
  115.  
  116.             for (int p = 0; p <= 21; p++)
  117.             {
  118.                 if (AnimationSettins1[p, 0] == 1)
  119.                 {
  120.                     Console.ResetColor();
  121.                     Console.Clear();
  122.                 }
  123.                 if (AnimationSettins1[p, 1] == 1)
  124.                 {
  125.                     Console.BackgroundColor = ConsoleColor.Red;
  126.                 }
  127.                 if (AnimationSettins1[p, 1] == 2)
  128.                 {
  129.                     Console.BackgroundColor = ConsoleColor.Green;
  130.                 }
  131.                 if (AnimationSettins1[p, 1] == 3)
  132.                 {
  133.                     Console.BackgroundColor = ConsoleColor.Blue;
  134.                 }
  135.                 if (AnimationSettins1[p, 1] == 4)
  136.                 {
  137.                     Console.BackgroundColor = ConsoleColor.Yellow;
  138.                 }
  139.                 if (AnimationSettins1[p, 1] == 5)
  140.                 {
  141.                     Console.BackgroundColor = ConsoleColor.Black;
  142.                 }
  143.                 xBox = AnimationSettins1[p, 2];
  144.                 yBox = AnimationSettins1[p, 3];
  145.                 xPBox = AnimationSettins1[p, 4];
  146.                 yPBox = AnimationSettins1[p, 5];
  147.                 Box(xBox, yBox, xPBox, yPBox);
  148.                 Thread.Sleep(AnimationSettins1[p, 6]);
  149.             }
  150.  
  151.             for (int i = 1; i <= 40; i++)
  152.             {
  153.                 Console.ResetColor();
  154.                 Console.Clear();
  155.                 Console.BackgroundColor = ConsoleColor.Blue;
  156.                 Box(20, 20, (Console.WindowWidth / 2) - 10 - i, (Console.WindowHeight / 2) - 10);
  157.                 Console.BackgroundColor = ConsoleColor.Black;
  158.                 Box(2, 1, (Console.WindowWidth / 2) + 5 - i, Console.WindowHeight / 2);
  159.                 Thread.Sleep(10);
  160.             }
  161.  
  162.             for (int p = 0; p <= 6; p++)
  163.             {
  164.                 ChooseImage(AnimationSettins2[p, 0]);
  165.                 DrawImage(AnimationSettins2[p, 1], AnimationSettins2[p, 2]);
  166.                 Thread.Sleep(AnimationSettins2[p, 3]);
  167.             }
  168.  
  169.             Console.CursorVisible = true;
  170.  
  171.         }
  172.  
  173.         private static void Box(int Width, int Height, int XPos, int YPos)
  174.         {
  175.             for (int i = 0; i < Height; i++)
  176.             {
  177.                 Console.SetCursorPosition(XPos, YPos);
  178.                 Console.Write(" ".PadRight(Width));
  179.                 YPos++;
  180.             }
  181.         }
  182.  
  183.         private static void DrawImage(int m, int n)
  184.         {
  185.             Console.ResetColor();
  186.  
  187.             Console.SetCursorPosition(m, n);
  188.  
  189.             for (int i = 0; i < image.GetLength(0); i++)
  190.             {
  191.                 for (int j = 0; j < image.GetLength(1); j++)
  192.                 {
  193.                     if (image[i, j] == 0)
  194.                     {
  195.                         n++;
  196.                         Console.SetCursorPosition(m, n);
  197.                     }
  198.                     else if (image[i, j] > 0)
  199.                     {
  200.                         ChooseColor(image[i, j]);
  201.                         Console.Write("  ");
  202.                     }
  203.                 }
  204.             }
  205.             Console.SetCursorPosition(0, 0);
  206.         }
  207.  
  208.         private static void ChooseColor(int number)
  209.         {
  210.             if (number == 1)
  211.                 Console.BackgroundColor = ConsoleColor.Black;
  212.             if (number == 2)
  213.                 Console.BackgroundColor = ConsoleColor.Blue;
  214.             if (number == 3)
  215.                 Console.BackgroundColor = ConsoleColor.Cyan;
  216.             if (number == 4)
  217.                 Console.BackgroundColor = ConsoleColor.DarkBlue;
  218.             if (number == 5)
  219.                 Console.BackgroundColor = ConsoleColor.DarkCyan;
  220.             if (number == 6)
  221.                 Console.BackgroundColor = ConsoleColor.DarkGray;
  222.             if (number == 7)
  223.                 Console.BackgroundColor = ConsoleColor.DarkGreen;
  224.             if (number == 8)
  225.                 Console.BackgroundColor = ConsoleColor.DarkMagenta;
  226.             if (number == 9)
  227.                 Console.BackgroundColor = ConsoleColor.DarkRed;
  228.             if (number == 10)
  229.                 Console.BackgroundColor = ConsoleColor.DarkYellow;
  230.             if (number == 11)
  231.                 Console.BackgroundColor = ConsoleColor.Gray;
  232.             if (number == 12)
  233.                 Console.BackgroundColor = ConsoleColor.Green;
  234.             if (number == 13)
  235.                 Console.BackgroundColor = ConsoleColor.Magenta;
  236.             if (number == 14)
  237.                 Console.BackgroundColor = ConsoleColor.Red;
  238.             if (number == 15)
  239.                 Console.BackgroundColor = ConsoleColor.White;
  240.             if (number == 16)
  241.                 Console.BackgroundColor = ConsoleColor.Yellow;
  242.         }
  243.  
  244.         private static void ChooseImage(int i)
  245.         {
  246.             if (i == 0)
  247.             {
  248.                 if (Kitty)
  249.                 {
  250.                     image = new int[,] //Kitty
  251.                     {
  252.                 {2 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,1 ,1 ,2 ,2 ,0},
  253.                 {2 ,1 ,11,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,1 ,11,11,1 ,2 ,0},
  254.                 {2 ,1 ,11,11,1 ,2 ,2 ,2 ,2 ,2 ,1 ,11,11,11,1 ,2 ,0},
  255.                 {2 ,1 ,11,11,11,1 ,1 ,1 ,1 ,1 ,11,11,11,11,1 ,2 ,0},
  256.                 {1 ,11,11,11,11,11,11,11,11,11,11,11,11,11,1 ,2 ,0},
  257.                 {1 ,11,11,11,11,11,11,11,11,11,11,11,11,11,1 ,2 ,0},
  258.                 {1 ,11,11,11,11,11,11,11,11,11,11,11,11,11,11,1 ,0},
  259.                 {1 ,11,11,11,15,1 ,11,11,11,11,11,15,1 ,11,11,1 ,0},
  260.                 {1 ,11,11,11,1 ,1 ,11,11,11,1 ,11,1 ,1 ,11,11,1 ,0},
  261.                 {1 ,11,9 ,9 ,11,11,11,11,11,11,11,11,11,9 ,9 ,1 ,0},
  262.                 {1 ,11,9 ,9 ,11,1 ,11,11,1 ,11,11,1 ,11,9 ,9 ,1 ,0},
  263.                 {2 ,1 ,11,11,11,11,1 ,1 ,11,1 ,1 ,11,11,11,1 ,2 ,0},
  264.                 {2 ,2 ,1 ,11,11,11,11,11,11,11,11,11,11,1 ,2 ,2 ,0},
  265.                 {2 ,2 ,2 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,0}
  266.                     };
  267.                 }
  268.                 else
  269.                 {
  270.                     image = new int[,] //Mario
  271.             {
  272.                 {2 ,2 ,2 ,14,14,14,14,14,2 ,2 ,2 ,2 ,0},
  273.                 {2 ,2 ,14,14,14,14,14,14,14,14,14,2 ,0},
  274.                 {2 ,2 ,9 ,9 ,9 ,15,15,1 ,15,2 ,2 ,2 ,0},
  275.                 {2 ,9 ,15,9 ,15,15,15,1 ,15,15,15,2 ,0},
  276.                 {2 ,9 ,15,9 ,9 ,15,15,15,9 ,15,15,15,0},
  277.                 {2 ,9 ,9 ,15,15,15,15,9 ,9 ,9 ,9 ,2 ,0},
  278.                 {2 ,2 ,2 ,15,15,15,15,15,15,15,2 ,2 ,0},
  279.                 {2 ,2 ,14,14,4 ,14,14,14,2 ,2 ,2 ,2 ,0},
  280.                 {2 ,14,14,14,4 ,14,14,4 ,14,14,14,2 ,0},
  281.                 {14,14,14,14,4 ,4 ,4 ,4 ,14,14,14,14,0},
  282.                 {15,15,14,4 ,16,4 ,4 ,16,4 ,14,15,15,0},
  283.                 {15,15,15,4 ,4 ,4 ,4 ,4 ,4 ,15,15,15,0},
  284.                 {15,15,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,15,15,0},
  285.                 {2 ,2 ,4 ,4 ,4 ,2 ,2 ,4 ,4 ,4 ,2 ,2 ,0},
  286.                 {2 ,9 ,9 ,9 ,2 ,2 ,2 ,2 ,9 ,9 ,9 ,2 ,0},
  287.                 {9 ,9 ,9 ,9 ,2 ,2 ,2 ,2 ,9 ,9 ,9 ,9 ,0}
  288.             };
  289.                 }
  290.             }
  291.             if (i == 1)
  292.             {
  293.                 image = new int[,]
  294.                 {
  295.                 {15,15,15,15,1 ,0},
  296.                 {15,1 ,1 ,1 ,15,0},
  297.                 {15,1 ,1 ,1 ,15,0},
  298.                 {15,1 ,1 ,1 ,15,0},
  299.                 {15,15,15,15,1 ,0},
  300.                 };
  301.             }
  302.             if (i == 2)
  303.             {
  304.                 image = new int[,]
  305.                 {
  306.                 {15,15,15,15,0},
  307.                 {15,1 ,1 ,15,0},
  308.                 {15,1 ,1 ,15,0},
  309.                 {15,1 ,1 ,15,0},
  310.                 {15,15,15,15,0},
  311.                 };
  312.             }
  313.             if (i == 3)
  314.             {
  315.                 image = new int[,]
  316.                 {
  317.                 {15,15,15,15,0},
  318.                 {15,1 ,1 ,15,0},
  319.                 {15,15,15,15,0},
  320.                 {15,1 ,15,1 ,0},
  321.                 {15,1 ,15,1 ,0},
  322.                 };
  323.             }
  324.             if (i == 4)
  325.             {
  326.                 image = new int[,]
  327.                 {
  328.                 {15,15,15,0},
  329.                 {15,1 ,1 ,0},
  330.                 {15,15,15,0},
  331.                 {1 ,1 ,15,0},
  332.                 {15,15,15,0},
  333.                 };
  334.             }
  335.             if (i == 5)
  336.             {
  337.                 image = new int[,]
  338.                 {
  339.                 {1 ,0},
  340.                 {2 ,0},
  341.                 {3 ,0},
  342.                 {4 ,0},
  343.                 {5 ,0},
  344.                 {6 ,0},
  345.                 {7 ,0},
  346.                 {8 ,0},
  347.                 {9 ,0},
  348.                 {10,0},
  349.                 {11,0},
  350.                 {12,0},
  351.                 {13,0},
  352.                 {14,0},
  353.                 {15,0},
  354.                 {16,0}
  355.                 };
  356.             }
  357.             if (i == 6)
  358.             {
  359.                 image = DrawingSaveMain;
  360.             }
  361.         }
  362.  
  363.         private static void MoveCursor()
  364.         {
  365.             Update();
  366.  
  367.             Console.SetCursorPosition(x, y);
  368.  
  369.             ConsoleKey k = Console.ReadKey(true).Key;
  370.  
  371.             if (k == ConsoleKey.D || k == ConsoleKey.RightArrow)
  372.             {
  373.                 x += 2;
  374.                 if (x > Console.WindowWidth - 3)
  375.                 {
  376.                     x = 2;
  377.                 }
  378.             }
  379.             if (k == ConsoleKey.A || k == ConsoleKey.LeftArrow)
  380.             {
  381.                 x -= 2;
  382.                 if (x < 1)
  383.                 {
  384.                     x = Console.WindowWidth - 4;
  385.                 }
  386.             }
  387.             if (k == ConsoleKey.W || k == ConsoleKey.UpArrow)
  388.             {
  389.                 y -= 1;
  390.                 if (y < 1)
  391.                 {
  392.                     y = Console.WindowHeight - 2;
  393.                 }
  394.             }
  395.             if (k == ConsoleKey.S || k == ConsoleKey.DownArrow)
  396.             {
  397.                 y += 1;
  398.                 if (y > Console.WindowHeight - 2)
  399.                 {
  400.                     y = 1;
  401.                 }
  402.             }
  403.             if (k == ConsoleKey.Enter || k == ConsoleKey.Spacebar)
  404.             {
  405.                 Bottoms();
  406.             }
  407.         }
  408.  
  409.         private static void Time()
  410.         {
  411.             Console.BackgroundColor = ConsoleColor.Green;
  412.             Console.ForegroundColor = ConsoleColor.Black;
  413.             Console.SetCursorPosition(Console.WindowWidth - 28, Console.WindowHeight - 3);
  414.             Console.Write(DateTime.Now.ToString("dd MMMM yyyy | HH:mm:ss"));
  415.             Console.ResetColor();
  416.         }
  417.  
  418.         private static void Bottoms()
  419.         {
  420.             if (x <= 10 && y >= Console.WindowHeight - 4 && !StartOpen)
  421.             {
  422.                 StartOpen = true;
  423.                 StartDraw();
  424.             }
  425.             else if (x <= 10 && y >= Console.WindowHeight - 4 && StartOpen)
  426.             {
  427.                 StartOpen = false;
  428.                 OperatingSystem();
  429.             }
  430.             else if (x <= 26 && (y > Console.WindowHeight - 27) && (y < Console.WindowHeight - 23) && StartOpen)
  431.             {
  432.                 FolderOpen = true;
  433.                 StartOpen = false;
  434.                 OperatingSystem();
  435.             }
  436.             else if (x <= 26 && (y > Console.WindowHeight - 23) && (y < Console.WindowHeight - 19) && StartOpen)
  437.             {
  438.                 DrawingOpen = true;
  439.                 Drawing = true;
  440.                 StartOpen = false;
  441.                 OperatingSystem();
  442.             }
  443.             else if (x == 6 && y >= 7 && y <= 22 && DrawingOpen)
  444.             {
  445.                 for (int i = 7; i <= 22; i++)
  446.                 {
  447.                     if (y == i)
  448.                     {
  449.                         color = i - 6;
  450.                     }
  451.                 }
  452.             }
  453.             else if (x >= 64 && x <= 72 && y == 6 && SaveOrLoadOpen)
  454.             {
  455.                 Drawing = true;
  456.                 SaveOrLoadOpen = false;
  457.                 OperatingSystem();
  458.             }
  459.             else if (x >= 64 && x <= 76 && (y == 8 || y == 10 || y == 12) && SaveOrLoadOpen)
  460.             {
  461.                 if (SaveDrawing)
  462.                 {
  463.                     if (y == 8)
  464.                     {
  465.                         Image1Save = true;
  466.                         Array.Copy(DrawingSaveMain, DrawingSave1 = new int[18, 52], DrawingSaveMain.Length);
  467.                     }
  468.                     if (y == 10)
  469.                     {
  470.                         Image2Save = true;
  471.                         Array.Copy(DrawingSaveMain, DrawingSave2 = new int[18, 52], DrawingSaveMain.Length);
  472.                     }
  473.                     if (y == 12)
  474.                     {
  475.                         Image3Save = true;
  476.                         Array.Copy(DrawingSaveMain, DrawingSave3 = new int[18, 52], DrawingSaveMain.Length);
  477.                     }
  478.                 }
  479.                 else
  480.                 {
  481.                     if (y == 8)
  482.                         if (Image1Save)
  483.                             Array.Copy(DrawingSave1, DrawingSaveMain = new int[18, 52], DrawingSave1.Length);
  484.                     if (y == 10)
  485.                         if (Image2Save)
  486.                             Array.Copy(DrawingSave2, DrawingSaveMain = new int[18, 52], DrawingSave1.Length);
  487.                     if (y == 12)
  488.                         if (Image3Save)
  489.                             Array.Copy(DrawingSave3, DrawingSaveMain = new int[18, 52], DrawingSave1.Length);
  490.                 }
  491.                 Drawing = true;
  492.                 SaveOrLoadOpen = false;
  493.                 OperatingSystem();
  494.             }
  495.             else if (x >= 12 && x <= 30 && y == 4 && DrawingOpen && Drawing)
  496.             {
  497.                 ResetDrawingSaveMain();
  498.                 OperatingSystem();
  499.             }
  500.             else if (x >= 12 && x <= 112 && y >= 6 && y <= 23 && DrawingOpen && Drawing)
  501.             {
  502.                 DrawingSaveMain[y - 6, (x - 12) / 2] = color;
  503.                 ChooseColor(color);
  504.                 Console.Write("  ");
  505.             }
  506.             else if (x >= 40 && x <= 80 && y == 4 && DrawingOpen)
  507.             {
  508.                 SaveOrLoadOpen = true;
  509.                 if (x >= 40 && x <= 53)
  510.                 {
  511.                     Drawing = false;
  512.                     SaveDrawing = true;
  513.                     SaveOrLoadDrawingDraw();
  514.                 }
  515.                 else if (x >= 66 && x <= 78)
  516.                 {
  517.                     Drawing = false;
  518.                     SaveDrawing = false;
  519.                     SaveOrLoadDrawingDraw();
  520.                 }
  521.             }
  522.             else if (x <= 26 && (y > Console.WindowHeight - 8) && (y < Console.WindowHeight - 4) && StartOpen)
  523.             {
  524.                 Exit = true;
  525.                 StartOpen = false;
  526.                 OperatingSystem();
  527.             }
  528.             else if (x >= Console.WindowWidth - 18 && x <= Console.WindowWidth - 6 && y == Console.WindowHeight - 28 && FolderOpen)
  529.             {
  530.                 FolderOpen = false;
  531.                 OperatingSystem();
  532.             }
  533.             else if (x >= Console.WindowWidth - 18 && x <= Console.WindowWidth - 6 && y == 2 && DrawingOpen)
  534.             {
  535.                 SaveOrLoadOpen = false;
  536.                 DrawingOpen = false;
  537.                 OperatingSystem();
  538.             }
  539.             else if (x >= Console.WindowWidth - 74 && x <= Console.WindowWidth - 66 && y >= 16 && y <= Console.WindowHeight - 12 && Exit)
  540.             {
  541.                 Exit = false;
  542.                 OperatingSystem();
  543.             }
  544.             else if (x >= Console.WindowWidth - 56 && x <= Console.WindowWidth - 48 && y >= 16 && y <= Console.WindowHeight - 12 && Exit)
  545.             {
  546.                 System.Environment.Exit(1);
  547.             }
  548.         }
  549.  
  550.         private static void UIDraw()
  551.         {
  552.             Console.BackgroundColor = ConsoleColor.Blue;
  553.             Box(Console.WindowWidth - 4, Console.WindowHeight - 5, 2, 1);
  554.  
  555.             Console.BackgroundColor = ConsoleColor.DarkCyan;
  556.             Box(Console.WindowWidth - 43, 3, 11, (Console.WindowHeight - 4));
  557.  
  558.             for (int i = 1; i <= 3; i++)
  559.             {
  560.                 Console.SetCursorPosition(12, Console.WindowHeight - i - 1);
  561.                 Console.Write("║");
  562.             }
  563.  
  564.             Console.BackgroundColor = ConsoleColor.Green;
  565.             Box(9, 3, 2, (Console.WindowHeight - 4));
  566.  
  567.             Box(30, 3, (Console.WindowWidth - 32), (Console.WindowHeight - 4));
  568.  
  569.             Console.ForegroundColor = ConsoleColor.Black;
  570.             Console.SetCursorPosition(4, Console.WindowHeight - 3);
  571.             Console.Write("Старт");
  572.  
  573.             if (!FolderOpen && !DrawingOpen && !Exit)
  574.             {
  575.                 ChooseImage(0);
  576.  
  577.                 DrawImage((Console.WindowWidth / 2 - 16), (Console.WindowHeight - 18) / 2);
  578.             }
  579.  
  580.             if (StartOpen)
  581.             {
  582.                 StartDraw();
  583.             }
  584.             if (FolderOpen)
  585.             {
  586.                 FolderDraw();
  587.             }
  588.             if (DrawingOpen)
  589.             {
  590.                 DrawingDraw();
  591.             }
  592.             if (Exit)
  593.             {
  594.                 ExitDraw();
  595.             }
  596.             Console.BackgroundColor = ConsoleColor.Black;
  597.         }
  598.  
  599.         private static void StartDraw()
  600.         {
  601.             Console.BackgroundColor = ConsoleColor.Black;
  602.             Box(26, 1, 2, Console.WindowHeight - 23);
  603.  
  604.             Console.ForegroundColor = ConsoleColor.White;
  605.             Console.SetCursorPosition(2, Console.WindowHeight - 28);
  606.             Console.Write("USER PC           DOORS OS");
  607.  
  608.             Console.BackgroundColor = ConsoleColor.White;
  609.             Box(26, Console.WindowHeight - 10, 2, Console.WindowHeight - 27);
  610.  
  611.             Console.BackgroundColor = ConsoleColor.Red;
  612.             Box(26, 3, 2, Console.WindowHeight - 7);
  613.  
  614.             Console.ForegroundColor = ConsoleColor.Black;
  615.             Console.SetCursorPosition(6, Console.WindowHeight - 6);
  616.             Console.Write("Завершение работы");
  617.  
  618.             Console.BackgroundColor = ConsoleColor.Yellow;
  619.             Box(26, 3, 2, Console.WindowHeight - 26);
  620.  
  621.             Console.ForegroundColor = ConsoleColor.Black;
  622.             Console.SetCursorPosition(6, Console.WindowHeight - 25);
  623.             Console.Write("Папка с файлами");
  624.  
  625.             Console.BackgroundColor = ConsoleColor.Cyan;
  626.             Box(26, 3, 2, Console.WindowHeight - 22);
  627.  
  628.             Console.ForegroundColor = ConsoleColor.Black;
  629.             Console.SetCursorPosition(6, Console.WindowHeight - 21);
  630.             Console.Write("Рисовалка");
  631.         }
  632.  
  633.         private static void ExitDraw()
  634.         {
  635.             Console.BackgroundColor = ConsoleColor.Black;
  636.             Box(32, 3, (Console.WindowWidth - 32) / 2, (Console.WindowHeight - 10) / 2);
  637.  
  638.             Console.ForegroundColor = ConsoleColor.White;
  639.             Console.SetCursorPosition((Console.WindowWidth - 20) / 2, (Console.WindowHeight - 8) / 2);
  640.             Console.Write("Выключить Doors OS?");
  641.  
  642.             Console.BackgroundColor = ConsoleColor.Cyan;
  643.             Box(32, 7, (Console.WindowWidth - 32) / 2, Console.WindowHeight - 17);
  644.  
  645.             Console.BackgroundColor = ConsoleColor.Red;
  646.             Box(10, 3, Console.WindowWidth - 74, Console.WindowHeight - 14);
  647.  
  648.             Console.ForegroundColor = ConsoleColor.Black;
  649.             Console.SetCursorPosition(Console.WindowWidth - 71, Console.WindowHeight - 13);
  650.             Console.Write("Нет");
  651.  
  652.             Console.BackgroundColor = ConsoleColor.Green;
  653.             Box(10, 3, Console.WindowWidth - 56, Console.WindowHeight - 14);
  654.  
  655.             Console.SetCursorPosition(Console.WindowWidth - 52, Console.WindowHeight - 13);
  656.             Console.Write("Да");
  657.         }
  658.  
  659.         private static void FolderDraw()
  660.         {
  661.             Console.BackgroundColor = ConsoleColor.Black;
  662.             Box(Console.WindowWidth - 8, 1, 4, Console.WindowHeight - 28);
  663.  
  664.             Console.ForegroundColor = ConsoleColor.White;
  665.             Console.SetCursorPosition(4, Console.WindowHeight - 28);
  666.             Console.Write("Папка с файлами");
  667.  
  668.             Console.BackgroundColor = ConsoleColor.Red;
  669.             Box(14, 1, Console.WindowWidth - 18, Console.WindowHeight - 28);
  670.  
  671.             Console.ForegroundColor = ConsoleColor.Black;
  672.             Console.SetCursorPosition(Console.WindowWidth - 16, Console.WindowHeight - 28);
  673.             Console.Write("Закрыть[X]");
  674.  
  675.             Console.BackgroundColor = ConsoleColor.White;
  676.             Box(Console.WindowWidth - 8, Console.WindowHeight - 8, 4, Console.WindowHeight - 27);
  677.  
  678.             Console.ForegroundColor = ConsoleColor.Black;
  679.             Console.SetCursorPosition(8, Console.WindowHeight - 26);
  680.             Console.Write("Файлов и функционала пока нет, но Вы там держитесь!");
  681.         }
  682.  
  683.         private static void DrawingDraw()
  684.         {
  685.             Console.BackgroundColor = ConsoleColor.Black;
  686.             Console.ForegroundColor = ConsoleColor.Gray;
  687.             Console.SetCursorPosition(4, 2);
  688.             Console.Write("Рисовалка".PadRight(98));
  689.  
  690.             Console.BackgroundColor = ConsoleColor.Red;
  691.             Console.ForegroundColor = ConsoleColor.Black;
  692.             Console.SetCursorPosition(102, 2);
  693.             Console.Write("  Закрыть[X]  ");
  694.  
  695.             Console.BackgroundColor = ConsoleColor.Gray;
  696.             Box(112, 22, 4, 3);
  697.  
  698.             Console.SetCursorPosition(5, 4);
  699.             Console.Write("Цвет:");
  700.  
  701.             Console.SetCursorPosition(5, 6);
  702.             Console.Write("╔══╗");
  703.  
  704.             for (int i = 1; i <= 16; i++)
  705.             {
  706.                 Console.SetCursorPosition(5, 6 + i);
  707.                 Console.Write("║  ║");
  708.             }
  709.  
  710.             Console.SetCursorPosition(5, 23);
  711.             Console.Write("╚══╝");
  712.  
  713.             Console.BackgroundColor = ConsoleColor.Black;
  714.             Console.ForegroundColor = ConsoleColor.White;
  715.  
  716.             Console.SetCursorPosition(12, 4);
  717.             Console.Write("  Очистить полотно  ");
  718.  
  719.             Console.SetCursorPosition(40, 4);
  720.             Console.Write("  Сохранить   ");
  721.  
  722.             Console.SetCursorPosition(66, 4);
  723.             Console.Write("  Загрузить   ");
  724.  
  725.             ChooseImage(5);
  726.             DrawImage(6, 7);
  727.  
  728.             ChooseImage(6);
  729.             DrawImage(12, 6);
  730.  
  731.             if (SaveOrLoadOpen)
  732.             {
  733.                 SaveOrLoadDrawingDraw();
  734.             }
  735.         }
  736.  
  737.         private static void SaveOrLoadDrawingDraw()
  738.         {
  739.             Console.BackgroundColor = ConsoleColor.DarkCyan;
  740.             Box(40, 9, 40, 5);
  741.             string chooseText;
  742.  
  743.             string chooseCell;
  744.             string SaveOrLoad;
  745.  
  746.             if (SaveDrawing)
  747.             {
  748.                 chooseText = "ячейки  ";
  749.                 chooseCell = "ячейка  ";
  750.                 SaveOrLoad = "  Сохранить   ";
  751.             }
  752.             else
  753.             {
  754.                 chooseText = "картинки  ";
  755.                 chooseCell = "картинка  ";
  756.                 SaveOrLoad = "  Загрузить   ";
  757.             }
  758.  
  759.             Console.ForegroundColor = ConsoleColor.White;
  760.             Console.SetCursorPosition(42, 6);
  761.             Console.Write("Выбор {0}", chooseText);
  762.  
  763.             Console.BackgroundColor = ConsoleColor.White;
  764.             Console.ForegroundColor = ConsoleColor.Black;
  765.  
  766.             for (int i = 1; i <= 3; i++)
  767.             {
  768.                 Console.SetCursorPosition(42, 6 + i * 2);
  769.                 Console.Write("{0} {1}", i, chooseCell);
  770.  
  771.                 Console.SetCursorPosition(64, 6 + i * 2);
  772.                 Console.Write(SaveOrLoad);
  773.             }
  774.             Console.SetCursorPosition(64, 6);
  775.             Console.Write("  Отмена  ");
  776.         }
  777.  
  778.         private static void UpdateDraw()
  779.         {
  780.             Console.CursorVisible = false;
  781.  
  782.             Console.BackgroundColor = ConsoleColor.Blue;
  783.             Box(Console.WindowWidth - 4, Console.WindowHeight - 2, 2, 1);
  784.  
  785.             Console.ForegroundColor = ConsoleColor.White;
  786.             string UpdateDoorsOS = "Обновление Doors OS";
  787.             string EverythingIsFine = "Все нормально. Это может занять некоторое время.";
  788.  
  789.             Console.SetCursorPosition((Console.WindowWidth - UpdateDoorsOS.Length) / 2, (Console.WindowHeight / 2) - 10);
  790.             Console.WriteLine(UpdateDoorsOS);
  791.  
  792.             Console.SetCursorPosition((Console.WindowWidth - EverythingIsFine.Length) / 2, (Console.WindowHeight / 2) - 8);
  793.             Console.WriteLine(EverythingIsFine);
  794.  
  795.             int ProgressPersents = 0;
  796.  
  797.             while (ProgressPersents < 100)
  798.             {
  799.                 Random r = new Random();
  800.                 int ProgressPlus = r.Next(0, 6);
  801.  
  802.                 if (ProgressPersents > 95)
  803.                 {
  804.                     ProgressPlus = 100 - ProgressPersents;
  805.                 }
  806.  
  807.                 ProgressPersents += ProgressPlus;
  808.  
  809.                 string Progress = "Выполнено: " + ProgressPersents + " % ";
  810.  
  811.                 Console.SetCursorPosition((Console.WindowWidth - Progress.Length) / 2, (Console.WindowHeight / 2) - 4);
  812.                 Console.WriteLine(Progress);
  813.  
  814.                 Thread.Sleep(400);
  815.                 Console.CursorVisible = true;
  816.             }
  817.         }
  818.  
  819.         private static void Update()
  820.         {
  821.             if ((timeStart + 2) <= TimeCheck() && ToUpDate)
  822.             {
  823.                 Kitty = true;
  824.                 ToUpDate = false;
  825.                 UpdateDraw();
  826.                 Main();
  827.             }
  828.         }
  829.  
  830.         private static void OperatingSystem()
  831.         {
  832.             UIDraw();
  833.             PingPong();
  834.             while (true)
  835.             {
  836.                 Time();
  837.                 MoveCursor();
  838.                 Update();
  839.             }
  840.         }
  841.  
  842.  
  843.         //--------------------------------------------------------------------------------------------------------------
  844.         //--------------------------------------------------------------------------------------------------------------
  845.         //--------------------------------------------------------------------------------------------------------------
  846.         //--------------------------------------------------------------------------------------------------------------
  847.         //--------------------------------------------------------------------------------------------------------------
  848.         //--------------------------------------------------------------------------------------------------------------
  849.  
  850.         private static void PingPongDraw()
  851.         {
  852.             Console.BackgroundColor = ConsoleColor.Black;
  853.             Console.ForegroundColor = ConsoleColor.Gray;
  854.             Console.SetCursorPosition(4, 2);
  855.             Console.Write("Пинг-Понг".PadRight(98));
  856.  
  857.             Console.BackgroundColor = ConsoleColor.Red;
  858.             Console.ForegroundColor = ConsoleColor.Black;
  859.             Console.SetCursorPosition(102, 2);
  860.             Console.Write("  Закрыть[X]  ");
  861.  
  862.             Console.BackgroundColor = ConsoleColor.White;
  863.             Box(112, 22, 4, 3);
  864.  
  865.             Console.BackgroundColor = ConsoleColor.Black;
  866.             Box(4, 2, 6, 4);
  867.             Box(4, 2, 6, 22);
  868.             Box(4, 2, 110, 4);
  869.             Box(4, 2, 110, 22);
  870.  
  871.             Console.BackgroundColor = ConsoleColor.Green;
  872.             Box(104, 18, 8, 5);
  873.         }
  874.  
  875.         private static void PingPong()
  876.         {
  877.             PingPongDraw();
  878.  
  879.             ballPosX = 0;
  880.             ballPosY = 0;
  881.             playerPos = 12;
  882.             botPos = 12;
  883.             playerSize = 6;
  884.             botSize = 6;
  885.             playerResult = 0;
  886.             botResult = 0;
  887.             ballDirectionUp = true;
  888.             ballDirectionRight = true;
  889.  
  890.             SetInitialPositions();
  891.  
  892.             while (true)
  893.             {
  894.                 PlayerMove();
  895.                 BotMove();
  896.                 MoveBall();
  897.                 Console.BackgroundColor = ConsoleColor.Green;
  898.                 Box(104, 18, 8, 5);
  899.                 Console.ResetColor();
  900.  
  901.                 DrawPlayer();
  902.  
  903.                 DrawBot();
  904.  
  905.                 DrawBall();
  906.  
  907.                 PrintResult();
  908.  
  909.                 Thread.Sleep(60);
  910.             }
  911.         }
  912.  
  913.         static void SetInitialPositions()
  914.         {
  915.             playerPos = Console.WindowHeight / 2 - playerSize / 2;
  916.             botPos = Console.WindowHeight / 2 - botSize / 2;
  917.             ResetBall();
  918.         }
  919.  
  920.         static void PlayerMove()
  921.         {
  922.             if (Console.KeyAvailable)
  923.             {
  924.                 ConsoleKeyInfo keyInfo = Console.ReadKey();
  925.  
  926.                 if (keyInfo.Key == ConsoleKey.UpArrow || keyInfo.Key == ConsoleKey.W)
  927.                 {
  928.                     MovePlayerUp();
  929.                 }
  930.  
  931.                 if (keyInfo.Key == ConsoleKey.DownArrow || keyInfo.Key == ConsoleKey.S)
  932.                 {
  933.                     MovePlayerDown();
  934.                 }
  935.             }
  936.         }
  937.  
  938.         static void MovePlayerUp()
  939.         {
  940.             if (playerPos > 6)
  941.             {
  942.                 playerPos--;
  943.             }
  944.         }
  945.  
  946.         static void MovePlayerDown()
  947.         {
  948.             if (playerPos < 24 - playerSize)
  949.             {
  950.                 playerPos++;
  951.             }
  952.         }
  953.  
  954.         static void BotMove()
  955.         {
  956.             int randomNumber = randomGenerator.Next(1, 100);
  957.  
  958.             if (randomNumber < 45)
  959.             {
  960.                 if (ballDirectionUp == true)
  961.                 {
  962.                     MoveBotUp();
  963.                 }
  964.                 else
  965.                 {
  966.                     MoveBotDown();
  967.                 }
  968.             }
  969.         }
  970.  
  971.         static void MoveBotDown()
  972.         {
  973.             if (playerPos < 23 - playerSize)
  974.             {
  975.                 playerPos++;
  976.             }
  977.         }
  978.  
  979.         static void MoveBotUp()
  980.         {
  981.             if (playerPos > 5)
  982.             {
  983.                 playerPos--;
  984.             }
  985.         }
  986.  
  987.         static void MoveBall()
  988.         {
  989.             if (ballPosY == 5)
  990.             {
  991.                 ballDirectionUp = false;
  992.             }
  993.  
  994.             if (ballPosY == 22)
  995.             {
  996.                 ballDirectionUp = true;
  997.             }
  998.  
  999.             if (ballPosX == 110)
  1000.             {
  1001.                 ResetBall();
  1002.                 ballDirectionUp = false;
  1003.                 ballDirectionRight = false;
  1004.                 playerResult++;
  1005.             }
  1006.  
  1007.             if (ballPosX == 8)
  1008.             {
  1009.                 ResetBall();
  1010.                 ballDirectionUp = true;
  1011.                 ballDirectionRight = true;
  1012.                 botResult++;
  1013.             }
  1014.  
  1015.             if (ballPosX < 3)
  1016.             {
  1017.                 if (ballPosY >= playerPos && ballPosY < playerPos + playerSize)
  1018.                 {
  1019.                     ballDirectionRight = true;
  1020.                 }
  1021.             }
  1022.  
  1023.             if (ballPosX >= 116)
  1024.             {
  1025.                 if (ballPosY >= botPos && ballPosY < botPos + playerSize)
  1026.                 {
  1027.                     ballDirectionRight = false;
  1028.                 }
  1029.             }
  1030.  
  1031.             if (ballDirectionUp)
  1032.             {
  1033.                 ballPosY--;
  1034.             }
  1035.             else
  1036.             {
  1037.                 ballPosY++;
  1038.             }
  1039.  
  1040.             if (ballDirectionRight)
  1041.             {
  1042.                 ballPosX++;
  1043.             }
  1044.             else
  1045.             {
  1046.                 ballPosX--;
  1047.             }
  1048.  
  1049.         }
  1050.         static void ResetBall()
  1051.         {
  1052.             ballPosX = 60;
  1053.             ballPosY = 15;
  1054.         }
  1055.  
  1056.         static void DrawPlayer()
  1057.         {
  1058.             for (int y = playerPos; y < playerPos + botSize; y++)
  1059.             {
  1060.                 PrintAtPosition(110, y, ' ');
  1061.                 PrintAtPosition(111, y, ' ');
  1062.             }
  1063.         }
  1064.  
  1065.         static void PrintAtPosition(int x, int y, char symbol)
  1066.         {
  1067.             Console.SetCursorPosition(x, y);
  1068.             Console.Write(symbol);
  1069.         }
  1070.  
  1071.         static void DrawBot()
  1072.         {
  1073.             for (int y = botPos; y < botPos + playerSize; y++)
  1074.             {
  1075.                 PrintAtPosition(8, y, ' ');
  1076.                 PrintAtPosition(9, y, ' ');
  1077.             }
  1078.         }
  1079.  
  1080.         static void DrawBall()
  1081.         {
  1082.             Console.BackgroundColor = ConsoleColor.Green;
  1083.             Console.ForegroundColor = ConsoleColor.Black;
  1084.             PrintAtPosition(ballPosX, ballPosY, 'O');
  1085.             Console.ResetColor();
  1086.         }
  1087.  
  1088.  
  1089.         static void PrintResult()
  1090.         {
  1091.             Console.BackgroundColor = ConsoleColor.White;
  1092.             Console.ForegroundColor = ConsoleColor.Black;
  1093.             Console.SetCursorPosition(59, 4);
  1094.             Console.WriteLine("{0} - {1}", playerResult, botResult);
  1095.             Console.ResetColor();
  1096.         }
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.     }
  1104. }
Advertisement
Add Comment
Please, Sign In to add comment