private void TakeAllContent(Player player) { hookStatus = containerStatus.EMPTY; player.EquipAnItem(content); content.BeEquipped(); content = null; }
public void EquipAnItem(Equippable equippableItem, bool moveItemToPlayer = true, Transform overwriteTransform = null) //TODO Y U NO WORK? Transform is not passed. test again at some other point? //Debug.Log ("equip an item with params: equippableItem " + equippableItem.name + ", moveItemToPlayer: " + moveItemToPlayer + ", overwriteTransform: " + overwriteTransform); //I put this in bc horse sank through floor on mounting, but is it correct in every case? { if (equippableItem.id == equippableItemID.HORSE_MOUNTED) { equippableItem.BeEquipped(true); } else { equippableItem.BeEquipped(false); } currentlyEquippedItem = equippableItem; if (currentlyEquippedItem.overrideTurnRate != -1) { maximumTurnRate = currentlyEquippedItem.overrideTurnRate; } if (overwriteTransform != null) { Debug.Log("overwrite transform, parent " + overwriteTransform.name + " to equippeditemPos"); overwriteTransform.SetParent(equippedItemPos, true); } else { currentlyEquippedItem.transform.SetParent(equippedItemPos, true); } if (moveItemToPlayer) { currentlyEquippedItem.transform.position = equippedItemPos.position; currentlyEquippedItem.transform.localEulerAngles = currentlyEquippedItem.equippedRotation; currentlyEquippedItem.transform.localPosition = equippableItem.equippedOffset; } inventory.UpdateActiveSlot(currentlyEquippedItem, false); //update active slot in inventory //update UI //active slot always shows what you have currently equipped, whether it's something that can be put into inventory or not }
private void TakeOffHalter(Player player) { Equippable halterEquippable = headGear.GetComponent <Equippable> (); headGear = null; player.EquipAnItem(halterEquippable); halterEquippable.BeEquipped(); }
private void TakeOffBridle(Player player) { headGear.anim.Play("Still"); Equippable bridleEquippable = headGear.GetComponent <Equippable> (); headGear = null; player.EquipAnItem(bridleEquippable); bridleEquippable.BeEquipped(); }
private void TakeOffSaddleAndPad(Player player) { Equippable saddleEquippable = backGear.GetComponent <Equippable> (); backGear.girth.position = backGear.girthPosHanging.position; backGear.girth.rotation = backGear.girthPosHanging.rotation; backGear = null; player.EquipAnItem(saddleEquippable); saddleEquippable.BeEquipped(); }
private void TakeOffLead(Player player) { headGearAttachment.anim.Play("Still"); Equippable leadEquippable = headGearAttachment.GetComponent <Equippable> (); headGearAttachment = null; player.UnequipEquippedItem(); player.EquipAnItem(leadEquippable); leadEquippable.BeEquipped(); horseOnLeadEquippable.EnableAllColliders(true); StopLeadingHorse(player); }
private void TakeOffHalterAndLead(Player player) { //find combined equippable, which is a child of Halter (but hierarchy changes, so it's not always the 0th child) Equippable combinedEquippable = null; Equippable[] equippablesInHalter = headGear.GetComponentsInChildren <Equippable> (); for (int i = 0; i < equippablesInHalter.Length; ++i) { if (equippablesInHalter [i].id == equippableItemID.HALTER_WITH_LEAD) { combinedEquippable = equippablesInHalter [i]; } } headGearAttachment.anim.Play("Still"); headGearAttachment.transform.SetParent(combinedEquippable.transform); player.UnequipEquippedItem(); player.EquipAnItem(combinedEquippable); combinedEquippable.BeEquipped(); StopLeadingHorse(player); Debug.Log("combined was equipped"); headGear.transform.SetParent(combinedEquippable.transform); headGearAttachment = null; headGear = null; foreach (Transform child in combinedEquippable.transform) { //fix positions child.position = player.equippedItemPos.position; child.localEulerAngles = player.currentlyEquippedItem.equippedRotation; child.localPosition = child.GetComponent <Equippable>().equippedOffset; } horseOnLeadEquippable.EnableAllColliders(true, true); combinedEquippable.EnableAllColliders(false, true); }
private void PickUpHorseGear(Player player, equippableItemID itemToTake) { Equippable combined = null; Equippable halter = null; Equippable lead = null; if (equippable.id == equippableItemID.HALTER_WITH_LEAD) { combined = equippable; foreach (Transform child in equippable.transform) { Equippable childEquippable = child.GetComponent <Equippable> (); if (childEquippable.id == equippableItemID.HALTER) { halter = childEquippable; } else if (childEquippable.id == equippableItemID.LEAD) { lead = childEquippable; } } } switch (itemToTake) { case equippableItemID.HALTER: //if content.id is halter and lead, but i only want to take halter, unparent lead and halter from halter_w_lead. take halter, lead remains if (equippable.id == equippableItemID.HALTER_WITH_LEAD) { halter.BeEquipped(); player.EquipAnItem(halter); combined.transform.SetParent(halter.transform); lead.transform.SetParent(null); lead.GetComponent <SphereCollider> ().enabled = true; } else if (equippable.id == equippableItemID.HALTER) { PickUpAll(player); } break; case equippableItemID.LEAD: //if content.id is halter and lead, but i only want to take halter, unparent lead and halter from halter_w_lead. take lead, halter remains if (equippable.id == equippableItemID.HALTER_WITH_LEAD) { lead.BeEquipped(); player.EquipAnItem(lead); halter.transform.SetParent(null); combined.transform.SetParent(halter.transform); halter.GetComponent <SphereCollider> ().enabled = true; combined.GetComponent <SphereCollider> ().enabled = false; } else if (equippable.id == equippableItemID.LEAD) { PickUpAll(player); } break; case equippableItemID.HALTER_WITH_LEAD: PickUpAll(player); break; } }
private void TakeContent(Player player, equippableItemID contentToTake) { Equippable combined = content; Equippable halter = null; Equippable lead = null; if (content.id == equippableItemID.HALTER_WITH_LEAD) { foreach (Transform child in content.transform) { Equippable childEquippable = child.GetComponent <Equippable> (); if (childEquippable.id == equippableItemID.HALTER) { halter = childEquippable; } else if (childEquippable.id == equippableItemID.LEAD) { lead = childEquippable; } } } switch (contentToTake) { case equippableItemID.HALTER: //if content.id is halter and lead, but i only want to take halter, unparent lead and halter from halter_w_lead. take halter, lead remains if (content.id == equippableItemID.HALTER_WITH_LEAD) { content = lead; halter.BeEquipped(); player.EquipAnItem(halter); combined.transform.SetParent(halter.transform); lead.transform.SetParent(transform); } else if (content.id == equippableItemID.HALTER) { TakeAllContent(player); } break; case equippableItemID.LEAD: //if content.id is halter and lead, but i only want to take halter, unparent lead and halter from halter_w_lead. take lead, halter remains if (content.id == equippableItemID.HALTER_WITH_LEAD) { content = halter; lead.BeEquipped(); player.EquipAnItem(lead); halter.transform.SetParent(transform); combined.transform.SetParent(halter.transform); } else if (content.id == equippableItemID.LEAD) { TakeAllContent(player); } break; case equippableItemID.HALTER_WITH_LEAD: TakeAllContent(player); break; } }