Beispiel #1
0
    void OnCollisionEnter(Collision thing)
    {
        var name = thing.collider.name;

        //Debug.Log("Thing is " + name);
        if (name == "cube2")
        {
            ci.Play();
            blood.add();
        }
        else if (name == "cube3")
        {
            putong.Play();
            //Destroy(thing.collider);
        }
        else if (name == "cube4")
        {
            putong.Play();
        }
        else if (name == "cube5")
        {
            /*Vector3 vex_1 = thing.transform.position;
             * Vector3 vex_2 = thing.other.gameObject.transform.position;
             * Vector3 vex_3 = thing.other.gameObject.GetComponent<Renderer>().bounds.size;*/

            Debug.Log(name);
            ContactPoint vPoint = thing.contacts[0];                                        //获取第一个碰撞点

            Quaternion quate = Quaternion.FromToRotation(Vector3.up, new Vector3(0, 1, 0)); //碰撞点法线

            count = 0;
            suilie.Play();
            anima = Instantiate(break_brick_anim, vPoint.point, quate) as GameObject;


            boards.Remove(thing.gameObject);
            Destroy(thing.gameObject);
        }
        else if (name == "cube6")
        {
            transform.Translate(new Vector3(0, 12, 0) * speed * Time.deltaTime);

            tanhuang.Play();

            /*  Debug.Log(name);
             * ContactPoint vPoint = thing.contacts[0];//获取第一个碰撞点
             *
             * Quaternion quate = Quaternion.FromToRotation(Vector3.up, new Vector3(0, 1, 0));
             *
             * count = 0;
             *
             * anima = Instantiate(spring_brick_anim, vPoint.point, quate) as GameObject;
             *
             * boards.Remove(thing.gameObject);
             * Destroy(thing.gameObject);
             */
        }
        else if (name == "cube1")
        {
            putong.Play();
        }
        else if (name == "bullet")
        {
            blood.add();
            Bomb.Play();

            GameObject bul_explore = Instantiate(bullet_explore_anim);
            bul_explore.transform.localScale = new Vector3(2.0f, 2.0f, 1.0f);

            ContactPoint vPoint = thing.contacts[0];                                     //获取第一个碰撞点

            Quaternion quate     = Quaternion.FromToRotation(Vector3.up, vPoint.normal); //碰撞点法线
            GameObject animation = Instantiate(bul_explore, vPoint.point, quate) as GameObject;
            bomb.Add(animation);
            bombtime.Add(frame);
            thing.gameObject.name = "nonactive";
            Destroy(bul_explore);
        }

        // Collision on GoldCoins
        else if (name == "GoldCoin")
        {
            isGoldAway = true;
            // Go to an inaccessible place
            RealGC.transform.position = new Vector3(100.0f, 100.0f, 0);
            // Coin add one
            coin.Add(1);
        }
    }
Beispiel #2
0
    void OnCollisionEnter(Collision thing)
    {
        var name = thing.collider.name;

        //Debug.Log("Thing is " + name);
        if (name == "cube2")
        {
            ci.Play();
            blood.add();
            if (blood_screen == null)
            {
                blood_screen = Instantiate(bloodscreen);
            }
        }
        else if (name == "cube3")
        {
            putong.Play();
            //Destroy(thing.collider);
        }
        else if (name == "cube4")
        {
            putong.Play();
        }
        else if (name == "cube5")
        {
            Debug.Log(name);
            ContactPoint vPoint = thing.contacts [0];                                       //获取第一个碰撞点

            Quaternion quate = Quaternion.FromToRotation(Vector3.up, new Vector3(0, 1, 0)); //碰撞点法线

            count = 0;
            suilie.Play();
            anima = Instantiate(break_brick_anim, vPoint.point, quate) as GameObject;

            breakarray.Add(anima);
            framearray.Add(frame);

            boards.Remove(thing.gameObject);
            Destroy(thing.gameObject);
        }
        else if (name == "cube6")
        {
            transform.Translate(new Vector3(0, 12, 0) * speed * Time.deltaTime);
            is_jumping    = false;
            ready_to_jump = true;
            tanhuang.Play();
        }
        else if (name == "cube1")
        {
            putong.Play();
        }
        else if (name == "bullet")
        {
            blood.add();
            Bomb.Play();

            GameObject bul_explore = Instantiate(bullet_explore_anim);
            bul_explore.transform.localScale = new Vector3(2.0f, 2.0f, 1.0f);

            ContactPoint vPoint = thing.contacts [0];                                    //获取第一个碰撞点

            Quaternion quate     = Quaternion.FromToRotation(Vector3.up, vPoint.normal); //碰撞点法线
            GameObject animation = Instantiate(bul_explore, vPoint.point, quate) as GameObject;
            bomb.Add(animation);
            bombtime.Add(frame);
            thing.gameObject.name = "nonactive";
            Destroy(bul_explore);
        }

        // Collision on GoldCoins
        else if (name == "GoldCoin")
        {
            GetCoins.Play();
            isGoldAway = true;
            // Go to an inaccessible place
            // RealGC.transform.position = new Vector3 (10000.0f, 10000.0f, 0);
            // RealGC.transform.position = new Vector3(0.08f, -6.9f, 0);

            Destroy(RealGC);
            // Coin add one
            coin.Add(1);
        }

        // Collision on MagicPotion
        else if (name == "MagicPotionOne")
        {
            GetMagicPotions.Play();
            isMP1Away = true;
            Destroy(RealMP1);
            //	NumberOfMP--;
            // RealMP1.transform.position = new Vector3(0.08f, -6.9f, 0); //new Vector3 (10000.0f, 10000.0f, 0);

            // HP add some
            blood.add3();
        }
        else if (name == "MagicPotionTwo")
        {
            GetMagicPotions.Play();
            isMP2Away = true;
            Destroy(RealMP2);
            NumberOfMP--;
            RealMP2.transform.position = new Vector3(0.08f, -6.9f, 0);            //new Vector3 (10000.0f, 10000.0f, 0);
            // HP add some
            blood.add3();
        }
    }