public void Init() { GameState.playerID = 0; playerList = GameState.AllPlayerIDs; /*At the beginning of the mainGame, the server will get playerList from server's roomController * Then instantiaite all the player tanks locally * */ if (!isOffline) { instructionReceiver.Init(); for (int i = 0; i < playerList.Length; i++) { int index = Singletons.gameRoutineController.RegisterNewTank(playerList[i]); if (index != -1) { Transform startTransform = birthPoints.points[i]; GameObject newPlayer = Instantiate(playerPrefab, startTransform.position, startTransform.rotation); clientTanks[i] = newPlayer.GetComponentInChildren <Tank>(); Syncer newSyncer = PhotonNetwork.Instantiate(syncerPrefab.name, clientTanks[i].transform.position, clientTanks[i].transform.rotation, 0).GetComponent <Syncer>(); SyncerViewIDs[i] = newSyncer.gameObject.GetPhotonView().viewID; clientTanks[i].motion.tankNetworkComponents.Set(newSyncer); clientTanks[i].InitOnServer(i, instructionReceiver.ReceivedInstructions[index], newSyncer); } } } else { serverUIController.Init(); sensoringSimulator.Init(clientTanks); } statManager.Init(clientTanks); if (GameState.isRecording) { recorder.Init(clientTanks, statManager.GetAllStats(), System.DateTime.Now.ToLocalTime().ToString("yyyyMMdd_HHmmss") + ".rec"); recorder.StartRecord(); } else { recorder.enabled = false; } serverCameraController = Instantiate(serverCameraPreafab, birthPoints.points[0].position + new Vector3(0, 5, 0), birthPoints.points[0].rotation).GetComponent <ServerCameraController>(); serverCameraController.Init(serverInputManager); serverInfoHUD.Init(statManager.GetAllStats(), clientTanks, serverCameraController.GetComponent <Camera>()); }
public bool Init(string filePath) { if (!File.Exists(filePath)) { return(false); } fileStream = File.Open(filePath, FileMode.Open); binaryReader = new BinaryReader(fileStream); header.Read(binaryReader); AllPlayers = new Tank[Global.Global.playerPerRoom]; for (int i = 0; i < Global.Global.playerPerRoom; i++) { AllPlayers[i] = Instantiate(tankPrefab, i * new Vector3(-100, -100, 10), Quaternion.identity).GetComponentInChildren <Tank>(); AllPlayers[i].GetComponent <Rigidbody>().isKinematic = true; AllPlayers[i].motion.SetMode(TankMode.None); } ServerCameraController serverCameraController = Instantiate(serverCameraPrefab).GetComponent <ServerCameraController>(); serverCameraController.Init(inputManager); serverCamera = serverCameraController.GetComponent <Camera>(); enabled = true; return(true); }