Ejemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        var objectTag = other.gameObject.tag;

        switch (objectTag)
        {
        case ItemTag.Coin:
        case ItemTag.Emerald:
        case ItemTag.Diamond:
            AudioManager.audioManager.PlaySound(AudioFile.Coin);
            collectedItemsCount += 1;
            other.gameObject.SetActive(false);
            ShowPopUp("You got something valuable!");
            GameState.gameState.AddAccesory(other.gameObject.transform.position.sqrMagnitude);
            ChestController.AddToItems(objectTag);
            break;

        case ItemTag.Key:
            hasKey = true;
            AudioManager.audioManager.PlaySound(AudioFile.Key);
            ShowPopUp("You got a key!");
            ChestController.AddToItems(objectTag);
            GameState.gameState.AddAccesory(other.gameObject.transform.position.sqrMagnitude);
            other.gameObject.SetActive(false);
            break;

        case ItemTag.Medkit:
            AudioManager.audioManager.PlaySound(AudioFile.Other);
            health += healthIncreaseStep;
            other.gameObject.SetActive(false);
            GameState.gameState.AddAccesory(other.gameObject.transform.position.sqrMagnitude);
            ShowPopUp(string.Format("Health {0}", healthIncreaseStep.ToString()));
            HealthIconController.gotHealth = true;
            break;

        case ItemTag.Tank:
            AudioManager.audioManager.PlaySound(AudioFile.Gas);
            breathingGasAmount += breathingGasIncreaseStep;
            ShowPopUp(string.Format("Breathing gas {0}", breathingGasIncreaseStep.ToString()));
            other.gameObject.SetActive(false);
            GameState.gameState.AddAccesory(other.gameObject.transform.position.sqrMagnitude);
            GasIconController.gotTank = true;
            break;

        case ItemTag.Tnt:
            AudioManager.audioManager.PlaySound(AudioFile.Other);
            ShowPopUp("You got a TNT!");
            ChestController.AddToItems(objectTag);
            GameState.gameState.AddAccesory(other.gameObject.transform.position.sqrMagnitude);
            other.gameObject.SetActive(false);
            break;

        case ItemTag.Map:
            //hasMap = true;
            AudioManager.audioManager.PlaySound(AudioFile.Map);
            ShowPopUp("You got a Map!");
            ChestController.AddToItems(objectTag);
            GameState.gameState.AddAccesory(other.gameObject.transform.position.sqrMagnitude);
            other.gameObject.transform.position = new Vector3(100, 100, 100);
            break;

        case ItemTag.Banana:
            hasBanana = true;
            other.gameObject.SetActive(false);
            AudioManager.audioManager.PlaySound(AudioFile.Coin);
            GameState.gameState.AddAccesory(other.gameObject.transform.position.sqrMagnitude);
            ShowPopUp("You got a Jack Sparrows's compass!!!");
            break;

        case ItemTag.End:
            end();
            break;

        default:
            break;
        }
    }