예제 #1
0
        /// <summary>
        /// Calculate the current combo value, update the combomultipier if applicable
        /// </summary>
        /// <param name="roundResult"></param>
        public void HandleCombo(RoundResultInfo roundResult)
        {
            ComboMultiplier = 0;
            switch (roundResult.State)
            {
            case FinishState.Right:
                OverallResult.Combo++;
                break;

            case FinishState.Wrong:
                OverallResult.Combo = 0;
                break;

            case FinishState.Timeout:
            case FinishState.Quit:
                OverallResult.Combo = 0;
                break;
            }

            if (OverallResult.Combo > OverallResult.MaxStreak)
            {
                OverallResult.MaxStreak = OverallResult.Combo;
            }
            if (RewardComboInterval > 0)
            {
                if (OverallResult.Combo % RewardComboInterval == 0)
                {
                    ComboMultiplier           = OverallResult.Combo / RewardComboInterval;
                    OverallResult.EarnedLoot += (ComboReward * ComboMultiplier);
                    Debug.LogFormat("ComboMultiplier set to {0}, added ", ComboMultiplier, (ComboReward * ComboMultiplier));
                }
            }
        }
예제 #2
0
        public IEnumerator RoundComplete(Mission m, RoundResultInfo result)
        {
            var key = eventManager.OnRoundEndInvoke(result);

            while (EventMonitor.IsRunning(key))
            {
                yield return(null);
            }
            yield return(null);
        }
예제 #3
0
        public void HandlePoints(RoundResultInfo roundResult)
        {
            var m = roundResult.MyMission;

            switch (m.MissionType)
            {
            case MissionTypes.Sprint:
                // time limit counts down to a specified amount of rounds
                switch (roundResult.State)
                {
                case FinishState.Right:
                    var timeSlice     = m.TotalSeconds / m.Rounds;
                    var roundProgress = roundResult.Round / m.Rounds;
                    var baseTimeSlice = (timeSlice * m.TimeExchangeRate);
                    roundResult.RoundLoot.Time += (baseTimeSlice + (baseTimeSlice * roundProgress));
                    break;

                case FinishState.Wrong:
                    break;
                }
                break;

            case MissionTypes.ByRound:
                // you start with a given amount each round, for a specified number of rounds
                var remainingTime       = m.OverallResult.MissionTime;
                var remainingPercentage = 1 - m.OverallResult.Progress;
                switch (roundResult.State)
                {
                case FinishState.Right:
                    roundResult.RoundLoot.Time += (remainingTime * m.TimeExchangeRate);
                    break;

                case FinishState.Wrong:
                    break;
                }
                break;

            case MissionTypes.Survival:
                // rename this one.  maybe time attack or something
                // real survival could be pay a certain amount of time, then use that time to get as high a combo as possible, or a time target for
                // bonuses (tokens, coins)

                // you pay an initial fee of time to play.  then you get the chance to earn back
                // that time and more, if you play well enough.  But this scoring only happens at the end of the mission
                switch (roundResult.State)
                {
                case FinishState.Right:
                    break;

                case FinishState.Wrong:
                    break;
                }
                break;
            }
        }
예제 #4
0
        public IEnumerator StageComplete(Mission m, RoundResultInfo result)
        {
            var key = eventManager.OnStageEndInvoke(m);

            while (EventMonitor.IsRunning(key))
            {
                yield return(null);
            }
            yield return(StartCoroutine(RunMissionComplete(key, m)));

            yield return(null);
        }
예제 #5
0
 private IEnumerator HandleTimeAdjustment(string eventId, RoundResultInfo roundInfo)
 {
     EventMonitor.StartEvent(eventId);
     if (roundInfo.TimeAdjustment != 0)
     {
         AdjustmentText.text = string.Format("{0}{1}", roundInfo.TimeAdjustment > 0 ? "+" : "-", TimeUtility.FormattedTime_MSSMM(roundInfo.TimeAdjustment));
         textAnim.SetTrigger(roundInfo.TimeAdjustment > 0 ? "AddTime" : "RemoveTime");
         yield return(new WaitForSeconds(.25f));
     }
     EventMonitor.EndEvent(eventId);
     yield return(null);
 }
예제 #6
0
        /// <summary>
        /// Apply any adjustments to the time remaining that may apply for this mission based on the round result
        /// </summary>
        /// <param name="roundResult"></param>
        public void AdjustTime(RoundResultInfo roundResult)
        {
            float adjustment = 0;

            switch (MissionType)
            {
            case MissionTypes.Sprint:
            case MissionTypes.ByRound:
                break;

            case MissionTypes.Survival:
                adjustment = GetTimeAdjustmentForSurvival(roundResult.State, roundResult.Round);
                OverallResult.TimeRemaining += adjustment;
                break;
            }
            roundResult.TimeAdjustment = adjustment;
        }
예제 #7
0
        /// <summary>
        /// Process the round result and determing if we need to continue
        /// </summary>
        /// <param name="roundResult"></param>
        /// <param name="Round"></param>
        /// <returns>boolean whether or not to continue the mission</returns>
        public bool ProcessRoundResult(RoundResultInfo roundResult, ref int Round)
        {
            var continueMission = true;

            HandleCombo(roundResult);
            // adjust some time, based on the result
            AdjustTime(roundResult);
            HandlePoints(roundResult);

            OverallResult.EarnedLoot += roundResult.RoundLoot;

            switch (roundResult.State)
            {
            case FinishState.Right:
                break;

            case FinishState.Wrong:
                OverallResult.Failures++;
                if (Chances > 0 && OverallResult.Failures >= Chances)
                {
                    OverallResult.ResultType = MissionResultType.Failure;
                }
                break;

            case FinishState.Timeout:
                OverallResult.ResultType = MissionResultType.Timeout;
                break;

            case FinishState.Quit:
                OverallResult.ResultType = MissionResultType.Quit;
                break;
            }

            // check for a resulttype (unknown means it's still playing, or the max rounds being exceeded
            if (OverallResult.ResultType != MissionResultType._Unknown ||
                RoundsExceeded(Round, Rounds))
            {
                continueMission = false;
            }

            Round++;
            return(continueMission);
        }
예제 #8
0
        private IEnumerator Game()
        {
            var continueMission = true;
            var currentMission  = SetCurrentMission(currentMissionIndex);

            yield return(StartCoroutine(MissionChosen(currentMission)));

            // coroutine to show deducting the cost
            ProgressPanel.ToggleMenu();

            currentMission.OverallResult.Reset();
            if (currentMission.UseOverallTime)
            {
                currentMission.OverallResult.TimeRemaining = currentMission.TotalSeconds;
            }

            Debug.LogFormat("starting mission with {0} seconds.", currentMission.OverallResult.TimeRemaining);

            yield return(StartCoroutine(StageStart()));

            var roundResult = new RoundResultInfo(currentMission);

            switch (currentMission.MissionType)
            {
            case MissionTypes.Sprint:
                break;

            case MissionTypes.Survival:
                break;
            }
            Round = 1;
            while (continueMission)
            {
                mCurrentRoundData = GameProgression.GetRound(PlayerData.Level, PlayerData.Stage, Round, LED1.LEDArraySize);
                yield return(StartCoroutine(RoundStart(mCurrentRoundData)));

                var         highMessage  = mCurrentRoundData.High ? "     HIGHER!   " : "     LOWER!   "; // change this to an event or setter call
                ButtonState correctBtn   = mCurrentRoundData.Led1Right ? ButtonState.LEFT : ButtonState.RIGHT;
                ButtonState incorrectBtn = correctBtn == ButtonState.LEFT ? ButtonState.RIGHT : ButtonState.LEFT;
                LEDRendering.Graph(mCurrentRoundData.LEDInfo[0].graphType, LED1,
                                   mCurrentRoundData.LEDInfo[0].StartX, mCurrentRoundData.LEDInfo[0].StartY,
                                   mCurrentRoundData.LEDInfo[0].Count,
                                   mCurrentRoundData.LEDInfo[0].InvertX, mCurrentRoundData.LEDInfo[0].InvertY);

                LEDRendering.Graph(mCurrentRoundData.LEDInfo[1].graphType, LED2,
                                   mCurrentRoundData.LEDInfo[1].StartX, mCurrentRoundData.LEDInfo[1].StartY,
                                   mCurrentRoundData.LEDInfo[1].Count,
                                   mCurrentRoundData.LEDInfo[1].InvertX, mCurrentRoundData.LEDInfo[1].InvertY);

                float timeAdjustment = roundResult.TimeAdjustment;
                roundResult.Reset(Round);

                currentMission.OverallResult.StartTime = Time.time;
                var loop = true;
                ClearButtonState();
                var _gameState        = FinishState.None;
                int progressDashCount = 16;
                updateTimer = true;
                while (loop)
                {
                    //currentMission.TimerTick(mCurrentRoundData);

                    currentTimeValues.SetValues(currentMission.OverallResult.MissionTime, currentMission.OverallResult.Progress, currentMission.UseOverallTime);
                    yield return(StartCoroutine(TimerUpdate(currentTimeValues)));

                    progressDashCount = 16 - (Mathf.RoundToInt(16 * currentMission.OverallResult.Progress));
                    var progressMessage = progressDashCount > 0 ? new string('-', progressDashCount) : "";

                    //              Debug.LogFormat("progress: {0}", progress);
                    if (currentMission.OverallResult.Progress >= 1)
                    {
                        loop       = false;
                        _gameState = FinishState.Timeout;
                        continue;
                    }
                    if (_buttonState == ButtonState.MID)
                    {
                        //Debug.Log("exit");
                        loop       = false;
                        _gameState = FinishState.Quit;
                    }
                    else if (_buttonState == correctBtn)
                    {
                        //Debug.Log("right");
                        loop       = false;
                        _gameState = FinishState.Right;
                    }
                    else if (_buttonState == incorrectBtn)
                    {
                        //Debug.Log("wrong");
                        loop       = false;
                        _gameState = FinishState.Wrong;
                    }
                    yield return(null);
                }
                updateTimer       = false;
                _buttonState      = ButtonState.NONE;
                roundResult.State = _gameState;

                continueMission = currentMission.ProcessRoundResult(roundResult, ref Round);
                yield return(StartCoroutine(RoundComplete(currentMission, roundResult)));
            }
            if (currentMission.OverallResult.ResultType == MissionResultType._Unknown)
            {
                // if at this point it's still unknown, then nothing bad happened.  Success!
                currentMission.OverallResult.ResultType = MissionResultType.Complete;
            }
            yield return(StartCoroutine(StageComplete(currentMission, roundResult)));

            yield return(null);
        }
예제 #9
0
 public void OnRoundEnd(string eventId, RoundResultInfo roundInfo)
 {
     StartCoroutine(UpdateWalletAndDisplayAsync(eventId, roundInfo.MyMission.OverallResult.EarnedLoot));
 }
예제 #10
0
 public string OnRoundEndInvoke(RoundResultInfo result)
 {
     OnRoundEnd.Invoke(OnRoundEndKey, result);
     return(OnRoundEndKey);
 }
예제 #11
0
 public void OnRoundEnd(string eventId, RoundResultInfo roundInfo)
 {
     StartCoroutine(HandleTimeAdjustment(eventId, roundInfo));
 }
예제 #12
0
 public void OnRoundEnd(string eventId, RoundResultInfo roundInfo)
 {
     SetComboText(roundInfo.MyMission.OverallResult.Combo);
 }