/** Updates the item listings icon, text etc */ private void Refresh() { item = CoM.Items.ByID(ItemID); nameLabel.Caption = item.ColorisedName + ((link.Quantity > 1) ? (" (x" + link.Quantity + ")") : ""); coinsAmount.Value = price; link.ItemInstance = MDRItemInstance.Create(item); Invalidate(); }
/** Updates list of items based on the current GameStats */ private void CreateListings() { foreach (ItemStatRecord record in CoM.GameStats.ItemStats.Values) { if (record.NumberFound == 0) { continue; } ItemList.Add(MDRItemInstance.Create(record.Item, record.IDLevel)); } SyncItemInfo(null, null); }
/** * Attempts to use or equip the item stored in this container. * Equipable items will be equiped. Usable items will be used */ protected void UseOrEquipItem() { if (DataLink.IsEmpty) { return; } MDRItemInstance itemInstance = DataLink.ItemInstance; //stub: slots should know the character they're associated with */ MDRCharacter character = CoM.Party.Selected; if (!itemInstance.IDLevel.CanUse) { CoM.PostMessage("{0} must be more identified before it can be used.", CoM.Format(itemInstance)); return; } if (itemInstance.Item.Usable) { // first can this item be activated? string reason = itemInstance.GetCanNotUseReason(character); if (reason == "") { if (itemInstance.RemainingCharges <= 0) { CoM.PostMessage("Item is out of charges."); } else { itemInstance.Use(character); } } else { CoM.PostMessage(reason); } } else { // otherwise try equiping it string reason = itemInstance.GetCanNotEquipReason(character); if (reason == "") { character.EquipItem(DataLink); } else { CoM.PostMessage(reason); } } }
/** * Registers a monster seen in a given area. Each time this is called a new monster is registered, so register * only the first time the player enters an area. */ /* * public void RegisterMonsterSeen(MDRCharacter character, MDRMonsterInstance monsterFound) * { * if (!Enabled) * return; * * if (monsterStackFound == null || monsterStackFound.Monster == null) * return; * * MDRMonster monster = monsterStackFound.Monster; * * if (!MonsterStats.ContainsKey(monster)) { * MonsterStats[monster] = new MonsterStatRecord(monster); * if (character != null) * PostNotification("Discovered " + monsterStackFound.Name, monster.Portrait); * } * * MonsterStatRecord record = MonsterStats[monster]; * * if (record.NumberSeen == 0) * record.FirstSeenBy = (character == null ? "Unknown" : character.Name); * * record.NumberSeen += monsterStackFound.Count; * if (area != null) * record.LastSeenLocation = area.Origion; * record.LastSeenDate = DateTime.Now; * * RegisterMonsterIdentified(monster, monsterStackFound.IDLevel); * } */ /** * Records initial stats into the library. * I.e. easy to find monsters and items. */ public void AddDefaultStats() { foreach (MDRMonster monster in CoM.Monsters) { if ((monster.EncounterChance >= 10) && (monster.AppearsOnLevel <= 1) && (monster.ToughnessRaiting < 40)) { //RegisterMonsterSeen(null, new MDRMonsterStack(monster), null); RegisterMonsterIdentified(monster, IdentificationLevel.Full); } } foreach (MDRItem item in CoM.Items) { if ((item.ChanceOfFinding >= 20) && (item.AppearsOnLevel < 1)) { RegisterItemFound(null, MDRItemInstance.Create(item, IdentificationLevel.Full), null); } } InitDefaultGameRecords(); }
/** * Registers an item droped from a given monster. */ public void RegisterItemFound(MDRCharacter character, MDRItemInstance itemInstance, MDRMonster monsterFoundOn) { if (!Enabled) { return; } if (itemInstance == null || itemInstance.Item == null) { return; } var item = itemInstance.Item; if (!ItemStats.ContainsKey(item)) { ItemStats[item] = new ItemStatRecord(item); } ItemStatRecord record = ItemStats[item]; if (record.NumberFound == 0) { record.FirstFoundBy = (character == null ? "unknown" : character.Name); if (character != null) { PostNotification("Discovered " + itemInstance.Name, item.Icon); } } record.NumberFound++; if (monsterFoundOn != null) { record.LastFoundOnMonster = monsterFoundOn.Name; } record.LastSeenDate = DateTime.Now; RegisterItemIdentified(item, itemInstance.IDLevel); }
/** Update selected item etc */ public override void Update() { base.Update(); buyButton.SelfEnabled = selectedItem != null && CoM.Party.Gold >= selectedItemPrice; notEnoughGold.Visible = CoM.Party.Gold < selectedItemPrice; // Switch to sell mode as soon as we start dragging AutoShowSell = (Engine.DragDrop.IsDragging); switch (Mode) { case StoreMode.Buy: SelectedItemInfo.ItemInstance = (StoreSelectedItemID == -1) ? null : MDRItemInstance.Create(CoM.Items.ByID(StoreSelectedItemID)); buyItemArea.CompositeColorTransform = ColorTransform.Identity; break; case StoreMode.Sell: SelectedItemInfo.ItemInstance = sellItemArea.InspectedItem; buyItemArea.CompositeColorTransform = ColorTransform.BlackAndWhite; break; } buyItemArea.SelfEnabled = (Mode == StoreMode.Buy); SelectedItemInfo.ShowAllInfo = (Mode == StoreMode.Buy); // Highlight when user is dragging an item to the sell area. itemInfoBackground.Color = Colors.StoreItemInfoBackgroundColor; if (Feedback == DDFeedback.Accept) { itemInfoBackground.Color = Color.Lerp(itemInfoBackground.Color, Color.white, 0.5f); } }
override protected void processKeys(bool ctrl, bool alt, bool shift) { base.processKeys(ctrl, alt, shift); if (Input.GetKeyUp(KeyCode.Print)) { TakeScreenshot(); } if (Input.GetKeyUp(KeyCode.F10)) { if (CurrentState is DungeonState || CurrentState is TownState) { PushState(new InGameMenuState()); } } if (Settings.Advanced.PowerMode) { if (Input.GetKey(KeyCode.RightShift)) { Time.timeScale = 0.1f; } else { Time.timeScale = 1.0f; } if (shift) { if (Input.GetKeyDown(KeyCode.F1)) { ApplyQualityLevel(0); } if (Input.GetKeyDown(KeyCode.F2)) { ApplyQualityLevel(1); } if (Input.GetKeyDown(KeyCode.F3)) { ApplyQualityLevel(2); } } else { if (Input.GetKeyUp(KeyCode.F1)) { Settings.Advanced.ShowLogs = !Settings.Advanced.ShowLogs; } if (Input.GetKeyUp(KeyCode.F2)) { Settings.Advanced.ShowGuiBounds = !Settings.Advanced.ShowGuiBounds; } if (Input.GetKeyUp(KeyCode.F3)) { Settings.Advanced.ShowGuiMaterial = !Settings.Advanced.ShowGuiMaterial; } if (Input.GetKeyUp(KeyCode.F4)) { Settings.Advanced.UseHighDPIGui = !Settings.Advanced.UseHighDPIGui; } if (Input.GetKeyUp(KeyCode.F5)) { HideGUI = !HideGUI; } if (Input.GetKeyUp(KeyCode.F6)) { DungeonObject.SetActive(!DungeonObject.activeSelf); } if (Input.GetKeyUp(KeyCode.F7)) { CoM.Party.Selected.GiveItem(MDRItemInstance.Create(CoM.Items[0])); } if (Input.GetKeyUp(KeyCode.F8)) { Settings.Advanced.GuiCaching = !Settings.Advanced.GuiCaching; } if (Input.GetKeyUp(KeyCode.F9)) { Settings.Advanced.ShowLogs = !Settings.Advanced.ShowLogs; } if (Input.GetKeyUp(KeyCode.F11)) { Settings.General.FXStyle = (Settings.General.FXStyle.Next()); } } } }
/** Formats item instance including coloring */ public static string Format(MDRItemInstance item) { return(Util.Colorise(item.Name, item.Item.QualityColor)); }
private void ProcessCheatKeys() { if (!Input.GetKey(KeyCode.LeftShift)) { return; } if (Input.GetKeyUp(KeyCode.L)) { Party.Selected.CurrentMembership.XP += Party.Selected.CurrentMembership.ReqXP; Party.Selected.GainLevel(); } if (Input.GetKeyUp(KeyCode.K)) { Party.Selected.ReceiveDamage(20); } if (Input.GetKeyUp(KeyCode.M)) { Party.ExploredMap.Clear(); if (CoM.Instance.DungeonState != null) { CoM.Instance.DungeonState.AutoMap.Repaint(); } } if (Input.GetKeyUp(KeyCode.O)) { PartyController.Instance.EnableDoorOpener = !PartyController.Instance.EnableDoorOpener; } //stub: remove or use for testing /* * if (Input.GetKeyUp(KeyCode.H)) { * var spell = CoM.Spells.ByName("Minor Heal"); * var result = spell.Cast(Party.Selected, Party.Selected); * CoM.PostMessage(result.Formatted); * } */ // give cursed item if (Input.GetKeyUp(KeyCode.C)) { Party.Selected.GiveItem(MDRItemInstance.Create(CoM.Items.ByName("Ball and Chain"))); } // uncurse all items if (Input.GetKeyUp(KeyCode.U)) { CoM.PostMessage("Uncursing all equiped items"); foreach (MDRItemSlot item in Party.Selected.Equiped) { if (!item.IsEmpty) { item.ItemInstance.Cursed = false; } } } if (Input.GetKeyUp(KeyCode.M)) { CoM.PostMessage("fish and chips " + Time.frameCount); } if (Input.GetKeyUp(KeyCode.N)) { Engine.PostNotification("Fish and chips is a long sentance that takes 3 lines:" + Time.frameCount, Party.Selected.Portrait); } }
/** Notice when our linked item changes. */ private void monitorDataLinkChanges(MDRItemSlot source, MDRItemInstance item) { _dirty = true; }