public void RpcPrepareForNewGame(MPGameSetup gamesetup) { this.left = gamesetup.goalLeft; this.right = gamesetup.goalRight; curPos = 0.5f; transform.position = left + ((right - left) * curPos); transform.LookAt(this.right); transform.rotation *= Quaternion.Euler(0f, -90f, 0f); if (isLocalPlayer) { Camera.main.GetComponent<PongCameraController>().target = this; } }
private void ServerStartNewGame() { //start by deleting the previous level: foreach (GameObject o in this.LevelList) { NetworkServer.Destroy(o); } this.LevelList = new List<GameObject>(); Debug.Log("initializing playfield"); Vector3[] points = CreateEllipse(radius, radius, new Vector3(0f, 0f, 0f), this.PlayerList.Count * 2); GameObject wall; GameObject goal; var playerEnum = this.PlayerList.GetEnumerator(); for (int i = 0; i < points.Length - 2; i += 2) { wall = Instantiate<GameObject>(PrefabWall); RotateAndSpawn(wall, points[i + 1], points[i + 2]); goal = Instantiate<GameObject>(PrefabGoal); RotateAndSpawn(goal, points[i], points[i + 1]); if (playerEnum.MoveNext()) { MPGameSetup gs = new MPGameSetup(); gs.goalLeft = points[i]; gs.goalRight = points[i + 1]; gs.height = PADDLE_HEIGHT; gs.length = PADDLE_LENGTH; gs.playerLeft = gs.goalLeft + (goal.transform.forward * PADDLE_DISTANCE); gs.playerRight = gs.goalRight + (goal.transform.forward * PADDLE_DISTANCE); goal.name = "goal for " + playerEnum.Current.playerName; goal.GetComponent<MPGoalController>().setPlayer(playerEnum.Current); playerEnum.Current.RpcPrepareForNewGame(gs); } else { Debug.LogError("mismatch between playfield size(" + (points.Length / 2) + ") and playercount(" + this.PlayerList.Count + ")"); } } if (this.ball != null) { this.ball.transform.position = new Vector3(0f, 0f, 0f); //this.ball.GetComponent<Rigidbody>().velocity = } else { this.ball = CreateBall(); } }