Beispiel #1
0
        // 创建UI界面的水果;
        public static GameObject CreateUIFruit(GameObject parent, fruitType type, Vector3 vec)
        {
            GameObject obj = Instantiate(Resources.Load(UIPrafabs.oneFruit)) as GameObject;

            obj.transform.parent        = parent.transform;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localPosition = vec;
            FruitItem fruit = AddOneComponent <FruitItem>(obj);

            fruit.init(type);
            return(fruit.getOne());
        }
Beispiel #2
0
        public static GameObject loadFruit(GameObject parent, fruitType type, Vector3 vec)
        {
            GameObject go = Instantiate(Resources.Load(UIPrafabs.oneFruit)) as GameObject;

            go.transform.parent        = parent.transform;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = Vector3.zero;
            FruitItem fruit = AddOneComponent <FruitItem>(go);

            fruit.init(type);
            fruit.setPos(vec);
            return(fruit.getOne());
        }
Beispiel #3
0
        public void setUp(FruitItemOne fruit)
        {
            fruit.transform.localPosition = new Vector3(0f, GameData.mMaxBottomY);
            Rigidbody body = fruit.GetComponent <Rigidbody>();

            body.velocity = Vector3.zero;
            int randForceX = Random.Range(GameData.mMinUpForceX, GameData.mMaxUpForceX);
            int randForceY = Random.Range(GameData.mMinUpForceY, GameData.mMaxUpForceY);

            body.AddForce(new Vector3(randForceX, randForceY, 0f));
            int       rand = Random.Range((int)fruitType.apple, (int)fruitType.sandia);
            fruitType type = Framework.getTypeByID(rand);
            FruitItem item = fruit.GetComponentInParent <FruitItem>();

            item.init(type);
            body.isKinematic = false;
        }