Beispiel #1
0
    private void OnCollisionEnter(Collision collision)
    {
        if (hasCollided)
        {
            return;
        }

        if (collision.gameObject.tag == "RedBall" ||
            collision.gameObject.tag == "Player")
        {
            //灰球变红
            EffectManager.ChangeColor(gameObject, collision, Resources.Load <Material>("C_Red"));
            this.enabled = false;
            Invoke("Grey2Red", 1);
            hasCollided = true;
        }
        else if (collision.gameObject.tag == "Wall")
        {
            StopCoroutine(RandomMove());
            StartCoroutine(RandomMove());
        }
        if (collision.gameObject.tag == "Boss" || collision.gameObject.tag == "SmallBlackBall" || collision.gameObject.tag == "RedBall" || collision.gameObject.tag == "GreyBall" || collision.gameObject.tag == "Player")
        {
            Rebound(collision);
            hasCollided = true;
        }

        if (collision.gameObject.layer == 10)
        {
            CollideWall(collision);
            //Debug.Log("撞墙");
            hasCollided = true;
        }
    }
Beispiel #2
0
    private void OnCollisionEnter(Collision collision)
    {
        if (hasCollided)
        {
            return;
        }

        //遇见第三阶段合体主角且体积大于自己
        if (collision.gameObject.tag == "Player" && collision.transform.localScale.x >= transform.localScale.x && collision.gameObject.GetComponent <Player>().union)
        {
            //体积减小,范围减小,炸出黑球
            bossHP--;
            transform.localScale = new Vector3(1, 1, 1) * Mathf.Lerp(1f, 2.2f, (float)bossHP / sumHP);
            //transform.GetChild(2).transform.localScale = transform.localScale;
            Debug.LogFormat("boss体积减小到{0}", Mathf.Lerp(1f, 2.2f, (float)bossHP / sumHP));

            transform.GetChild(0).transform.localScale       = new Vector3(1, 1, 1) * Mathf.Lerp(1f, 5f, (float)bossHP / sumHP);
            transform.GetComponent <SphereCollider>().radius = transform.GetChild(0).transform.localScale.x * 0.5f;
            sqrShadowRange = transform.GetChild(0).transform.localScale.x *transform.GetChild(0).transform.localScale.x;

            //炸出黑球在范围边缘?
            int a = 2;
            for (int i = 0; i < a; i++)
            {
                Vector3 dir = new Vector3(Random.Range(-1f, 1f), 0, Random.Range(-1f, 1f));
                // EffectManager.GenerateTrailBlack(transform, transform.position + dir * transform.GetChild(0).transform.localScale.x * 1.5f, 5, 1);
                Enemy.GenerateSelf(transform.position + dir * transform.GetChild(0).transform.localScale.x * 1.5f);
            }

            if (bossHP <= 0)
            {
                Debug.Log("BOSS死亡");
                GameObject.Find("Manager").GetComponent <GameManager>().SetBallNum("black", false);

                Destroy(GameObject.Find("BossRings"));
                EffectManager.ChangeColor(gameObject, collision, Resources.Load <Material>("C_Red"));
                this.enabled = false;
                Invoke("Boss2Red", 1);
                GameObject.Find("Manager").GetComponent <GameManager>().PlayerWin();

                hasCollided = true;
            }
            hasCollided = true;
            StartCoroutine(AllowCollide());
        }
    }
Beispiel #3
0
    private void OnCollisionEnter(Collision collision)
    {
        if (hasCollided)
        {
            return;
        }

        if (collision.gameObject.tag == "SmallBlackBall")
        {
            //红球变灰
            EffectManager.ChangeColor(gameObject, collision, Resources.Load <Material>("C_Grey"));
            this.enabled = false;
            Invoke("Red2Grey", 1);


            hasCollided = true;
        }
        else if (collision.gameObject.tag == "Boss")
        {
            //红球变黑
            EffectManager.ChangeColor(gameObject, collision, Resources.Load <Material>("C_Black"));
            this.enabled = false;
            Invoke("Red2Black", 1);


            hasCollided = true;
        }

        if (collision.gameObject.tag == "Boss" || collision.gameObject.tag == "SmallBlackBall" || collision.gameObject.tag == "RedBall" || collision.gameObject.tag == "GreyBall" || collision.gameObject.tag == "Player")
        {
            //Debug.Log(collision.gameObject.tag);
            Rebound(collision);
            // Debug.Log(rb.velocity);
            hasCollided = true;
        }

        if (collision.gameObject.layer == 10)
        {
            CollideWall(collision);
            //Debug.Log("撞墙");
            hasCollided = true;
        }
    }
Beispiel #4
0
    private void OnCollisionEnter(Collision collision)
    {
        if (hasCollided)
        {
            return;
        }

        if (collision.gameObject.tag == "Player" && collision.gameObject.GetComponent <Player>().state == 2)
        {
            //小黑球与中主角:小黑球变灰,速度加快
            EffectManager.ChangeColor(gameObject, collision, Resources.Load <Material>("C_Grey"));
            this.enabled = false;
            Invoke("Black2Grey", 1);


            hasCollided = true;
        }
        else if (collision.gameObject.tag == "Player" && collision.gameObject.GetComponent <Player>().state == 3)
        {
            //小黑球与大主角:小黑球变红,速度加快
            EffectManager.ChangeColor(gameObject, collision, Resources.Load <Material>("C_Red"));
            this.enabled = false;
            Invoke("Black2Red", 1);


            hasCollided = true;
        }

        if (collision.gameObject.tag == "Boss" || collision.gameObject.tag == "SmallBlackBall" || collision.gameObject.tag == "RedBall" || collision.gameObject.tag == "GreyBall" || collision.gameObject.tag == "Player")
        {
            Rebound(collision);
            hasCollided = true;
        }

        if (collision.gameObject.layer == 10)
        {
            CollideWall(collision);
            //Debug.Log("撞墙");
            hasCollided = true;
        }
    }