Пример #1
0
 protected void UpdateAvatorAttributes(DestinationController _destinationController)
 {
     DestinationControllerReference = _destinationController;
     gameObject.name            = _destinationController.gameObject.name + " avator - " + networkObject.NetworkId;
     SelectedUma                = _destinationController.SelectedUma;
     CharacterController.center = new Vector3(0, 1.0f, 0);
     CurrentUserInfo            = _destinationController.CurrentUserInformations;
     DestinationTransform       = _destinationController.gameObject.GetComponent <Transform>();
     CameraOnDestination        = _destinationController.DestinationCamera;
     _destinationController.AvatorController = this;
     GameEntityRegister = _destinationController.GameEntityRegister;
 }
        public override void OnInspectorGUI()
        {
            //base.OnInspectorGUI();
            GameEntityRegister           gameEditor  = (GameEntityRegister)target;
            List <TowerEntityController> towersList  = gameEditor.TowersList;
            List <DestinationController> playersList = gameEditor.DestinationsList;

            if (towersList.Count > 0)
            {
                GUIContent towerLabel = new GUIContent("Towers");
                showTowers = EditorGUILayout.Foldout(showTowers, towerLabel);
                if (showTowers)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("NetworkId", EditorStyles.boldLabel);
                    EditorGUILayout.LabelField("GPS Coordinates", EditorStyles.boldLabel);
                    EditorGUILayout.EndHorizontal();

                    towersList.ForEach(x =>
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.IntField("", (int)x.networkObject.NetworkId);
                        GUIContent guiGPS = new GUIContent("");
                        Vector2 gpsCoords = new Vector2(x.GPSCoords.x, x.GPSCoords.y);
                        EditorGUILayout.Vector2Field(guiGPS, gpsCoords);
                        EditorGUILayout.EndHorizontal();
                    });
                }
            }

            if (playersList.Count > 0)
            {
                GUIContent playerLabel = new GUIContent("Players");
                showPlayer = EditorGUILayout.Foldout(showPlayer, playerLabel);
                if (showPlayer)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("NetworkId", EditorStyles.boldLabel);
                    EditorGUILayout.LabelField("Nickname", EditorStyles.boldLabel);
                    EditorGUILayout.EndHorizontal();

                    playersList.ForEach(x =>
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.IntField("", (int)x.networkObject.NetworkId);
                        GUIContent guiGPS = new GUIContent("");
                        EditorGUILayout.TextField(guiGPS, x.PlayerName);
                        EditorGUILayout.EndHorizontal();
                    });
                }
            }
        }
Пример #3
0
        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 override void UpdateTowerAttrributes(RpcArgs args)
        {
            OwnerFaction = args.GetNext <string>();
            GPSCoords    = networkObject.towerGPSCoords;
            //Update tower position on network
            transform.position = networkObject.towerNetPosition;
            ActivateBoxColliders(true);//This call isn't necessary for the towers on the network but we don't care

            //Find GameEntityRegister
            GameEntityRegister = FindObjectOfType <GameEntityRegister>();

            //Add this tower controller to the register
            GameEntityRegister.AddEntity(this);

            //Register the callback for deleting the Destination controller from the register when it will disconnect
            networkObject.onDestroy += NetworkObject_onDestroyRemoveFromRegister;
        }
Пример #5
0
        /// <summary>
        /// Initialize AvatorUI.
        /// </summary>
        /// <param name="_cameraOnDestination"></param>
        /// <param name="_playerEntity"></param>
        /// <param name="_compass"></param>
        public void InitAvatorUI(Camera _cameraOnDestination,
                                 PlayerEntity _playerEntity,
                                 Transform _compass)
        {
            CameraOnDestination = _cameraOnDestination;
            PlayerEntity        = _playerEntity;
            UsernameText.Value  = _playerEntity.username;
            IsCompassOwner      = _compass.gameObject.activeInHierarchy;

            if (IsCompassOwner)
            {
                CompassGameObject  = _compass;
                CompassItem        = CompassGameObject.GetChild(0);
                GameEntityRegister = _playerEntity.GameEntityRegister;
            }

            SetUpReady = true;
        }
Пример #6
0
        //TODO : This function must be moved somewhere else
        /// <summary>
        /// Find the nearest tower to the transform given in input that is not captured
        /// by no faction
        /// </summary>
        /// <param name="_gameEntityRegister"></param>
        /// <param name="_originPosition"></param>
        /// <returns>The nearest tower entity controller found</returns>
        public static TowerEntityController FindNearestTower(GameEntityRegister _gameEntityRegister,
                                                             Vector3 _originPosition)
        {
            TowerEntityController res = null;

            if (!ReferenceEquals(_gameEntityRegister, null) && !ReferenceEquals(_originPosition, null))
            {
                var allTowersReg = _gameEntityRegister.GetAllEntity(typeof(TowerEntityController));
                var allTowers    = allTowersReg.Cast <TowerEntityController>();

                res = allTowers.Where <TowerEntityController>(x => !x.IsTowerCaptured()).
                      OrderBy <TowerEntityController, double>(x => Vector3.Distance(_originPosition, x.transform.position)).
                      FirstOrDefault <TowerEntityController>();
            }
            else
            {
                Debug.LogError("No game entity register supplied.");
            }
            return(res);
        }
        private void UpdateTowerUINetController(TowerEntityController _towerEntityController)
        {
            _towerEntityController.TowerUINetworkController = this;
            TowerEntityController          = _towerEntityController;
            networkObject.TowerEntityNetID = TowerEntityController.networkObject.NetworkId;
            var towerEntityTransf = _towerEntityController.GetComponent <Transform>();

            GameEntityRegister = _towerEntityController.GameEntityRegister;
            transform.SetParent(towerEntityTransf);

            // Set Tower UI only for non owner process (client of the player)
            if (!isServerProcess && !networkObject.IsOwner)
            {
                TowerUIInstantiated.gameObject.transform.SetParent(this.gameObject.transform);
                //Deactivates the EventSystem
                var eventSystem = TowerUIInstantiated.GetComponentInChildren <EventSystem>();
                eventSystem.gameObject.SetActive(false);
                //set the towerEntity as the parent of tower effect
                InstantiatedTowerEffect.transform.SetParent(TowerEntityController.transform);
                InstantiatedTowerEffect.transform.localPosition = Vector3.zero;
            }
        }
        protected void UpdateDestinationAttributes(string _playerName,
                                                   string _selectedUma,
                                                   Color _cursorColor,
                                                   Vector3 _cursorsDimension)
        {
            //Change the name of the gameObject and make it visible in the editor
            PlayerName      = _playerName;
            SelectedUma     = _selectedUma;
            gameObject.name = PlayerName;

            //Assign the color/dimension of the cursor and make it visible in the editor
            cursorColor = _cursorColor;
            sphereRend.material.color   = _cursorColor;
            sphere.transform.localScale = _cursorsDimension;

            //Find GameEntityRegister
            GameEntityRegister = FindObjectOfType <GameEntityRegister>();

            //Add this Destination controller to the register
            GameEntityRegister.AddEntity(this);

            //Register the callback for deleting the Destination controller from the register when it will disconnect
            networkObject.onDestroy += NetworkObject_onDestroyRemoveFromRegister;
        }
 private void NetworkObject_onDestroyRemoveFromRegister(NetWorker sender)
 {
     GameEntityRegister.RemoveEntity(this);
 }
Пример #10
0
 private void Awake()
 {
     GameEntityRegister = GetComponent <GameEntityRegister>();
 }