Beispiel #1
0
        private void OnObjectMove(UInt16 id, MemoryStream stream)
        {
            NFMsg.MsgBase xMsg = new NFMsg.MsgBase();
            xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream);

            NFMsg.ReqAckPlayerMove xData = new NFMsg.ReqAckPlayerMove();
            xData = Serializer.Deserialize <NFMsg.ReqAckPlayerMove>(new MemoryStream(xMsg.msg_data));
            if (xData.target_pos.Count <= 0)
            {
                return;
            }
            float fSpeed = NFCKernelModule.Instance().QueryPropertyInt(PBToNF(xData.mover), "MOVE_SPEED") / 10000.0f;

            Debug.LogWarning("Object Move: " + PBToNF(xData.mover).ToString());
            NFIDataList var = new NFCDataList();

            var.AddObject(PBToNF(xData.mover));
            var.AddFloat(fSpeed);
            NFVector3 pos   = PBToNF(xData.target_pos[0]);
            float     fTemp = pos.Z();

            pos.SetZ(pos.Y());
            pos.SetY(fTemp);
            var.AddVector3(pos);

            DoEvent((int)Event.PlayerMove, var);
        }
Beispiel #2
0
        public void OnPlayerMove(NFDataList valueList)
        {
            NFGUID tar = valueList.ObjectVal(0);

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

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

            double    fSpeed = valueList.FloatVal(1);
            long      nType  = valueList.IntVal(2);
            NFVector3 pos    = valueList.Vector3Val(3);
            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());
        }
Beispiel #3
0
        private void OnClassNPCEventHandler(NFGUID self, int nContainerID, int nGroupID, NFIObject.CLASS_EVENT_TYPE eType, string strClassName, string strConfigIndex)
        {
            if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE)
            {
                string    strConfigID = mKernelModule.QueryPropertyString(self, NFrame.NPC.ConfigID);
                NFVector3 vec3        = mKernelModule.QueryPropertyVector3(self, NFrame.NPC.Position);

                Vector3 vec = new Vector3();
                vec.x = vec3.X();
                vec.y = vec3.Y();
                vec.z = vec3.Z();

                string strPrefabPath = "";
                if (strConfigID.Length <= 0)
                {
                    strPrefabPath = mElementModule.QueryPropertyString("Enemy", NPC.Prefab);
                }
                else
                {
                    strPrefabPath = mElementModule.QueryPropertyString(strConfigID, NPC.Prefab);
                }

                GameObject xNPC = CreateObject(self, strPrefabPath, vec, strClassName);
                if (xNPC == null)
                {
                    Debug.LogError("Create GameObject fail in " + strConfigID + "  " + strPrefabPath);

                    return;
                }

                xNPC.name = strConfigIndex;
                xNPC.transform.Rotate(new Vector3(0, 90, 0));

                NFBodyIdent xBodyIdent = xNPC.GetComponent <NFBodyIdent>();
                if (null != xBodyIdent)
                {//不能没有
                    xBodyIdent.enabled = true;
                    xBodyIdent.SetObjectID(self);
                    xBodyIdent.cnfID = strConfigID;
                }
                else
                {
                    Debug.LogError("No 'BodyIdent' component in " + strConfigID + "  " + strPrefabPath);
                }

                InitPlayerComponent(self, xNPC, false);
            }
            else if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_LOADDATA)
            {
            }
            else if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_DESTROY)
            {
                DestroyObject(self);
            }
            else if (eType == NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE_FINISH)
            {
                //NFCKernelModule.Instance.RegisterPropertyCallback(self, NFrame.Player.PrefabPath, OnClassPrefabEventHandler);
            }
        }
Beispiel #4
0
 public void BeforeLoadSceneEnd(int nSceneID)
 {
     foreach (var v in mhtObject)
     {
         NFVector3 vPos = mKernelModule.QueryPropertyVector3(v.Key, NFrame.NPC.Position);
         v.Value.transform.position = new Vector3(vPos.X(), vPos.Y() + 0.1f, vPos.Z());
     }
 }
        static public NFMsg.Vector3 NFToPB(NFVector3 value)
        {
            NFMsg.Vector3 vector = new NFMsg.Vector3();
            vector.x = value.X();
            vector.y = value.Y();
            vector.z = value.Z();

            return(vector);
        }
Beispiel #6
0
        public static NFVector3 sub(NFVector3 va, NFVector3 vb)
        {
            NFVector3 vector = new NFVector3();

            vector.SetX(va.X() - vb.X());
            vector.SetY(va.Y() - vb.Y());
            vector.SetZ(va.Z() - vb.Z());
            return(vector);
        }
Beispiel #7
0
        private void OnConfigChangeHandler(NFGUID self, string strProperty, NFDataList.TData oldVar, NFDataList.TData newVar)
        {
            Vector3 vec = GetRenderObjectPosition(self);

            DestroyObject(self);

            if (vec.Equals(Vector3.zero))
            {
                NFVector3 vec3 = mKernelModule.QueryPropertyVector3(self, NPC.Position);
                vec.x = vec3.X();
                vec.y = vec3.Y();
                vec.z = vec3.Z();
            }

            string strHeroCnfID  = newVar.StringVal();
            string strPrefabPath = mElementModule.QueryPropertyString(strHeroCnfID, NPC.Prefab);

            if (strPrefabPath.Length <= 0)
            {
                strPrefabPath = mElementModule.QueryPropertyString("Enemy", NPC.Prefab);
            }
            GameObject xPlayer = CreateObject(self, strPrefabPath, vec, NFrame.Player.ThisName);

            if (xPlayer)
            {
                xPlayer.name = NFrame.Player.ThisName;
                xPlayer.transform.Rotate(new Vector3(0, 90, 0));

                NFBodyIdent xBodyIdent = xPlayer.GetComponent <NFBodyIdent>();
                if (null != xBodyIdent)
                {//不能没有
                    xBodyIdent.enabled = true;
                    xBodyIdent.SetObjectID(self);
                    xBodyIdent.cnfID = strHeroCnfID;
                }
                else
                {
                    Debug.LogError("No 'BodyIdent' component in " + strPrefabPath);
                }

                if (self == mLoginModule.mRoleID)
                {
                    InitPlayerComponent(self, xPlayer, true);
                }
                else
                {
                    InitPlayerComponent(self, xPlayer, false);
                }

                Debug.Log("Create Object successful" + NFrame.Player.ThisName + " " + vec.ToString() + " " + self.ToString());
            }
            else
            {
                Debug.LogError("Create Object failed" + NFrame.Player.ThisName + " " + vec.ToString() + " " + self.ToString());
            }
        }
Beispiel #8
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());
        }