Пример #1
0
        public SecurityBehaviour(SecurityBuilding securityBuilding)
        {
            _type = securityBuilding;

            var pos = new Vector3(0, -10, 0);

            switch (_type)
            {
            case SecurityBuilding.SecurityCabin: _currentProject = GameController.InitObj(SecurityCabin.Data.Project, pos); break;

            case SecurityBuilding.PoliceStation: _currentProject = GameController.InitObj(PoliceStation.Data.Project, pos); break;

            case SecurityBuilding.PoliceHeadquarters: _currentProject = GameController.InitObj(PoliceHeadquarters.Data.Project, pos); break;
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            map[19, 19] = 1;
            int haveInput = 0;

            // choose difficulty level
            Console.WriteLine("Choose difficulty (Easy, Medium or Hard)");
            string d = Console.ReadLine().ToLower();                     // toLower just in case

            Console.Clear();                                             // Remove the Choose difficulty text
            Difficulty difficult = new Difficulty();

            switch (d)
            {
            case "easy": difficult = Difficulty.Easy; break;

            case "medium": difficult = Difficulty.Medium; break;

            case "hard": difficult = Difficulty.Hard; break;
            }

            if (difficult == Difficulty.Easy)
            {
                timer = 100 * 2;
            }
            else if (difficult == Difficulty.Medium)
            {
                timer = 70 * 2;
            }
            else if (difficult == Difficulty.Hard)
            {
                timer = 50;
            }
            drawMap(map, buildings, true);
            while (!lose)
            {
                Thread.Sleep(timer);
                if (Console.KeyAvailable)
                {
                    keyInfo = Console.ReadKey();

                    if (Convert.ToString(keyInfo.Key) == "Enter")
                    {
                        Console.Clear();
                        Console.WriteLine("What kind of building you want to build?");
                        Console.WriteLine("e) Electricity factory                  ");
                        Console.WriteLine("f) Food factory                         ");
                        Console.WriteLine("w) Water factory                        ");
                        Console.WriteLine("h) Hospital                             ");
                        Console.WriteLine("r) Residence                            ");
                        Console.WriteLine("s) Security                             ");
                        Console.WriteLine("Write only letter a, b, c, d, e or f    ");
                        string   letter   = Console.ReadLine();
                        Position position = new Position();

                        position.x = cursorX;
                        position.y = cursorY;

                        switch (letter)
                        {
                        case "e": buildings[countOfBuildings] = new ElectricityFactory('E', position, Color.Blue, ref electricity); break;

                        case "f": buildings[countOfBuildings] = new FoodFactory('F', position, Color.Gray, ref electricity, ref food); break;

                        case "w": buildings[countOfBuildings] = new WaterFactory('W', position, Color.Green, ref electricity, ref water); break;

                        case "h": buildings[countOfBuildings] = new HospitalBuilding('H', position, Color.Pink, 1, ref health, ref electricity); break;

                        case "r": buildings[countOfBuildings] = new ResidenceBuilding('R', position, Color.Yellow, 1, ref security, ref health, ref electricity, ref food, ref water, ref money); residenceBuildingsCount++; break;

                        case "s": buildings[countOfBuildings] = new SecurityBuilding('S', position, Color.Red, 1, ref security, ref electricity); break;
                        }
                        countOfBuildings++;
                        drawMap(map, buildings, true);
                    }
                    if (Convert.ToString(keyInfo.Key) == "LeftArrow")
                    {
                        cursorX--;
                    }
                    if (Convert.ToString(keyInfo.Key) == "RightArrow")
                    {
                        cursorX++;
                    }
                    if (Convert.ToString(keyInfo.Key) == "UpArrow")
                    {
                        cursorY--;
                    }
                    if (Convert.ToString(keyInfo.Key) == "DownArrow")
                    {
                        cursorY++;
                    }
                    if (cursorX < 0)
                    {
                        cursorX = 0;
                    }
                    if (cursorX >= Map_Size_X)
                    {
                        cursorX = Map_Size_X - 1;
                    }
                    if (cursorY < 0)
                    {
                        cursorY = 0;
                    }
                    if (cursorY >= Map_Size_Y)
                    {
                        cursorY = Map_Size_Y - 1;
                    }

                    Console.Clear();
                    keyInfo = new ConsoleKeyInfo();
                    EnemyMove(ref map, ref buildings, sizeOfEnemy);
                    sizeOfEnemy++;
                    drawMap(map, buildings, true);
                    Console.SetCursorPosition(0, 20);
                    Console.WriteLine("Electricity: {0} Food: {1} Water: {2} Happiness: {3} \nHealth: {4} Money: {5} Population: {6} Security: {7}",
                                      electricity.Amount, food.Amount, water.Amount, happiness.Amount, health.Amount, money.Amount, population.Amount, security.Amount);
                    Console.WriteLine("Use up, down, left and right arrow keys to choose your position to build!");
                    Console.WriteLine("Press enter to choose a building!");

                    Console.SetCursorPosition(cursorX, cursorY);
                    Console.WriteLine("X");
                    haveInput = 1;
                }
                else
                {
                    drawMap(map, buildings, false);
                    Console.SetCursorPosition(0, 20);
                    Console.WriteLine("Electricity: {0} Food: {1} Water: {2} Happiness: {3} \nHealth: {4} Money: {5} Population: {6} Security: {7}",
                                      electricity.Amount, food.Amount, water.Amount, happiness.Amount, health.Amount, money.Amount, population.Amount, security.Amount);
                    Console.WriteLine("Use up, down, left and right arrow keys to choose your position to build!");
                    Console.WriteLine("Press enter to choose a building!");
                    Console.SetCursorPosition(cursorX, cursorY);
                    Console.WriteLine("X");
                }
            }
        }