示例#1
0
    // Update is called once per frame
    void Update()
    {
        foreach (whaleClass w in whaleList2)
        {
            if (w.whale.GetComponent <ActionObject>().ClickedOn(/*kinectClickedOn, clickedPos*/))
            {
                w.targetPos = Utility.GetRandomVector(0f, 5f, 5f, 10f);
                w.whale.GetComponent <ActionObject>().MoveTowardsTarget(w.targetPos);
                music.PlayFeedback(music.pos);
            }
            if (Utility.V3Equal(w.whale.GetComponent <ActionObject>().pos, w.targetPos))
            {
                w.targetReached = true;
                print("Change target pos");
                w.targetPos = Utility.GetRandomVector(10);
                w.whale.GetComponent <ActionObject>().MoveTowardsTarget(w.targetPos);
            }
            if (w.targetReached)
            {
                lineCount++;
            }
        }
        //kinectClickedOn = false;
        if (lineCount == numObjects)
        {
            GetComponent <AquariumGame> ().enabled = false;
            GetComponent <Main> ().enabled         = true;

            foreach (whaleClass w in whaleList2)
            {
                Vector3 off = new Vector3(-4, 0, 0);
                w.whale.GetComponent <ActionObject>().MoveTowardsTarget(off);
            }
        }
        lineCount = 0;
    }
示例#2
0
    void Update()
    {
        if (end)
        {
            Debug.Log("Moving offscreen");
            foreach (whaleWithState w in whaleList)
            {
                w.whale.GetComponent <ActionObject>().MoveTowardsTarget(offscreenPos);
            }
            GetComponent <LineGame>().enabled = false;
            GetComponent <Main>().enabled     = true;
        }
        else
        {
            //			audioIsPlaying = false;
            foreach (whaleWithState w in whaleList)
            {
                ActionObject script = w.whale.GetComponent <ActionObject>();
                switch (w.state)
                {
                case objectState.NORMAL:
                    /*kinectClickedOn, clickedPos*/
                    if (script.ClickedOn())
                    {
                        w.state = objectState.MOVINGTO;
                        script.MoveTowardsTarget(w.targetPos);
                        break;
                    }
                    break;

                case objectState.MOVINGTO:
                    //print ("MOVING TO");
                    if (Utility.V3Equal(script.pos, w.targetPos))
                    {
                        lineCount++;
                        if (lineCount == numObjects)
                        {
                            //all objects must dive
                            music.PlayFeedback(music.neg);
                            foreach (whaleWithState item in whaleList)
                            {
                                item.state = objectState.SHOULD_DIVE;
                            }
                        }
                        else
                        {
                            w.state = objectState.DONE;
                        }
                    }
                    break;

                case objectState.SHOULD_DIVE:
                    //print ("DIVING");
                    w.diveTargetPos.x = w.targetPos.x - 0.5f;
                    w.diveTargetPos.y = w.targetPos.y - 1;
                    script.MoveTowardsTarget(w.diveTargetPos);
                    w.state = objectState.DIVING;
                    lineCount--;
                    break;

                case objectState.DIVING:
                    //print ("IS DIVING");
                    if (Utility.V3Equal(script.pos, w.diveTargetPos))
                    {
                        lineCount++;
                        if (lineCount == numObjects)
                        {
                            //all objects must dive
                            foreach (whaleWithState item in whaleList)
                            {
                                item.state = objectState.RESTART;
                            }
                        }
                        else
                        {
                            w.state = objectState.DONE;
                        }
                    }
                    break;

                case objectState.DONE:
                    break;

                case objectState.RESTART:
                    Debug.Log("RESTART");
                    foreach (whaleWithState item in whaleList)
                    {
                        item.state = objectState.DONE;
                        lineCount--;
                    }
                    end = true;

                    /*
                     * whalePos = script.GetRandomVector(8);
                     * script.pos = whalePos;
                     * script.targetLocation = whalePos;
                     * w.state = objectState.NORMAL;
                     * w.targetPos.y = 0;
                     * lineCount--;
                     * audioIsPlaying = false;
                     */
                    break;
                }
            }
        }
        //kinectClickedOn = false;
    }