Exemple #1
0
    public void SetGold4(GlodType type, float z, float time, int num_rc)
    {
        GameObject player = GameObject.Find("Player");

        Vector3 newpos = new Vector3(0, 0.3590007f, player.transform.position.z + z);

        //Vector3 newpos2 = new Vector3(0, 0.3590007f, player.transform.position.z + z);
        num_rc4 = num_rc;
        if (type == GlodType.Red)
        {
            GameObject gold = GameObject.Instantiate <GameObject>(obs5[num_rc]);
            gold.transform.position = newpos;
            gold.transform.SetParent(glodParents.transform);
        }

        if (type == GlodType.Blue || type == GlodType.Yellow)
        {
            //System.Random r = new System.Random();
            int num = r.Next(0, 48);

            if (num >= num_rc * 6 && num < (num_rc * 6 + 6))
            {
                if (num_rc == 0)
                {
                    num = r.Next(6, 48);
                }
                else if (num_rc == 1)
                {
                    num = r.Next(12, 48);
                }
                else
                {
                    num = r.Next(0, num_rc * 6);
                }
            }

            //Debug.Log(num*10000);
            GameObject gold = GameObject.Instantiate <GameObject>(obs5b[num]);    //obs4与obs4b顺序是一种映射关系,不要变 !!!!!!
            gold.transform.position = newpos;
            gold.transform.SetParent(glodParents.transform);
        }


        if (type == GlodType.ob)
        {
            //System.Random r = new System.Random();
            int num = r.Next(0, 12);
            //Debug.Log(num);

            GameObject gold = GameObject.Instantiate <GameObject>(myobs[num]);
            gold.transform.position = newpos;
            gold.transform.SetParent(glodParents.transform);
        }


        // 延迟消失
        CancelInvoke("DisplayGlod");
        Invoke("DisplayGlod", time);
    }
Exemple #2
0
    // 添加一个标识
    public void SetGold(GlodType type, float z, float time)
    {
        GameObject player = GameObject.Find("Player");

        Vector3 newpos = new Vector3(0, 0, player.transform.position.z + z);

        //Vector3 newpos2 = new Vector3(0, 0.3590007f, player.transform.position.z + z);
        if (type == GlodType.Red)
        {
            //Debug.Log(1111);
            GameObject gold = GameObject.Instantiate <GameObject>(golds[0]);
            gold.transform.position = newpos;
            gold.transform.SetParent(glodParents.transform);
        }

        if (type == GlodType.Blue)
        {
            //System.Random r = new System.Random();
            int num = r.Next(1, 7);
            //Debug.Log(num);

            GameObject gold = GameObject.Instantiate <GameObject>(golds[num]);
            gold.transform.position = newpos;
            gold.transform.SetParent(glodParents.transform);
        }

        if (type == GlodType.Yellow)
        {
            //System.Random r = new System.Random();
            int num = r.Next(1, 7);
            //Debug.Log(num);

            GameObject gold = GameObject.Instantiate <GameObject>(golds[num]);
            gold.transform.position = newpos;
            gold.transform.SetParent(glodParents.transform);
        }

        if (type == GlodType.ob)
        {
            //System.Random r = new System.Random();
            int num = r.Next(0, 12);
            //Debug.Log(num);

            GameObject gold = GameObject.Instantiate <GameObject>(myobs[num]);
            gold.transform.position = newpos;
            gold.transform.SetParent(glodParents.transform);
        }


        // 延迟消失
        CancelInvoke("DisplayGlod");
        Invoke("DisplayGlod", time);
    }