// Use this for initialization void Awake() { IWeaponAnimation weaponAnimation = new WeaponAnimationInfo(weaponAnimations.OnEquipTime, weaponAnimations.UnequipTime); List <ISlashInfo> slashes = new List <ISlashInfo>(); for (int i = 0; i < meleeAttacks.Slashes.Count; i++) { slashes.Add(meleeAttacks.Slashes[i]); } ISlashLogic slashLogic = new SlashLogic(meleeAttacks.TimeToWait, ref slashes); IRangedWeaponInfo weaponInfo = new RangedWeaponInfo ( rangedWeaponInfo.WeaponName, rangedWeaponInfo.Damage, rangedWeaponInfo.NumberOfAmmoInMagazine, rangedWeaponInfo.MaximumMagazineSize, rangedWeaponInfo.ReloadTime, rangedWeaponInfo.ShootDurationTime, rangedWeaponInfo.WeaponType, slashLogic, bulletSpawn, rangedWeaponInfo.DamagableLayer ); IWeaponPlace weaponPlace = new WeaponPlaces(ref idle, ref use); this.rangedWeapon = new RangedWeapon(ref weaponAnimation, ref weaponInfo, ref weaponPlace, this.transform); this.rangedWeapon.PlaceWeapon(true); this.weaponRenderer = GetComponent <LineRenderer>(); }
// If you have melee and ranged weapon public EquippedWeapon(IWeapon meleeWeapon, IWeapon rangedWeapon) { this.meleeWeapon = meleeWeapon; this.rangedWeapon = (rangedWeapon is IRangedWeapon) ? (IRangedWeapon)rangedWeapon : null; if (this.rangedWeapon == null) { throw new System.Exception("Not a ranged weapon added"); } }
void LoadItemInfo(GameObject itemObj, IItem itemInfo) { //TODO: This can maybe use the item tag system? ClearItemInfo(); if (itemInfo is IConsumable) { useButton.onClick.AddListener(delegate { UseItem(itemObj); }); ToggleButton(useButtonObj, true); } else if (itemInfo is IEquipment) { equipButton.onClick.AddListener(delegate { EquipItem(itemObj); }); ToggleButton(equipButtonObj, true); } else if (itemInfo is IWeapon) { equipButton.onClick.AddListener(delegate { EquipWeapon(itemObj, true); }); IRangedWeapon rangedWeapon = itemObj.GetComponent <IRangedWeapon>(); if (rangedWeapon.Modifiable()) { modifyButtonObj.GetComponent <Button>().onClick.AddListener(delegate { ToggleWeaponModifyCanvas(itemObj); }); ToggleButton(modifyButtonObj, true); } ToggleButton(equipButtonObj, true); } else if (itemInfo is IBag) { //GameObject obj = (GameObject)Resources.Load(item.ID); //IBag bag = obj.GetComponent<IBag>(); equipButton.onClick.AddListener(delegate { EquipBag(itemObj); }); ToggleButton(equipButtonObj, true); } itemDescription.text = itemInfo.FlavourText + "\n" + getTagList(itemInfo.Tags); itemImage.sprite = itemInfo.ItemImage; dropButton.onClick.AddListener(delegate { DropItem(itemObj); }); ToggleButton(dropButtonObj, true); }
public void RebuildTooltipDescription(UIMouseEvents sender) { UITooltip.Text = ""; UITooltip.DisableForceHide(); int senderIndex = System.Array.FindIndex(armorSlots, x => x.gameObject == sender.gameObject); if (senderIndex != -1 && armorTarget != null) { if (armorTarget.Armor[senderIndex] != null && armorTarget.Armor[senderIndex].ItemPrefab != null) { IItem item = armorTarget.Armor[senderIndex].ItemPrefab.GetComponent <IItem>(); if (item != null) { Armor a = armorTarget.Armor[senderIndex]; UITooltip.Text += "<size=12>"; UITooltip.Text += "<color=#" + item.Quality.ToColor().ToHexStringRGBA() + ">" + item.Name; UITooltip.Text += "</color>"; UITooltip.Text += "</size>\n"; UITooltip.Text += "<color=yellow><size=7><i>"; UITooltip.Text += item.Description; UITooltip.Text += "</i></size></color>\n\n"; UITooltip.Text += a.Type.ToString() + " armor\n"; UITooltip.Text += "Armor value : " + a.ArmorValue + "\n"; if (a.Stats != 0) { UITooltip.Text += "<color=green>"; if (a.Stats.Strength != 0) { UITooltip.Text += "Strength +" + a.Stats.Strength + "\n"; } if (a.Stats.Stamina != 0) { UITooltip.Text += "Stamina +" + a.Stats.Stamina + "\n"; } if (a.Stats.Defense != 0) { UITooltip.Text += "Defense +" + a.Stats.Defense + "\n"; } if (a.Stats.Energy != 0) { UITooltip.Text += "Energy +" + a.Stats.Energy + "\n"; } UITooltip.Text += "</color>"; } UITooltip.Text += "\n<color=green><i>Right click to Unequip</i></color>"; } } else { UITooltip.ForceHide(); } } else if (senderIndex == -1 && weapTarget != null) { IWeapon weapon = null; IRangedWeaponAmmo ammo = null; if (sender == mainHandSlot.GetComponent <UIMouseEvents>()) { weapon = weapTarget.MainHandWeapon; } else if (sender == offHandSlot.GetComponent <UIMouseEvents>()) { weapon = weapTarget.OffHandWeapon; } else if (sender == ammoSlot.GetComponent <UIMouseEvents>()) { ammo = weapTarget.CurrentAmmos; } if (weapon != null) { IItem item = weapon.InventoryItemPrefab != null?weapon.InventoryItemPrefab.GetComponent <IItem>() : null; if (item != null) { UITooltip.Text += "<size=12>"; UITooltip.Text += "<color=#" + item.Quality.ToColor().ToHexStringRGBA() + ">" + item.Name; UITooltip.Text += "</color>"; UITooltip.Text += "</size>\n"; UITooltip.Text += "<color=yellow><size=7><i>"; UITooltip.Text += item.Description; UITooltip.Text += "</i></size></color>\n\n"; if (weapon.WeaponRestrictions != WeaponRestriction.Both) { UITooltip.Text += "Only usable on " + (weapon.WeaponRestrictions == WeaponRestriction.MainHand ? "main hand." : "offhand.") + "\n"; } UITooltip.Text += (weapon.WeaponHand == WeaponHand.OneHanded ? "One Handed " : "Two Handed ") + weapon.WeaponType.ToString() + "\n"; if (weapon is IPhysicalWeapon) { IPhysicalWeapon physWeap = weapon as IPhysicalWeapon; UITooltip.Text += "Damages : " + physWeap.MinDamages + " - " + physWeap.MaxDamages + "\n"; UITooltip.Text += "Attack speed : " + physWeap.AttackSpeed + "\n"; } else if (weapon is IMagicalWeapon) { UITooltip.Text += weapon.GetInventoryDescription() + "\n"; } else if (weapon is IRangedWeapon) { IRangedWeapon rweap = weapon as IRangedWeapon; UITooltip.Text += "Base damages : " + rweap.BaseDamages + " X" + rweap.ProjectilePerShot + "\n"; UITooltip.Text += "Consumed ammo per shot : " + rweap.ConsumedAmmoPerShot + "\n"; UITooltip.Text += "Projectile deviation : " + rweap.ProjectileDeviation + "\n"; } if (weapon.GearStats != 0) { UITooltip.Text += "<color=green>"; if (weapon.GearStats.Strength != 0) { UITooltip.Text += "Strength +" + weapon.GearStats.Strength + "\n"; } if (weapon.GearStats.Stamina != 0) { UITooltip.Text += "Stamina +" + weapon.GearStats.Stamina + "\n"; } if (weapon.GearStats.Defense != 0) { UITooltip.Text += "Defense +" + weapon.GearStats.Defense + "\n"; } if (weapon.GearStats.Energy != 0) { UITooltip.Text += "Energy +" + weapon.GearStats.Energy + "\n"; } UITooltip.Text += "</color>"; } UITooltip.Text += "<color=green><i>Right click to Unequip</i></color>"; } } else if (ammo != null) { ItemAmmo item = ammo.ItemPrefab as ItemAmmo; UITooltip.Text += "<size=12>"; UITooltip.Text += "<color=#" + item.Quality.ToColor().ToHexStringRGBA() + ">" + item.Name; UITooltip.Text += "</color>"; UITooltip.Text += "</size>\n"; UITooltip.Text += "<color=yellow><size=7><i>"; UITooltip.Text += item.RealDescription; UITooltip.Text += "</i></size></color>\n\n"; UITooltip.Text += "Added damages : " + ammo.AddedDamages + "\n"; UITooltip.Text += "Ammo left : " + ammo.AmmoLeft + "\n"; UITooltip.Text += "\n<color=green><i>Right click to Unequip</i></color>"; } else { UITooltip.ForceHide(); } } }
public void Initialize(IRangedWeapon weapon) { this.weapon = weapon; direction = transform.forward; }
// Only ranged or melee weapon public EquippedWeapon(IWeapon weapon) { meleeWeapon = weapon; rangedWeapon = (weapon is IRangedWeapon) ? (IRangedWeapon)weapon : null; }
public EquippedWeapon() { this.rangedWeapon = null; this.meleeWeapon = null; }