void UseItem() { switch (slot) { case Item.Cloak: timerCloak = timeCloak; isCloak = true; AudioManager.Instance.Playsound(soundHat, 0.2f); break; case Item.Invincible: timerInvincible = timeInvincible; isInvincible = true; AudioManager.Instance.Playsound(soundPotion, 0.5f); break; case Item.Heal: this.Damage(1); AudioManager.Instance.Playsound(soundBandage, 0.2f); break; case Item.TP: ArtefactController anchor = FindObjectOfType(typeof(ArtefactController)) as ArtefactController; if (anchor != null) { Vector2 positionTP = new Vector2(anchor.x - 1, anchor.y); transform.position = positionTP; } else { LaMontreController gate = FindObjectOfType(typeof(LaMontreController)) as LaMontreController; Vector2 positionTP = new Vector2(gate.x, gate.y); transform.position = positionTP; } AudioManager.Instance.Playsound(soundTeleportation, 1); break; case Item.Shield: shieldOn = true; energyShield.SetActive(true); AudioManager.Instance.Playsound(soundShield, 0.1f); break; } slot = Item.Empty; UIManager.Instance.UpdateSlot(ItemInSlot()); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0) && !pauseState.GamePaused()) { Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { Plataforma ground = hit.collider.GetComponent <Plataforma>(); if (ground != null) { interaccioPlataforma(ground); } ArtefactController artefact = hit.collider.GetComponent <ArtefactController>(); if (artefact != null) { artefact.setLvlArt(numLevel); playSound(0); } GemController gem = hit.collider.GetComponent <GemController>(); if (gem != null) { Debug.Log("ieee"); gem.getGem(numLevel); playSound(0); } /*ButtonPlatform button = hit.collider.GetComponent<ButtonPlatform>(); * if(button != null) * if (button.platform.entity != null) * if (button.platform.entity.tag == "Player") * foreach (MovingPlatform movingPlatform in button.movingPlatforms) * movingPlatform.Interacciona();*/ } } }