public ContainerButton(Button button, BoxedMonster boxedMonster) { Button = button; Move = null; Monster = null; Medicine = null; Capture = null; BoxedMonster = boxedMonster; }
public ContainerButton(Button button, Capture capture) { Button = button; Move = null; Monster = null; Medicine = null; Capture = capture; BoxedMonster = null; }
public ContainerButton(Button button, Medicine medicine) { Button = button; Move = null; Monster = null; Medicine = medicine; Capture = null; BoxedMonster = null; }
/// <summary> /// Add Capture item to inventory /// </summary> /// <param name="item"></param> /// <param name="amount"></param> public void Add(Capture item, int amount) { if (Captures.ContainsKey(item.Id)) { Captures[item.Id].Amount += amount; } else { item.Amount = amount; Captures.Add(item.Id, item); } }
public void Buy(MouseState cur, MouseState prev) { if (Drawer.DrawMedicine) { foreach (var m in shopMedicineButtons) { if (m.Button.IsClicked(cur, prev)) { SelectedMedicine = m.Medicine; } } } if (Drawer.DrawCapture) { foreach (var m in shopCaptureButtons) { if (m.Button.IsClicked(cur, prev)) { SelectedCapture = m.Capture; } } } }
public static List<Monster> GetMonsters(int playerId, ref List<Monster> box) { bool capture = false; int Uid = 0; int Id = 0; int statsId = 0; int level = 0; int experience = 0; string itemKind = ""; int itemId = 0; Ability ability = Ability.Ordinary(); string gen = ""; Gender gender = Gender.Male; bool boxed = false; var monsterList = new List<Monster>(); var linkCmd = connection.CreateCommand(); linkCmd.CommandText = "SELECT * FROM `monsterlink` WHERE `playerId` = @X"; linkCmd.Parameters.AddWithValue("@X", playerId); using (var rdr = linkCmd.ExecuteReader()) { while (rdr.Read()) { if (playerId == rdr.GetInt32("playerId")) { var monsterId = rdr.GetInt32("Uid"); monsterIdList.Add(monsterId); } } } foreach (var monsterId in monsterIdList) { var item = new Item(); linkCmd = connection.CreateCommand(); linkCmd.CommandText = "SELECT * FROM `monsterlink` WHERE Uid = @uid"; linkCmd.Parameters.AddWithValue("@uid", monsterId); using (var rdr = linkCmd.ExecuteReader()) { while (rdr.Read()) { Uid = rdr.GetInt32("Uid"); Id = rdr.GetInt32("monsterId"); statsId = rdr.GetInt32("statsId"); level = rdr.GetInt32("Level"); experience = rdr.GetInt32("Experience"); itemKind = rdr.GetString("ItemKind"); if (itemKind == "Capture") capture = true; itemId = rdr.GetInt32("ItemId"); ability = Ability.GetAbilityFromString(rdr.GetString("Ability")); gen = rdr.GetString("Gender"); gender = gen == "Male" ? Gender.Male : Gender.Female; boxed = rdr.GetBoolean("Boxed"); } } var itemCmd = connection.CreateCommand(); itemCmd.CommandText = capture ? $"SELECT * FROM `capture` WHERE `Id` = {itemId}" : $"SELECT * FROM `medicine` WHERE `id` = {itemId}"; using (var rdr = itemCmd.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { var cause = false; var cure = Medicine.Cure.None; var healAmount = 0; var captureChance = 0; var name = rdr.GetString("Name"); var description = rdr.GetString("Description"); if (capture) { captureChance = rdr.GetInt32("CaptureChance"); } else { healAmount = rdr.GetInt32("HealAmount"); cure = Medicine.GetCureFromString(rdr.GetString("Cures")); cause = rdr.GetBoolean("Cause"); } var worth = rdr.GetInt32("Worth"); var maxAmount = rdr.GetInt32("MaxAmount"); if (capture) item = new Capture(itemId, name, description, ContentLoader.GetTextureFromCapture(itemId), captureChance, true, worth, 1, maxAmount); else item = new Medicine(itemId, name, description, ContentLoader.GetTextureFromMedicine(itemId), healAmount, cure, worth, 1, maxAmount, cause); } } } var mon = GetMonster(Id, level); mon.UId = Uid; mon.Experience = experience; mon.Ability = ability; mon.HeldItem = item; mon.Gender = gender; mon.StatId = statsId; var statCmd = connection.CreateCommand(); statCmd.CommandText = $"SELECT * FROM `stats` WHERE `Id` = {statsId}"; using (var rdr = statCmd.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { mon.Stats.Health = rdr.GetInt32("Health"); mon.Stats.Attack = rdr.GetInt32("Attack"); mon.Stats.Defense = rdr.GetInt32("Defense"); mon.Stats.SpecialAttack = rdr.GetInt32("SpecialAttack"); mon.Stats.SpecialDefense = rdr.GetInt32("SpecialDefense"); mon.Stats.Speed = rdr.GetInt32("Speed"); mon.Stats.RandAttack = rdr.GetInt32("RandAttack"); mon.Stats.RandDefense = rdr.GetInt32("RandDefense"); mon.Stats.RandSpecialAttack = rdr.GetInt32("RandSpecialAttack"); mon.Stats.RandSpecialDefense = rdr.GetInt32("RandSpecialDefense"); mon.Stats.RandSpeed = rdr.GetInt32("RandSpeed"); } } } if (boxed) box.Add(mon); else { monsterList.Add(mon); } } return monsterList; }
public void Update(MouseState cur, MouseState prev) { if (buyButton.IsClicked(cur, prev)) { Buy(cur, prev); drawBuy = true; drawSell = false; } if (sellButton.IsClicked(cur, prev)) { Sell(cur, prev); drawSell = true; drawBuy = false; } if (drawSell) Sell(cur, prev); if (drawBuy) Buy(cur, prev); if (SelectedCapture != null && SelectedCapture.Amount > 0 || SelectedMedicine != null && SelectedMedicine.Amount > 0) { if (drawSell) { List<string> selllines = new List<string> { "Are you sure you want to sell this?" }; drawSellConfirm = true; sell = new Conversation.Message(selllines, Color.Black, ShopKeeper); Rectangle rec = new Rectangle(0, ContentLoader.GrassyBackground.Height + (ContentLoader.Button.Height * 2), ContentLoader.Button.Width, ContentLoader.Button.Height); yesButton = new Button(new Rectangle(rec.X += ContentLoader.Button.Width, rec.Y + (ContentLoader.Button.Height * 4), rec.Width, rec.Height), ContentLoader.Button, "Yes", ContentLoader.Arial); NoButton = new Button(new Rectangle(rec.X += ContentLoader.Button.Width, rec.Y + (ContentLoader.Button.Height * 4), rec.Width, rec.Height), ContentLoader.Button, "No", ContentLoader.Arial); } if (drawBuy) { List<string> buylines = new List<string>(); if (SelectedMedicine != null) { if (player.Money >= SelectedMedicine.Worth) { buylines = new List<string> { $"Are you sure you want to buy this? It costs {SelectedMedicine.Worth}" }; drawBuyConfirm = true; buy = new Conversation.Message(buylines, Color.Black, ShopKeeper); Rectangle rec = new Rectangle(0, ContentLoader.GrassyBackground.Height + (ContentLoader.Button.Height * 2), ContentLoader.Button.Width, ContentLoader.Button.Height); yesButton = new Button(new Rectangle(rec.X += ContentLoader.Button.Width, rec.Y + (ContentLoader.Button.Height * 4), rec.Width, rec.Height), ContentLoader.Button, "Yes", ContentLoader.Arial); NoButton = new Button(new Rectangle(rec.X += ContentLoader.Button.Width, rec.Y + (ContentLoader.Button.Height * 4), rec.Width, rec.Height), ContentLoader.Button, "No", ContentLoader.Arial); } else { buylines = new List<string> { "You don't have enough money" }; buy = new Conversation.Message(buylines, Color.Black, ShopKeeper); } } else if (SelectedCapture != null) { if (player.Money >= SelectedCapture.Worth) { buylines = new List<string> { $"Are you sure you want to buy this? It costs {SelectedCapture.Worth}" }; drawBuyConfirm = true; buy = new Conversation.Message(buylines, Color.Black, ShopKeeper); Rectangle rec = new Rectangle(0, ContentLoader.GrassyBackground.Height + (ContentLoader.Button.Height * 2), ContentLoader.Button.Width, ContentLoader.Button.Height); yesButton = new Button(new Rectangle(rec.X += ContentLoader.Button.Width, rec.Y + (ContentLoader.Button.Height * 4), rec.Width, rec.Height), ContentLoader.Button, "Yes", ContentLoader.Arial); NoButton = new Button(new Rectangle(rec.X += ContentLoader.Button.Width, rec.Y + (ContentLoader.Button.Height * 4), rec.Width, rec.Height), ContentLoader.Button, "No", ContentLoader.Arial); } else { buylines = new List<string> { "You don't have enough money" }; buy = new Conversation.Message(buylines, Color.Black, ShopKeeper); } } } } if (drawSellConfirm) { if (yesButton.IsClicked(cur, prev)) { if (SelectedMedicine != null) { SelectedMedicine.Amount -= 1; player.Money += SelectedMedicine.Worth / 2; drawSellConfirm = false; SelectedMedicine = null; } if (SelectedCapture != null) { SelectedCapture.Amount -= 1; player.Money += SelectedCapture.Worth / 2; drawSellConfirm = false; SelectedCapture = null; } } if (NoButton.IsClicked(cur, prev)) { SelectedMedicine = null; SelectedCapture = null; } } if (drawBuyConfirm) { if (yesButton.IsClicked(cur, prev)) { if (SelectedMedicine != null) { player.Inventory.Add(SelectedMedicine, 1); player.Money -= SelectedMedicine.Worth; drawBuyConfirm = false; SelectedMedicine = null; } if (SelectedCapture != null) { player.Inventory.Add(SelectedCapture, 1); player.Money -= SelectedCapture.Worth; drawBuyConfirm = false; SelectedCapture = null; } } if (NoButton.IsClicked(cur, prev)) { SelectedMedicine = null; SelectedCapture = null; drawBuyConfirm = false; } } Drawer.UpdateItemButtons(cur, prev); }