/// <summary> /// Set up this tank with the correct properties /// </summary> private void Initialize(TanksNetworkPlayer player) { if (initialized) { return; } initialized = true; this.player = player; playerTankType = TankLibrary.s_Instance.GetTankDataForIndex(player.tankType); // Create visual tank GameObject tankDisplay = (GameObject)Instantiate(playerTankType.displayPrefab, transform.position, transform.rotation); tankDisplay.transform.SetParent(transform, true); // Analytics messages on server if (isServer) { AnalyticsHelper.PlayerUsedTankInGame(playerTankType.id); TankDecorationDefinition itemData = TankDecorationLibrary.s_Instance.GetDecorationForIndex(player.tankDecoration); if (itemData.id != "none") { AnalyticsHelper.PlayerUsedDecorationInGame(itemData.id); } } // Get references to the components. display = tankDisplay.GetComponent <TankDisplay>(); movement = GetComponent <TankMovement>(); shooting = GetComponent <TankShooting>(); health = GetComponent <TankHealth>(); // Initialize components movement.Init(this); shooting.Init(this); health.Init(this); display.Init(this); GameManager.AddTank(this); if (player.hasAuthority) { DisableShooting(); player.CmdSetReady(); } }
/// ------------------------------------------------------------------------------------------------------ /// <summary> /// Set up this tank with the correct properties /// </summary> /// ------------------------------------------------------------------------------------------------------ private void Initialize(TanksNetworkPlayer player) { if (initialized) { return; } initialized = true; this.player = player; playerTankType = TankLibrary.s_Instance.GetTankDataForIndex(player.tankType); // Analytics messages on server if (isServer) { AnalyticsHelper.PlayerUsedTankInGame(playerTankType.id); } // Create visual tank player.transform.position = transform.position; player.transform.SetParent(transform, true); if (isServer) { AnalyticsHelper.PlayerUsedTankInGame(playerTankType.id); } hudPlayer = HUDPlayerManager.Get().CreateHUDPlayerPrefab(transform); movement = GetComponent <TankMovement>(); shooting = GetComponent <TankShooting>(); movement.Init(this); hudPlayer.Init(transform); shooting.SetPlayerWeapon(0); GameManager.AddTank(this); if (player.hasAuthority) { DisableShooting(); player.CmdSetReady(); } }
IEnumerator SetupVideoSurface(TanksNetworkPlayer player) { Debug.Log("Tank initializing player:" + player); yield return(new WaitForFixedUpdate()); if (player.hasAuthority) { // doesn't seem necessary // DisableShooting(); } player.CmdSetReady(); if (videoSurface == null) { videoSurface = RenderObject.AddComponent <VideoSurface>(); } if (player.isLocalPlayer) { if (videoSurface != null) { videoSurface.gameObject.name = LocalTankVideoName; } } else { uint uid = AgoraPlayerController.instance.GetAgoraID(player); Debug.LogFormat("Tank player {0}: Found agora uid for player ------> {1} ", player, uid); if (uid != 0 && videoSurface != null) { videoSurface.gameObject.name = string.Format("video-{0}", uid); videoSurface.SetForUser(uid); } else { Debug.Assert(uid != 0, "Couldn't find uid for player:" + player.playerId); AgoraPlayerController.instance.Print(); Debug.Assert(videoSurface != null, "videoSurface = null"); } } }