public override void pickUp(Tile tilePickingUsUp) { transform.parent = null; if (field != null) { field.being_farmed = false; } field = null; windmill = null; anim.Play("idle"); Physics2D.IgnoreCollision(tilePickingUsUp.GetComponent <Collider2D>(), GetComponent <Collider2D>(), true); base.pickUp(tilePickingUsUp); }
// Initialize Field public virtual void Start() { // Finds the windmill of the field's room if (transform.parent.transform.Find("inno_industry_windmill") != null) { GameObject temp_windmill = transform.parent.transform.Find("inno_industry_windmill").gameObject; if (temp_windmill.GetComponent <innoWindmillBehaviour>() != null) { windmill = temp_windmill.GetComponent <innoWindmillBehaviour>(); windmill.fields.Add(this); } } // Components anim = GetComponent <Animator>(); // Variables wheat_growth_counter = 0; being_farmed = false; }
void OnTriggerStay2D(Collider2D other) { if (!isBeingHeld) { if (other.gameObject.name == "inno_farm_collider") { if (windmill != other.gameObject.GetComponent <innoWindmillFarmArea>().windmill) { if (field != null) { field.being_farmed = false; } windmill = other.gameObject.GetComponent <innoWindmillFarmArea>().windmill; transform.SetParent(windmill.transform.GetChild(0)); for (int i = 0; i < windmill.transform.GetChild(0).childCount; i++) { Physics2D.IgnoreCollision(GetComponent <Collider2D>(), windmill.transform.GetChild(0).GetChild(i).GetComponent <Collider2D>(), true); } step_time = 0; } } } }