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;
- namespace Task7
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.SetWindowSize(120, 40);
- string command = "";
- string[] weapons = new string[0];
- int[] damages = new int[0];
- int[] rates = new int[0];
- string currentWepon = "";
- int currentIndex = 0;
- while (command != "/exit")
- {
- int line = 8;
- Console.WriteLine("Введите команду:");
- Console.WriteLine("\n/add - добавить новое оружие\n/equip - экипировать оружие" +
- "\n/remove - удалить оружие\n/exit - выход из арсенала");
- command = Console.ReadLine().ToLower();
- if (command == "/add")
- {
- string[] tempWeapons = new string[weapons.Length + 1];
- int[] tempDamages = new int[weapons.Length + 1];
- int[] tempRates = new int[weapons.Length + 1];
- for (int i = 0; i < weapons.Length; i++)
- {
- tempWeapons[i] = weapons[i];
- tempDamages[i] = damages[i];
- tempRates[i] = rates[i];
- }
- Console.WriteLine("Введите название оружия:");
- tempWeapons[tempWeapons.Length - 1] = Console.ReadLine();
- Console.WriteLine($"Какой урон будет наносить {tempWeapons[tempWeapons.Length - 1]}:");
- tempDamages[tempDamages.Length - 1] = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine($"Какая скорострельность у {tempWeapons[tempWeapons.Length - 1]}:");
- tempRates[tempRates.Length - 1] = Convert.ToInt32(Console.ReadLine());
- weapons = tempWeapons;
- damages = tempDamages;
- rates = tempRates;
- }
- else if (command == "/equip")
- {
- Console.WriteLine("Какое оружие экипировать:");
- currentWepon = Console.ReadLine().ToLower();
- for (int i = 0; i < weapons.Length; i++)
- {
- if (currentWepon == weapons[i])
- {
- currentIndex = i;
- }
- }
- }
- else if (command == "/remove" && weapons.Length > 0)
- {
- Console.WriteLine("Какое оружие удалить из инвентаря:");
- string removeWeapon = Console.ReadLine();
- string[] tempWeapons = new string[weapons.Length - 1];
- int[] tempDamages = new int[weapons.Length - 1];
- int[] tempRates = new int[weapons.Length - 1];
- int tempIndex = 0;
- for (int i = 0; i < weapons.Length - 1; i++)
- {
- if (weapons[i] != removeWeapon)
- {
- tempWeapons[i] = weapons[i];
- tempDamages[i] = damages[i];
- tempRates[i] = rates[i];
- if(i == weapons.Length - 2)
- {
- tempIndex = weapons.Length - 1;
- }
- }
- else
- {
- tempIndex = i;
- break;
- }
- }
- if (weapons[weapons.Length - 1] != removeWeapon)
- {
- for (int j = tempIndex; j < weapons.Length - 1; j++)
- {
- tempWeapons[j] = weapons[j + 1];
- tempDamages[j] = damages[j + 1];
- tempRates[j] = rates[j + 1];
- }
- }
- if (weapons.Length > 0 && currentIndex != 0 && tempIndex <= currentIndex)
- currentIndex--;
- weapons = tempWeapons;
- damages = tempDamages;
- rates = tempRates;
- }
- Console.Clear();
- Console.ForegroundColor = ConsoleColor.Red;
- Console.SetCursorPosition(55, 0);
- Console.WriteLine("PARATROOPER - ARSENAL");
- if(weapons.Length > 0)
- {
- Console.SetCursorPosition(50, 2);
- Console.WriteLine("Экипировано: " + weapons[currentIndex]);
- Console.SetCursorPosition(50, 3);
- Console.WriteLine("Урон - " + damages[currentIndex]);
- Console.SetCursorPosition(50, 4);
- Console.WriteLine("Скорострельность - " + rates[currentIndex] + " выстрелов в минуту");
- }
- Console.SetCursorPosition(50, 7);
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.WriteLine("Инвентарь:");
- for (int i = 0; i < weapons.Length; i++)
- {
- Console.SetCursorPosition(50, ++line);
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine($"| {weapons[i]} | damage-{damages[i]} | rate-{rates[i]} |");
- Console.ForegroundColor = ConsoleColor.Gray;
- }
- Console.SetCursorPosition(0, 0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement