private void PickUpKey(long id, Player player) { BlueKey bk = new BlueKey(); Keys k = new Keys(); k.BlueKey = bk; Items i = new Items(); i.Keys.Add(k); player.Items.Add(i); context.SaveChanges(); bot.SendTextMessageAsync(id, "Ключ был успешно поднят"); }
private void OpenDoor(long id, Player player) { bool nothing = true; bot.SendChatActionAsync(id, Telegram.Bot.Types.Enums.ChatAction.Typing); List <object> objects = missions.Location[player.Location].Position[player.Position].Items.ToList(); foreach (var openDoor in objects) { if (openDoor.GetType() == typeof(MissionsLocationPositionDoor)) { MissionsLocationPositionDoor tempDoor = (MissionsLocationPositionDoor)openDoor; //Item tempItem = (Item)item; //Item temp = new Item(); //if (true) //{ // bot.SendTextMessageAsync(update.message.chat.id, "1234"); //} //bot.SendTextMessageAsync(update.message.chat.id, ",fkdfaskj;"); if (player.Items.Count != 0) { if (FindBlueKeyAtPlayer(player)) { foreach (var items in player.Items) { if (items.Keys.Count != 0) { foreach (var keys in items.Keys) { if (keys.BlueKey != null) { //keys.BlueKey = null; BlueKey bk = new BlueKey(); Keys k = new Keys() { BlueKey = bk }; if (items.Keys.Remove(k)) { context.SaveChanges(); } } } } } bot.SendTextMessageAsync(id, "Найден нужный ключ у игрока"); } else { bot.SendTextMessageAsync(id, "Нужный предмет у игрока не был найден"); } } //string str = "Необходимо: " + tempDoor.need; //bot.SendTextMessageAsync(id, str); nothing = false; } } if (nothing) { bot.SendTextMessageAsync(id, "Тут нет двери"); } }