protected override void ReadInput()
        {
            //End the Action Command after the command time
            if (ElapsedCommandTime >= CommandTime)
            {
                //Check to see how well the player did and send the appropriate result
                if (CurBarValue >= SuccessRange.StartBarVal)
                {
                    SendCommandRank(CommandRank.Nice);
                    OnComplete(CommandResults.Success);
                }
                else
                {
                    OnComplete(CommandResults.Failure);
                }

                return;
            }

            //Make the bar go down by a certain amount
            FillBar(-DecelerationRate, true);

            //Check if you pressed the correct button
            if (IsBarFull == false)
            {
                if (AutoComplete == true || Input.GetKeyDown(CurButton) == true)
                {
                    //If so, fill up the bar by the correct amount
                    FillBar(AmountPerPress, true);

                    //If the bar is full, the bar flashes color and deceleration no longer applies
                    if (IsBarFull == true)
                    {
                        DecelerationRate = 0d;
                    }
                }
            }
            else
            {
                //Interpolate the color of the bar
                //Interpolate the color of the bar
                float colorVal = UtilityGlobals.PingPong(ElapsedCommandTime / 300f, .3f, 1f);
                BarFillColor = new Color(colorVal, colorVal, colorVal, 1f);
            }

            ElapsedCommandTime += Time.ElapsedMilliseconds;

            //Check for switching buttons
            if (Time.ActiveMilliseconds >= PrevButtonSwitchTime)
            {
                //Wrap the button index
                CurButtonIndex = UtilityGlobals.Wrap(CurButtonIndex + 1, 0, ButtonsToPress.Length - 1);

                PrevButtonSwitchTime = Time.ActiveMilliseconds + ButtonSwitchTime;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Changes the current selection.
        /// </summary>
        /// <param name="amount">The amount to change the selection.</param>
        protected void ChangeSelection(int amount)
        {
            if (WrapCursor == false)
            {
                CurSelection = UtilityGlobals.Clamp(CurSelection + amount, 0, LastSelection);
            }
            else
            {
                CurSelection = UtilityGlobals.Wrap(CurSelection + amount, 0, LastSelection);
            }

            OnSelectionChanged(CurSelection);
        }
        /// <summary>
        /// Updates the color of the lines by cycling through the array of defined colors.
        /// </summary>
        private void CycleLineColors()
        {
            //Increment elapsed time
            ColorElapsedTime += Time.ElapsedMilliseconds;

            //Compare the current color with the next, and wrap around
            int nextColorIndex = UtilityGlobals.Wrap(ColorIndex + 1, 0, CycleColors.Length - 1);

            //Lerp the colors
            LineColor = Color.Lerp(CycleColors[ColorIndex], CycleColors[nextColorIndex], (float)(ColorElapsedTime / ColorDuration));

            //Move onto the next color and reset the elapsed time
            if (ColorElapsedTime >= ColorDuration)
            {
                ColorIndex       = nextColorIndex;
                ColorElapsedTime = 0d;
            }
        }