Пример #1
0
        public void InvokePlayerScore(int _enemyID, Enemy.EnemyType _type, int playerID)
        {
            int enemyKill = GetEnemyKillFromID(playerID);

            playerControllerInstance.UpdateScore(_enemyID, _type);
            EnemyKill?.Invoke(playerControllerInstance.GetID(), enemyKill);
        }
Пример #2
0
    void OnCollisionEnter2D(Collision2D other)
    {
        Debug.Log(other.gameObject.tag);
        if (other.gameObject.tag == "Player")
        {
            bool isSuper = mario.getHasSuperStar();
            if (isSuper)
            {
                Dies();
            }
            else if (lives == 2)
            {
                if (!isSuper)
                {
                    float height = other.contacts [0].point.y - weakness.position.y;

                    if (height > 0)
                    {
                        //Dies();
                        lives--;
                        if (lives == 0)
                        {
                            Dies();
                        }

                        if (lives == 1)
                        {
                            enemy.velocity = new Vector2(0, 0);
                            anim.SetBool("isHit", true);
                        }

                        other.rigidbody.AddForce(new Vector2(0, 300));
                    }
                    else
                    {
                        mario.removeLife();
                    }
                }
            }
            else if (lives == 1)
            {
                if (moveSpeed > 4 || moveSpeed < -4)
                {
                    //	mario.removeLife ();
                }

                float distance = transform.position.x - other.transform.position.x;
                if (distance >= 0)
                {
                    moveSpeed = 5;                    //enemy.velocity = new Vector2(7,enemy.velocity.y);
                }
                else if (distance < 0)
                {
                    moveSpeed = -5;                    //enemy.velocity = new Vector2(-7,enemy.velocity.y);
                }
                other.rigidbody.AddForce(new Vector2(0, 300));
            }
        }
        else if (other.gameObject.tag == "deadly" && lives == 1)
        {
            if (moveSpeed > 4 || moveSpeed < -4)
            {
                EnemyKill k = other.gameObject.GetComponent <EnemyKill> ();
                if (k != null)
                {
                    k.gotShot();
                }
            }
        }
        else if (other.gameObject.tag == "pipe")
        {
            moveSpeed = moveSpeed * -1;
        }
    }
Пример #3
0
 void Start()
 {
     player    = GameObject.Find("Player").transform;
     enemyKill = GetComponent <EnemyKill>();
 }