Esempio n. 1
0
        public GameObject ActivateSuspendedObject(Vector3 _position, Quaternion _rotation)
        {
            GameObject _object = null;

            if (SuspendedObjects.Count > 0)
            {
                _object = SuspendedObjects[0];

                if (_object != null)
                {
                    SuspendedObjects.Remove(_object);

                    _object.transform.position = _position;
                    _object.transform.rotation = _rotation;

                    ICEWorldEntity _entity = _object.GetComponent <ICEWorldEntity>();

                    if (_entity != null)
                    {
                        _entity.Reset();
                    }

                    _object.SetActive(true);
                    Register(_object);
                }
            }

            return(_object);
        }
Esempio n. 2
0
        public bool Deregister(GameObject _object)
        {
            if (_object == null || !Enabled)
            {
                return(false);
            }

            ICECreatureEntity _entity = _object.GetComponent <ICECreatureEntity>();

            if (_entity != null)
            {
                OnGroupMessage -= _entity.Message.ReceiveGroupMessage;
            }

            if (SuspendedObjects.Count > 0)
            {
                SuspendedObjects.Remove(_object);
            }

            if (ActiveObjects.Count > 0)
            {
                return(ActiveObjects.Remove(_object));
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        private GameObject SpawnLocalPlayer()
        {
            if (!SpawningLocalPlayerIsAvailable)
            {
                return(null);
            }

            Vector3 _position = GetSpawnPosition();

            Quaternion _rotation = Random.rotation;

            _rotation.z = 0;
            _rotation.x = 0;

            if (WorldManager.LocalPlayer != null && WorldManager.LocalPlayer.activeInHierarchy == false)
            {
                SuspendedObjects.Remove(WorldManager.LocalPlayer);

                WorldManager.LocalPlayer.transform.position = _position;
                WorldManager.LocalPlayer.transform.rotation = _rotation;
            }

            if (WorldManager.LocalPlayer == null)
            {
                WorldManager.LocalPlayer = WorldManager.Instantiate(ReferenceGameObject, _position, _rotation);
            }

            if (WorldManager.LocalPlayer != null)
            {
                //WorldManager.LocalPlayer.name = ReferenceGameObject.name;

                ICEWorldEntity _entity = WorldManager.LocalPlayer.GetComponent <ICEWorldEntity>();

                // if the player is an ICE entity we have to adapt the parent according to it's hierarchy settings
                if (_entity != null && _entity.UseHierarchyManagement)
                {
                    WorldManager.LocalPlayer.transform.SetParent(UpdateGroupParent(), true);
                }

                if (_entity != null)
                {
                    _entity.Reset();
                    _entity.IsLocal = true;
                }

                WorldManager.LocalPlayer.SetActive(true);
                Register(WorldManager.LocalPlayer);

                m_SpawnCycles++;
            }

            return(WorldManager.LocalPlayer);
        }
Esempio n. 4
0
        public void DestroyItem(GameObject _object)
        {
            if (_object == null && EntityGameObject != _object)
            {
                return;
            }

            SuspendedObjects.Remove(_object);
            ActiveObjects.Remove(_object);

            if (!CompareByID(_object.GetInstanceID()))
            {
                CreatureRegister.Destroy(_object);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Remove the specified _object by using the UseSoftRespawn option of the ReferenceGroup. If UseSoftRespawn
        /// is active the specified _object will be moved from the ActiveObjects list to the SuspendedObjects list and
        /// its values will be adjusted to the default values, otherwise if UseSoftRespawn is disabled the specified
        /// _object will be finally destroyed.
        /// </summary>
        /// <param name="_object">Object.</param>
        public bool Remove(GameObject _object)
        {
            if (_object == null)
            {
                return(false);
            }

            if (UseSoftRespawn)
            {
                //Debug.Log( "ReferenceGroupObject.Remove: " + _object.name );

                _object.transform.position = Vector3.zero;
                _object.transform.rotation = Quaternion.identity;
                _object.SetActive(false);

                if (ActiveObjects.Count > 0)
                {
                    return(ActiveObjects.Remove(_object));
                }

                SuspendedObjects.Add(_object);

                ICECreatureEntity _entity = _object.GetComponent <ICECreatureEntity>();

                // if the object is an ICE entity we have to adapt the parent according to it's hierarchy settings
                if (_entity != null && _entity.UseHierarchyManagement)
                {
                    _object.transform.SetParent(UpdateGroupParent(), true);
                }


                //TODO: CreatureRegister.DetachFromTransform( _object );
            }
            else
            {
                DestroyItem(_object);
            }

            return(true);
        }