/// <summary> /// All games start from here. /// </summary> /// <returns></returns> private IEnumerator GameCountdown() { while (startCountdown == true && startTimer >= 0) { yield return(new WaitForSeconds(1f)); startTimer--; } if (startCountdown == true) { //BOTTLENECK AND HOOK TO START A GAME // Mark room as "GameStarted" ExitGames.Client.Photon.Hashtable tempRoomTable = PhotonNetwork.room.CustomProperties; tempRoomTable["GameStarted"] = true; PhotonNetwork.room.SetCustomProperties(tempRoomTable); startTheMatch = true; // used by WaitGUI //Does the following: //set "gameStarted" as true. //GameStarted: // - Triggers WaitUI to go into SpectateMode // if GameStarted is caught in Start() // - Disables WaitUI's polling if GameStarted // - Activates the Fade Effect on the Border Images M.GameStarts(readyTotal); //Does the following: // - Reenabled escape function (disabled during spawn) // TODO: Find use for room size? StageAnimations.Activate(); //Does the following: // - Activates animations for things that need to be in sync Network-wise. GameManager.GameStart(NetIDs.PlayerNumber(PhotonNetwork.player.ID), M.GetClientCharacterName()); //Does the following: // - Spawns local player over network. } }
private IEnumerator doRespawnOrGhost <PlayerController>(int deadPlayerNum, bool isDisconnect) where PlayerController : PlayerController2D { if (playerLives[deadPlayerNum] <= -1 || isDisconnect) { totalGhosts++; Players[deadPlayerNum].GetComponent <PlayerController>().Ghost(); //ONLY OUR PLAYER SHOPULD SPECTATE MODE if (deadPlayerNum == NetIDs.PlayerNumber(PhotonNetwork.player.ID)) { WaitGUIController.ActivateSpectatingMode(); } yield return(null); } else { yield return(respawnWait); //Player spawn position is controlled by Game Manager. //But we only wanna reposition OUR player's position. //BUT ALSO Players[deadPlayerNum].GetComponent <PlayerController>().Respawn( SpawnPositions[Random.Range(0, SpawnPositions.Length - 1)].position ); } }
private void updatePlayerCharDisplay() { int slotNum; int charNum; for (int x = 0; x < PhotonNetwork.room.PlayerCount; x++) { slotNum = NetIDs.PlayerNumber(PhotonNetwork.playerList[x].ID); charNum = N.GetCharNum(PhotonNetwork.playerList[x].ID); RoomSlotImages[slotNum].sprite = UIHeads[charNum]; CBUG.Log(string.Format("UpdateHUDCharDisplay playerID/slotNum: {0} charNum: {1}", slotNum, charNum)); } }
void OnPhotonPlayerDisconnected(PhotonPlayer player) { CBUG.Log("OnPhotonPlayerDisconnected: " + player); //Tell everyone to reset their ready status. ResetReadyStatus(); unassignPlayerTracking(player); plrStateChange = true; rdyStateChange = true; if (gameStarted) { GameManager.RecordDeath(-1, NetIDs.PlayerNumber(player.ID), true); GameManager.HandleDeath(NetIDs.PlayerNumber(player.ID), true); } }
void Awake() { isFrozen = false; //DontDestroyOnLoad(gameObject); anim = GetComponentInChildren <Animator>(); moveRight = 0; moveLeft = 0; controlsPaused = false; myAudioSrc = GetComponent <AudioSource>(); myAudioSrc.clip = DeathNoise; punching = false; isDead = false; StrengthsList = GameObject.FindGameObjectWithTag("Master"). GetComponent <Master>().GetStrengthList(); CBUG.Log("Str List: " + StrengthsList.ToStringFull()); jumpForceTemp = 0f; SpeedTemp = 0f; attackDisableDelay = new WaitForSeconds(AttackLife); facingRight = true; position = new Vector2(); _Rigibody2D = GetComponent <Rigidbody2D>(); jumpsRemaining = TotalJumpsAllowed; _PhotonView = GetComponent <PhotonView>(); _PhotonTransform = GetComponent <PhotonTransformView>(); AttackObjs = new GameObject[3]; AttackObjs[0] = transform.GetChild(3).gameObject; AttackObjs[1] = transform.GetChild(1).gameObject; AttackObjs[2] = transform.GetChild(2).gameObject; _MobileInput = GameObject.FindGameObjectWithTag("MobileController").GetComponent <MobileController>(); spawnPause = 0.5f; spawnPauseWait = new WaitForSeconds(spawnPause); lastHitBy = -1; lastHitTime = Time.time; lastHitForgetLength = 5;//Seconds if (_PhotonView.isMine) { tag = "PlayerSelf"; _PhotonView.RPC("SetSlotNum", PhotonTargets.All, NetIDs.PlayerNumber(PhotonNetwork.player.ID)); CamManager.SetTarget(transform); } }
private void updateReadyStatusDisplay() { PercentReady.text = "" + N.ReadyTotal + "/" + N.GetInRoomTotal; //Any change to the ready status requires everyone to re-ready up. //Yes.SetActive(true); //No.SetActive(false); int playerNumber; for (int x = 0; x < PhotonNetwork.room.PlayerCount; x++) { playerNumber = NetIDs.PlayerNumber(PhotonNetwork.playerList[x].ID); RoomSlotImages[playerNumber].color = N.GetRdyStatus(PhotonNetwork.playerList[x].ID) ? rdyColor : unRdyColor; } }
/// <summary> /// Helper function used by "OnJoinedRoom" /// </summary> private void clearLocalTracking( ) { ID_to_CharNum.Clear(); ID_to_IsRdy.Clear(); NetIDs.Clear(); }
/// <summary> /// Helper function called when a player leaves. /// </summary> /// <param name="player">player that disconnected.</param> private void unassignPlayerTracking(PhotonPlayer player) { ID_to_CharNum.Remove(player.ID); ID_to_IsRdy.Remove(player.ID); NetIDs.Remove(player.ID); }
private void _LaunchEndGame(int[,] KillsMatrix) { int totalPlayers = KillsMatrix.GetLength(0); int mostKills = 0; int tempKills = 0; int leastDeaths = SettingsManager._StartLives; int tempDeaths = 0; bestKillers.Clear(); bestSurvivors.Clear(); //CBUG.Do("X max: " + totalPlayers); for (int x = 0; x < totalPlayers; x++) { tempKills = 0; for (int y = 0; y < totalPlayers; y++) { CBUG.Do("Y Max: " + KillsMatrix.GetLength(1)); CBUG.Do("" + x + " Killed " + y + "|" + KillsMatrix[x, y]); tempKills += KillsMatrix[x, y]; } if (tempKills == mostKills) { bestKillers.Add(x); } else if (tempKills > mostKills) { bestKillers.Clear(); mostKills = tempKills; bestKillers.Add(x); } } for (int y = 0; y < totalPlayers; y++) { tempDeaths = 0; for (int x = 0; x < totalPlayers; x++) { tempDeaths += KillsMatrix[x, y]; } if (tempDeaths == leastDeaths) { bestSurvivors.Add(y); } if (tempDeaths < leastDeaths) { bestSurvivors.Clear(); leastDeaths = tempDeaths; bestSurvivors.Add(y); } } for (int x = 0; x < 5; x++) { WinnerTexts[x].text = ""; WinnerTexts_BG[x].text = ""; textUsernames[x].text = ""; textUsernames_BG[x].text = ""; RootPlayerSlots[x].SetActive(false); winnerGraphicImages[x].SetActive(false); } int startSlot = Mathf.Clamp(4 - N.ReadyTotal, 0, 5); int endSlot = Mathf.Clamp(startSlot + N.ReadyTotal, 0, 5); int tempPlayerNum = 0; for (int x = startSlot; x < endSlot; x++) { RootPlayerSlots[x].SetActive(true); playerImages[x].sprite = M.AllCharacters[N.GetCharNum(NetIDs.GetNetID(tempPlayerNum))].GetComponentInChildren <Image>().sprite; if (bestKillers.Contains(tempPlayerNum) || bestSurvivors.Contains(tempPlayerNum)) { winnerGraphicImages[x].SetActive(true); if (bestKillers.Contains(tempPlayerNum)) { WinnerTexts[x].text += "Most Kills"; WinnerTexts_BG[x].text += "Most Kills"; } if (bestKillers.Contains(tempPlayerNum) && bestSurvivors.Contains(tempPlayerNum)) { WinnerTexts[x].text += "\n"; WinnerTexts_BG[x].text += "\n"; } if (bestSurvivors.Contains(tempPlayerNum)) { WinnerTexts[x].text += "Most Lives"; WinnerTexts_BG[x].text += "Most Lives"; } } tempPlayerNum++; } //if (manyBestSurvivor) { // if (manyBestKiller) { // GameHUDController.Won(); // } else if (NetID.Convert(PhotonNetwork.player.ID) == bestKiller) { // GameHUDController.Won(); // } else { // GameHUDController.Lost(); // } //} else if (NetID.Convert(PhotonNetwork.player.ID) == bestSurvivor) { // CBUG.Do("I WIN! netID: " + PhotonNetwork.player.ID + " realID: " + NetID.Convert(PhotonNetwork.player.ID)); // GameHUDController.Won(); //} else { // GameHUDController.Lost(); //} StartCoroutine(clearPlayers()); StartCoroutine(slowTime()); StartCoroutine(loadScoreboard()); StartCoroutine(reloadArena()); StartCoroutine(autoKick()); //StartCoroutine(savePlayers()); }