Example #1
0
    // In every other mode the user has to click on this box
    private void SetHitboxAtPosition()
    {
        // Check when the hitbox can be hit
        if (_timeSystem.IsTakingBreak)
        {
            return;
        }

        // Find out which position the hitbox is at
        if (_currentPositon == null)
        {
            _index = 0;

            // Set the current and next positions
            CurrentPosition = _positionList[_index];
            NextPosition    = _positionList[_index];

            // Set the hitbox to currentposition
            transform.position = _currentPositon.Pos;
        }
        else if (_nextPosition == null)
        {
            return;
        }
        else if (_nextPosition.TimePassed(_timeSystem.Now))
        {
            // When the system has gotten passed the next position, set next to current
            CurrentPosition = _nextPosition;

            // Find next position on new index (new index set by changing the current position, see line 39)
            if (_index >= _positionList.Count)
            {
                if (!hasbeenselected)
                {
                    MissedBox();
                }
                _boxResult.gameObject.SetActive(false);
                _nextPosition = null;
            }
            else
            {
                NextPosition = _positionList[_index];
            }
        }
        // When not passed the next position, but passed the current position
        else if (_currentPositon.TimePassed(_timeSystem.Now))
        {
            // Make the hitbox active (for when the currentposition is the starting position)
            _boxResult.gameObject.SetActive(true);

            // Make the hitbox move to the next frame in the scene
            timestep          += _timeSystem.TimeStep / timeToReach;
            transform.position = Vector3.Lerp(_currentPositon.Pos, _nextPosition.Pos, timestep);
        }
    }
Example #2
0
    // Called when the scene is started to set the modes that are being used
    public void StartHitbox(ModeStop mStop, ModeFeedback mFeedback)
    {
        // Set the mode
        modeStop = mStop;

        // Reset all the variables neccessary
        _currentPositon = null;
        _nextPosition   = null;

        hasbeenselected = false;
        hastakenbreak   = false;

        // Tell the result script which feedback mode to use
        _boxResult.ResetResults(mFeedback);
    }
Example #3
0
 // Calculate how much time in between positions
 public static float SecondsBetween(HitboxPosition startPos, HitboxPosition endPos)
 {
     return(TimeStamp.TimeBetween(startPos.TimePosition, endPos.TimePosition));
 }