private void EndTheTurn(TurnEndCheck tec) {
		Game.Instance.circleGuiObj.SetActive(false);
		Game.Instance.TriggerWaitForTurnOver();
		if(!Game.Instance.turnOver) {
			Game.Instance.StopWaitForStunOver();
			Game.Instance.CancelStun();
			Game.Instance.SetText("breathe...");
			return;
		}

		Game.Instance.StopWaitForTurnOver();
		TurnEnd turnEnd = Game.Instance.CalculateTurnSuccess(tec);
		if(turnEnd.successful) {
			StateManager.Instance.ChangeGameState(GameStateId.GoodTurn);
		}
		else {
			StateManager.Instance.ChangeGameState(GameStateId.BadTurn);
		}
	}
Esempio n. 2
0
	public TurnEnd CalculateTurnSuccess(TurnEndCheck tec) {
		this.turnEnd.successful = false;

		switch(tec) {
			// turn time is up, fill the rest of the buttons with failure
			case TurnEndCheck.OutOfTime:
				// fallthrough
				goto case TurnEndCheck.CompletedActions;
			case TurnEndCheck.CompletedActions:
				float CCC = (float) this.turnInfo.currentIdx;
				float EEE = (float) this.turnInfo.numActionsExpected;
				float PPP = (float) this.turnInfo.numActionsPerformed;
				float ratioTop = CCC;
				float ratioBottom = 0.0f;
				// E > P
				if(this.turnInfo.numActionsExpected > this.turnInfo.numActionsPerformed) {
					ratioBottom = EEE + (EEE - PPP);
				}
				// E < P
				else if (this.turnInfo.numActionsExpected < this.turnInfo.numActionsPerformed){
					ratioBottom = EEE + (PPP - EEE) * Difficulty.imperfectModifier;
				}
				// E == P
				else {
					ratioBottom = EEE;
				}
				ratioBottom *= Difficulty.ratioModifier;

				this.currentRatio = ratioTop / ratioBottom;
				this.totalScore.sumRatio += this.currentRatio;

				// Debug.Log("e." + EEE + " -- p; + PPP + " -- c." + CCC);
				// Debug.Log("ratio: " + this.currentRatio + " = " + ratioTop + " / " + ratioBottom);
				Debug.Log("ratio: " + this.currentRatio);
				if(this.currentRatio > Difficulty.ratioToTurnSuccess) {
					this.turnEnd.successful = true;
				}
				break;
			case TurnEndCheck.NotYet:
				Debug.Log("turn hasnt ended. shouldnt calculate success");
				Debug.Break();
				break;
			default:
				Debug.Log("unknown turn end check");
				Debug.Break();
				break;
		}

		return this.turnEnd;
	}