/// <summary> /// Set the choice of the local player /// </summary> /// <param name="type">Which round type they are selecting</param> public void SetMyChoice(RoundTypes type) { myChoice = type; switch (type) { case RoundTypes.Assess: MultiplayerController.Instance.SendAssessRequest(); break; case RoundTypes.Escalate: MultiplayerController.Instance.SendEscalationRequest(); break; case RoundTypes.Fight: MultiplayerController.Instance.SendFightRequest(); break; case RoundTypes.RunAway: MultiplayerController.Instance.SendFleeRequest(); break; } //Setting the choices of players dependant on who is keeping track Debug.Log("Check track?????????????????????????????????????????????????????"); if (GameInfo.current.isKeepingTrack) { SetNames(); Debug.Log("Keeping track"); RoundInfo.current.userOneMiniGameChoice = type.ToString(); } else { RoundInfo.current.userTwoMiniGameChoice = type.ToString(); Debug.Log("Not Keeping track"); } CheckChoices(); }
/// <summary> /// Called when the enemy's choice is received /// </summary> /// <param name="type"></param> public void SetEnemyChoice(RoundTypes type) { RoundInfo.current.PopulateFromGameInfo(); enemyChoice = type; //Setting the choices of players dependant on who is keeping track if (GameInfo.current.isKeepingTrack) { SetNames(); RoundInfo.current.userTwoMiniGameChoice = type.ToString(); } else { RoundInfo.current.userOneMiniGameChoice = type.ToString(); } CheckChoices(); }
/// <summary> /// Whenever the player makes their choice or the enemy's choice is received /// Check to see if both choices are made and then take action /// </summary> void CheckChoices() { if (enemyChoice != RoundTypes.none && myChoice != RoundTypes.none) { //If either player is trying to run away, inform the other player and set them as the winner if (myChoice == RoundTypes.RunAway || enemyChoice == RoundTypes.RunAway) { roundsPlayed++; ResultsUI.instance.runAwayPanel.SetActive(true); if (myChoice == RoundTypes.RunAway) { ResultsUI.instance.runAwayPanelValue.text = "You have run away"; } else { ResultsUI.instance.runAwayPanelValue.text = "Your enemy has run away\n\nYou have won"; MiniGameTracker.instance.GiveXP(50); } GameInfo.current.SendToGameSparks(); } //If both choices match then load the correct scene else if (enemyChoice == myChoice) { roundsPlayed++; RoundInfo.current.miniGameOutcome = myChoice.ToString(); LoadMiniGame(); } //If the enemy's choice has a higher value than the local players choice then the local player will need to select again else if (roundValues[enemyChoice] > roundValues[myChoice]) { //Make user choose again Debug.Log("I Need to choose again"); myChoice = RoundTypes.none; ResultsUI.instance.enemyChosePanel.SetActive(true); ResultsUI.instance.enemyChoseValue.text = enemyChoice.ToString(); } //Likewise if the local players choice has a higher value than the enemy's choice, the enemy will need to choose again //They will have the same calculation on their device and will know so no information needs to be sent else if (roundValues[myChoice] > roundValues[enemyChoice]) { //Make enemy choose again Debug.Log("Enemy needs to choose again"); enemyChoice = RoundTypes.none; } } }