///////////////////// ///// EQUIPMENT ///// ///////////////////// // TODO: Move this to an "Equipper" trait. /// <summary> /// /// </summary> /// <param name="slot"></param> /// <param name="item"></param> public void Equip(ItemSlots slot, Item item) { switch (slot) { case ItemSlots.Primary: { PrimaryItem = item; break; } case ItemSlots.Secondary: { SecondaryItem = item; break; } case ItemSlots.Tertiary: { TertiaryItem = item; break; } case ItemSlots.Quaternary: { QuaternaryItem = item; break; } default: { throw new ArgumentOutOfRangeException(nameof(slot), slot, "Invalid slot."); } } }
public static bool Contains(this EquipSlotCategory self, ItemSlots slot) { switch (slot) { case ItemSlots.MainHand: return(self.MainHand != 0); case ItemSlots.Head: return(self.Head != 0); case ItemSlots.Body: return(self.Body != 0); case ItemSlots.Hands: return(self.Gloves != 0); case ItemSlots.Waist: return(self.Waist != 0); case ItemSlots.Legs: return(self.Legs != 0); case ItemSlots.Feet: return(self.Feet != 0); case ItemSlots.OffHand: return(self.OffHand != 0); case ItemSlots.Ears: return(self.Ears != 0); case ItemSlots.Neck: return(self.Neck != 0); case ItemSlots.Wrists: return(self.Wrists != 0); case ItemSlots.RightRing: return(self.FingerR != 0); case ItemSlots.LeftRing: return(self.FingerL != 0); case ItemSlots.SoulCrystal: return(self.SoulCrystal != 0); } return(false); }
public EquipmentSelector(ItemSlots slot) { this.slot = slot; this.InitializeComponent(); this.DataContext = this; IGameDataService gameData = Services.Get <IGameDataService>(); this.Selector.Items.Add(EquipmentBaseViewModel.NoneItem); this.Selector.Items.Add(EquipmentBaseViewModel.NpcbodyItem); // Special case for hands to also list props if (slot == ItemSlots.MainHand || slot == ItemSlots.OffHand) { foreach (IItem prop in Module.Props) { this.Selector.Items.Add(prop); } } foreach (IItem item in gameData.Items.All) { this.Selector.Items.Add(item); } this.ClassFilter = Classes.All; }
public EquipmentSelector(ItemSlots slot) { this.slot = slot; this.InitializeComponent(); this.ContentArea.DataContext = this; this.Selector.AddItem(ItemUtility.NoneItem); this.Selector.AddItem(ItemUtility.NpcBodyItem); this.Selector.AddItem(ItemUtility.InvisibileBodyItem); this.Selector.AddItem(ItemUtility.InvisibileHeadItem); // Special case for hands to also list props if (GameDataService.Props != null) { this.Selector.AddItems(GameDataService.Props); } if (GameDataService.Items != null) { this.Selector.AddItems(GameDataService.Items); } if (GameDataService.Perform != null) { this.Selector.AddItems(GameDataService.Perform); } this.JobFilterText.Text = classFilter.Describe(); this.Selector.FilterItems(); }
public void swapItem(Item item, ItemSlots slot, Level level) { level.removeItem(item); level.addItem(Items[(int)slot]); Items[(int)slot].unEquipt(); equiptItem(item); }
public bool FitsInSlot(ItemSlots slot) { if (this.fitsInSlotsCache.ContainsKey(slot)) { return(this.fitsInSlotsCache[slot]); } try { foreach (EquipSlot equipSlot in this.Value.EquipSlotCategory.PossibleSlots) { if (equipSlot.IsSlot(slot)) { this.fitsInSlotsCache.Add(slot, true); return(true); } } } catch (Exception ex) { Log.Write(new Exception("Failed to check item slot compatibility for item: " + this.Name, ex), @"Saint Coinach", Log.Severity.Error); } this.fitsInSlotsCache.Add(slot, false); return(false); }
public static void SetItemSlots(Character character, ItemSlots slots) { GmSerializer serializer = new GmSerializer(); MemoryStream stream = new MemoryStream(); serializer.Serialize(stream, slots); character.itemSlotData = System.Convert.ToBase64String(stream.ToArray()); }
private void SetMaxSlots(int value) { if (value <= 0) { maxSlots = 1; } else { maxSlots = value; } if (maxSlots < ItemSlots.Count) { for (int i = maxSlots; i < ItemSlots.Count; i++) { Destroy(ItemSlots[i].transform.parent.gameObject); } int diff = ItemSlots.Count - maxSlots; ItemSlots.RemoveRange(maxSlots, diff); } else if (maxSlots > ItemSlots.Count) { int diff = maxSlots - ItemSlots.Count; for (int i = 0; i < diff; i++) { GameObject gameObject = Instantiate(itemSlotPrefab); gameObject.transform.SetParent(itemsParent, worldPositionStays: false); ItemSlots.Add(gameObject.GetComponentInChildren<ItemSlot>()); } } }
public EquipmentItemViewModel(IMemory <Equipment> equipmentMemory, ItemSlots slot, Selection selection) : base(slot, selection) { this.memory = equipmentMemory; Equipment.Item item = equipmentMemory.Value.GetItem(slot); if (item == null) { return; } this.modelBase = item.Base; this.modelVariant = item.Variant; this.dyeId = item.Dye; // hmm. doesn't seem to be any reason you _cant_ dye accessories... // TODO: test what happens when you dye an accessory. this.CanDye = slot != ItemSlots.Ears && slot != ItemSlots.Neck && slot != ItemSlots.Wrists && slot != ItemSlots.LeftRing && slot != ItemSlots.RightRing; this.CanColor = false; this.CanScale = false; this.HasModelSet = false; this.Item = this.GetItem(); this.Dye = this.GetDye(); }
public SlotsPanel(GameContext Context, ItemSlots Slots, int Count) { this.Size = new Size(10 * (SlotsWidth + SlotsGap), 300); this.Location = new Point(5, 5); ItemSlots = new ItemIcon[Count]; for (int i = 0; i < ItemSlots.Length; i++) { int row = (int)Math.Floor((double)(i / 10)); int off = i % 10; ItemSlots[i] = new ItemIcon(Context, Slots, i, i) { Size = new Size(SlotsWidth, SlotsWidth), Location = new Point(off * (SlotsWidth + SlotsGap), row * (SlotsWidth + SlotsGap)), BackColor = Color.FromArgb(90, 90, 90), SizeMode = PictureBoxSizeMode.CenterImage, Selected = false }; ItemSlots[i].Click += (s, e) => { OnItemSlotClick(s as ItemIcon, e as MouseEventArgs); }; this.Controls.Add(ItemSlots[i]); } }
public EquipmentWeaponViewModel(ItemSlots slot, IBaseMemoryOffset baseOffset) : base(slot, baseOffset) { this.memory = baseOffset.GetMemory(slot == ItemSlots.MainHand ? Offsets.Main.MainHand : Offsets.Main.OffHand); this.memory.Name = slot.ToString(); this.memory.ValueChanged += this.Memory_ValueChanged; this.modelSet = this.memory.Value.Set; this.modelBase = this.memory.Value.Base; this.modelVariant = this.memory.Value.Variant; this.dyeId = this.memory.Value.Dye; if (this.HasWeapon) { this.scaleMem = baseOffset.GetMemory(slot == ItemSlots.MainHand ? Offsets.Main.MainHandScale : Offsets.Main.OffhandScale); this.scaleMem.Name = slot + "_Scale"; this.scaleMem.ValueChanged += this.ScaleMem_ValueChanged; this.colorMem = baseOffset.GetMemory(slot == ItemSlots.MainHand ? Offsets.Main.MainHandColor : Offsets.Main.OffhandColor); this.colorMem.Name = slot + "_Color"; this.colorMem.ValueChanged += this.ColorMem_ValueChanged; this.scale = this.scaleMem.Value; this.color = this.colorMem.Value; } this.Item = this.GetItem(); this.Dye = this.GetDye(); }
public static Equipment.Item GetItem(this Equipment self, ItemSlots slot) { switch (slot) { case ItemSlots.Head: return(self.Head); case ItemSlots.Body: return(self.Chest); case ItemSlots.Hands: return(self.Arms); case ItemSlots.Legs: return(self.Legs); case ItemSlots.Feet: return(self.Feet); case ItemSlots.Ears: return(self.Ear); case ItemSlots.Neck: return(self.Neck); case ItemSlots.Wrists: return(self.Wrist); case ItemSlots.RightRing: return(self.RFinger); case ItemSlots.LeftRing: return(self.LFinger); } throw new Exception("Invalid slot " + slot); }
public EquipmentSelector(ItemSlots slot) { this.slot = slot; this.InitializeComponent(); this.DataContext = this; this.Selector.Items.Add(ItemUtility.NoneItem); this.Selector.Items.Add(ItemUtility.NpcbodyItem); // Special case for hands to also list props if (GameDataService.Props != null) { if (slot == ItemSlots.MainHand || slot == ItemSlots.OffHand) { foreach (IItem prop in GameDataService.Props) { this.Selector.Items.Add(prop); } } } if (GameDataService.Items != null) { foreach (IItem item in GameDataService.Items.All) { this.Selector.Items.Add(item); } } this.ClassFilter = Classes.All; }
public Item GetItem(ItemSlots slot) { switch (slot) { case ItemSlots.Head: return(this.Head); case ItemSlots.Body: return(this.Chest); case ItemSlots.Hands: return(this.Arms); case ItemSlots.Legs: return(this.Legs); case ItemSlots.Feet: return(this.Feet); case ItemSlots.Ears: return(this.Ear); case ItemSlots.Neck: return(this.Neck); case ItemSlots.Wrists: return(this.Wrist); case ItemSlots.RightRing: return(this.RFinger); case ItemSlots.LeftRing: return(this.LFinger); } return(null); }
private void Drag(ItemSlots itemSlot) { if (draggableItem.enabled) { draggableItem.transform.position = Input.mousePosition; } }
public static bool IsSlot(this EquipSlot self, ItemSlots slot) { switch (slot) { // TODO: ensuire this works in every laguage! case ItemSlots.MainHand: return(self.Name == "Main Hand"); case ItemSlots.Head: return(self.Name == "Head"); case ItemSlots.Body: return(self.Name == "Body"); case ItemSlots.Hands: return(self.Name == "Hands"); case ItemSlots.Waist: return(self.Name == "Waist"); case ItemSlots.Legs: return(self.Name == "Legs"); case ItemSlots.Feet: return(self.Name == "Feet"); case ItemSlots.OffHand: return(self.Name == "Off Hand"); case ItemSlots.Ears: return(self.Name == "Ears"); case ItemSlots.Neck: return(self.Name == "Neck"); case ItemSlots.Wrists: return(self.Name == "Wrists"); case ItemSlots.RightRing: return(self.Name == "Right Ring"); case ItemSlots.LeftRing: return(self.Name == "Left Ring"); } throw new Exception($"Unknown item slot: {slot}"); }
private void SetMaxSlots(int value) { base.Awake(); if (value <= 0) { maxSlots = 1; } else { maxSlots = value; } if (maxSlots < ItemSlots.Count) { for (int i = maxSlots; i < ItemSlots.Count; i++) { Destroy(ItemSlots[i]); } int diff = ItemSlots.Count - maxSlots; ItemSlots.RemoveRange(maxSlots, diff); } else if (maxSlots > ItemSlots.Count) { int diff = maxSlots - ItemSlots.Count; for (int i = 0; i < diff; i++) { ItemSlot slot = Instantiate(itemSlotPrefab).GetComponent <ItemSlot>(); slot.transform.SetParent(itemsParent, worldPositionStays: false); slot.transform.SetAsLastSibling(); LayoutRebuilder.ForceRebuildLayoutImmediate(itemsParent.GetComponent <RectTransform>()); ItemSlots.Add(slot); } } }
protected new void Start() { base.Start(); _stackableItemSlots = new ItemSlots <StackableItemHandler>(StackSize); _stackableItemSlots.Slots[0].Set(this); }
private static IItem ItemSearch(ItemSlots slot, ushort modelSet, ushort modelBase, ushort modelVariant) { foreach (IItem tItem in GameDataService.Items) { if (slot == ItemSlots.MainHand || slot == ItemSlots.OffHand) { if (!tItem.IsWeapon) { continue; } } else { if (!tItem.FitsInSlot(slot)) { continue; } } // Big old hack, but we prefer the emperors bracelets to the promise bracelets (even though they are the same model) if (slot == ItemSlots.Wrists && tItem.Name.StartsWith("Promise of")) { continue; } if (slot == ItemSlots.MainHand || slot == ItemSlots.OffHand) { if (tItem.ModelSet == modelSet && tItem.ModelBase == modelBase && tItem.ModelVariant == modelVariant) { return(tItem); } if (tItem.HasSubModel && tItem.SubModelSet == modelSet && tItem.SubModelBase == modelBase && tItem.SubModelVariant == modelVariant) { return(tItem); } } else { if (tItem.ModelBase == modelBase && tItem.ModelVariant == modelVariant) { return(tItem); } } } if (GameDataService.Props != null) { foreach (IItem tItem in GameDataService.Props) { if (tItem.ModelSet == modelSet && tItem.ModelBase == modelBase && tItem.ModelVariant == modelVariant) { return(tItem); } } } return(new DummyItem(modelSet, modelBase, modelVariant)); }
public EquipmentWeaponViewModel(ItemSlots slot, Actor actor) : base(slot, actor) { this.memory = actor.GetMemory(slot == ItemSlots.MainHand ? Offsets.Main.MainHand : Offsets.Main.OffHand); this.memory.ValueChanged += this.OnMemoryValueChanged; this.OnMemoryValueChanged(null, null); }
public EquipmentItemViewModel(IMemory <Equipment> equipmentMemory, ItemSlots slot, Actor actor) : base(slot, actor) { this.memory = equipmentMemory; this.memory.ValueChanged += this.OnMemoryValueChanged; this.OnMemoryValueChanged(null, null); }
public ItemIcon(GameContext Context, ItemSlots slots, int num, int id) { this.Context = Context; Slots = slots; Number = num; ID = id; Tip = new ToolTip(); }
private void ShowTooltip(ItemSlots itemSlot) { EquippableItem equippableItem = itemSlot.Item as EquippableItem; if (equippableItem != null) { itemTooltip.ShowTooltip(equippableItem); } }
private IItem GetItem(ItemSlots slot, uint baseVal, uint?equipVal) { if (equipVal != null) { return(LuminaExtensions.GetGearItem(slot, (uint)equipVal)); } return(LuminaExtensions.GetGearItem(slot, baseVal)); }
private void Equip(ItemSlots itemSlot) { EquippableItem equippableItem = itemSlot.Item as EquippableItem; if (equippableItem != null) { Equip(equippableItem, 0); } }
private IItem GetItem(ItemSlots slot, uint baseVal, uint?equipVal) { if (equipVal != null && equipVal != 0 && equipVal != uint.MaxValue && equipVal != long.MaxValue) { return(LuminaExtensions.GetGearItem(slot, (uint)equipVal)); } return(LuminaExtensions.GetGearItem(slot, baseVal)); }
public Inventory(Item[] itemsInBag) : this() { Bag = new List <Item>(); Slot1 = null; Slot2 = null; Armor = null; ActiveSlot = ItemSlots.Slot1; Bag.AddRange(itemsInBag); }
public static BitmapImage GetIcon(this ItemSlots self) { BitmapImage logo = new BitmapImage(); logo.BeginInit(); logo.UriSource = new Uri("pack://application:,,,/Anamnesis;component/Assets/Slots/" + self.ToString() + ".png"); logo.EndInit(); return(logo); }
public void Slots() { for (int i = 0; i < inventorySlots; i++) { Transform slot = Instantiate(slotPrefab); //slot.transform.SetParent(GameObject.FindObjectOfType<Inventory>().transform); slot.transform.SetParent(itemsParent, false); ItemSlots.Add(slot.gameObject.GetComponent <ItemSlot>()); } }
private void BeginDrag(ItemSlots itemSlot) { if (itemSlot.Item != null) { draggedSlot = itemSlot; draggableItem.enabled = true; draggableItem.sprite = itemSlot.Item.Icon; draggableItem.transform.position = Input.mousePosition; } }
void activeItemChanged(ItemSlots slot) { modes.Clear(); BaseChar selectedChar = GameMaster.instance.selectedChar; if (slot != selectedChar.Items.ActiveSlot) return; Item activeItem; if (selectedChar.Items.ActiveSlot == ItemSlots.Slot1) activeItem = selectedChar.Items.Slot1; else activeItem = selectedChar.Items.Slot2; if (activeItem == null || !(activeItem is Weapon)) return; List<string> knownSkills = new List<string>(); List<string> replacedSkills = new List<string>(); foreach (Skill skill in selectedChar.CharClass.SkillTree.Skills.Values) if (skill.Known) foreach (string gunName in skill.GunNames) if (gunName.Equals(activeItem.Name)) { knownSkills.Add(skill.Name); replacedSkills.AddRange(skill.Replaces); } foreach (string skillName in replacedSkills) if (knownSkills.Contains(skillName)) knownSkills.Remove(skillName); foreach (string skillName in knownSkills) { Skill skill = selectedChar.CharClass.SkillTree.Skills[skillName]; string mode = activeItem.Name; if ((skill.Mode == Mode.MultiHit || skill.Mode == Mode.MultiGunAndHit) && skill.Bonuses.ContainsKey(BonusType.nrOfHits)) { mode += " " + (int)skill.Bonuses[BonusType.nrOfHits] + "Hits"; } if (skill.Mode == Mode.MultiGun || skill.Mode == Mode.MultiGunAndHit) { mode += " 2Guns"; } if (mode.Equals(activeItem.Name)) continue; modes.Add(mode); } if (modes.Count > 0) modes.Insert(0, ""); activeMode = 0; }
public Inventory(Item[] itemsInBag): this() { Bag = new List<Item>(); Slot1 = null; Slot2 = null; Armor = null; ActiveSlot = ItemSlots.Slot1; Bag.AddRange(itemsInBag); }
public ItemModifier(string prefix, string suffix, int rank, Statistics statistics, ItemSlots[] slots, ItemArmorClasses[] armorClasses) { Prefix = prefix; Suffix = suffix; Rank = rank; Statistics = statistics; Slots = slots; ArmorClasses = armorClasses; }
public ItemDefinition Generate(int itemLevel, ItemSlots slot, ItemRarities rarity) { var armorClass = randomizer.Next<ItemArmorClasses>(); var item = new ItemDefinition(); item.Level = itemLevel; item.Rarity = rarity; item.Quality = ItemQualities.Superior; item.Slot = slot; item.ArmorClass = armorClass; var slotName = ItemSlotHelper.ItemSlotNames[(int)slot, (int)armorClass]; var slotModifier = ItemSlotHelper.ItemSlotModifier[(int)slot]; var itemLevelMultiplier = (float)(Math.Pow(2, (double)itemLevel / 10.0)) * 0.5f; var armorClassHealthMultiplier = (float)(armorClass == ItemArmorClasses.Plate ? 4 : 1); var armorClassArmorMultipler = (float)Math.Pow(2, (int)armorClass); //var baseStatistics = new Statistics(); //baseStatistics.Add(new Health(itemLevelMultiplier * armorClassHealthMultiplier * slotModifier * 25)); //baseStatistics.Add(new DamageReduction { ArmorRating = (int)(itemLevelMultiplier * armorClassArmorMultipler * slotModifier * 25)}); item.Statistics.Add(new StatDefinition(typeof(Health))); item.Statistics.Add(new StatDefinition(typeof(Armor))); if (rarity > ItemRarities.Common) { var prefix = string.Empty; var suffix = string.Empty; //var statistics = new Statistics(); for (int i = (int)rarity + 1; i > 0;) { var modifier = randomizer.From(ItemModifier.AllModifiers.Where(m => m.Rank <= i && m.Slots.Contains(slot) && m.ArmorClasses.Contains(armorClass)).ToArray()); if (string.IsNullOrEmpty(prefix)) prefix = modifier.Prefix; else if (string.IsNullOrEmpty(suffix)) suffix = modifier.Suffix; //statistics = statistics + modifier.Statistics * itemLevelMultiplier * slotModifier * 6.25f; foreach (var stat in modifier.Statistics) { var statType = stat.GetType(); if (!item.Statistics.Any(x => x.StatType == statType)) item.Statistics.Add(new StatDefinition(statType)); } i -= modifier.Rank; } //item.Statistics = baseStatistics + statistics; item.Name = string.Format("{0} {1} {2}", prefix, slotName, suffix); } else { var quality = randomizer.Next<ItemQualities>(); item.Name = quality.ToString() + " " + slotName; item.Quality = quality; } return item; }
public Item(ItemSlots slot, string name) { this.name = name; this.slot = slot; }