コード例 #1
0
 public GameLoop(GameProcess gameProcess = null)
 {
     GameProcess   = gameProcess ?? new GameProcess();
     GameActions   = new GameActions(GameProcess);
     UserInterface = new UserInterface();
     Step          = 120;
 }
コード例 #2
0
 public MapActions(GameProcess gameProcess)
 {
     onMove      += gameProcess.Move;
     onInteract  += gameProcess.Interact;
     onInventory += gameProcess.ChangeGameState;
     //onHome += gameProcess.HeroGoHome;
     onMenu += gameProcess.ChangeGameState;
     onHelp += gameProcess.ShowHelp;
 }
コード例 #3
0
        private void RenderChangeMap(GameProcess gameProcess)
        {
            Console.Clear();
            Console.WriteLine("Выберите локацию:");

            for (int i = 0; i < gameProcess.Level.Locations.Count; i++)
            {
                Console.WriteLine(i + 1 + ". " + gameProcess.Level.Locations[i].Name);
            }
            Console.WriteLine("\nЗакрыть(Q)");
        }
コード例 #4
0
 public GameActions(GameProcess gameProcess)
 {
     MapActions                 = new MapActions(gameProcess);
     InventoryActions           = new InventoryActions(gameProcess);
     CommunicationActions       = new CommunicationActions(gameProcess);
     CommunicationDialogActions = new CommunicationDialogActions(gameProcess);
     CommunicationBayActions    = new CommunicationBayActions(gameProcess);
     CommunicationSellActions   = new CommunicationSellActions(gameProcess);
     BoilerActions              = new BoilerActions(gameProcess);
     NotepadActions             = new NotepadActions(gameProcess);
     ChangeMapActions           = new ChangeMapActions(gameProcess);
     InformationPageAction      = new MainLevelRecipePageAction(gameProcess);
 }
コード例 #5
0
        public void RenderCommunication(GameProcess gameProcess)
        {
            var character = gameProcess.GetCharacterNextHero();

            Console.Clear();
            Console.WriteLine(character.Name + ":");
            Console.WriteLine();
            int i = 1;

            foreach (var characterCommunicationType in character.CommunicationTypes)
            {
                Console.WriteLine(i++ + ". " + characterCommunicationType.GetName());
            }
            Console.WriteLine("\nУйти(Q)");
        }
コード例 #6
0
        public void Render(GameProcess gameProcess)
        {
            switch (gameProcess.GameState)
            {
            case GameState.Map:
                RenderMap(gameProcess);
                break;

            case GameState.Inventory:
                RenderInventory(gameProcess.Hero.Inventory);
                break;

            case GameState.Communication:
                RenderCommunication(gameProcess);
                break;

            case GameState.CommunicationDialog:
                RenderCommunicationDialog(gameProcess.GetCharacterNextHero().Dialog);
                break;

            case GameState.CommunicationBay:
                RenderBay(gameProcess.GetCharacterNextHero().ShopThings, gameProcess.Hero.GetNumberOfTeaLeavs());
                break;

            case GameState.CommunicationSell:
                RenderSell(gameProcess.Hero.Inventory.Things, gameProcess.Hero.GetNumberOfTeaLeavs());
                break;

            case GameState.Boiler:
                RenderBoiler(gameProcess.Hero.Notepad.Recipes, gameProcess.Hero.Inventory.Ingredients);
                break;

            case GameState.Notepad:
                RenderNotepad(gameProcess.Hero.Notepad);
                break;

            case GameState.ChangeMap:
                RenderChangeMap(gameProcess);
                break;

            case GameState.InformationPage:
                RenderInformationPage(gameProcess.InformationPageText);
                break;
            }
            Console.SetCursorPosition(0, 54);
            Console.WriteLine(gameProcess.Message);
        }
コード例 #7
0
 public NotepadActions(GameProcess gameProcess)
 {
     onClose += gameProcess.ChangeGameState;
 }
コード例 #8
0
 public CommunicationBayActions(GameProcess gameProcess)
 {
     onChoice += gameProcess.BayThing;
     onClose  += gameProcess.ChangeGameState;
 }
コード例 #9
0
 public ChangeMapActions(GameProcess gameProcess)
 {
     onUse   += gameProcess.ChangeMap;
     onClose += gameProcess.ChangeGameState;
 }
コード例 #10
0
 public CommunicationActions(GameProcess gameProcess)
 {
     onChoice += gameProcess.ChoiceCommunicationType;
     onClose  += gameProcess.ChangeGameState;
 }
コード例 #11
0
 public BoilerActions(GameProcess gameProcess)
 {
     onBrewThing += gameProcess.BrewThing;
     onClose     += gameProcess.ChangeGameState;
 }
コード例 #12
0
 public InventoryActions(GameProcess gameProcess)
 {
     onUse   += gameProcess.UseThing;
     onClose += gameProcess.ChangeGameState;
 }
コード例 #13
0
 public MainLevelRecipePageAction(GameProcess gameProcess)
 {
     onClose += gameProcess.ChangeGameState;
 }
コード例 #14
0
 public CommunicationDialogActions(GameProcess gameProcess)
 {
     onChoice += gameProcess.ChoiceDialoglAnsver;
     onClose  += gameProcess.ChangeGameState;
 }
コード例 #15
0
        public void RenderMap(GameProcess gameProcess)
        {
            var thisLocation = gameProcess.Level.GetLocation();
            var thisMap      = thisLocation.Map.Select(t => t.Select(c => c).ToList()).ToList();

            foreach (var character in thisLocation.Characters)
            {
                thisMap[character.Y][character.X] = 99;
            }

            foreach (var activeObject in thisLocation.ActiveObjects)
            {
                switch (activeObject.Name)
                {
                case "Чайный куст":
                    thisMap[activeObject.Y][activeObject.X] = 21;
                    break;

                case "Лимонное дерево":
                    thisMap[activeObject.Y][activeObject.X] = 22;
                    break;

                case "Апельсиновое дерево":
                    thisMap[activeObject.Y][activeObject.X] = 23;
                    break;

                case "Куст клюквы":
                    thisMap[activeObject.Y][activeObject.X] = 24;
                    break;

                case "Дерево корицы":
                    thisMap[activeObject.Y][activeObject.X] = 25;
                    break;

                case "Куст имбиря":
                    thisMap[activeObject.Y][activeObject.X] = 26;
                    break;

                case "Улей":
                    thisMap[activeObject.Y][activeObject.X] = 27;
                    break;
                }
            }


            if (gameProcess.Level.ThisLocationNumber == 0)
            {
                var boiler = gameProcess.Level.Boiler;
                thisMap[boiler.Y][boiler.X] = 10;
                var table = gameProcess.Level.Table;
                thisMap[table.Y][table.X] = 11;
            }

            var hero = gameProcess.Hero;

            if (hero.Direction == DirectionType.Right)
            {
                thisMap[hero.Y][hero.X] = 100;
            }
            if (hero.Direction == DirectionType.Left)
            {
                thisMap[hero.Y][hero.X] = 101;
            }
            if (hero.Direction == DirectionType.Top)
            {
                thisMap[hero.Y][hero.X] = 102;
            }
            if (hero.Direction == DirectionType.Down)
            {
                thisMap[hero.Y][hero.X] = 103;
            }


            List <string> bufferString = new List <string>();

            for (var i = 0; i < thisMap.Count; i++)
            {
                char[] temp = new char[thisMap[0].Count];
                for (var j = 0; j < thisMap[0].Count; j++)
                {
                    switch (thisMap[i][j])
                    {
                    case (int)MapTypes.Grass:
                        temp[j] = '·';
                        break;

                    case (int)MapTypes.Floor:
                        temp[j] = ' ';
                        break;

                    case (int)MapTypes.Wall:
                        temp[j] = '░';
                        break;

                    case (int)MapTypes.Plant:
                        temp[j] = '+';
                        break;

                    case 10:
                        temp[j] = 'o';
                        break;

                    case 11:
                        temp[j] = '▄';
                        break;

                    case 21:
                        temp[j] = '*';
                        break;

                    case 22:
                        temp[j] = '▼';
                        break;

                    case 23:
                        temp[j] = '▼';
                        break;

                    case 24:
                        temp[j] = '*';
                        break;

                    case 25:
                        temp[j] = '▼';
                        break;

                    case 26:
                        temp[j] = '*';
                        break;

                    case 27:
                        temp[j] = '⌂';
                        break;

                    case 99:
                        temp[j] = '☺';
                        break;

                    case 100:
                        temp[j] = '→';
                        break;

                    case 101:
                        temp[j] = '←';
                        break;

                    case 102:
                        temp[j] = '↑';
                        break;

                    case 103:
                        temp[j] = '↓';
                        break;
                    }
                }
                bufferString.Add(new string(temp));
            }

            Console.Clear();
            Console.Write("Меню(M)       ");
            Console.Write("Помощь(H)       ");
            Console.Write("Инвентарь(I)       ");
            Console.Write("Блокнот(N)       ");
            Console.WriteLine("Взаимодействовать(Enter)       ");

            for (var i = 0; i < bufferString.Count; i++)
            {
                Console.WriteLine("  " + bufferString[i]);
            }
            Console.WriteLine("\n Локация: " + thisLocation.Name);
            Console.WriteLine(" Счастье: " + hero.Happiness);
            //Console.WriteLine(" " + IngredientType.TeaLeaves.GetName() + ": " + (hero.Inventory.Ingredients.Any(t => t.Item.Type == IngredientType.TeaLeaves) ? hero.Inventory.Ingredients.Find(t => t.Item.Type == IngredientType.TeaLeaves).Number : 0));
            Console.WriteLine(" Опыт: " + hero.Experience + " / " + (hero.ExperienceLevel != gameProcess.Level.ExperienceLevels.Count ? gameProcess.Level.ExperienceLevels[hero.ExperienceLevel].ToString() : "Максимальный уровень") + " (Доступно " + gameProcess.HeroNumberCanInventRecipe + " новых рецептов)");
        }