private IEnumerator RoundEnding() { // Stop tanks from moving. DisableTankControl(); // Clear the winner from the previous round. m_RoundWinner = null; // See if there is a winner now the round is over. m_RoundWinner = GetRoundWinner(); // If there is a winner, increment their score. if (m_RoundWinner != null) { m_RoundWinner.m_Wins++; } // Now the winner's score has been incremented, see if someone has one the game. m_GameWinner = GetGameWinner(); // Get a message based on the scores and whether or not there is a game winner and display it. string message = EndMessage(); m_MessageText.text = message; // Wait for the specified length of time until yielding control back to the game loop. yield return(m_EndWait); }
public EndTextMaker(TankManager[] tankManagers, TankManager m_GameWinner, TankManager m_RoundWinner, string drawColoredPlayerText) { this.tankManagers = tankManagers; this.gameWinner = m_GameWinner; this.roundWinner = m_RoundWinner; this.drawColoredPlayerText = drawColoredPlayerText; }
private IEnumerator RoundEnding() { DisableTanksControls(); roundWinner = GetRoundWinner(); roundWinner.m_Wins++; gameWinner = GetGameWinner(); DisplayEndMessage(); yield return(endDelay); }
public static void AddTank(GameObject tank, int playerNum, Color c, string name) { TankManager tmp = new TankManager { m_Instance = tank, m_PlayerNumber = playerNum, m_PlayerColor = c, m_PlayerName = name }; tmp.Setup(); m_Tanks.Add(tmp); }
private IEnumerator RoundEnding() { // Stop tanks from moving. DisableTankControl(); // Clear the winner from the previous round. m_RoundWinner = null; // See if there is a winner now the round is over. m_RoundWinner = GetRoundWinner(); // If there is a winner, increment their score. if (m_RoundWinner != null) { m_RoundWinner.m_Wins++; } // Now the winner's score has been incremented, see if someone has one the game. m_GameWinner = GetGameWinner(); // Get a message based on the scores and whether or not there is a game winner and display it. string message = EndMessage(); m_MessageText.text = message; bool isEndOfGame = m_GameWinner != null; #if WINDOWS_UWP SetLiveTile(GetTileMessage(isEndOfGame)); ScheduleReEngageToast(); #endif // Wait for the specified length of time until yielding control back to the game loop. yield return(m_EndWait); if (m_showAds && (m_RoundNumber % 3 == 2)) { ShowAd(); } else if (m_RoundNumber % 3 == 1 && m_showSocialPrompt) { ShowSocialPrompt(); } while (m_isDisplayingAd || m_isDisplayingSocialPrompt) { yield return(null); } Debug.Log("Round Ended"); }
private IEnumerator RoundEnding() { DisableTankControl(); m_RoundWinner = null; m_RoundWinner = GetRoundWinner(); if (m_RoundWinner != null) { m_RoundWinner.m_Wins++; } m_GameWinner = GetGameWinner(); string message = EndMessage(); m_MessageText.text = message; yield return(m_EndWait); }
private IEnumerator RoundEnding() { // Stop tanks from moving DisableTankControl(); if (player_waiting > 0) { players_on_start += player_waiting; if (players_on_start >= 4) { players_on_start = 4; } } // Clear the winner from the previous round m_RoundWinner = null; // See if there is a winner now the round is over m_RoundWinner = GetRoundWinner(); // If there is a winner, increment their score if (m_RoundWinner != null) { m_RoundWinner.m_Wins++; } // Now the winner's score has been incremented, see if someone has one the game m_GameWinner = GetGameWinner(); // Get a message based on the scores and whether or not there is a game winner and display it string message = EndMessage(); m_MessageText.text = message; if (m_GameWinner != null) { yield return(gameEnd_wait); SceneManager.LoadScene("Main-menu"); } else { // Wait for the specified length of time until yielding control back to the game loop yield return(m_EndWait); } }
public void RemoveTank(GameObject tank) { TankManager toRemove = null; foreach (var tmp in m_Tanks) { if (tmp.m_Instance == tank) { toRemove = tmp; break; } } if (toRemove != null) { m_Tanks.Remove(toRemove); } }
/// <summary> /// Step 3, Part3: Round has ended, get ready for future rounds, look for winners /// </summary> private IEnumerator RoundHasEnded() { _playerTanks.ToList().ForEach(x => x.DisableControl()); _roundWinner = null; _roundWinner = GetRoundWinner(); if (_roundWinner != null) { _roundWinner._wins++; } _gameWinner = GetGameWinner(); string message = EndMessage(); _messageText.text = message; yield return(_endWait); }
/// <summary> /// 创建Tank /// </summary> /// <param name="tank"></param> /// <param name="playerNum"></param> /// <param name="color"></param> /// <param name="name"></param> /// <param name="localId"></param> public GameObject AddTank(int playerNum, Color color, string name, string localId, Vector3 position, Quaternion rotation) { TankManager tm = new TankManager { m_Instance = Instantiate(m_TankPrefab, position, rotation) as GameObject, m_PlayerNumber = playerNum, m_PlayerColor = color, m_playerName = name, m_LocalPlayerId = localId, isLocalPlayer = false }; tm.m_SpawnPoint = tm.m_Instance.transform; tm.Setup(); m_Tanks.Add(tm); SetCameraTargets(); return(tm.m_Instance); }
private IEnumerator RoundEnding() { // 禁用坦克移动 DisableTankControl(); // 重置本局的胜者 m_RoundWinner = null; // 找出本局的存活者为胜者 m_RoundWinner = GetRoundWinner(); // 求出赢得比赛的玩家(当前赢得场数等于5) m_GameWinner = GetGameWinner(); // 计算需要显示的字符串,并显示 string message = EndMessage(); m_MessageText.text = message; // 完成上面以后返回gameloop yield return(m_EndWait); }
/// <summary> /// 创建Tank /// </summary> /// <param name="tank"></param> /// <param name="playerNum"></param> /// <param name="color"></param> /// <param name="name"></param> /// <param name="localId"></param> public GameObject AddTank(int playerNum, Color color, string name, string localId, bool isLocalPlayer) { System.Random r = new System.Random(); Transform t = spawnPoints[playerNum]; TankManager tm = new TankManager { m_Instance = Instantiate(m_TankPrefab, t.position, t.rotation) as GameObject, m_PlayerNumber = playerNum, m_PlayerColor = color, m_playerName = name, m_LocalPlayerId = localId, m_SpawnPoint = t, isLocalPlayer = isLocalPlayer }; tm.Setup(); m_Tanks.Add(tm); SetCameraTargets(); return(tm.m_Instance); }
private void SpawnAllTanks() { // 主客户端 if (g_MainPlayer != null) { g_MainPlayer.m_TankManager.m_Instance = Instantiate(m_TankPrefab, g_MainPlayer.position, Quaternion.Euler(g_MainPlayer.direction)) as GameObject; g_MainPlayer.m_TankManager.m_PlayerNumber = 1; g_MainPlayer.m_TankManager.Setup(); } // 其他客户端 foreach (var avatar in g_OtherPlayers.Values) { TankManager tank = new TankManager { m_Instance = Instantiate(m_TankPrefab, avatar.position, Quaternion.Euler(avatar.direction)) as GameObject, m_PlayerNumber = avatar.id }; tank.Setup(); avatar.m_TankManager = tank; } }
public async void Payout(Complete.TankManager winner) { TankLnd lnd = null; if (winner.m_PlayerNumber == 1) { lnd = p1Donner; p1Earnings += roundBounty; P1Texts[0].text = "Earnings: " + p1Earnings; } else { lnd = p2Donner; p2Earnings += roundBounty; P2Texts[0].text = "Earnings: " + p2Earnings; } //var invoice = await lnd.AddInvoice((int)roundBounty, "bounty"); //var hash = await SendPayment(invoice); roundBounty = 0; ResetAmmo(); UpdateBounty(); }
private IEnumerator RoundEnding() { // Stop tanks from moving. DisableTankControl(); UIDeactivation(); timeText.enabled = false; pointsP1.enabled = false; pointsP2.enabled = false; timeLeft = 90; // Clear the winner from the previous round. m_RoundWinner = null; m_ActiveBarrels = 10; // See if there is a winner now the round is over. m_RoundWinner = GetRoundWinner(); // If there is a winner, increment their score. if (m_RoundWinner != null) { m_RoundWinner.m_Wins++; } // Now the winner's score has been incremented, see if someone has one the game. m_GameWinner = GetGameWinner(); // Get a message based on the scores and whether or not there is a game winner and display it. string message = EndMessage(); m_MessageText.text = message; barrelPointP1 = 0; barrelPointP2 = 0; pointsP1.text = ("Points P1: " + barrelPointP1); pointsP2.text = ("Points P2: " + barrelPointP2); DisableBarrels(); // Wait for the specified length of time until yielding control back to the game loop. yield return(m_EndWait); }
/// <summary> /// Game Loop Step 4: Reset for new players /// </summary> private IEnumerator DestroyGameSetup() { _roundNumber = 0; _roundWinner = null; _gameWinner = null; _bluePlayer._wins = 0; _bluePlayer.OnlineParticipant = null; _redPlayer._wins = 0; _redPlayer.OnlineParticipant = null; _stateMachine.ResetToDefault(); Destroy(_redPlayer._instance); Destroy(_bluePlayer._instance); _redPlayer._instance = null; _bluePlayer._instance = null; _stateMachine.SetAllParticipantsToLobby(); _cameraControl._targets = new Transform[0]; yield return(null); }
private IEnumerator RoundEnding () { // Stop tanks from moving. DisableTankControl (); // Clear the winner from the previous round. m_RoundWinner = null; // See if there is a winner now the round is over. m_RoundWinner = GetRoundWinner (); // If there is a winner, increment their score. if (m_RoundWinner != null) m_RoundWinner.m_Wins++; // Now the winner's score has been incremented, see if someone has one the game. m_GameWinner = GetGameWinner (); // Get a message based on the scores and whether or not there is a game winner and display it. string message = EndMessage (); m_MessageText.text = message; // Wait for the specified length of time until yielding control back to the game loop. yield return m_EndWait; }
public void AddPlayer(TankManager tank, NetworkConnection conn) { m_PendingPlayers.Add(tank); RpcDisablePendingPlayer(tank); RpcSyncPendingPlayer(conn, m_Tanks, m_TanksTransform, m_Enemies); }
private void RpcDisablePendingPlayer(TankManager tank) { tank.m_Instance.SetActive(false); }
// The next two functions are called once the player has been hit by a shell and we dont want to disable the tank UI too public void EnablePlayerMovement(int playerNumber) { TankManager player = m_PlayerByNumber[playerNumber]; player.EnableControl(); }
// This function prints the current lap of the player private void PrintLapInfo(TankManager player) { string info = "<color=#" + ColorUtility.ToHtmlStringRGB(player.m_PlayerColor) + ">LAPS: " + player.m_Laps.ToString() + "/" + m_LapsToWin + "</color>"; player.m_LapDial.text = info; }
private void Start() { mConnectionManager = new Complete.SignalRManager(); mConnectionManager.OnActionTrack = (x, v, r) => { if (m_Tanks[0].m_TankId == x /*&& _TankToTrack!=0*/) { m_Tanks[0].m_Movement.SetLocation(v, r); } if (m_Tanks[1].m_TankId == x /*&& _TankToTrack != 1*/) { m_Tanks[1].m_Movement.SetLocation(v, r); } }; mConnectionManager.OnActionFire = (p, r, v) => { m_Tanks[1].m_Shooting.ExecFire(p, r, v); }; mConnectionManager.OnStartSession = (list) => { foreach (GameSessionPlayerItem i in list) { TankManager tm = m_Tanks[i.Sequence - 1]; tm.m_AssociatedUserId = i.UserId; tm.m_TankId = i.TankId; if (i.UserId == mConnectionManager._UserId) { tm.SetColor(Color.green); } } hasSession = true; }; mConnectionManager.OnActionSetDamage = (tankId, amount) => { if (m_Tanks[0].m_TankId == tankId) { m_Tanks[0].SetDamage(amount); } if (m_Tanks[1].m_TankId == tankId) { m_Tanks[1].SetDamage(amount); } }; mConnectionManager.OnRoundBegins = (roundno) => { remoteRoundNo = roundno; canStartRound = true; }; StartCoroutine(Connect()); // Create the delays so they only have to be made once. m_StartWait = new WaitForSeconds(m_StartDelay); m_EndWait = new WaitForSeconds(m_EndDelay); SpawnAllTanks(); SetCameraTargets(); // Once the tanks have been created and the camera is using them as targets, start the game. StartCoroutine(GameLoop()); }
public void DisablePlayerMovement(int playerNumber) { TankManager player = m_PlayerByNumber[playerNumber]; player.DisableControl(false); }
string coloredSentinelPlayerText; // the nickname of a player who represents a draw private void Awake() { ConfigureSingleton(); ConfigureDelays(); gameWinner = CreateSentinelPlayer(); }