Beispiel #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Enemy")
        {
            //Destroy(gameObject);
            if (collision.gameObject.GetComponent <enemyMovement>())
            {
                theEnemyMovement.HurtEnemyMethod(collision.GetComponent <enemyMovement>(), 0.5f);
            }
            else if (collision.gameObject.GetComponent <DemonEnemyScript>())
            {
                theDemonEnemyScript.HurtEnemyMethod(collision.GetComponent <DemonEnemyScript>(), 0.5f);
            }
            else if (collision.gameObject.GetComponent <RollyScript>())
            {
                theRollyScript.HurtEnemyMethod(collision.GetComponent <RollyScript>(), 0.5f);
            }
            else if (collision.gameObject.GetComponent <BossSpoooderScript>())
            {
                theBossSpoooderScript.HurtEnemyMethod(collision.GetComponent <BossSpoooderScript>(), 0.5f);
                this.gameObject.GetComponent <Rigidbody2D>().velocity = Vector3.zero;
                this.gameObject.transform.position = pickaxePoint1.gameObject.transform.position;
                theManager.FlashRed(collision.GetComponent <SpriteRenderer>());
            }
            else if (collision.gameObject.GetComponent <BossRollyScript>())
            {
                theBossRollyScript.HurtEnemyMethod(collision.GetComponent <BossRollyScript>(), 1f);
                this.gameObject.GetComponent <Rigidbody2D>().velocity = Vector3.zero;
                this.gameObject.transform.position = pickaxePoint1.gameObject.transform.position;
                theManager.FlashRed(collision.GetComponent <SpriteRenderer>());
            }
        }
        if (collision.tag == "Ground")
        {
            //Destroy(gameObject);
            theCharacterMovement.canPickUpObject = true;

            if (theCharacterMovement.shotRight)
            {
                isOnGroundRight = true;
            }
            else if (theCharacterMovement.shotLeft)
            {
                isOnGroundLeft = true;
            }
        }
    }