private PickAxe pickaxe_script; // Load Key Script // Start is called before the first frame update void Start() { UIObject_plant1.SetActive(false); UIObject_plant2.SetActive(false); opendoor_script = doorisopen.GetComponent <OpenDoor>(); // get doorisopenvalue pickaxe_script = hastheaxe.GetComponent <PickAxe>(); // get hasthekey value }
void OnTriggerEnter(Collider other) // colliding with other object { pickaxe_script = hastheaxe.GetComponent <PickAxe>(); // aquires "hasthekey" value if (other.tag == "Player" && pickaxe_script.hastheaxe == false) // if other object is PLAYER + player does NOT have the key { UIObject_axe.SetActive(true); // show key message } }
void GetComponents() { _RigidBody = GetComponent <Rigidbody2D>(); _Collider = GetComponent <BoxCollider2D>(); _PickAxeScript = _PickAxeTransform.GetComponent <PickAxe>(); _PickAxeScript._Player = this; _AxeAnim = _PickAxeTransform.GetComponent <Animator>(); _AxeRenderer = _PickAxeTransform.GetComponent <SpriteRenderer>(); }
void ThrowPickAxe() { if (pickTimer > 0) { pickTimer -= Time.deltaTime; } if (!building && Input.GetMouseButtonUp(0) && pickTimer <= 0) { Vector3 spawnPos = transform.position + new Vector3(0, 0.25f, 0); GameObject newGO = Instantiate(pickAxe, spawnPos, new Quaternion()); PickAxe pickComp = newGO.GetComponent <PickAxe>(); Vector3 mousePos = cam.ScreenToWorldPoint(Input.mousePosition); pickComp.Launch((mousePos - spawnPos).normalized); pickTimer = pickDelay; animator.SetBool("hasThrown", true); } }