private bool IsHoldingItem(GameObject sender) { if (HoldingItem != null) { Character c = GameObject.Find(sender.name).GetComponent <Character>(); if (c.heldItem != null) { Item heldItem = c.heldItem.GetComponent <Item>(); Item targetItem = HoldingItem.GetComponent <Item>(); if (heldItem.resource != targetItem.resource) { return(false); } else { return(true); } } else { return(false); } } return(true); }
public EntityMeta() { //defaults MaxHealth = Health = 20; MaxMana = Mana = 1000; Holding = new HoldingItem(); }
// Use this for initialization void Start() { playerStamina = GetComponent <PlayerStamina> (); camera = Camera.main; tool = Tools.NONE; hoe = GetComponent <Hoe> (); plant = GetComponent <PlantSeeds> (); wateringCan = GetComponent <WateringCan> (); sickle = GetComponent <Sickle> (); none = GetComponent <None> (); holdingItem = GetComponent <HoldingItem> (); inventory = GetComponent <InventoryManager> (); fountainCollision = GetComponent <FountainCollider> (); NPCCollision = GetComponentInChildren <NPCCollision> (); if (SceneManager.GetActiveScene().name.Contains("Outside") || SceneManager.GetActiveScene().name == "Farming" || SceneManager.GetActiveScene().name == "Farm") { outside = true; } else { outside = false; } anim = GetComponent <Animator> (); hoeGO = this.transform.Find("hoe").gameObject; wcanGO = this.transform.Find("wateringcan").gameObject; sickleGO = this.transform.Find("sickle").gameObject; buttonToPress = FindObjectOfType(typeof(ButtonToPress)) as ButtonToPress; }
protected override void OnThisTierChanged(ResizingTier obj) { // If holding an item, change this item's tier value // (or do it automatically from the item's perspective) if (HoldingItem != null) { HoldingItem.OnTierChanged(); } UpdateParticles(); Instance_OnAfterResize(ResizeParent.Instance); }
void hold(InventoryItem item, Button iob) { Debug.Log("hold"); HoldingItem holdingItem = GameObject.FindGameObjectWithTag("Player").GetComponent <HoldingItem> (); holdingItem.holdingItem = true; ButtonToPress btp = FindObjectOfType(typeof(ButtonToPress)) as ButtonToPress; btp.showPanel("X", "Save " + item.name); anim.SetBool("isHolding", true); if (item.inventoryType.Equals(InventoryItem.inventoryTypes.EDIBLE) || item.inventoryType.Equals(InventoryItem.inventoryTypes.NOTEDIBLE)) { Debug.Log("Hold " + item.inventoryType.ToString().ToLower() + "/" + item.name.ToLower()); GameObject resource = Resources.Load <GameObject> ("Hold " + item.inventoryType.ToString().ToLower() + "/" + item.name.ToLower()); GameObject instance = Instantiate(resource, GameObject.FindGameObjectWithTag("Player").transform); holdingItem.item = instance; holdingItem.itemCode = item.code; } Destroy(iob.transform.parent.gameObject); enableButtons(); Exit(); }
void Start() { anim = GetComponent <Animator> (); holdingItem = GetComponent <HoldingItem> (); }
void switchBody(GameObject newBody) { if (controlObject != null) { controlObject.GetComponent <Rigidbody2D>().velocity = Vector3.zero; } if (!ReferenceEquals(newBody, mainBody)) { mainBody.transform.parent = newBody.transform; mainBody.transform.localPosition = Vector3.zero; mainBody.GetComponent <Rigidbody2D>().simulated = false; spiritMode = false; } else { spiritMode = true; mainBody.GetComponent <Rigidbody2D>().simulated = true; mainBody.transform.parent = controlObject.transform.parent; } controlObject = newBody; cameraTarget.rb = newBody.GetComponent <Rigidbody2D>(); if (controlObject.GetComponent <Health>() != null) { health = controlObject.GetComponent <Health>(); } else { health = null; } if (controlObject.GetComponent <Dash>() != null) { dash = controlObject.GetComponent <Dash>(); } else { dash = null; } if (controlObject.GetComponent <Jump>() != null) { jump = controlObject.GetComponent <Jump>(); } else { jump = null; } if (controlObject.GetComponent <HoldingItem>() != null) { heldItem = controlObject.GetComponent <HoldingItem>(); } else { heldItem = null; } if (controlObject.GetComponent <Move>() != null) { move = controlObject.GetComponent <Move>(); } else { move = null; } useableBody = null; }