コード例 #1
0
    // Bei Kontakt mit PowerUp wird die entsprechende Funktion aufgerufen
    void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.gameObject.GetComponent <PowerUpObject>())
        {
            SoundManager.instance.PlayEffect(5);

            FireRate  powerUpFireRate  = collider.gameObject.GetComponent <FireRate>();
            Health    powerUpHealth    = collider.gameObject.GetComponent <Health>();
            Assistant powerUpAssistant = collider.gameObject.GetComponent <Assistant>();
            Points    powerUpPoints    = collider.gameObject.GetComponent <Points>();

#if UNITY_STANDALONE
            Speed powerUpSpeed = collider.gameObject.GetComponent <Speed>();

            if (powerUpSpeed)
            {
                powerUpSpeed.AddSpeed(pMovement);
                powerUpSpeed.gameObject.SetActive(false);
            }
#endif

            if (powerUpFireRate)
            {
                powerUpFireRate.AddFireRate(pWeapon);
                powerUpFireRate.AddFireRate(aWeapon);
                powerUpFireRate.AddFireRate(aWeapon2);
                powerUpFireRate.gameObject.SetActive(false);
            }
            else if (powerUpHealth)
            {
                powerUpHealth.AddHealth(pBHealth);
                powerUpHealth.gameObject.SetActive(false);
            }
            else if (powerUpPoints)
            {
                powerUpPoints.AddPoints();
                powerUpPoints.gameObject.SetActive(false);
            }
            else if (powerUpAssistant)
            {
                assistantCount = powerUpAssistant.AddAssistantCount(assistantCount);
                powerUpAssistant.gameObject.SetActive(false);

                if (assistantCount == 3)
                {
                    assistant.SetActive(true);
                }
                else if (assistantCount == 5)
                {
                    assistant2.SetActive(true);
                }
            }
        }
    }