Beispiel #1
0
        public PlanetBuildings(string name, string description, int[] prices, int[] generate, int hp, int shield, int numOfTurns, Planet p = null)
        {
            //split to two because is too long
            string[] d = description.Split(' ');
            for (int i = 0; i < d.Length / 2; i++)
            {
                this.description += d[i] + " ";
            }
            if (this.description.Length > 24)
            {
                this.description = "";
                for (int i = 0; i < d.Length / 2 - 1; i++)
                {
                    this.description += d[i] + " ";
                }
                for (int i = d.Length / 2 - 1; i < d.Length; i++)
                {
                    this.description2 += d[i] + " ";
                }
            }
            else
            {
                for (int i = d.Length / 2; i < d.Length; i++)
                {
                    this.description2 += d[i] + " ";
                }
            }

            this.name       = name;
            this.prices     = prices;
            this.generate   = generate;
            this.hp         = hp;
            this.shield     = shield;
            this.numOfTurns = numOfTurns;
            this.number     = 1;
            this.p          = p;
        }
Beispiel #2
0
        public static void fleetPicker(int x, int y, Planet p)
        {
            Console.Clear();
            manager.Showmove = false;

            int numOfFleets = 0;

            fleet[] f = manager.Fleet;

            for (int i = 0; i < f.Length; i++)
            {
                if (f[i] != null)
                {
                    f[i].calcETA(x, y);
                    numOfFleets++;
                }
            }


            if (numOfFleets == 0)
            {
                Console.CursorVisible = true;
                setCur(Console.WindowWidth / 2, Console.WindowHeight / 2);
                Console.WriteLine("No Fleets...");
                Console.CursorVisible = false;
                return;
            }
            int selector = 1;

            while (true)
            {
                Console.Clear();

                //int i is used to go thrue all the fleets and counter is used to
                //count the usable fleets to find which one is the last one that is an actual fleet
                int counter = 1;

                //title
                setCur(Console.WindowWidth / 2 - 20, 6);
                Console.Write("┌────────┬───────────────────────────────────────┬───────┬───────┐");
                setCur(Console.WindowWidth / 2 - 20, 7);
                Console.Write("│  Name  │                  Ships                │ speed │  ETA  │");
                setCur(Console.WindowWidth / 2 - 20, 8);
                Console.Write("├────────┼───────────────────────────────────────┼───────┼───────┤");


                for (int i = 0; i < f.Length; i++)
                {
                    if (f[i] != null)
                    {
                        //calculating the space between each │ in the table
                        string sn1 = ""; //space name
                        string sn2 = ""; //space ships
                        for (int j = 0; j < 8 - f[i].Name.Length; j++)
                        {
                            sn1 += " ";
                        }
                        for (int j = 0; j < 39 - f[i].getInfoString().Length; j++)
                        {
                            sn2 += " ";
                        }

                        setCur(Console.WindowWidth / 2 - 20, 6 + (i + 1) * 2);
                        Console.Write("├────────┼───────────────────────────────────────┼───────┼───────┤");
                        setCur(Console.WindowWidth / 2 - 20, 7 + (i + 1) * 2);
                        Console.Write("│                                                                │");

                        if (selector == counter)
                        {
                            Console.BackgroundColor = ConsoleColor.Red;
                        }
                        setCur(Console.WindowWidth / 2 - 19, 7 + (i + 1) * 2);
                        Console.Write(f[i].Name + sn1);
                        Console.BackgroundColor = ConsoleColor.Black;

                        Console.Write("│" + f[i].getInfoString() + sn2 + "│" + "   " + f[i].getSpeed() + "   │" + f[i].calcETA(x, y) + " / R");

                        setCur(Console.WindowWidth / 2 - 20, 8 + (i + 1) * 2);

                        //not the last one
                        if (counter != numOfFleets)
                        {
                            Console.Write("├────────┼───────────────────────────────────────┼───────┼───────┤");
                        }
                        //the last one
                        else
                        {
                            Console.Write("└────────┴───────────────────────────────────────┴───────┴───────┘");
                        }

                        counter++;
                    }
                }

                //input
                ConsoleKey key = Console.ReadKey(true).Key;
                if (key == ConsoleKey.DownArrow || key == ConsoleKey.S)
                {
                    selector++;
                    if (selector == counter)
                    {
                        selector = 1;
                    }
                }
                if (key == ConsoleKey.UpArrow || key == ConsoleKey.W)
                {
                    selector--;
                    if (selector == 0)
                    {
                        selector = counter - 1;
                    }
                }
                if (key == ConsoleKey.Escape)
                {
                    break;
                }
                if (key == ConsoleKey.Enter)
                {
                    selector--;
                    //x and y to calc distance, true to lunch and p is the target planet
                    f[selector].calcETA(x, y, true, p);
                    break;
                }
            }

            Console.Clear();
            manager.Showmove = true;
        }