public void Respawn(int losePlayer) { if (losePlayer <= 0) { lastPosition = transform.position; lastVelocity = startForce; timeSinceLast = 0; GetComponent <Renderer>().material.color = GlobalGameManager.GetColor(lastPlayerID); Quaternion rotation = PongGameManager.CalculateCircleRotation(0, 0, PhotonNetwork.CurrentRoom.PlayerCount); photonView.RPC("AddForce", RpcTarget.All, lastPosition, rotation * startForce, losePlayer, true); return; } for (int i = 0; i < PhotonNetwork.CurrentRoom.PlayerCount; i++) { if (PhotonNetwork.PlayerList[i].ActorNumber == losePlayer) { float radius = 15f / Mathf.Tan(Mathf.PI / PhotonNetwork.CurrentRoom.PlayerCount); Quaternion rotation = PongGameManager.CalculateCircleRotation(0, i, PhotonNetwork.CurrentRoom.PlayerCount); Vector3 position = PongGameManager.CalculateCirclePosition(0, radius - 3, i, PhotonNetwork.CurrentRoom.PlayerCount); position += Vector3.up; photonView.RPC("AddForce", RpcTarget.All, position, rotation * startForce, losePlayer, true); break; } } }
// Start is called before the first frame update void Start() { photonView = GetComponent <PhotonView>(); lastPosition = transform.position; lastVelocity = startForce; timeSinceLast = 0; GetComponent <Renderer>().material.color = GlobalGameManager.GetColor(lastPlayerID); }
public IEnumerator Freezed() { freezed = true; SetColor(GlobalGameManager.GetColor(playerID) + Color.gray); yield return(new WaitForSeconds(5.0f)); SetColor(GlobalGameManager.GetColor(playerID)); freezed = false; }
// Start is called before the first frame update void Start() { photonView = GetComponent <PhotonView>(); playerID = photonView.Owner.ActorNumber; SetColor(GlobalGameManager.GetColor(playerID)); startOrientation = transform.right; startPosition = transform.position; standardScale = transform.localScale; }
private void OnPlayerNumberingChanged() { foreach (Player player in PhotonNetwork.PlayerList) { if (player.ActorNumber == ownerId) { playerColorImage.color = GlobalGameManager.GetColor(player.ActorNumber); } } }
public void NewPlayer(Player newPlayer) { GameObject entry = Instantiate(scoreTëxtPrefab); entry.transform.SetParent(gameObject.transform); entry.transform.localScale = Vector3.one; TextMeshProUGUI entryText = entry.GetComponent <TextMeshProUGUI>(); entryText.color = GlobalGameManager.GetColor(newPlayer.ActorNumber); entryText.text = "Player " + newPlayer.ActorNumber + " : 0"; playerUIs.Add(newPlayer.ActorNumber, entryText); }
private void StartGame() { int totalPlayer = PhotonNetwork.CurrentRoom.PlayerCount; float radius = 15f / Mathf.Tan(Mathf.PI / totalPlayer); if (totalPlayer <= 2) { radius = 12.5f; } for (int i = 0; i < totalPlayer; i++) { Vector3 position = CalculateCirclePosition(0, radius, i, totalPlayer); Quaternion rotation = CalculateCircleRotation(0, i, totalPlayer); PongWall wall = Instantiate(wallPrefab, position, rotation).GetComponent <PongWall>(); wall.WallPlayerId = PhotonNetwork.PlayerList[i].ActorNumber; wall.SetColor(GlobalGameManager.GetColor(wall.WallPlayerId) - Color.gray); if (totalPlayer % 2 != 0) { position = CalculateCirclePosition(180, radius + 3, i, totalPlayer); rotation = CalculateCircleRotation(180, i, totalPlayer); PongWall wallCorner = Instantiate(wallEmptyPrefab, position, rotation).GetComponent <PongWall>(); wallCorner.WallPlayerId = -1; } if (PhotonNetwork.LocalPlayer == PhotonNetwork.PlayerList[i]) { position = CalculateCirclePosition(0, radius - 2, i, totalPlayer); rotation = CalculateCircleRotation(0, i, totalPlayer); myPlayer = PhotonNetwork.Instantiate("PongPlayer", position, rotation, 0).GetComponent <PongPlayer>(); position = CalculateCirclePosition(0, radius, i, totalPlayer); rotation = CalculateCircleRotation(0, i, totalPlayer); camera.transform.rotation = rotation; camera.transform.Rotate(Vector3.right, 45); position += Vector3.up * 10; camera.transform.position = position; } } if (PhotonNetwork.IsMasterClient) { StartCoroutine(SpawnCase()); } gameStarted = true; }
private IEnumerator RespawnMessage(string message, int losePlayerID, int winPlayerID) { float timer = 1.0f; while (timer > 0.0f) { infoText.text = message + "\n\n\nBall will respawn in " + timer.ToString("n2"); infoText.color = GlobalGameManager.GetColor(winPlayerID); yield return(new WaitForEndOfFrame()); timer -= Time.deltaTime; } infoText.text = ""; RespawnBall(losePlayerID); }
private IEnumerator EndOfGame(Player winner) { float timer = 5.0f; while (timer > 0.0f) { infoText.text = string.Format("{0} won with {1} points.\n\n\nReturning to login screen in {2} seconds.", winner.NickName, winner.GetScore(), timer.ToString("n2")); infoText.color = GlobalGameManager.GetColor(winner.ActorNumber); yield return(new WaitForEndOfFrame()); timer -= Time.deltaTime; } PhotonNetwork.LeaveRoom(); }
public void Start() { playerUIs = new Dictionary <int, TextMeshProUGUI>(); foreach (Player player in PhotonNetwork.PlayerList) { GameObject entry = Instantiate(scoreTëxtPrefab); entry.transform.SetParent(gameObject.transform); entry.transform.localScale = Vector3.one; TextMeshProUGUI entryText = entry.GetComponent <TextMeshProUGUI>(); entryText.color = GlobalGameManager.GetColor(player.ActorNumber); entryText.text = "Player " + player.NickName + " : 0"; playerUIs.Add(player.ActorNumber, entryText); } }
public void AddForce(Vector3 currentPosition, Vector3 newForce, int playerID, bool spawn) { lastPlayerID = playerID; GetComponent <Renderer>().material.color = GlobalGameManager.GetColor(lastPlayerID); lastVelocity = newForce; lastPosition = currentPosition; if (spawn) { timeSinceLast = 0; } else { timeSinceLast = PhotonNetwork.GetPing() / 1000f / 2; Debug.Log(timeSinceLast); } }