public bool InitializeNetworkGameUI(AvatorController _avatorControllerReference) { UpdateGameUINetworkControllerAttributes(_avatorControllerReference); var _destinationNetId = AvatorControllerReference.networkObject.destNetwId; networkObject.SendRpc(RPC_UPDATE_ON_NETWORK_GAME_U_I, Receivers.AllBuffered, _destinationNetId); return(true); }
protected bool UpdatePlayerEntityAttributes(AvatorController _avatorControllerReference) { AvatorControllerReference = _avatorControllerReference; //Gets the AvatorController transform var _parentTransform = AvatorControllerReference.gameObject.GetComponent <Transform>(); transform.SetParent(_parentTransform); //Get the GameEntityRegister GameEntityRegister = _avatorControllerReference.GameEntityRegister; return(true); }
public bool InitializePlayerEntity(AvatorController _avatorControllerReference, UserInformations _user, Camera _cameraOnDestination) { //Updates attributes of this GameObject UpdatePlayerEntityAttributes(_avatorControllerReference); //I'm sorry Demetra var destinationOwnerNetId = AvatorControllerReference. DestinationControllerReference. networkObject.NetworkId; //Updates attributes of this networkObject UpdatePlayerEntityNetworkAttributes(destinationOwnerNetId, _user.username, _user.password, _user.email, _user.faction, _user.selectedUma); //When the avator controller is destroyed, destroy also the player entity AvatorControllerReference.networkObject.onDestroy += NetworkObject_onDestroy; //Create the Game UI Controller Entity in the network var gameUiNetworkController = NetworkManager.Instance.InstantiateGameUINetworkEntity(0, transform.position); gameUiNetworkController.networkStarted += GameUiNetworkController_networkStarted; networkObject.SendRpc(RPC_UPDATE_PLAYER_ENTITY, Receivers.AllBuffered, _user.username, _user.password, _user.email, _user.faction, _user.selectedUma); return(true); }
protected void UpdateGameUINetworkControllerAttributes(AvatorController _avatorControllerReference) { _avatorControllerReference.networkObject.onDestroy += NetworkObject_onDestroy; if (ServerProcess) { return; //Do not execute any initialization for the ServerController process } //Gets the AvatorUI AvatorUI = InstantiatedAvatorUI.GetComponentInChildren <AvatorUI>(); //Gets the PlayerUI PlayerUI = InstantiatedPlayerUI.GetComponentInChildren <PlayerUI>(); AvatorControllerReference = _avatorControllerReference; PlayerEntity = AvatorControllerReference.PlayerEntity; Transform _avatorTransform = AvatorControllerReference.gameObject.GetComponent <Transform>(); this.transform.SetParent(_avatorTransform); //assign the camera that ui should point to CameraOnDestination = AvatorControllerReference.CameraOnDestination; //Puts the UI under the hieararchy of the GameUIController object InstantiatedPlayerUI.transform.SetParent(_avatorTransform); //Puts AvatorUI under avator hierarchy InstantiatedAvatorUI.transform.SetParent(_avatorTransform); //Set the AvatorUI(nickname) on the head of the avator character InstantiatedAvatorUI.transform.localPosition = new Vector3(0, 2.3f, 0); //Sets the correct position for the UI InstantiatedPlayerUI.transform.localPosition = new Vector3(0.0f, 0, 0f); //Set the Compass InstantiatedCompassPrefab.transform.SetParent(_avatorTransform); InstantiatedCompassPrefab.transform.localPosition = new Vector3(0, 1.0f, 0); //If the code isn't executed by the owner or the process is the Server, deactivate the 2D GUI if (!networkObject.IsOwner) { //Deactivates static parts of the UI PlayerUI.gameObject.SetActive(false); //Deactivates the EventSystem var eventSystem = InstantiatedPlayerUI.GetComponentInChildren <EventSystem>(); eventSystem.gameObject.SetActive(false); //Deactivate the Compass object, the others player must not see it InstantiatedCompassPrefab.gameObject.SetActive(false); } else { PlayerUI.InitPlayerUI(AvatorControllerReference); } if (!ReferenceEquals(AvatorUI, null)) { AvatorUI.InitAvatorUI(CameraOnDestination, PlayerEntity, InstantiatedCompassPrefab.transform); } }