Пример #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            Player player = other.transform.GetComponent <Player>();
            if (player != null)
            {
                _audioSource.Play();

                switch (_powerUpID)
                {
                case 0:
                    player.TripleShotActive();
                    break;

                case 1:
                    PlayerScript_InputAction inputAction = _gameManager.GetComponent <PlayerScript_InputAction>();
                    inputAction.SpeedPowerUp();
                    break;

                case 2:
                    player.ActivateShields();
                    break;

                default:
                    Debug.LogError("Unknown PowerUpID");
                    break;
                }
            }

            Destroy(this.gameObject);
        }
    }
Пример #2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            Player player = other.transform.GetComponent <Player>();
            if (player != null)
            {
                _audioSource.Play();

                switch (_powerUpID)
                {
                case 0:
                    if (player.GetLaserInventory() >= 3)
                    {
                        player.TripleShotActive();
                    }
                    break;

                case 1:
                    PlayerScript_InputAction inputAction = _gameManager.GetComponent <PlayerScript_InputAction>();
                    inputAction.SpeedPowerUp();
                    break;

                case 2:
                    player.ActivateShields();
                    break;

                case 3:     // Ammo
                    player.ReloadLaserInventory();
                    break;

                case 4:     // Health
                    player.AddHealth();
                    break;

                case 5:     // Space Mine
                    player.LoadMine();
                    break;

                default:
                    Debug.LogError("Unknown PowerUpID");
                    break;
                }
            }

            Destroy(this.gameObject);
        }
    }