private void OnTriggerStay2D(Collider2D collision) { //climbing ladders and ropes if ((collision.gameObject.CompareTag("Ladder")) || (collision.gameObject.CompareTag("Rope") && hasGem == false)) { climbspeed = 3; rb.gravityScale = 0; rb.velocity = new Vector2(rb.velocity.x, moveY * climbspeed); } else if (collision.gameObject.CompareTag("Rope") && hasGem) { climbspeed = 1.5f; rb.gravityScale = 0; rb.velocity = new Vector2(rb.velocity.x, moveY * climbspeed); } //interaction with gem if (collision.gameObject.CompareTag("Gem")) { atGem = true; if (interactCharge >= 0.5f) { Debug.Log("gem"); if (hasGem == false) { GemControl gemScript = collision.gameObject.GetComponent <GemControl>(); if (gemScript.isHeld == false) { hasGem = true; gemScript.isHeld = true; gemScript.holder = gameObject; } } else { hasGem = false; GemControl gemScript = collision.gameObject.GetComponent <GemControl>(); gemScript.isHeld = false; } interactCharge = 0; } } //interaction with cannon else if (collision.gameObject.CompareTag("Cannon")) { atCannon = true; if (interactCharge >= 0.5f) { Debug.Log("cannon"); CannonControl cc = collision.gameObject.GetComponent <CannonControl>(); cc.status = 1; interactCharge = 0; } } //interaction with switch if (collision.gameObject.CompareTag("Switch")) { atSwitch = true; if (interactCharge >= 0.5f) { Debug.Log("switch"); SwitchControl sc = collision.gameObject.GetComponent <SwitchControl>(); sc.switchflip = 1; interactCharge = 0; } } //interaction with supply if (collision.gameObject.CompareTag("Supply")) { atSupply = true; if (interactCharge >= 0.5f) { if (!hasBomb) { Debug.Log("supply"); hasBomb = true; mybomb.SetActive(true); } interactCharge = 0; } } }
private void InitializeGemControl() { _gemControl = new GemControl(_board); }