コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey("escape"))
        {
            Application.Quit();
        }

        if (RumblingRightNow)
        {
            RumbleTimer += Time.deltaTime;
            CurrentRumble.UpdateRumble();
        }

        //if (ReadyToGetInputPreTime)
        //  PreTime += Time.deltaTime;

        if (ReadyToGetInput)
        {
            InputTime += Time.deltaTime;
        }

        //print(RumbleTimer);

        foreach (ControllerPlayer p in ControllerPlayers)
        {
            p.UpdateState();

            if (ReadyToGetInput)
            {
                if (inputCounter < ControllerPlayers.Count)
                {
                    // pressed
                    if (p.ButtonPressedRightNow(ButtonsToPress.A) == true && !p.HasInputted)
                    {
                        p.HasInputted = true;
                        inputCounter++;

                        float time;
                        time = InputTime;

                        bool correct = CurrentRumble.pattern == ButtonsToPress.A;

                        if (CurrentRumble is RightLeft)
                        {
                            if (CurrentRumble.pattern == ButtonsToPress.A || CurrentRumble.pattern == ButtonsToPress.B)
                            {
                                correct = true;
                            }
                        }

                        string test = string.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", (int)p.Index + 1, usingHelpPaper, CurrentRumble.ToString(), CurrentRumble.pattern, ButtonsToPress.A.ToString(), CurrentRumble.RumbleDuration, time, time - CurrentRumble.RumbleDuration, correct);

                        LoggingManager.AddTextNoTimeStamp(test);
                    }

                    if (p.ButtonPressedRightNow(ButtonsToPress.B) == true && !p.HasInputted)
                    {
                        p.HasInputted = true;
                        inputCounter++;

                        float time;
                        time = InputTime;

                        bool correct = CurrentRumble.pattern == ButtonsToPress.B;

                        if (CurrentRumble is RightLeft)
                        {
                            if (CurrentRumble.pattern == ButtonsToPress.B || CurrentRumble.pattern == ButtonsToPress.A)
                            {
                                correct = true;
                            }
                        }

                        string test = string.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", (int)p.Index + 1, usingHelpPaper, CurrentRumble.ToString(), CurrentRumble.pattern, ButtonsToPress.B.ToString(), CurrentRumble.RumbleDuration, time, time - CurrentRumble.RumbleDuration, correct);
                        LoggingManager.AddTextNoTimeStamp(test);
                    }

                    if (p.ButtonPressedRightNow(ButtonsToPress.X) == true && !p.HasInputted)
                    {
                        p.HasInputted = true;
                        inputCounter++;

                        float time;
                        time = InputTime;

                        bool correct = CurrentRumble.pattern == ButtonsToPress.X;

                        if (CurrentRumble is RightLeft)
                        {
                            if (CurrentRumble.pattern == ButtonsToPress.X || CurrentRumble.pattern == ButtonsToPress.Y)
                            {
                                correct = true;
                            }
                        }

                        string test = string.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", (int)p.Index + 1, usingHelpPaper, CurrentRumble.ToString(), CurrentRumble.pattern, ButtonsToPress.X.ToString(), CurrentRumble.RumbleDuration, time, time - CurrentRumble.RumbleDuration, correct);


                        LoggingManager.AddTextNoTimeStamp(test);
                    }

                    if (p.ButtonPressedRightNow(ButtonsToPress.Y) == true && !p.HasInputted)
                    {
                        p.HasInputted = true;
                        inputCounter++;

                        float time;
                        time = InputTime;

                        bool correct = CurrentRumble.pattern == ButtonsToPress.Y;
                        if (CurrentRumble is RightLeft)
                        {
                            if (CurrentRumble.pattern == ButtonsToPress.Y || CurrentRumble.pattern == ButtonsToPress.X)
                            {
                                correct = true;
                            }
                        }

                        string test = string.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", (int)p.Index + 1, usingHelpPaper, CurrentRumble.ToString(), CurrentRumble.pattern, ButtonsToPress.Y.ToString(), CurrentRumble.RumbleDuration, time, time - CurrentRumble.RumbleDuration, correct);

                        LoggingManager.AddTextNoTimeStamp(test);
                    }
                }
                else
                {
                    ReadyToGetInput = false;
                    //ReadyToGetInputPreTime = false;
                    inputCounter = 0;
                    InputTime    = 0;
                    //PreTime = 0;

                    if (!RumblingRightNow)
                    {
                        RemoveRumble();
                    }
                }
            }

            p.previousState = p.state;
        }
    }