private void InitializeBattle() { BattleInformation.RoundNum = 1; BattleInformation.Turn = 1; BattleInformation.IsDwarfTurn = true; BattleInformation.PlayerHasMadeAnActionInHisTurn = false; BattleInformation.DwarfPlayer = GameInformation.GetCurrentPlayer(); if (PlayerPrefs.GetInt(Constants.gameIsVsIAKey) == 1) { BattleInformation.TrollPlayer = new Player("IA"); } else if (PlayerPrefs.GetInt(Constants.gameIsOnlineKey) == 1) { BattleInformation.TrollPlayer = new Player("Online Player"); } else { BattleInformation.TrollPlayer = GameInformation.GetPlayer2(); } BattleInformation.Player1Point = 0; BattleInformation.Player2Point = 0; BattleInformation.TakenDwarfCount = 0; BattleInformation.TakenTrollCount = 0; HudLink.player1TakenPawnGrid.UpdateGrid(); HudLink.player2TakenPawnGrid.UpdateGrid(); HudLink.turnText.UpdateText(); ShowTurnBanner(); }
private void OnEnable() { player1Image.sprite = PPSerialization.Base64ToSprite(GameInformation.GetCurrentPlayer().Base64Image); player1Name.text = GameInformation.GetCurrentPlayer().Name; if (PlayerPrefs.GetInt(Constants.gameIsVsIAKey) == 1) { player2Image.sprite = null; player2Name.text = "IA"; } else if (PlayerPrefs.GetInt(Constants.gameIsOnlineKey) == 1) { player2Image.sprite = null; player2Name.text = "Online Player"; } else { player2Image.sprite = PPSerialization.Base64ToSprite(GameInformation.GetPlayer2().Base64Image); player2Name.text = GameInformation.GetPlayer2().Name; } player1Score.text = BattleInformation.Player1Point.ToString(); player2Score.text = BattleInformation.Player2Point.ToString(); if (BattleInformation.Player1Point > BattleInformation.Player2Point) { player1CardBackground.color = winnerColor; } else if (BattleInformation.Player1Point < BattleInformation.Player2Point) { player2CardBackground.color = winnerColor; } else if (BattleInformation.Player1Point == BattleInformation.Player2Point) { player1CardBackground.color = winnerColor; player2CardBackground.color = winnerColor; } }
// Use this for initialization void Start() { if (isPlayer1) { //Change image and text of player 1 info panel transform.GetComponentInChildren <AvatarItem>().avatarImage.sprite = PPSerialization.Base64ToSprite(GameInformation.GetCurrentPlayer().Base64Image); transform.GetComponentInChildren <AvatarItem>().avatarNameText.text = GameInformation.GetCurrentPlayer().Name; } else { if (PlayerPrefs.GetInt(Constants.gameIsVsIAKey) == 1) { //Change image and text of IA info panel transform.GetComponentInChildren <AvatarItem>().avatarImage.sprite = null; transform.GetComponentInChildren <AvatarItem>().avatarNameText.text = "IA"; } else if (PlayerPrefs.GetInt(Constants.gameIsOnlineKey) == 1) { //Change image and text of IA info panel transform.GetComponentInChildren <AvatarItem>().avatarImage.sprite = null; transform.GetComponentInChildren <AvatarItem>().avatarNameText.text = "Online Player"; } else //Is versus local player { //Change image and text of player 2 info panel transform.GetComponentInChildren <AvatarItem>().avatarImage.sprite = PPSerialization.Base64ToSprite(GameInformation.GetPlayer2().Base64Image); transform.GetComponentInChildren <AvatarItem>().avatarNameText.text = GameInformation.GetPlayer2().Name; } } }
private void InitializeBattle() { DebugLog.DebugMessage("Initialize battle ...", true); BattleInformation.RoundNum = 1; BattleInformation.Turn = 1; BattleInformation.ShotCount = 1; BattleInformation.IsDwarfTurn = true; BattleInformation.PlayerHasMadeAnActionInHisTurn = false; BattleInformation.currentPlayerShot = new ShotInfo(); if (PlayerPrefs.GetInt(Constants.gameIsVsIAKey) == 1) { DebugLog.DebugMessage("Battle is VS IA", true); DebugLog.DebugMessage("Current player play Dwarf, IA play Troll", true); BattleInformation.DwarfPlayer = GameInformation.GetCurrentPlayer(); BattleInformation.TrollPlayer = new Player("IA"); BattleInformation.TrollPlayer.ID = -1; } else if (PlayerPrefs.GetInt(Constants.gameIsOnlineKey) == 1) { DebugLog.DebugMessage("Battle is VS Online Player", true); //Est ce que le joueur courant est le créateur de la partie : if (Network.player.ipAddress == BattleInformation.OnlineGameInfo.starter) { DebugLog.DebugMessage("Current player play Dwarf, Online player play Troll", true); BattleInformation.DwarfPlayer = GameInformation.GetCurrentPlayer(); BattleInformation.TrollPlayer = new Player("Online Player"); BattleInformation.TrollPlayer.ID = -2; } else { DebugLog.DebugMessage("Current player play Troll, Online Player play Dwarf", true); BattleInformation.DwarfPlayer = new Player("Online Player"); BattleInformation.DwarfPlayer.ID = -2; BattleInformation.TrollPlayer = GameInformation.GetCurrentPlayer(); } } else { DebugLog.DebugMessage("Battle is VS Local Player", true); DebugLog.DebugMessage("Current player play Dwarf, Player2 play Troll", true); BattleInformation.DwarfPlayer = GameInformation.GetCurrentPlayer(); BattleInformation.TrollPlayer = GameInformation.GetPlayer2(); } DebugLog.DebugMessage("Init Points", true); BattleInformation.Player1Point = 0; BattleInformation.Player2Point = 0; BattleInformation.TakenDwarfCount = 0; BattleInformation.TakenTrollCount = 0; DebugLog.DebugMessage("Init HUD", true); HudLink.player1TakenPawnGrid.UpdateGrid(); HudLink.player2TakenPawnGrid.UpdateGrid(); HudLink.turnText.UpdateText(); ShowTurnBanner(); DebugLog.DebugMessage("Set parameters to the player who play his turn ...", true); DebugLog.DebugMessage("Dwarf Player name : " + BattleInformation.DwarfPlayer.Name + " Current Player name : " + GameInformation.GetCurrentPlayer().Name, false); if (BattleInformation.DwarfPlayer.ID == GameInformation.GetCurrentPlayer().ID) { BattleInformation.currentPlayerShot = new ShotInfo(); DebugLog.DebugMessage("Wait for current player action", true); //Keep the player to play his turn } else { if (PlayerPrefs.GetInt(Constants.gameIsVsIAKey) == 1) { DebugLog.DebugMessage("Wait for IA action", true); //Unallow current player to do an action BattleInformation.PlayerHasMadeAnActionInHisTurn = true; //IA Turn } else if (PlayerPrefs.GetInt(Constants.gameIsOnlineKey) == 1) { DebugLog.DebugMessage("Wait for online player action", true); //Unallow current player to do an action BattleInformation.PlayerHasMadeAnActionInHisTurn = true; //Disable buttons SetButtonsState(false); //Show online player loading shot block HudLink.player2ThinkingBlock.gameObject.SetActive(true); //Wait online player shot OnlineBattleManager.WaitOtherPlayerShot(); } else { DebugLog.DebugMessage("Wait for local player 2 action", true); //Keep the player 2 to play his turn } } }