示例#1
0
        public void RequireEnterGameServer(int nRoleIndex)
        {
            m_nRoleIndex = nRoleIndex;
            Debug.Log("RequireEnterGameServer:" + nRoleIndex);
            NFMsg.RoleLiteInfo       info  = (NFMsg.RoleLiteInfo)mRoleList[nRoleIndex];
            NFMsg.ReqEnterGameServer xData = new NFMsg.ReqEnterGameServer();
            xData.name    = info.noob_name;
            xData.account = ByteString.CopyFromUtf8(mLoginModule.mAccount);
            xData.game_id = mLoginModule.mServerID;
            xData.id      = info.id;
            MemoryStream stream = new MemoryStream();

            xData.WriteTo(stream);

            mRoleID             = mHelpModule.PBToNF(info.id);
            mNetModule.mOwnerID = mRoleID;

            mNetModule.SendToServerByPB(NFMsg.EGameMsgID.EGMI_REQ_ENTER_GAME, stream);
        }
        public void RequireEnterGameServer(int nRoleIndex)
        {
            m_nRoleIndex = nRoleIndex;
            Debug.Log("RequireEnterGameServer:" + nRoleIndex);
            NFMsg.RoleLiteInfo       info  = (NFMsg.RoleLiteInfo)mRoleList[nRoleIndex];
            NFMsg.ReqEnterGameServer xData = new NFMsg.ReqEnterGameServer();
            xData.name    = info.noob_name;
            xData.account = UnicodeEncoding.Default.GetBytes(mLoginModule.mAccount);
            xData.game_id = mLoginModule.mServerID;
            xData.id      = info.id;
            MemoryStream stream = new MemoryStream();

            Serializer.Serialize <NFMsg.ReqEnterGameServer>(stream, xData);

            mRoleID             = mHelpModule.PBToNF(info.id);
            mNetModule.mOwnerID = mRoleID;

            mNetModule.SendToServerByPB(NFMsg.EGameMsgID.EGMI_REQ_ENTER_GAME, stream);
        }
示例#3
0
        public void OnPlayerMove(UInt16 id, MemoryStream stream)
        {
            NFMsg.MsgBase xMsg = NFMsg.MsgBase.Parser.ParseFrom(stream);

            NFMsg.ReqAckPlayerMove xData = NFMsg.ReqAckPlayerMove.Parser.ParseFrom(xMsg.msg_data);

            if (xData.target_pos.Count <= 0)
            {
                return;
            }

            NFGUID tar = mHelpModule.PBToNF(xData.mover);

            if (tar == mLoginModule.mRoleID)
            {
                return;
            }

            GameObject  player      = GetObject(tar);
            OtherPlayer otherPlayer = player.GetComponent <OtherPlayer>();

            float fSpeed = xData.speed;

            long      nType = xData.moveType;
            NFVector3 pos   = mHelpModule.PBToNF(xData.target_pos[0]);
            Vector3   vPos  = new Vector3(pos.X(), pos.Y(), pos.Z());

            if (nType > 0)
            {
                otherPlayer.JumpTo(vPos);
            }
            else
            {
                otherPlayer.MoveTo((float)fSpeed, vPos);
            }

            Debug.Log("Player Move:" + vPos.ToString());
        }
示例#4
0
        private void ADD_ROW(NFGUID self, string strRecordName, NFMsg.RecordAddRowStruct xAddStruct)
        {
            NFIObject go = mKernelModule.GetObject(self);

            if (go == null)
            {
                return;
            }
            NFIRecordManager xRecordManager = go.GetRecordManager();

            Hashtable recordVecDesc = new Hashtable();
            Hashtable recordVecData = new Hashtable();

            for (int k = 0; k < xAddStruct.record_int_list.Count; ++k)
            {
                NFMsg.RecordInt addIntStruct = (NFMsg.RecordInt)xAddStruct.record_int_list[k];

                if (addIntStruct.col >= 0)
                {
                    recordVecDesc[addIntStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_INT;
                    recordVecData[addIntStruct.col] = addIntStruct.data;
                }
            }

            for (int k = 0; k < xAddStruct.record_float_list.Count; ++k)
            {
                NFMsg.RecordFloat addFloatStruct = (NFMsg.RecordFloat)xAddStruct.record_float_list[k];

                if (addFloatStruct.col >= 0)
                {
                    recordVecDesc[addFloatStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_FLOAT;
                    recordVecData[addFloatStruct.col] = addFloatStruct.data;
                }
            }

            for (int k = 0; k < xAddStruct.record_string_list.Count; ++k)
            {
                NFMsg.RecordString addStringStruct = (NFMsg.RecordString)xAddStruct.record_string_list[k];

                if (addStringStruct.col >= 0)
                {
                    recordVecDesc[addStringStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_STRING;
                    recordVecData[addStringStruct.col] = System.Text.Encoding.Default.GetString(addStringStruct.data);
                }
            }

            for (int k = 0; k < xAddStruct.record_object_list.Count; ++k)
            {
                NFMsg.RecordObject addObjectStruct = (NFMsg.RecordObject)xAddStruct.record_object_list[k];

                if (addObjectStruct.col >= 0)
                {
                    recordVecDesc[addObjectStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_OBJECT;
                    recordVecData[addObjectStruct.col] = mHelpModule.PBToNF(addObjectStruct.data);
                }
            }

            for (int k = 0; k < xAddStruct.record_vector2_list.Count; ++k)
            {
                NFMsg.RecordVector2 addObjectStruct = (NFMsg.RecordVector2)xAddStruct.record_vector2_list[k];

                if (addObjectStruct.col >= 0)
                {
                    recordVecDesc[addObjectStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_VECTOR2;
                    recordVecData[addObjectStruct.col] = mHelpModule.PBToNF(addObjectStruct.data);
                }
            }

            for (int k = 0; k < xAddStruct.record_vector3_list.Count; ++k)
            {
                NFMsg.RecordVector3 addObjectStruct = (NFMsg.RecordVector3)xAddStruct.record_vector3_list[k];

                if (addObjectStruct.col >= 0)
                {
                    recordVecDesc[addObjectStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_VECTOR3;
                    recordVecData[addObjectStruct.col] = mHelpModule.PBToNF(addObjectStruct.data);
                }
            }

            NFDataList varListDesc = new NFDataList();
            NFDataList varListData = new NFDataList();

            for (int m = 0; m < recordVecDesc.Count; m++)
            {
                if (recordVecDesc.ContainsKey(m) && recordVecData.ContainsKey(m))
                {
                    NFDataList.VARIANT_TYPE nType = (NFDataList.VARIANT_TYPE)recordVecDesc[m];
                    switch (nType)
                    {
                    case NFDataList.VARIANT_TYPE.VTYPE_INT:
                    {
                        varListDesc.AddInt(0);
                        varListData.AddInt((Int64)recordVecData[m]);
                    }

                    break;

                    case NFDataList.VARIANT_TYPE.VTYPE_FLOAT:
                    {
                        varListDesc.AddFloat(0.0f);
                        varListData.AddFloat((float)recordVecData[m]);
                    }
                    break;

                    case NFDataList.VARIANT_TYPE.VTYPE_STRING:
                    {
                        varListDesc.AddString("");
                        varListData.AddString((string)recordVecData[m]);
                    }
                    break;

                    case NFDataList.VARIANT_TYPE.VTYPE_OBJECT:
                    {
                        varListDesc.AddObject(new NFGUID());
                        varListData.AddObject((NFGUID)recordVecData[m]);
                    }
                    break;

                    case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2:
                    {
                        varListDesc.AddVector2(new NFVector2());
                        varListData.AddVector2((NFVector2)recordVecData[m]);
                    }
                    break;

                    case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3:
                    {
                        varListDesc.AddVector3(new NFVector3());
                        varListData.AddVector3((NFVector3)recordVecData[m]);
                    }
                    break;

                    default:
                        break;
                    }
                }
                else
                {
                    //����
                    //Debug.LogException(i);
                }
            }

            NFIRecord xRecord = xRecordManager.GetRecord(strRecordName);

            if (null == xRecord)
            {
                string    strClassName  = mKernelModule.QueryPropertyString(self, NFrame.IObject.ClassName);
                NFIClass  xLogicClass   = mClassModule.GetElement(strClassName);
                NFIRecord xStaticRecord = xLogicClass.GetRecordManager().GetRecord(strRecordName);

                xRecord = xRecordManager.AddRecord(strRecordName, 512, varListDesc, xStaticRecord.GetTagData());
            }

            xRecord.AddRow(xAddStruct.row, varListData);
        }
示例#5
0
        /////////////////////////////////////////////////////////////////////

        private void OnPropertyInt(UInt16 id, MemoryStream stream)
        {
            NFMsg.MsgBase xMsg = NFMsg.MsgBase.Parser.ParseFrom(stream);

            NFMsg.ObjectPropertyInt propertyData = NFMsg.ObjectPropertyInt.Parser.ParseFrom(xMsg.msg_data);

            NFIObject          go = mKernelModule.GetObject(mHelpModule.PBToNF(propertyData.player_id));
            NFIPropertyManager propertyManager = go.GetPropertyManager();

            for (int i = 0; i < propertyData.property_list.Count; i++)
            {
                NFIProperty property = propertyManager.GetProperty(propertyData.property_list[i].property_name.ToStringUtf8());
                if (null == property)
                {
                    NFDataList varList = new NFDataList();
                    varList.AddInt(0);

                    property = propertyManager.AddProperty(propertyData.property_list[i].property_name.ToStringUtf8(), varList);
                }

                property.SetInt(propertyData.property_list[i].data);
            }
        }
示例#6
0
        /////////////////////////////////////////////////////////////////////

        private void OnPropertyInt(UInt16 id, MemoryStream stream)
        {
            NFMsg.MsgBase xMsg = new NFMsg.MsgBase();
            xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream);

            NFMsg.ObjectPropertyInt propertyData = new NFMsg.ObjectPropertyInt();
            propertyData = Serializer.Deserialize <NFMsg.ObjectPropertyInt>(new MemoryStream(xMsg.msg_data));

            NFIObject          go = mKernelModule.GetObject(mHelpModule.PBToNF(propertyData.player_id));
            NFIPropertyManager propertyManager = go.GetPropertyManager();

            for (int i = 0; i < propertyData.property_list.Count; i++)
            {
                NFIProperty property = propertyManager.GetProperty(System.Text.Encoding.Default.GetString(propertyData.property_list[i].property_name));
                if (null == property)
                {
                    NFDataList varList = new NFDataList();
                    varList.AddInt(0);

                    property = propertyManager.AddProperty(System.Text.Encoding.Default.GetString(propertyData.property_list[i].property_name), varList);
                }

                property.SetInt(propertyData.property_list[i].data);
            }
        }