public void Aim(bool aiming) { if (aiming) { if (inHand && inHand.GetType() == typeof(FireArm)) { FireArm fireArm = (FireArm)inHand; playerCamera.SetZoom(fireArm.zoomMultiplyer); } } else { playerCamera.SetZoom(0); } }
public void Unequip(Equipable equipment) { if (!equips.ContainsKey(equipment.slot)) { return; } equipment.GetType().GetMethod("OnUnequip").Invoke(equipment, null); equips.Remove(equipment.slot); if (EquipRemoved != null) { EquipRemoved(equipment); } }
public void Equip(Equipable equipment) { if (!equips.ContainsKey(equipment.slot)) { return; } object[] param = { gameObject }; equipment.GetType().GetMethod("OnEquip").Invoke(equipment, param); equips[equipment.slot] = equipment; if (EquipAdded != null) { EquipAdded(equipment); } }
/// <summary> /// Equip the given equipable. /// Return true if the item was correctly equiped. /// </summary> /// <param name="item"></param> /// <returns></returns> public override bool EquipObject(Equipable item, Inventory inventory) { if (inventory.GetItemCount(item) <= 0) { return(false); } Type itemType = item.GetType(); if (itemType.Equals(typeof(BodyArmor))) { if (inventory.SwitchItems(Body, item)) { Body = (BodyArmor)item; } } else if (itemType.Equals(typeof(TwoHandedWeapon))) { if (inventory.CanAddItem(leftHand) && inventory.SwitchItems(rightHand, item)) { inventory.AddItem(leftHand); RightHand = (TwoHandedWeapon)item; LeftHand = null; } } else if (itemType.Equals(typeof(OneHandedWeapon))) { if (rightHand == null || rightHand.GetType().Equals(typeof(TwoHandedWeapon))) { if (inventory.SwitchItems(rightHand, item)) { RightHand = (OneHandedWeapon)item; } } else { if (inventory.SwitchItems(leftHand, item)) { LeftHand = (OneHandedWeapon)item; } } } return(false); }