private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject == player) { poderUI.SetActive(true); CooldownRadial cr = poderUI.GetComponent <CooldownRadial>(); if (cr) { cr.activated = true; this.gameObject.transform.GetChild(0).gameObject.SetActive(false); } ShowAdvice advice = this.gameObject.GetComponent <ShowAdvice>(); if (advice != null) { string message = ""; switch (power) { case POWER.FIRE: message = "Technology upgraded! You can now turn fire into grass!"; break; case POWER.ICE: message = "Technology upgraded! You can now freeze water!"; break; case POWER.GROUND: message = "Technology upgraded! You can now turn rocks into sand!"; break; } advice.showAdvice(message); Debug.Log(message); } } }
private void FixedUpdate() { float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); Vector2 movement = h * Vector2.right + v * Vector2.up; m_Rigidbody.velocity = (movement * m_Speed); m_Animator.SetFloat("XSpeed", m_Rigidbody.velocity.x); m_Animator.SetFloat("YSpeed", m_Rigidbody.velocity.y); switch (powerName) { case "Fire": CooldownRadial crf = fuegoUI.GetComponent <CooldownRadial>(); if (crf) { if (crf.activated && crf.ready) { if (m_CanvasMessage != null) { m_CanvasMessage.SetActive(powerEnabled && powerReady[powerName]); } } } break; case "Ice": CooldownRadial crw = waterUI.GetComponent <CooldownRadial>(); if (crw) { if (crw.activated && crw.ready) { if (m_CanvasMessage != null) { m_CanvasMessage.SetActive(powerEnabled && powerReady[powerName]); } } } break; case "Rock": CooldownRadial cr = rockUI.GetComponent <CooldownRadial>(); if (cr) { if (cr.activated && cr.ready) { if (m_CanvasMessage != null) { m_CanvasMessage.SetActive(powerEnabled && powerReady[powerName]); } } } break; } if (Input.GetKey(m_PowerButton) && powerEnabled && powerReady[powerName] && phasingZone != null) { switch (powerName) { case "Fire": CooldownRadial crf = fuegoUI.GetComponent <CooldownRadial>(); if (crf) { if (crf.activated && crf.ready) { phasingZone.SetActive(false); m_CanvasMessage.SetActive(false); crf.StartCooldown(5); desaparecerFuego.Play(); } } break; case "Ice": CooldownRadial crw = waterUI.GetComponent <CooldownRadial>(); if (crw) { if (crw.activated && crw.ready) { phasingZone.SetActive(false); m_CanvasMessage.SetActive(false); crw.StartCooldown(5); hielo.Play(); } } break; case "Rock": CooldownRadial cr = rockUI.GetComponent <CooldownRadial>(); if (cr) { if (cr.activated && cr.ready) { phasingZone.SetActive(false); m_CanvasMessage.SetActive(false); cr.StartCooldown(5); derrumbar.Play(); } } break; } } }