public void UISelectPlayerAttack(Attack selected) { // Disable all of the attack buttons (until enemy does its attack). foreach (var b in selectActionButtons) { b.GetComponent <Button>().interactable = false; } foreach (var b in selectElementButtons) { b.GetComponent <Button>().interactable = false; } // foreach(var b in doActionButtons) { b.GetComponent<Button>().interactable = false; } // Clicking any attack button triggers the attack. We then add the attack (and its result) // to the UIMoveLogMenu. bool successful = playerManager.DoAttack(enemyManager, selected); if (successful) { enemyManager.GetComponent <UIHitMarkerDisplay>().ShowHit(selected); } else { enemyManager.GetComponent <UIHitMarkerDisplay>().ShowMiss(selected); } PlayerActionResult result = new PlayerActionResult(playerManager.Element, selected, successful); UIMoveLogMenu.GetComponent <MoveLogManager>().AppendPlayerLogEntry(result); this.NextTurn(); }
public PlayerActionResult DoAction(PlayerAction action) { action.player = this; PlayerActionResult result = action.Execute(); return(result); }
public void OnButtonDrawCard() { if (GameController.instance.isPrintingText) { return; } if (hasDrawnToDeck) { if (!DrawNewCard()) { Debug.Log("Player drew a new card and busted."); GameController.instance.DisplayText(participantName + " drew a new letter and busted."); playerPAR = PlayerActionResult.Busted; } else { Debug.Log("Player drew a new card to their hand"); GameController.instance.DisplayText(participantName + " drew a new letter to their hand."); playerPAR = PlayerActionResult.DrawnToHand; } } else { GameController.instance.SetLineup(LetterController.instance.GenerateRandomLetter(), true); hasDrawnToDeck = true; Debug.Log("Player drew a new card to the deck"); GameController.instance.DisplayText(participantName + " drew a new letter to the playing field."); playerPAR = PlayerActionResult.DrawnToDeck; } }
public static String GetActionResultText(this PlayerActionResult actionResult) { switch (actionResult) { case PlayerActionResult.movedSafe: return("moved to safe tile"); case PlayerActionResult.movedOnMine: return("BOOM!!"); case PlayerActionResult.error: return("invalid move out of grid or inexistent option"); case PlayerActionResult.win: return("you won the game"); case PlayerActionResult.lose: return("you lost the game"); case PlayerActionResult.exit: return("you exited the game"); default: return("Unknown"); } }
/* * Perform Bayesian updates to calculate the true probability distribution * over enemy elements given the region, attributes, and actions. */ public static ElementDistribution ComputePosterior( Region region, Attribute attr, List <PlayerActionResult> player_actions, List <EnemyActionResult> enemy_actions) { // Step 1: Incorporate the prior information from the region. ElementDistribution prior = P_ELEMENT_GIVEN_REGION[region]; ElementDistribution posterior = Normalize(prior); // Step 2: Incorporate the attribute that was observed. ElementDistribution p_attr_all_elements = new ElementDistribution(); // i.e p(furry | water) List <Element> element_list = new List <Element>(P_ATTR_GIVEN_ELEMENT.Keys); for (int i = 0; i < element_list.Count; ++i) { Element element = element_list[i]; p_attr_all_elements.Add(element, P_ATTR_GIVEN_ELEMENT[element][attr]); } posterior = Normalize(Multiply(posterior, p_attr_all_elements)); // Step 3: Incorporate player actions. for (int i = 0; i < player_actions.Count; ++i) { PlayerActionResult action = player_actions[i]; for (int el_i = 0; el_i < element_list.Count; ++i) { Element possible_enemy_element = element_list[i]; int matchup_multiplier = ElementOrdering.Compare(action.element, possible_enemy_element); double accuracy_vs_element = ClampZeroOne(action.attack.accuracy + matchup_multiplier * GameStateManager.GameConstants.SUPER_EFFECTIVE_ACCURACY_BONUS); // For this possible enemy element, what is the probability of the outcome observed? double p_of_result = action.successful ? accuracy_vs_element : (1.0 - accuracy_vs_element); posterior[possible_enemy_element] *= p_of_result; } } posterior = Normalize(posterior); // Normalize again. // Step 4: Incorporate enemy actions. for (int i = 0; i < enemy_actions.Count; ++i) { EnemyActionResult action = enemy_actions[i]; for (int el_i = 0; el_i < element_list.Count; ++i) { Element possible_enemy_element = element_list[i]; int matchup_multiplier = ElementOrdering.Compare(possible_enemy_element, action.player_element_during); double accuracy_vs_player = ClampZeroOne(action.accuracy + matchup_multiplier * GameStateManager.GameConstants.SUPER_EFFECTIVE_ACCURACY_BONUS); // For this possible enemy element, what is the probability that their attack hit/missed? double p_of_result = action.successful ? accuracy_vs_player : (1.0 - accuracy_vs_player); posterior[possible_enemy_element] *= p_of_result; } } posterior = Normalize(posterior); // Normalize again. return(posterior); }
public override void Begin(object pastStateResult) { PlayerActionResult result = pastStateResult as PlayerActionResult; shootPath = result.path; playLoop.StartCoroutine(MovePlayerBubble()); }
public void TestDefeat() { BoardViewModel boardVM = setupTestData(); boardVM.attemptPlayerAction(PlayerActions.down); PlayerActionResult result = boardVM.attemptPlayerAction(PlayerActions.left); Assert.AreEqual(PlayerActionResult.lose, result, "Player should lose"); }
public void TestVictory() { BoardViewModel boardVM = setupTestData(); boardVM.attemptPlayerAction(PlayerActions.down); PlayerActionResult result = boardVM.attemptPlayerAction(PlayerActions.right); Assert.AreEqual(PlayerActionResult.win, result, "Player should win"); }
public void TestMoveOutsideGrid() { BoardViewModel boardVM = setupTestData(); boardVM.attemptPlayerAction(PlayerActions.left); PlayerActionResult result = boardVM.attemptPlayerAction(PlayerActions.left); Assert.AreEqual(PlayerActionResult.error, result, "Player should not move outside grid"); }
public void TestMoveOnSafeSpace() { BoardViewModel boardVM = setupTestData(); PlayerActionResult result = boardVM.attemptPlayerAction(PlayerActions.left); Assert.AreEqual(PlayerActionResult.movedSafe, result, "Player move should be safe tile"); Assert.AreEqual(2, boardVM.player.numberOfLives, "Player lost lives from safe tile"); Assert.AreEqual(0, boardVM.player.position.x, "Player position not updated on mine"); }
public void TestMoveOnMine() { BoardViewModel boardVM = setupTestData(); PlayerActionResult result = boardVM.attemptPlayerAction(PlayerActions.down); Assert.AreEqual(PlayerActionResult.movedOnMine, result, "Player move not triggering mine"); Assert.AreEqual(1, boardVM.player.numberOfLives, "Player not losing lives from mines"); Assert.AreEqual(2, boardVM.player.position.y, "Player position not updated on mine"); }
public void AppendPlayerLogEntry(PlayerActionResult result) { GameObject entry = Instantiate(moveLogEntryPrefab); string entryText = "Your " + result.element + " " + result.attack.name + " " + (result.successful ? "hit!" : "failed"); entry.GetComponent <TextMeshProUGUI>().text = entryText; entry.transform.SetParent(this.transform, false); // Really important to use false here!!!! entries.Add(entry); }
public PlayerActionResult Execute() { if (!CheckMP()) { return(new PlayerActionResult(false, ResultType.NoMovement)); } Kingdom kingdom = Action.player.CurrentKingdom; ArmyInfo armyinfo = new ArmyInfo(Action.player.CurrentKingdom.Army); PlayerActionResult result = new PlayerActionResult(true, ResultType.Success, army1: armyinfo); return(result); }
private bool ActionSelected(PlayerActions action) { PlayerActionResult actionResult = boardVM.attemptPlayerAction(action); Console.WriteLine("\nACTION FEEDBACK: " + actionResult.GetActionResultText() + "\n"); if (actionResult == PlayerActionResult.exit || actionResult == PlayerActionResult.win || actionResult == PlayerActionResult.lose) { return(false); } return(true); }
public ExecuteActionsState(BattleUIManager ui, PlayerActionResult playerAction, EnemyActionResult enemyAction) { uiManager = ui; this.playerAction = playerAction; this.enemyAction = enemyAction; }
IEnumerator GameLoop() { while (gameParticipatns.Count > 1) { //Debug.Log("It's " + curParticipant.participantName + "'s turn."); curParticipant.AnnouncePlayer(); curParticipant.BeginTurn(); if (curParticipant == PlayerController.instance) { bool playerTurn = true; while (playerTurn) { //PlayerController.instance.PlayersTurn(); yield return(new WaitUntil(() => playerStepThrough == true)); playerStepThrough = false; switch (PlayerController.instance.playerPAR) { case PlayerActionResult.Busted: curPlayersToElim.Add(curParticipant); playerTurn = false; break; case PlayerActionResult.DrawnToDeck: break; case PlayerActionResult.DrawnToHand: break; case PlayerActionResult.PlayedLetter: playerTurn = false; break; case PlayerActionResult.PickOne: PlayerController.instance.ChoosePlayer(); yield return(new WaitUntil(() => playerStepThrough == true)); playerStepThrough = false; playerTurn = false; break; } } advanceButton.SetActive(true); drawButton.SetActive(false); } else { yield return(new WaitUntil(() => stepThrough == true)); stepThrough = false; curPAR = curParticipant.TryAction(); while (curPAR != PlayerActionResult.PlayedLetter) { //Debug.Log("action failed."); if (curPAR == PlayerActionResult.Busted) { curPlayersToElim.Add(curParticipant); break; //EliminatePlayer(curParticipant); //yield break; } yield return(new WaitUntil(() => stepThrough == true)); stepThrough = false; curPAR = curParticipant.TryAction(); } } yield return(new WaitUntil(() => stepThrough == true)); stepThrough = false; for (int i = 0; i < curPlayersToElim.Count; i++) { EliminatePlayer(curPlayersToElim[i]); yield return(new WaitUntil(() => stepThrough == true)); stepThrough = false; } curPlayersToElim.Clear(); curParticipantID = (curParticipantID + 1) % gameParticipatns.Count; curParticipant = gameParticipatns[curParticipantID]; } ShowGameOverPanel(gameParticipatns[0].participantName + " won the game because all other players were eliminated."); }