Esempio n. 1
0
    // Update is called once per frame
    void Start()
    {
        GameObject playButton = GameObject.Find("Play Button");

        buttonScript = playButton.GetComponent <PlayButtonController>();
        GameObject counter = GameObject.Find("Countdown");

        countdownScript = counter.GetComponent <countdown>();
    }
Esempio n. 2
0
    public void main()
    {
        /*
         * カウントダウンを行なっている
         */
        enabled  = false;
        countobj = GameObject.Find("countdown");
        countdown c1 = countobj.GetComponent <countdown>();

        c1.main();
    }
Esempio n. 3
0
 public bool startCountdown(GameObject clock)
 {
     if (currentClock == null)
     {
         currentClock = Instantiate(clock).GetComponent<countdown>();
         currentClock.gameObject.transform.SetParent(transform);
         currentClock.gameObject.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
     }
     if(currentClock.isActive == false)
     {
         Destroy(currentClock.gameObject);
         currentClock = null;
         return false;
     }
     return currentClock.isActive;
 }
Esempio n. 4
0
    void Start()
    {
        instance = this;
        string       save      = Resources.Load <TextAsset>("SetTimers").text;
        List <Timer> setTimers = JsonUtility.FromJson <Timers>(save).setTimers;

        GameObject clock = Instantiate(Resources.Load <GameObject>("Prefabs/clock"), stage);

        for (int i = 0; i < setTimers.Count; i++)
        {
            timer x = InitTimer(setTimers[i]);
            if (x)
            {
                runTimers.Add(x);
            }
        }
    }
Esempio n. 5
0
 // Use this for initialization
 void Start()
 {
     player    = GetComponent <Rigidbody>();
     script    = canvas.GetComponent <countdown> ();
     dbcontrol = new printhighscores();
 }
Esempio n. 6
0
    void Update()
    {
        // Reset functions

        if (Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }

        if (Input.GetKeyDown(KeyCode.T))
        {
            SendSerial.sendAndReceive("00");
        }

        //***********************************//

        if (Input.GetKey(KeyCode.W))
        {
            print("W");

            contactPoint1 = true;
        }
        else
        {
            contactPoint1 = false;
        }

        // ********************************* //

        if (Input.GetKey(KeyCode.A))
        {
            print("A");
            contactPoint2 = true;
        }
        else
        {
            contactPoint2 = false;
        }

        // ********************************* //

        if (Input.GetKey(KeyCode.S))
        {
            print("S");
            contactPoint3 = true;
        }
        else
        {
            contactPoint3 = false;
        }

        // ********************************* //

        if (Input.GetKey(KeyCode.D))
        {
            print("D");
            contactPoint4 = true;
        }
        else
        {
            contactPoint4 = false;
        }

        // ********************************* //

        if (Input.GetKey(KeyCode.F))
        {
            print("F");
            contactPoint5 = true;
        }
        else
        {
            contactPoint5 = false;
        }

        // ********************************* //

        if (Input.GetKey(KeyCode.G))
        {
            print("G");
            contactPoint6 = true;
        }
        else
        {
            contactPoint6 = false;
        }



        // ************************************************************************************************************************************ //
        // ************************************************************************************************************************************ //
        // **************** SET ONE ***************** //

        if (contactPoint2 == true && contactPoint4 == true)
        {
            if (stretchToBeDone == 1)
            {
                if (timerIsGoing == false)
                {
                    timeremaining = 10;
                    timerIsGoing  = true;
                }

                /*if (timeremaining < 3) {
                 *                      playDoneAudio ();
                 *              }*/

                isBlinking = false;

                if (isSolid == false)
                {
                    isSolid = true;
                    SendSerial.sendStretch8Solid();
                }

                timeremaining -= Time.deltaTime;

                if (timeremaining < 0 && timerIsGoing == true)
                {
                    timerIsGoing = false;

                    stretchToBeDone = 2;

                    addToStretchCount();

                    SendSerial.sendAndReceive("3");

                    playStartAudio();

                    //*****************************//

                    animator.SetInteger("movementInt", 2);

                    //*************************************//

                    turnOffAllCP();

                    SendSerial.sendOff();

                    //*************************************//

                    GameObject    go            = GameObject.Find("cp5");
                    cp_FIVE_class secondDisplay = (cp_FIVE_class)go.GetComponent(typeof(cp_FIVE_class));
                    secondDisplay.turnOnCP_FIVE();

                    //***************** PAN THE CAMERA BELOW ********************//

                    giveTheCameraAPan();
                }
            }
        }

        if (contactPoint2 == false || contactPoint4 == false)
        {
            if (stretchToBeDone == 1)
            {
                isSolid = false;

                if (isBlinking == false)
                {
                    isBlinking = true;
                    SendSerial.sendStretch8Blink();
                }
            }
        }



        if (contactPoint5 == true)
        {
            if (stretchToBeDone == 2)
            {
                if (timerIsGoing == false)
                {
                    timeremaining = 10;
                    timerIsGoing  = true;
                }

                isBlinking = false;

                if (isSolid == false)
                {
                    isSolid = true;
                    SendSerial.sendStretch2Solid();
                }

                timeremaining -= Time.deltaTime;

                if (timeremaining < 0 && timerIsGoing == true)
                {
                    timerIsGoing = false;

                    addToStretchCount();

                    SendSerial.sendAndReceive("3");

                    stretchToBeDone = 3;

                    playStartAudio();

                    //*****************************//

                    animator.SetInteger("movementInt", 3);

                    //*************************************//

                    turnOffAllCP();

                    SendSerial.sendOff();

                    //*************************************//

                    GameObject   go            = GameObject.Find("cp2");
                    cp_TWO_class secondDisplay = (cp_TWO_class)go.GetComponent(typeof(cp_TWO_class));
                    secondDisplay.turnOnCP_TWO();

                    //*************************************//

                    GameObject     go2 = GameObject.Find("cp3");
                    cp_THREE_class another_go_class = (cp_THREE_class)go2.GetComponent(typeof(cp_THREE_class));
                    another_go_class.turnOnCP_THREE();

                    //***************** PAN THE CAMERA BELOW ********************//

                    giveTheCameraAPan();
                }
            }
        }



        if (contactPoint5 == false)
        {
            if (stretchToBeDone == 2)
            {
                isSolid = false;

                if (isBlinking == false)
                {
                    isBlinking = true;
                    SendSerial.sendStretch2Blink();
                }
            }
        }



        if (contactPoint2 == true && contactPoint3 == true)
        {
            if (stretchToBeDone == 3)
            {
                if (timerIsGoing == false)
                {
                    timeremaining = 10;
                    timerIsGoing  = true;
                }

                isBlinking = false;

                if (isSolid == false)
                {
                    isSolid = true;
                    SendSerial.sendStretch5Solid();
                }

                timeremaining -= Time.deltaTime;

                if (timeremaining < 0 && timerIsGoing == true)
                {
                    timerIsGoing = false;

                    addToStretchCount();

                    SendSerial.sendAndReceive("3");

                    stretchToBeDone = 0;

                    playStartAudio();

                    time_sitting.setRunning();

                    //*****************************//

                    animator.SetInteger("movementInt", 33);

                    //*************************************//

                    turnOffAllCP();

                    SendSerial.sendOff();

                    SendSerial.finishedStretching();

                    //**************** RESTART CLOCK *********************//

                    GameObject go_clock    = GameObject.Find("clock");
                    countdown  clock_class = (countdown)go_clock.GetComponent(typeof(countdown));
                    clock_class.restartClock();
                }
            }
        }



        if (contactPoint2 == false || contactPoint3 == false)
        {
            if (stretchToBeDone == 3)
            {
                isSolid = false;

                if (isBlinking == false)
                {
                    isBlinking = true;
                    SendSerial.sendStretch5Blink();
                }
            }
        }



        // ************************************************************************************************************************************ //
        // ************************************************************************************************************************************ //
        // **************** SET TWO ***************** //

        if (contactPoint1 == true && contactPoint3 == true)
        {
            if (stretchToBeDone == 4)
            {
                if (timerIsGoing == false)
                {
                    timeremaining = 10;
                    timerIsGoing  = true;
                }

                /*if (timeremaining < 3) {
                 *                      playDoneAudio ();
                 *              }*/

                isBlinking = false;

                if (isSolid == false)
                {
                    isSolid = true;
                    SendSerial.sendStretch9Solid();
                }

                timeremaining -= Time.deltaTime;

                if (timeremaining < 0 && timerIsGoing == true)
                {
                    timerIsGoing = false;

                    stretchToBeDone = 5;

                    addToStretchCount();

                    SendSerial.sendAndReceive("3");

                    playStartAudio();

                    //*****************************//

                    animator.SetInteger("movementInt", 5);

                    //*************************************//

                    turnOffAllCP();

                    SendSerial.sendOff();

                    //*************************************//

                    GameObject    go            = GameObject.Find("cp5");
                    cp_FIVE_class secondDisplay = (cp_FIVE_class)go.GetComponent(typeof(cp_FIVE_class));
                    secondDisplay.turnOnCP_FIVE();

                    //*************************************//

                    GameObject   go2 = GameObject.Find("cp6");
                    cp_SIX_class another_go_class = (cp_SIX_class)go2.GetComponent(typeof(cp_SIX_class));
                    another_go_class.turnOnCP_SIX();

                    //***************** PAN THE CAMERA BELOW ********************//

                    giveTheCameraAPan();
                }
            }
        }



        if (contactPoint1 == false || contactPoint3 == false)
        {
            if (stretchToBeDone == 4)
            {
                isSolid = false;

                if (isBlinking == false)
                {
                    isBlinking = true;
                    SendSerial.sendStretch9Blink();
                }
            }
        }



        if (contactPoint5 == true && contactPoint6 == true)
        {
            if (stretchToBeDone == 5)
            {
                if (timerIsGoing == false)
                {
                    timeremaining = 10;
                    timerIsGoing  = true;
                }

                isBlinking = false;

                if (isSolid == false)
                {
                    isSolid = true;
                    SendSerial.sendStretch7Solid();
                }

                timeremaining -= Time.deltaTime;

                if (timeremaining < 0 && timerIsGoing == true)
                {
                    timerIsGoing = false;

                    addToStretchCount();

                    SendSerial.sendAndReceive("3");

                    stretchToBeDone = 6;

                    playStartAudio();

                    //*****************************//

                    animator.SetInteger("movementInt", 6);

                    //*************************************//

                    turnOffAllCP();

                    SendSerial.sendOff();

                    //*************************************//

                    GameObject   go            = GameObject.Find("cp2");
                    cp_TWO_class secondDisplay = (cp_TWO_class)go.GetComponent(typeof(cp_TWO_class));
                    secondDisplay.turnOnCP_TWO();

                    //***************** PAN THE CAMERA BELOW ********************//

                    giveTheCameraAPan();
                }
            }
        }



        if (contactPoint5 == false || contactPoint6 == false)
        {
            if (stretchToBeDone == 5)
            {
                isSolid = false;

                if (isBlinking == false)
                {
                    isBlinking = true;
                    SendSerial.sendStretch7Blink();
                }
            }
        }



        if (contactPoint2 == true)
        {
            if (stretchToBeDone == 6)
            {
                if (timerIsGoing == false)
                {
                    timeremaining = 10;
                    timerIsGoing  = true;
                }

                isBlinking = false;

                if (isSolid == false)
                {
                    isSolid = true;
                    SendSerial.sendStretch3Solid();
                }

                timeremaining -= Time.deltaTime;

                if (timeremaining < 0 && timerIsGoing == true)
                {
                    timerIsGoing = false;

                    addToStretchCount();

                    SendSerial.sendAndReceive("3");

                    stretchToBeDone = 0;

                    time_sitting.setRunning();

                    playStartAudio();

                    //*****************************//

                    animator.SetInteger("movementInt", 66);

                    //*************************************//

                    turnOffAllCP();

                    SendSerial.sendOff();

                    SendSerial.finishedStretching();

                    //**************** RESTART CLOCK *********************//

                    GameObject go_clock    = GameObject.Find("clock");
                    countdown  clock_class = (countdown)go_clock.GetComponent(typeof(countdown));
                    clock_class.restartClock();
                }
            }
        }



        if (contactPoint2 == false)
        {
            if (stretchToBeDone == 6)
            {
                isSolid = false;

                if (isBlinking == false)
                {
                    isBlinking = true;
                    SendSerial.sendStretch3Blink();
                }
            }
        }



        // ********************************* //
        // ********************************* //
        // ********************************* //
        // ********************************* //
        // ********************************* //
        // ********************************* //
        // ********************************* //
        // ********************************* //
        // ********************************* //
        // ********************************* //
        // *************** SET THREE ****************** //

        if (contactPoint1 == true && contactPoint4 == true)
        {
            if (stretchToBeDone == 7)
            {
                if (timerIsGoing == false)
                {
                    timeremaining = 10;
                    timerIsGoing  = true;
                }

                /*if (timeremaining < 3) {
                 *                      playDoneAudio ();
                 *              }*/

                isBlinking = false;

                if (isSolid == false)
                {
                    isSolid = true;
                    SendSerial.sendStretch6Solid();
                }

                timeremaining -= Time.deltaTime;

                if (timeremaining < 0 && timerIsGoing == true)
                {
                    timerIsGoing = false;

                    stretchToBeDone = 8;

                    addToStretchCount();

                    SendSerial.sendAndReceive("3");

                    playStartAudio();

                    //*****************************//

                    animator.SetInteger("movementInt", 8);

                    //*************************************//

                    turnOffAllCP();

                    SendSerial.sendOff();

                    //*************************************//

                    GameObject   go            = GameObject.Find("cp1");
                    cp_ONE_class secondDisplay = (cp_ONE_class)go.GetComponent(typeof(cp_ONE_class));
                    secondDisplay.turnOnCP_ONE();

                    //***************** PAN THE CAMERA BELOW ********************//

                    giveTheCameraAPan();
                }
            }
        }



        if (contactPoint1 == false || contactPoint4 == false)
        {
            if (stretchToBeDone == 7)
            {
                isSolid = false;

                if (isBlinking == false)
                {
                    isBlinking = true;
                    SendSerial.sendStretch6Blink();
                }
            }
        }



        if (contactPoint1 == true)
        {
            if (stretchToBeDone == 8)
            {
                if (timerIsGoing == false)
                {
                    timeremaining = 10;
                    timerIsGoing  = true;
                }

                isBlinking = false;

                if (isSolid == false)
                {
                    isSolid = true;
                    SendSerial.sendStretch4Solid();
                }

                timeremaining -= Time.deltaTime;

                if (timeremaining < 0 && timerIsGoing == true)
                {
                    timerIsGoing = false;

                    addToStretchCount();

                    SendSerial.sendAndReceive("3");

                    stretchToBeDone = 9;

                    playStartAudio();

                    //*****************************//

                    animator.SetInteger("movementInt", 9);

                    //*************************************//

                    turnOffAllCP();

                    SendSerial.sendOff();

                    //*************************************//

                    GameObject   go            = GameObject.Find("cp6");
                    cp_SIX_class secondDisplay = (cp_SIX_class)go.GetComponent(typeof(cp_SIX_class));
                    secondDisplay.turnOnCP_SIX();

                    //***************** PAN THE CAMERA BELOW ********************//

                    giveTheCameraAPan();
                }
            }
        }



        if (contactPoint1 == false)
        {
            if (stretchToBeDone == 8)
            {
                isSolid = false;

                if (isBlinking == false)
                {
                    isBlinking = true;
                    SendSerial.sendStretch4Blink();
                }
            }
        }



        if (contactPoint6 == true)
        {
            if (stretchToBeDone == 9)
            {
                if (timerIsGoing == false)
                {
                    timeremaining = 10;
                    timerIsGoing  = true;
                }

                isBlinking = false;

                if (isSolid == false)
                {
                    isSolid = true;
                    SendSerial.sendStretch1Solid();
                }

                timeremaining -= Time.deltaTime;

                if (timeremaining < 0 && timerIsGoing == true)
                {
                    timerIsGoing = false;

                    addToStretchCount();

                    SendSerial.sendAndReceive("3");

                    stretchToBeDone = 0;

                    time_sitting.setRunning();

                    playStartAudio();

                    //*****************************//

                    animator.SetInteger("movementInt", 99);

                    //*************************************//

                    turnOffAllCP();

                    SendSerial.sendOff();

                    SendSerial.finishedStretching();

                    //**************** RESTART CLOCK *********************//

                    GameObject go_clock    = GameObject.Find("clock");
                    countdown  clock_class = (countdown)go_clock.GetComponent(typeof(countdown));
                    clock_class.restartClock();
                }
            }
        }



        if (contactPoint6 == false)
        {
            if (stretchToBeDone == 9)
            {
                isSolid = false;

                if (isBlinking == false)
                {
                    isBlinking = true;
                    SendSerial.sendStretch1Blink();
                }
            }
        }
    }