Exemplo n.º 1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space) || Input.acceleration.magnitude > maxAcceleration)
        {
            if (isReachTop)
            {
                ShowOverUI(true);
            }
            else
            {
                ShowContinueUI(true);
            }

            Pause(true);
            FallApple();
        }

        if (isPause)
        {
            return;
        }

        Vector3 targetPos;

        MathfHelper.GetScreenPos(out targetPos, transform.position);
        guidSprite.transform.position = targetPos;

        if (Input.GetMouseButtonDown(0) && _maxNum < maxNum)
        {
            _maxNum++;

            trunkParentList.Add(new GameObject("Tree" + trunkCount.ToString()).transform);
            GameObject go = Instantiate(trunkPrefab);
            go.transform.position = new Vector3(targetPos.x, bornPos.position.y, 0);

            go.transform.SetParent(trunkParentList[trunkCount]);
            Branch        branch     = new Branch(go);
            List <Branch> branchList = new List <Branch>();
            branchList.Add(branch);
            trunkDic.Add(trunkCount, branchList);
            trunkCount++;

            //========================================

            rootParentList.Add(new GameObject("Root" + rootCount.ToString()).transform);
            GameObject root = Instantiate(rootPrefab);
            root.transform.position = new Vector3(targetPos.x, bornPos.position.y, 0);

            root.transform.SetParent(rootParentList[rootCount]);
            Branch rootBranch = new Branch(root);

            List <Branch> rootList = new List <Branch>();

            rootList.Add(rootBranch);
            rootDic.Add(rootCount, rootList);
            rootCount++;
        }
        ControlPlants(trunkDic, Type.Branch);
        ControlPlants(rootDic, Type.Root);
    }
Exemplo n.º 2
0
    void Update()
    {
        Vector3 targetPos;

        MathfHelper.GetScreenPos(out targetPos, transform.position);

        if (Input.GetMouseButtonDown(1))
        {
            GameObject go = Instantiate(applePrefab);
            go.transform.position = targetPos;
        }
    }