Пример #1
0
        public static void SetButton(string name, bool value)
        {
            if (name == null)
            {
                Debug.LogError("[FduClusterInput]Button name can not be null");
                return;
            }
            if (!_instance.isMaster)
            {
                return;
            }
            if (!_instance._buttonMap.ContainsKey(name))
            {
                _instance.kmCollector.addButtonName(name);

                SerializeData _data = new SerializeData();
                _data.name = name;
                _data.type = FduClusterInputType.Button;
                ButtonData bData = new ButtonData();
                bData.reset();
                bData.setValue(value);
                _instance._sendList.Add(_data);
                _instance._buttonMap.Add_overlay(name, bData);
                return;
            }
            else
            {
                _instance._buttonMap[name].setValue(value);
            }
        }
Пример #2
0
        public override NetworkState.NETWORK_STATE_TYPE Deserialize()
        {
            NetworkState.NETWORK_STATE_TYPE state = NetworkState.NETWORK_STATE_TYPE.SUCCESS;
            int count = BufferedNetworkUtilsClient.ReadInt(ref state);

            for (int i = 0; i < count; ++i)
            {
                string name = BufferedNetworkUtilsClient.ReadString(ref state);
                FduClusterInputType type = (FduClusterInputType)BufferedNetworkUtilsClient.ReadByte(ref state);
                switch (type)
                {
                case FduClusterInputType.Axis:
                    float fvalue = BufferedNetworkUtilsClient.ReadFloat(ref state);
                    if (!_axisMap.ContainsKey(name))
                    {
                        AxisData _data = new AxisData();
                        _data.reset();
                        _data.setValue(fvalue);
                        _axisMap.Add(name, _data);
                    }
                    else
                    {
                        _axisMap[name].setValue(fvalue);
                    }
                    break;

                case FduClusterInputType.Button:
                    bool bvalue = BufferedNetworkUtilsClient.ReadBool(ref state);
                    if (!_buttonMap.ContainsKey(name))
                    {
                        ButtonData _data = new ButtonData();
                        _data.reset();
                        _data.setValue(bvalue);
                        _buttonMap.Add(name, _data);
                    }
                    else
                    {
                        _buttonMap[name].setValue(bvalue);
                    }
                    break;

                case FduClusterInputType.Tracker:
                    Vector3    v3Value = BufferedNetworkUtilsClient.ReadVector3(ref state);
                    Quaternion quValue = BufferedNetworkUtilsClient.ReadQuaternion(ref state);
                    if (!_trackerMap.ContainsKey(name))
                    {
                        TrackerData _data = new TrackerData();
                        _data.reset();
                        _data.setPosValue(v3Value);
                        _data.setRotValue(quValue);
                        _trackerMap.Add(name, _data);
                    }
                    else
                    {
                        _trackerMap[name].setPosValue(v3Value);
                        _trackerMap[name].setRotValue(quValue);
                    }
                    break;
                }
            }
            //if(!BufferedNetworkUtilsClient.ReadString(ref state).Equals("ClusterInputMgrEndFlag"))
            //{
            //    Debug.LogError("Wrong end!");
            //}
            //StartCoroutine(swapValueCo());
            return(state);
        }