public void SwapItemPanels(GameObject from, GameObject to) { ItemPanel panel = from.GetComponent <ItemPanel>(); ItemPanel otherPanel = to.GetComponent <ItemPanel>(); if (panel && otherPanel) { Equippable[] items = new Equippable[2]; items[0] = panel.obj; items[1] = otherPanel.obj; panel.Display(items[1]); otherPanel.Display(items[0]); Debug.Log("Display swap"); return; } EquippedItemPanel equipPanel = from.GetComponent <EquippedItemPanel>(); if (!equipPanel) { equipPanel = to.GetComponent <EquippedItemPanel>(); otherPanel = from.GetComponent <ItemPanel>(); } if (equipPanel.equipSlots == otherPanel.obj.defaultSlots || equipPanel.equipSlots == otherPanel.obj.secondarySlots) { Equippable[] items = new Equippable[2]; items[0] = equipPanel.obj; items[1] = otherPanel.obj; equipPanel.Display(items[1]); otherPanel.Display(items[0]); Debug.Log("Display swap"); return; } }
protected IEnumerator FindAndLoadProjectile(Equippable equippable, Weapon weapon, bool playLoadAnimation) { //get the projectile - if we don't find one, we don't need to do anything else if (!player.Inventory.FindProjectileForWeapon(weapon, out ProjectileObject, out ProjectileStack)) { //this will shut off the doppleganger //RefreshToolDoppleganger (false); yield break; } //otherwise move on //if playLoadAnimation is true, play the unequip/equip animations to simulate reaching down for the projectile if (playLoadAnimation) { yield return(StartCoroutine(PlayAnimation("ToolGenericUnequip"))); } //refresh the doppleganger here to add it to the weapon //break it down first RefreshToolDoppleganger(false); //then rebuild it RefreshToolDoppleganger(true); //if we're playing the animation, we have to play the 'equip' animation here to bring the weapon back up if (playLoadAnimation) { yield return(StartCoroutine(PlayAnimation("ToolGenericEquip"))); } ToolState = PlayerToolState.Equipped; yield break; }
public void Equip(Equippable pItem) { //Try removing the item from inventory if (_inventory.RemoveItem(pItem)) { //Add it to the equipment panel Equippable previousItem; if (_equipmentPanel.AddItem(pItem, out previousItem)) { //If the slot was already taken, return the other item in the inventory if (previousItem != null) { previousItem.Unequip(this); _statsPanel.UpdateStatValues(); _inventory.AddItem(previousItem); } pItem.Equip(this); _statsPanel.UpdateStatValues(); } else { //If for some reason the item couldn't be equipped return it back in the inventory _inventory.AddItem(pItem); } } }
public void DropEquippedItem() { Debug.Log("drop item: " + currentlyEquippedItem.id); if (currentlyEquippedItem.id != equippableItemID.HORSE_ON_LEAD && currentlyEquippedItem.id != equippableItemID.HORSE_MOUNTED) { currentlyEquippedItem.transform.position = new Vector3(dropItemPos.position.x, dropItemPos.position.y + currentlyEquippedItem.dropPosYOffset, dropItemPos.position.z); } currentlyEquippedItem.transform.SetParent(null); currentlyEquippedItem.BeDropped(); if (currentlyEquippedItem.id == equippableItemID.HORSE_ON_LEAD) { Horse_Interactable horseInt = currentlyEquippedItem.GetComponent <Horse_Interactable> (); if (horseInt.headGear.type == horseGearType.HALTER) { horseInt.LeadIsDropped(this); } else if (horseInt.headGear.type == horseGearType.BRIDLE) { horseInt.StopLeadingHorseByReins(this); } } else if (currentlyEquippedItem.id == equippableItemID.HORSE_MOUNTED) { Horse_Interactable horseInt = currentlyEquippedItem.GetComponent <Horse_Interactable> (); horseInt.Dismount(this); currentMovementSet = playerMovementSet.WALKING; } maximumTurnRate = defaultMaximumTurnRate; Debug.Log("calling removeitem from Drop"); inventory.RemoveActiveItemFromInventory(currentlyEquippedItem); currentlyEquippedItem = playerHands; }
private void TakeAllContent(Player player) { hookStatus = containerStatus.EMPTY; player.EquipAnItem(content); content.BeEquipped(); content = null; }
public bool RemoveItem(Equippable pItem) { //Loop through the array until the item is found and remove it from that equipment slot for (int i = 0; i < _equipmentSlots.Length; i++) { if (_equipmentSlots[i].Item == pItem) { _equipmentSlots[i].Amount = 0; if (_equipmentSlots[i].Amount == 0) { if (pItem.ItemType == EquipmentType.Gloves) { _equipmentSlots[i + 1].Amount = 0; _equipmentSlots[i + 1].Item = null; } else if (pItem.ItemType == EquipmentType.Gloves1) { _equipmentSlots[i - 1].Amount = 0; _equipmentSlots[i - 1].Item = null; } _equipmentSlots[i].Item = null; } return(true); } } return(false); }
public void Initialize() { string startupState = DefaultState; if (worlditem.HasSaveState && !string.IsNullOrEmpty(worlditem.SaveState.LastState)) { //Debug.Log("Setting startup state to " + worlditem.SaveState.LastState + " in states"); startupState = worlditem.SaveState.LastState; } else { //Debug.Log("Didn't have save state or startup state was empty in states"); } for (int i = 0; i < States.Count; i++) { if (States [i].CanUseToSelect) { worlditem.OnPlayerUse += OnPlayerUse; } } SetState(startupState); worlditem.OnModeChange += OnModeChange; worlditem.OnAddedToGroup += OnAddedToGroup; Equippable e = null; if (worlditem.Is <Equippable> (out e)) { e.OnEquip += OnEquip; } }
public void RegisterEquipment(IEquipmentConfig config) { EquipmentDef equipmentDef = config.CreateEquipmentDef(); string id = equipmentDef.Id; string name = equipmentDef.Name; string recipeDescription = equipmentDef.RecipeDescription; float mass = equipmentDef.Mass; bool unitMass = true; KAnimFile anim = equipmentDef.Anim; string initialAnim = "object"; Grid.SceneLayer sceneLayer = Grid.SceneLayer.Ore; EntityTemplates.CollisionShape collisionShape = equipmentDef.CollisionShape; float width = equipmentDef.width; float height = equipmentDef.height; bool isPickupable = true; SimHashes outputElement = equipmentDef.OutputElement; GameObject gameObject = EntityTemplates.CreateLooseEntity(id, name, recipeDescription, mass, unitMass, anim, initialAnim, sceneLayer, collisionShape, width, height, isPickupable, 0, outputElement, null); Equippable equippable = gameObject.AddComponent <Equippable>(); equippable.def = equipmentDef; Debug.Assert((Object)equippable.def != (Object)null); equippable.slotID = equipmentDef.Slot; Debug.Assert(equippable.slot != null); config.DoPostConfigure(gameObject); Assets.AddPrefab(gameObject.GetComponent <KPrefabID>()); }
public void UnequipItem(Equippable item) { if (!Equipped.ContainsKey(item.EquipSlot)) { Equipped[item.EquipSlot] = null; } }
/// <summary> /// Equips the new item, returning the old one so it can be returned to the inventory. /// </summary> public Equippable EquipItem(Equippable newEquippable, int slot) { Equippable item = equipment[slot]; equipment[slot] = newEquippable; return(item); }
private void TakeHayBale(Player player) { if (player.currentlyEquippedItem.id == equippableItemID.BAREHANDS) { GameObject newBale; if (fillType == equippableItemID.STRAW) { newBale = Instantiate(PrefabManager.instance.strawBale, player.equippedItemPos.position, player.equippedItemPos.rotation) as GameObject; } else // if (fillType == equippableItemID.HAY) { is implied but this way newbale is definitely defined { newBale = Instantiate(PrefabManager.instance.hayBale, player.equippedItemPos.position, player.equippedItemPos.rotation) as GameObject; } --currentUnits; Equippable equippable = newBale.GetComponent <Equippable> (); equippable.Initialize(); player.EquipAnItem(equippable); if (currentUnits == 0) { hayPileRenderer.enabled = false; } } }
public Equippable SpawnEquippable() { var ent = new Equippable(Game); AddEntity(ent); return(ent); }
protected override int GetDamageRoll() { int damage = 0; Equipment eq = GetComponentInParent <Equipment>(); Equippable item = eq.GetItem(EquipSlots.Primary); //use STR mod for unarmed hits if (item == null) { return(GetBaseDamageModifier()); } //add weapon base damage roll WeaponBase weapon = item.gameObject.GetComponent <WeaponBase>(); for (int i = 0; i < weapon.rolls; i++) { damage += Random.Range(1, weapon.d); } //add damage from additional item effects StatModifierFeature[] features = item.GetComponentsInChildren <StatModifierFeature>(); for (int i = 0; i < features.Length; ++i) { if (features[i].type == StatTypes.STR) { damage += features[i].amount; } } return(damage); }
public bool AddItem(Equippable pItem, out Equippable pPrevioursItem) { for (int i = 0; i < _equipmentSlots.Length; i++) { //Use the out parameter to check if there is an item in that equipment slot if (_equipmentSlots[i].EquipmentType == pItem.ItemType) { pPrevioursItem = (Equippable)_equipmentSlots[i].Item; if (pItem.ItemType == EquipmentType.Gloves) { _equipmentSlots[i + 1].Item = pItem; } else if (pItem.ItemType == EquipmentType.Gloves1) { _equipmentSlots[i - 1].Item = pItem; } _equipmentSlots[i].Item = pItem; _equipmentSlots[i].Amount = 1; return(true); } } pPrevioursItem = null; return(false); }
protected int PowerFromEquippedWeapon() { int power = 0; Equipment eq = GetComponentInParent <Equipment>(); Equippable item = eq.GetItem(EquipSlots.Primary); if (item == null || !item.GetComponentInChildren <WeaponAbilityPower>().GetType().Equals(GetType())) { item = eq.GetItem(EquipSlots.Secondary); } if (item == null || !item.GetComponentInChildren <WeaponAbilityPower>().GetType().Equals(GetType())) { return(power); } if (item != null && item.GetComponentInChildren <WeaponAbilityPower>().GetType().Equals(GetType())) { StatModifierFeature[] features = item.GetComponentsInChildren <StatModifierFeature>(); for (int i = 0; i < features.Length; ++i) { if (features[i].type == StatTypes.MEL) { power += features[i].amount; } } } return(power); }
public override void PlayerInteracts(Player player) { base.PlayerInteracts(player); if (currentlyRelevantActionIDs.Count > selectedInteractionIndex) { switch (currentlyRelevantActionIDs [selectedInteractionIndex]) { case actionID.TALK_TO: UI.instance.ShowDialogue(Dialogues.RetrieveDialogue(TimeLogic.day, characterId, DialogueID.GREETING) [0], portrait, characterId, Dialogues.RetrieveReward(TimeLogic.day, characterId, DialogueID.GREETING)); if (characterId == Character.GRANDMA) { Quests.instance.FulfilledQuestCondition(QuestTask.TALK_TO_GRANDMA); } break; case actionID.SELL: Equippable item = player.currentlyEquippedItem; PlayerEconomy.ReceiveMoney(Prices.GetPriceByID(player.currentlyEquippedItem.id)); player.UnequipEquippedItem(false, true); Destroy(item.gameObject); break; } } }
// Is standing in a hazardous area public CorrosiveChemical CorrosiveChemicalSearch() { if (!gameObject.HasTag(GameTags.Dead)) { Equippable isWearingProtectiveSuit = IsWearingProtectiveSuit(); if (!isWearingProtectiveSuit) { int cell_1 = Grid.PosToCell(gameObject); Element element_1 = Grid.Element[cell_1]; float mass_1 = Grid.Mass[cell_1]; if (IsHazardousChemical(element_1.id, mass_1)) { return(chemicalList[element_1.id]); } int cell_2 = Grid.CellAbove(Grid.PosToCell(gameObject)); Element element_2 = Grid.Element[cell_2]; float mass_2 = Grid.Mass[cell_2]; if (IsHazardousChemical(element_2.id, mass_2)) { return(chemicalList[element_2.id]); } } } return(null); }
// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); playerMov = FindObjectOfType <PlayerMovement>(); tool = equippable; Inventory.itemInHand = tool; }
public void AddStatsFromEquippable(Equippable equippable) { foreach (StatValue statValue in equippable.BaseStats()) { AddBonus(statValue); } }
public void RemoveStatsFromEquippable(Equippable equippable) { foreach (StatValue statValue in equippable.BaseStats()) { RemoveBonus(statValue); } }
private void SetEquippableStoredModifiers(Equippable equippable, bool isStoring) { GameObject gameObject = equippable.gameObject; Storage.MakeItemTemperatureInsulated(gameObject, isStoring, false); Storage.MakeItemInvisible(gameObject, isStoring, false); }
public UnitEquipment( Weapon weaponPrimary, Weapon weaponSecondary, Equippable[] misc, Biomod biomod = null ) { this.weaponPrimary = weaponPrimary; this.weaponSecondary = weaponSecondary; this.misc = misc; this.biomod = biomod; }
public void UnEquipItem(Equippable itemToUnequip) { UIEventHandler.ItemUnequipped(itemToUnequip); characterStats.RemoveStatBonuses(itemToUnequip.Stats); equippedItems.Remove(itemToUnequip); Debug.Log("Unequipped: " + itemToUnequip); TakeItem(itemToUnequip); // unequipped items automatically go to the inventory for now }
public Equippable(Equippable copyFrom) : base(copyFrom) { combatBonus = copyFrom.combatBonus; jobBonus = copyFrom.jobBonus; equipmentSlot = copyFrom.equipmentSlot; breakChance = copyFrom.breakChance; isEquipped = false; }
public static void AddComponents(Entity subject) { ItemBase.AddComponents(subject); // Item stuff Equippable.AddTo(subject, null); Countable.AddTo(subject); }
GameObject CreateEquippableItem(string title, StatTypes type, int amount, EquipSlots slot) { GameObject item = CreateItem(title, type, amount); Equippable equip = item.AddComponent <Equippable>(); equip.defaultSlots = slot; return(item); }
void EquipItem(GameObject item) { Debug.Log("Perhaps this will help..."); Equippable toEquip = item.GetComponent <Equippable>(); Equipment equipment = combatants[0].GetComponent <Equipment>(); equipment.Equip(toEquip, toEquip.defaultSlots); }
void OnRespawn() { if (equippedItem) { equippedItem.CmdDrop(); equippedItem = null; } }
public static void AddComponents(Entity subject) { ItemBase.AddComponents(subject); Equippable.AddTo(subject, null); SlotComponent.AddTo(subject, Slot.Id); BowComponent.AddTo(subject); ItemActivation.AddTo(subject, GetChargeAction); }
public static void AddComponents(Entity subject, IntVector2 relativeDirection, int pierceIncrease) { ItemBase.AddComponents(subject); // Item stuff Equippable.AddTo(subject, ShieldComponent.Hookable); SlotComponent.AddTo(subject, Slot.Id); }
public void UnEquip(Equippable item) { item.OnUnEquip(); item.slots = EquipSlots.None; item.transform.SetParent(transform); _items.Remove(item); this.PostNotification(UnEquippedNotification, item); }
public void Equip(Equippable item, EquipSlots slots) { UnEquip(slots); _items.Add(item); item.transform.SetParent(transform); item.slots = slots; item.OnEquip(); this.PostNotification(EquippedNotification, item); }
/// /// /// // Use this for initialization void Start() { WeaponManager wm = this.GetComponent<WeaponManager>(); Debug.Log("WeaponHand"); wm.setUpForPlay(); wm.loadUnlockedWeapons(ref equips); currentEquippedWeapon = equips[0]; fired = false; player = GameObject.FindWithTag("Player"); rightHand = GameObject.Find("Beta/Beta:Hips/Beta:Spine/Beta:Spine1/Beta:Spine2/Beta:RightShoulder/Beta:RightArm/Beta:RightForeArm/Beta:RightHand"); // Draw the initial weapons mat and mes renderer.material = currentEquippedWeapon.getMaterial(); this.GetComponent<MeshFilter>().mesh = currentEquippedWeapon.getMesh(); this.transform.localEulerAngles = currentEquippedWeapon.getRotation(); currentEquippedWeapon.setTransform(this.transform); // Load List of available weapons from InventoryManager //Debug.Log(reloadTime); // For rigidBody Ammo // Default is grenade launcher, this code will be changed once we have a filesystem or database to load from reloadTime = currentEquippedWeapon.getReloadTime(); currentEquippedWeapon.setReloadTimer(reloadTime+1.0f); reloadTimer = currentEquippedWeapon.getReloadTimer(); currentEquippedWeapon.setReloadTime(0.5f); //equips[0].setShotPower(1000); currentEquippedWeapon.setShotOffset(2); currentEquippedWeapon.setShotPower(900); /*************************************/ // Add Weapons to equips // equips[i] = new Laser(); }
// void switchWeapon() { if (++i >= equips.Count) { i = 0; } // DEBUG Debug.Log(i); Debug.Log(equips[i].getMaterial()); Debug.Log(equips[i].getMesh()); Debug.Log(equips[i].getRotation()); // Switch Weapon type weaponType = (WeaponType)weaponNum; // Change mesh and material renderer.material = equips[i].getMaterial(); this.GetComponent<MeshFilter>().mesh = equips[i].getMesh(); // correctly orient the weapon this.transform.localEulerAngles = equips[i].getRotation(); currentEquippedWeapon = equips[i]; currentEquippedWeapon.setTransform(this.transform); }
public ToxicRush( Unit owner, Equippable source ) : base(owner, source, "Toxic Rush", 1, 0) { }
public Heal( Unit owner, Equippable source, int amount ) : base(owner, source, "Heal " + amount) { oneUse = true; healAmount = amount; }
public Jump( Unit owner, Equippable source ) : base(owner, source, "JumpTo", ActionSubjectType.GridTile, 2) { }
public Lunge( Unit owner, Equippable source ) : base(owner, source, "LungeAttack!", ActionSubjectType.Unit) { }
public void Remove( Equippable item ) { //item.Init( this ); //model.Add( item ); //model.Hide( item ); }
public void Add( Equippable item ) { item.Init( this ); model.Equip( item ); model.Hide( item ); }
public Stomp( Unit owner, Equippable source ) : base(owner, source, "Stomp!", ActionSubjectType.GridTile) { }
internal void Hide( Equippable item ) { // weapon.model.enabled = false; if( item.equipmentType == EquipmentType.Hidden ) { item.gameObject.SetActive( false ); } else { item.transform.AttachTo( equiomentHolders.NextAvailable( item.equipmentType ) ); } //if( item.animation != null && item.animation.GetClip( "load" ) != null ) { // item.animation.Play( "load" ); //} }
internal static void PassEquipment( Unit passer , Unit passee , Equippable item ) { List<Equippable> eList = new List<Equippable>( passer.equipment.misc ); if( !eList.Contains( item ) ) { throw new UnityException( passer + " tried to pass item " + item + " to " + passee + " but it was not found in his equipment." ); } eList.Remove( item ); passer.equipment.misc = eList.ToArray( ); passer.actions.RemoveAll( item.actions ); eList = new List<Equippable>( passee.equipment.misc ) {item}; passee.equipment.misc = eList.ToArray(); passee.actions.AddRange( item.actions ); foreach( Action a in item.actions ) { a.SetOwner( passee ); } passee.model.Reload(); }
internal void Show( Equippable item ) { item.transform.AttachTo( mainHand ); //item.gameObject.SetActive( true ); //if( item.animation != null && item.animation.GetClip( "load" ) != null ) { // item.animation.Play( "load" ); //} }
internal void Equip( Equippable item, Transform hand = null ) { hand = hand ?? mainHand; item.transform.AttachTo( hand ); //item.transform.position = hand.transform.position; //item.transform.rotation = hand.transform.rotation; //item.transform.parent = hand; }