Exemplo n.º 1
0
        private bool OnNorth(long id, Player player)
        {
            bot.SendChatActionAsync(id, Telegram.Bot.Types.Enums.ChatAction.Typing);
            List <object> objects = missions.Location[player.Location].Position[player.Position].Items.ToList();

            foreach (var north in objects)
            {
                if (north.GetType() == typeof(MissionsLocationPositionNorth))
                {
                    MissionsLocationPositionNorth temp = (MissionsLocationPositionNorth)north;
                    player.Position = temp.Value;
                    context.SaveChanges();
                    YouAreIn(id, player);
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        public void YouAreIn(long id, Player player)
        {
            bot.SendChatActionAsync(id, Telegram.Bot.Types.Enums.ChatAction.Typing);
            bot.SendTextMessageAsync(id, missions.Location[player.Location].Position[player.Position].description);
            ReplyKeyboardMarkup keyboard = null;

            //KeyboardButton[] eastButton, northButton, southButton, westButton = null;
            //bot.SendTextMessageAsync(update.message.chat.id, "You are: " + update.message.from.id
            //    + "\nLocation: " + player.Location
            //    + "\nPosition: " + player.Position);
            //string str = null;
            //foreach (var items in missions.Location)
            //{
            //    str += "\nLocation.Id: " + items.id;
            //    foreach (var item in items.Position)
            //    {
            //        str += "\nPosition.Id: " + item.id + "\nEast: " + item.East + "\nEastSpecified: " + item.EastSpecified
            //        + "\nNorth: " + item.North + "\nNorthSpecified: " + item.NorthSpecified + "\nSouth: " + item.South
            //        + "\nSouthSpecified: " + item.SouthSpecified + "\nWest: " + item.West + "\nWestSpecified: " + item.WestSpecified;
            //    }
            //}
            //bot.SendTextMessageAsync(update.message.chat.id, str);

            //#region MyRegion
            //List<string> nameButtons = new List<string>();
            //string go = null;
            //if (missions.Location[player.Location].Position[player.Position].EastSpecified)
            //{
            //    go += "\nна Восток";
            //    nameButtons.Add("На восток");
            //    //eastButton = new KeyboardButton[] { new KeyboardButton("На восток") };
            //    //keyboard = new ReplyKeyboardMarkup(keyboardRow: eastButton, resizeKeyboard: true, oneTimeKeyboard: true);
            //}
            //if (missions.Location[player.Location].Position[player.Position].NorthSpecified)
            //{
            //    nameButtons.Add("На север");
            //    go += "\nна Север";
            //    //ReplyKeyboardMarkup newKeyboard = new ReplyKeyboardMarkup(new[] { new KeyboardButton("На север") }, true, true);

            //    //northButton = new KeyboardButton[] { new KeyboardButton("На север") };

            //    //keyboard = new ReplyKeyboardMarkup(keyboardRow: northButton, resizeKeyboard: true, oneTimeKeyboard: true);
            //    //newKeyboard = keyboard.Keyboard.Concat<KeyboardButton>(newKeyboard.Keyboard;
            //}
            //if (missions.Location[player.Location].Position[player.Position].SouthSpecified)
            //{
            //    nameButtons.Add("На юг");
            //    go += "\nна Юг";
            //    //southButton = new KeyboardButton[] { new KeyboardButton("На юг") };
            //    //keyboard = new ReplyKeyboardMarkup(keyboardRow: southButton, resizeKeyboard: true, oneTimeKeyboard: true);
            //}
            //if (missions.Location[player.Location].Position[player.Position].WestSpecified)
            //{
            //    nameButtons.Add("На запад");
            //    go += "\nна Запад";
            //    //westButton = new KeyboardButton[] { new KeyboardButton("На запад") };
            //    //keyboard = new ReplyKeyboardMarkup(keyboardRow: westButton, resizeKeyboard: true, oneTimeKeyboard: true);
            //}

            //if (nameButtons.Count == 1)
            //{
            //    keyboard = new ReplyKeyboardMarkup(new[] { new KeyboardButton(nameButtons[0]) }, resizeKeyboard: true, oneTimeKeyboard: true);
            //}
            //else if (nameButtons.Count == 2)
            //{
            //    keyboard = new ReplyKeyboardMarkup(new[] { new KeyboardButton(nameButtons[0]), new KeyboardButton(nameButtons[1]) }, resizeKeyboard: true, oneTimeKeyboard: true);
            //}
            //else if (nameButtons.Count == 3)
            //{
            //    keyboard = new ReplyKeyboardMarkup(new[] { new KeyboardButton(nameButtons[0]), new KeyboardButton(nameButtons[1]), new KeyboardButton(nameButtons[2]) }, resizeKeyboard: true, oneTimeKeyboard: true);
            //}
            //else if (nameButtons.Count == 4)
            //{
            //    keyboard = new ReplyKeyboardMarkup(new[] { new KeyboardButton(nameButtons[0]), new KeyboardButton(nameButtons[1]), new KeyboardButton(nameButtons[2]), new KeyboardButton(nameButtons[3]) }, resizeKeyboard: true, oneTimeKeyboard: true);
            //}
            //#endregion

            //keyboard = new ReplyKeyboardMarkup(keyboardRow: eastButton, keyboardRow: northButton, keyboardRow: southButton, keyboardRow: westButton, true, true);
            //bot.SendTextMessageAsync(update.message.chat.id, "Вы можете пойти:" + go);

            List <string> moveButton   = new List <string>();
            List <string> actionButton = new List <string>();
            string        move         = null;
            string        action       = null;

            List <object> obj = missions.Location[player.Location].Position[player.Position].Items.ToList();

            foreach (var item in obj)
            {
                if (item.GetType() == typeof(MissionsLocationPositionEast))
                {
                    MissionsLocationPositionEast temp = (MissionsLocationPositionEast)item;
                    moveButton.Add(temp.description);
                    move += "\n" + temp.description;
                }
                if (item.GetType() == typeof(MissionsLocationPositionNorth))
                {
                    MissionsLocationPositionNorth temp = (MissionsLocationPositionNorth)item;
                    moveButton.Add(temp.description);
                    move += "\n" + temp.description;
                }
                if (item.GetType() == typeof(MissionsLocationPositionSouth))
                {
                    MissionsLocationPositionSouth temp = (MissionsLocationPositionSouth)item;
                    moveButton.Add(temp.description);
                    move += "\n" + temp.description;
                }
                if (item.GetType() == typeof(MissionsLocationPositionWest))
                {
                    MissionsLocationPositionWest temp = (MissionsLocationPositionWest)item;
                    moveButton.Add(temp.description);
                    move += "\n" + temp.description;
                }
                if (item.GetType() == typeof(MissionsLocationPositionBlueKey))
                {
                    if (!FindBlueKeyAtPlayer(player))
                    {
                        MissionsLocationPositionBlueKey temp = (MissionsLocationPositionBlueKey)item;
                        actionButton.Add(temp.description);
                        action += "\n" + temp.description;
                    }
                }
                if (item.GetType() == typeof(MissionsLocationPositionDoor))
                {
                    MissionsLocationPositionDoor temp = (MissionsLocationPositionDoor)item;
                    actionButton.Add(temp.description);
                    action += "\n" + temp.description;
                }
                if (item.GetType() == typeof(MissionsLocationPositionFlashlight))
                {
                    if (!FindFlashlightAtPlayer(player))
                    {
                        MissionsLocationPositionFlashlight temp = (MissionsLocationPositionFlashlight)item;
                        actionButton.Add(temp.description);
                        action += "\n" + temp.description;
                    }
                }
            }

            if (moveButton.Count == 1 && actionButton.Count == 0)
            {
                keyboard = new ReplyKeyboardMarkup(
                    new[] {
                    new KeyboardButton(moveButton[0])
                }, true, true);
            }
            else if (moveButton.Count == 1 && actionButton.Count == 1)
            {
                keyboard = new ReplyKeyboardMarkup(
                    new[] {
                    new[]
                    {
                        new KeyboardButton(moveButton[0])
                    },
                    new []
                    {
                        new KeyboardButton(actionButton[0])
                    },
                }, true, true);
            }
            else if (moveButton.Count == 2 && actionButton.Count == 0)
            {
                keyboard = new ReplyKeyboardMarkup(
                    new[] {
                    new KeyboardButton(moveButton[0]),
                    new KeyboardButton(moveButton[1])
                }, true, true);
            }
            else if (moveButton.Count == 2 && actionButton.Count == 1)
            {
                keyboard = new ReplyKeyboardMarkup(
                    new[]
                {
                    new[]
                    {
                        new KeyboardButton(moveButton[0]),
                        new KeyboardButton(moveButton[1])
                    },
                    new[] {
                        new KeyboardButton(actionButton[0])
                    }
                }, true, true);
            }
            else if (moveButton.Count == 2 && actionButton.Count == 2)
            {
                keyboard = new ReplyKeyboardMarkup(
                    new[]
                {
                    new[]
                    {
                        new KeyboardButton(moveButton[0]),
                        new KeyboardButton(moveButton[1])
                    },
                    new[] {
                        new KeyboardButton(actionButton[0]),
                        new KeyboardButton(actionButton[1])
                    }
                }, true, true);
            }
            else if (moveButton.Count == 3 && actionButton.Count == 0)
            {
                keyboard = new ReplyKeyboardMarkup(
                    new[]
                {
                    new[]
                    {
                        new KeyboardButton(moveButton[0]),
                        new KeyboardButton(moveButton[1]),
                        new KeyboardButton(moveButton[2])
                    },
                }, true, true);
            }
            else if (moveButton.Count == 3 && actionButton.Count == 1)
            {
                keyboard = new ReplyKeyboardMarkup(
                    new[]
                {
                    new[]
                    {
                        new KeyboardButton(moveButton[0]),
                        new KeyboardButton(moveButton[1]),
                        new KeyboardButton(moveButton[2])
                    },
                    new[] {
                        new KeyboardButton(actionButton[0])
                    }
                }, true, true);
            }
            else if (moveButton.Count == 3 && actionButton.Count == 2)
            {
                keyboard = new ReplyKeyboardMarkup(
                    new[]
                {
                    new[]
                    {
                        new KeyboardButton(moveButton[0]),
                        new KeyboardButton(moveButton[1]),
                        new KeyboardButton(moveButton[2])
                    },
                    new[] {
                        new KeyboardButton(actionButton[0]),
                        new KeyboardButton(actionButton[1])
                    }
                }, true, true);
            }

            bot.SendTextMessageAsync(id, "Вы можете пойти:" + move + "\nВы можете сделать: " + action, replyMarkup: keyboard);
        }