// -------------------------------------------

        /*
         * CheckForwardVectorRemote
         */
        private void CheckForwardVectorRemote()
        {
            for (int i = 0; i < m_clients.Count; i++)
            {
                if (m_clients[i] != null)
                {
                    ItemClientView itemClientView = m_clients[i].GetComponent <ItemClientView>();
                    if (itemClientView != null)
                    {
                        if (itemClientView.Forward == null)
                        {
                            for (int j = 0; j < NetworkVariablesController.Instance.NetworkVariables.Count; j++)
                            {
                                INetworkVariable variable = NetworkVariablesController.Instance.NetworkVariables[j];
                                if (itemClientView.ConnectionData.Id == variable.Owner)
                                {
                                    if (variable is NetworkVector3)
                                    {
                                        itemClientView.Forward = (NetworkVector3)variable;
                                        NetworkEventController.Instance.DelayNetworkEvent(EVENT_MAINMENU_REQUEST_PHONE_NUMBERS, 0.2f);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // -------------------------------------------

        /*
         * OnNetworkEvent
         */
        private void OnNetworkEvent(string _nameEvent, bool _isLocalEvent, int _networkOriginID, int _networkTargetID, object[] _list)
        {
            if (!this.gameObject.activeSelf)
            {
                return;
            }

            if (_nameEvent == NetworkEventController.EVENT_SYSTEM_INITIALITZATION_LOCAL_COMPLETED)
            {
                if (ENABLE_ARCORE_CLOUD_SHARED)
                {
                    if (YourNetworkTools.Instance.IsServer)
                    {
                        m_enableSetUpAnchor = true;
                    }
                }
                else
                {
                    m_enableSetUpAnchor = true;
                }
            }
            if (_nameEvent == NetworkEventController.EVENT_SYSTEM_VARIABLE_CREATE_LOCAL)
            {
                if (!ENABLE_ARCORE_CLOUD_SHARED)
                {
                    return;
                }

                if (!YourNetworkTools.Instance.IsServer)
                {
                    INetworkVariable objData = (INetworkVariable)_list[0];
                    bool             check   = false;
                    if (objData.Name == NAME_CLOUD_ANCHOR_ID)
                    {
                        m_networkCloudId = (NetworkString)objData;
                        check            = true;
                    }
                    if (objData.Name == NAME_CLOUD_VECTOR_BASE)
                    {
                        m_networkVectorBaseServer = (NetworkVector3)objData;
                        check = true;
                    }
                    if (objData.Name == NAME_CLOUD_ANCHOR_POSITION)
                    {
                        m_networkAnchorBaseServer = (NetworkVector3)objData;
                        check = true;
                    }
                    if (check)
                    {
                        if ((m_networkCloudId != null) && (m_networkVectorBaseServer != null) && (m_networkAnchorBaseServer != null))
                        {
                            Debug.Log("**************************START JOINING PROCESS**************************");
                            WaitForARCoreValid();
                        }
                    }
                }
            }
        }
Exemple #3
0
        // -------------------------------------------

        /*
         * Get the network variable by its name
         */
        protected INetworkVariable GetNetworkVariable(INetworkVariable _networkVariable)
        {
            for (int i = 0; i < m_networkVariables.Count; i++)
            {
                if (m_networkVariables[i] == _networkVariable)
                {
                    return(m_networkVariables[i]);
                }
            }
            return(null);
        }
        internal void InitializeVariables()
        {
            if (m_VarInit)
            {
                return;
            }
            m_VarInit = true;

            FieldInfo[] sortedFields = GetFieldInfoForType(GetType());

            for (int i = 0; i < sortedFields.Length; i++)
            {
                Type fieldType = sortedFields[i].FieldType;

                if (fieldType.HasInterface(typeof(INetworkVariable)))
                {
                    INetworkVariable instance = (INetworkVariable)sortedFields[i].GetValue(this);

                    if (instance == null)
                    {
                        instance = (INetworkVariable)Activator.CreateInstance(fieldType, true);
                        sortedFields[i].SetValue(this, instance);
                    }

                    instance.SetNetworkBehaviour(this);
                    NetworkVariableFields.Add(instance);
                }
            }

            {
                // Create index map for channels
                var firstLevelIndex    = new Dictionary <NetworkChannel, int>();
                int secondLevelCounter = 0;

                for (int i = 0; i < NetworkVariableFields.Count; i++)
                {
                    NetworkChannel networkChannel = NetworkVariableFields[i].GetChannel();

                    if (!firstLevelIndex.ContainsKey(networkChannel))
                    {
                        firstLevelIndex.Add(networkChannel, secondLevelCounter);
                        m_ChannelsForNetworkVariableGroups.Add(networkChannel);
                        secondLevelCounter++;
                    }

                    if (firstLevelIndex[networkChannel] >= m_ChannelMappedNetworkVariableIndexes.Count)
                    {
                        m_ChannelMappedNetworkVariableIndexes.Add(new HashSet <int>());
                    }

                    m_ChannelMappedNetworkVariableIndexes[firstLevelIndex[networkChannel]].Add(i);
                }
            }
        }
        // -------------------------------------------

        /*
         * Destroy all the references
         */
        public override void Destroy()
        {
            base.Destroy();
            if (m_networkVariable != null)
            {
                m_networkVariable.Destroy();
            }
            m_networkVariable = null;
            if (m_networkObject != null)
            {
                NetworkObject.Destroy();
            }
            m_networkObject = null;
        }
        public BaseNetworkVariableHelper(INetworkVariable networkVariable)
        {
            if (s_Instances == null)
            {
                s_Instances = new Dictionary <BaseNetworkVariableHelper, INetworkVariable>();
            }

            if (s_InstanceChangedCount == null)
            {
                s_InstanceChangedCount = new Dictionary <INetworkVariable, int>();
            }

            // Register new instance and associated INetworkVariable
            if (!s_Instances.ContainsKey(this))
            {
                s_Instances.Add(this, networkVariable);
                if (!s_InstanceChangedCount.ContainsKey(networkVariable))
                {
                    s_InstanceChangedCount.Add(networkVariable, 0);
                }
            }
        }
Exemple #7
0
        // -------------------------------------------

        /*
         * Manager of global events
         */
        protected override void OnNetworkEvent(string _nameEvent, bool _isLocalEvent, int _networkOriginID, int _networkTargetID, params object[] _list)
        {
            base.OnNetworkEvent(_nameEvent, _isLocalEvent, _networkOriginID, _networkTargetID, _list);

            if (_nameEvent == NetworkEventController.EVENT_SYSTEM_DESTROY_NETWORK_COMMUNICATIONS)
            {
                m_requestedDestroyEverything = true;
                Destroy();
            }
            if (_nameEvent == NetworkEventController.EVENT_SYSTEM_INITIALITZATION_REMOTE_COMPLETED)
            {
                NetworkEventController.Instance.DispatchLocalEvent(NetworkVariable.EVENT_NETWORKVARIABLE_REQUEST_ALL);
            }
            if (_nameEvent == NetworkEventController.EVENT_SYSTEM_VARIABLE_CREATE_LOCAL)
            {
                INetworkVariable networkVariable = (INetworkVariable)_list[0];
                if (GetNetworkVariable(networkVariable) == null)
                {
                    Debug.Log("ADDING THE NEW VARIABLE TO THE SYSTEM::networkVariable=" + networkVariable.Name);
                    m_networkVariables.Add(networkVariable);
                }
            }
            if (_nameEvent == NetworkEventController.EVENT_SYSTEM_VARIABLE_CREATE_REMOTE)
            {
                int    ownerVariable = int.Parse((string)_list[0]);
                string nameVariable  = (string)_list[1];
                string valueVariable = (string)_list[2];
                string typeVariable  = (string)_list[3];
                Debug.Log("EVENT_SYSTEM_VARIABLE_CREATE_REMOTE::nameVariable[" + nameVariable + "]=" + valueVariable);
                if (GetNetworkVariable(nameVariable) == null)
                {
                    INetworkVariable networkVariable = null;
                    if (NetworkVector3.GetTypeVector3() == typeVariable)
                    {
                        NetworkVector3 networkVector3 = new NetworkVector3();
                        networkVector3.InitLocal(ownerVariable, nameVariable, valueVariable);
                        networkVariable = networkVector3;
                    }
                    else if (NetworkQuaternion.GetTypeQuaternion().ToString() == typeVariable)
                    {
                        NetworkQuaternion networkQuaternion = new NetworkQuaternion();
                        networkQuaternion.InitLocal(ownerVariable, nameVariable, valueVariable);
                        networkVariable = networkQuaternion;
                    }
                    else if (NetworkInteger.GetTypeInteger().ToString() == typeVariable)
                    {
                        NetworkInteger networkInteger = new NetworkInteger();
                        networkInteger.InitLocal(ownerVariable, nameVariable, int.Parse(valueVariable));
                        networkVariable = networkInteger;
                    }
                    else if (NetworkString.GetTypeString().ToString() == typeVariable)
                    {
                        NetworkString networkString = new NetworkString();
                        networkString.InitLocal(ownerVariable, nameVariable, valueVariable);
                        networkVariable = networkString;
                    }
                    else if (NetworkFloat.GetTypeFloat().ToString() == typeVariable)
                    {
                        NetworkFloat networkFloat = new NetworkFloat();
                        networkFloat.InitLocal(ownerVariable, nameVariable, valueVariable);
                        networkVariable = networkFloat;
                    }

                    if (networkVariable != null)
                    {
                        m_networkVariables.Add(networkVariable);
                    }
                }
            }
            if (_nameEvent == NetworkEventController.EVENT_WORLDOBJECTCONTROLLER_DESTROY_CONFIRMATION)
            {
                if (!m_requestedDestroyEverything)
                {
                    string nameAssignedToDestroy = (string)_list[0];
                    if (!RemoveNetworkVariable(nameAssignedToDestroy))
                    {
                        Debug.Log("NetworkVariablesController::EVENT_WORLDOBJECTCONTROLLER_DESTROY_CONFIRMATION::The network variable[" + nameAssignedToDestroy + "] was NOT removed");
                    }
                }
            }
        }
Exemple #8
0
        // -------------------------------------------

        /*
         * Check equality
         */
        public virtual bool Equals(INetworkVariable _other)
        {
            return(m_name == _other.Name);
        }
 public NetworkVariableHelper(INetworkVariable networkVariable) : base(networkVariable)
 {
     m_NetworkVariable = networkVariable as NetworkVariable <T>;
     m_NetworkVariable.OnValueChanged = OnVariableChanged;
 }
        // -------------------------------------------

        /*
         * Set reference
         */
        public virtual void SetReference(INetworkVariable _reference)
        {
            m_networkVariable = _reference;
        }