Beispiel #1
0
    void onTriggerEnterEvent(Collider2D col)
    {
        Debug.Log("onTriggerEnterEvent: " + col.gameObject.name);


        //powerup collision
        if (col.gameObject.tag == "Powerup")
        {
            Powerup powerup = col.gameObject.GetComponent <Powerup> ();
            powerup.SetPlayer(gameObject);
            if (powerup.IsRelevant())
            {
                activePowerup = powerup;
                powerup.ApplyPowerup();
                powerupEndTime             = 400f;
                hasPowerup                 = true;
                powerup.transform.position = new Vector2(transform.position.y, 20);
            }
        }
        //shark collision detection
        if (col.gameObject.tag == "Enemy")
        {
            if (col.gameObject.GetComponent <Enemy> ().eType == "Shark")
            {
                print("shark collision");
                DamagePlayer(2);
                Destroy(col.gameObject);
            }
        }
    }