Beispiel #1
0
 public static void SendMsg2Client(PlayerInstance player, CSCommon.Data.Message msg)
 {
     RPC.PackageWriter pkg = new RPC.PackageWriter();
     pkg.SetSinglePkg();
     Wuxia.H_RpcRoot.smInstance.RPC_ReceiveMsg(pkg, msg);
     pkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
 }
Beispiel #2
0
 public void AcceptTask()
 {
     //调用客户端接受任务了
     RPC.PackageWriter pkg = new RPC.PackageWriter();
     pkg.SetSinglePkg();
     Wuxia.H_RpcRoot.smInstance.RPC_AcceptTask(pkg, this.mCurTask.TaskData);
     pkg.DoCommandPlanes2Client(this.Planes2GateConnect, this.ClientLinkId);
 }
Beispiel #3
0
        public void ItemStackNumChangedToClient(ulong id, byte inventoryType, int stackNum)
        {
            var player = mHostRole as PlayerInstance;

            if (player != null)
            {
                RPC.PackageWriter pkg = new RPC.PackageWriter();
                Wuxia.H_RpcRoot.smInstance.RPC_ItemStackNumChanged(pkg, id, inventoryType, stackNum);
                pkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
            }
        }
Beispiel #4
0
        private void ItemRmoveToClient(ulong id, byte inventoryType)
        {
            var player = mHostRole as PlayerInstance;

            if (player != null)
            {
                RPC.PackageWriter pkg = new RPC.PackageWriter();
                Wuxia.H_RpcRoot.smInstance.RPC_ItemRemove(pkg, id, inventoryType);
                pkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
            }
        }
Beispiel #5
0
        public bool AutoAddItem(Item item)
        {
            //先找能堆叠的
            for (UInt16 i = 0; i < mBagSize; i++)
            {
                if (mItems[i] != null && mItems[i].ItemTemplate == item.ItemTemplate)
                {
                    if (mItems[i].StackNum >= item.MaxStackNum)
                    {
                        continue;
                    }
                    int canPut = item.MaxStackNum - mItems[i].StackNum;
                    if (item.StackNum >= canPut)
                    {
                        item.StackNum     -= canPut;
                        mItems[i].StackNum = item.MaxStackNum;
                    }
                    else
                    {
                        mItems[i].StackNum += item.StackNum;
                        item.StackNum       = 0;
                    }

                    ItemStackNumChangedToClient(mItems[i].ItemData.ItemId, (byte)InventoryType, mItems[i].StackNum);

                    if (item.StackNum <= 0)
                    {
                        item.DestroyFromDB(mHostRole);
                        return(true);
                    }
                }
            }

            for (UInt16 i = 0; i < mBagSize; i++)
            {
                if (mItems[i] == null)
                {
                    this[i] = item;

                    var player = mHostRole as PlayerInstance;
                    if (player != null)
                    {
                        RPC.PackageWriter pkg = new RPC.PackageWriter();
                        pkg.SetSinglePkg();
                        Wuxia.H_RpcRoot.smInstance.RPC_ItemAdd2Bag(pkg, item.ItemData, (byte)InventoryType, i);
                        pkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
                    }
                    OnItemsChanged();
                    return(true);
                }
            }
            return(false);
        }
Beispiel #6
0
        protected override void OnPutItem(UInt16 index, Item item)
        {
            this[index] = item;
            var player = mHostRole as PlayerInstance;

            if (player != null)
            {
                RPC.PackageWriter pkg = new RPC.PackageWriter();
                pkg.SetSinglePkg();
                Wuxia.H_RpcRoot.smInstance.RPC_ItemAdd2Bag(pkg, item.ItemData, (byte)InventoryType, index);
                pkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
            }
        }
Beispiel #7
0
        public override bool OnValueChanged(string name, RPC.DataWriter value)
        {
            if (true == base.OnValueChanged(name, value))
            {
                return(true);
            }

            //这些数据只需要告诉玩家自己,不需要告诉别的客户端
            var pkg = new RPC.PackageWriter();

            Wuxia.H_RpcRoot.smInstance.RPC_UpdateRoleValue(pkg, name, value);
            pkg.DoCommandPlanes2Client(this.Planes2GateConnect, this.ClientLinkId);
            return(true);
        }
Beispiel #8
0
        //// TODO: 增加筛选条件,如根据阵营来筛选结果
        //public List<RoleActor> HandleRoleCollide(Summon.SummonRole summon, RoleActor ignore)
        //{
        //    //这里以后最好分和哪些类型对象碰撞来做,这样效率高
        //    List<RoleActor> retList = new List<RoleActor>();

        //    foreach (var role in mRoleDictionary)
        //    {
        //        if (role.Value.Id == ignore.Id)
        //            continue;
        //        if (role.Value.Id == summon.OwnerRole.Id)
        //            continue;

        //        var distance = summon.SummonData.Position - role.Value.GetPosition();
        //        if (distance.Length() < summon.SummonData.RuneData.Template.Radius)
        //        {
        //            retList.Add(role.Value);
        //        }
        //    }

        //    return retList;
        //}


        // 将player的信息同步给该格子中的其他玩家, 返回值是实际同步的玩家数量
        public int SendPkg2Client(PlayerInstance player, int maxCount, Random rand, RPC.PackageWriter pkg)
        {
            int retValue = maxCount;

            if (Players.Count <= maxCount)
            {
                retValue = Players.Count;
                foreach (var role in Players)
                {
                    if (player != null && role.Id == player.Id)
                    {
                        retValue--;
                        continue;
                    }

                    pkg.DoCommandPlanes2Client(role.Planes2GateConnect, role.ClientLinkId);
                }
            }
            else
            {
                retValue = maxCount;
                int startIdx = rand.Next(Players.Count - maxCount);
                for (int i = startIdx; i < startIdx + maxCount; i++)
                {
                    if (player != null && Players[i].Id == player.Id)
                    {
                        retValue--;
                        continue;
                    }

                    pkg.DoCommandPlanes2Client(Players[i].Planes2GateConnect, Players[i].ClientLinkId);
                }
            }

            return(retValue);
        }
Beispiel #9
0
        public void used(ServerFrame.TimerEvent et)
        {
            持续时间 -= 时间间隔;
            if (持续时间 <= 0)
            {
                ServerFrame.TimerManager.clearTimer(mTimeHandle);
                return;
            }
            user.ChangeHP(一次加血, user);
            var pkg = new RPC.PackageWriter();

            //Wuxia.H_RpcRoot.smInstance.HIndex(pkg, user.Id).RPC_SkillReceiveData(pkg, 0, 0, (byte)CSCommon.eHitType.AddHp, 一次加血);
            Wuxia.H_RpcRoot.smInstance.HIndex(pkg, user.Id).RPC_FlutterInfo(pkg, (byte)CSCommon.eFlutterInfoType.AddHp, 0, 0, 0);
            pkg.DoCommandPlanes2Client(user.Planes2GateConnect, user.ClientLinkId);
        }
Beispiel #10
0
        //服务器开放
        public void OpenMartial(byte type)
        {
            var build = GetBuild((CSCommon.eBuildType)type);

            if (build == null)
            {
                Log.Log.Item.Info("OpenMartial GetBuild Failed eBuildType : {0}", type);
                return;
            }
            build.Open();
            CreateOutPutToDict(build.OutPutInfo);
            //通知客户端
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            Wuxia.H_RpcRoot.smInstance.RPC_MartialOpen(pkg, type);
            pkg.DoCommandPlanes2Client(this.Planes2GateConnect, this.ClientLinkId);
        }
Beispiel #11
0
        public int Execute(PlayerInstance _user, int count, string arg1, string arg2, string arg3)
        {
            if (_user.PlayerData.RoleDetail.RoleHp >= _user.PlayerData.RoleDetail.RoleMaxHp)
            {
                return((int)CSCommon.eRet_UseItem.HpMax);
            }
            var 一次加血 = Convert.ToInt32(arg1);

            _user.ChangeHP(一次加血, _user);
            var pkg = new RPC.PackageWriter();

            //Wuxia.H_RpcRoot.smInstance.HIndex(pkg, _user.Id).RPC_SkillReceiveData(pkg, 0, 0, (byte)CSCommon.eHitType.AddHp, 一次加血);
            Wuxia.H_RpcRoot.smInstance.HIndex(pkg, _user.Id).RPC_FlutterInfo(pkg, (byte)CSCommon.eFlutterInfoType.AddHp, 0, 0, 0);
            pkg.DoCommandPlanes2Client(_user.Planes2GateConnect, _user.ClientLinkId);
            return(1);
        }
Beispiel #12
0
        public void TellToClientCopyEnd(bool rlt)
        {
            byte result = (byte)CSCommon.eBoolState.False;

            if (rlt)
            {
                if (!mRecordMgr.CopyList.Contains(mInstanceId))
                {
                    mRecordMgr.CopyList.Add(mInstanceId);
                }
                result = (byte)CSCommon.eBoolState.True;
            }
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            Wuxia.H_RpcRoot.smInstance.RPC_OnCopyEnd(pkg, result);
            pkg.DoCommandPlanes2Client(this.Planes2GateConnect, this.ClientLinkId);
        }
Beispiel #13
0
        public sbyte Use(int count, PlayerInstance player)
        {
            sbyte result      = (sbyte)CSCommon.eRet_UseItem.Succeed;
            var   useTemplate = CSTable.StaticDataManager.ItemUse[ItemData.Template.ItemUseId];

            if (useTemplate == null)
            {
                result = (sbyte)CSCommon.eRet_UseItem.TplNull;
                Log.Log.Item.Print("useTemplate == null id={0}", ItemData.Template.ItemUseId);
                return(result);
            }
            if (Script == null)
            {
                Script = System.Activator.CreateInstance(Type.GetType(string.Format("ServerCommon.Planes.{0}", useTemplate.ItemUseMethod)), null) as IUseCommand;
                if (Script == null)
                {
                    result = (sbyte)CSCommon.eRet_UseItem.MethodNull;
                    Log.Log.Item.Print("ERROR:item Use,CreateInstance={0}", useTemplate.ItemUseMethod);
                    return(result);
                }
            }
            int useResult = Script.Execute(player, count, useTemplate.Arg1, useTemplate.Arg2, useTemplate.Arg3);

            if (useResult < 0)
            {
                result = (sbyte)useResult;
            }
            else
            {
                if (useResult > 0)
                {
                    mItemData.StackNum -= useResult;
                    if (mItemData.StackNum > 0)
                    {
                        RPC.PackageWriter pkg = new RPC.PackageWriter();
                        Wuxia.H_RpcRoot.smInstance.RPC_ItemStackNumChanged(pkg, mItemData.ItemId, (byte)mItemData.Inventory, mItemData.StackNum);
                        pkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
                    }
                    else
                    {
                        Inventory.DeleteItem(mItemData.ItemId);
                    }
                }
            }
            return(result);
        }
Beispiel #14
0
        public void TakeOffFashionByType(int type)
        {
            var player = mHostRole as PlayerInstance;

            foreach (var i in mItems)
            {
                if (i == null)
                {
                    continue;
                }
                var tType = (i.ItemTemplate as CSTable.ItemFashionData).FashionType;
                if (i.ItemData.WearState == (byte)CSCommon.eBoolState.True && tType == type)
                {
                    i.ItemData.WearState = (byte)CSCommon.eBoolState.False;
                    RPC.PackageWriter pkg = new RPC.PackageWriter();
                    Wuxia.H_RpcRoot.smInstance.RPC_TakeOffFashion(pkg, i.ItemData.ItemId);
                    pkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
                }
            }
        }
Beispiel #15
0
        public void SendFlutterInfo(int type, int param1, int param2, int value, RoleActor _caster)
        {
            //只把技能结果数据同步给发技能的玩家,或者是收到技能攻击的玩家
            var target = this as PlayerInstance;
            var caster = _caster as PlayerInstance;
            var pkg    = new RPC.PackageWriter();

            if (null != target)
            {
                Wuxia.H_RpcRoot.smInstance.HIndex(pkg, this.Id).RPC_FlutterInfo(pkg, (byte)type, param1, param2, value);
                pkg.DoCommandPlanes2Client(target.Planes2GateConnect, target.ClientLinkId);
            }

            if (caster != null && caster != target)
            {
                pkg = new RPC.PackageWriter();
                Wuxia.H_RpcRoot.smInstance.HIndex(pkg, this.Id).RPC_FlutterInfo(pkg, (byte)type, param1, param2, value);
                pkg.DoCommandPlanes2Client(caster.Planes2GateConnect, caster.ClientLinkId);
            }
        }
Beispiel #16
0
        public bool AddItem2Position(UInt16 pos, Item item)
        {
            if (mItems[pos] != null)
            {
                return(false);
            }
            else
            {
                this[pos] = item;

                var player = mHostRole as PlayerInstance;
                if (player != null)
                {
                    RPC.PackageWriter pkg = new RPC.PackageWriter();
                    pkg.SetSinglePkg();
                    Wuxia.H_RpcRoot.smInstance.RPC_ItemAdd2Bag(pkg, item.ItemData, (byte)InventoryType, pos);
                    pkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
                }
            }
            OnItemsChanged();
            return(true);
        }
Beispiel #17
0
 public void OnChangeTaskProcess()
 {
     RPC.PackageWriter pkg = new RPC.PackageWriter();
     Wuxia.H_RpcRoot.smInstance.RPC_UpdateTaskProcess(pkg, mCurTask.TaskData.Process);
     pkg.DoCommandPlanes2Client(this.Planes2GateConnect, this.ClientLinkId);
 }
Beispiel #18
0
 public static void NoticeNewMail2Client(PlayerInstance player)
 {
     RPC.PackageWriter pkg = new RPC.PackageWriter();
     Wuxia.H_RpcRoot.smInstance.RPC_AddMail(pkg);
     pkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
 }
Beispiel #19
0
 public static void SendTalkMsg2Client(PlayerInstance player, sbyte channel, string sender, string msg, RPC.DataWriter hyperLink)
 {
     RPC.PackageWriter pkg = new RPC.PackageWriter();
     Wuxia.H_RpcRoot.smInstance.RPC_AddTalkMsg(pkg, channel, sender, msg, hyperLink);
     pkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
 }
Beispiel #20
0
        public void EnterMap(CSCommon.Data.PlayerData pd, CSCommon.Data.PlanesData planesData, ushort mapSourceId, ulong instanceId, SlimDX.Vector3 pos, UInt16 cltHandle, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
//             var map = Planes.PlanesManager.Instance.GetGlobalMap(planesData, pd.RoleDetail.MapSourceId);
//             if (map == null)
//                 return;

            Planes.PlayerInstance player = Planes.PlanesServerDataManager.Instance.FindPlayerInstance(pd.RoleDetail.RoleId);
            if (player != null)
            {                                                                                                  //玩家就在这个服务器
                Planes.MapInstanceManager.Instance.PlayerLeaveMap(player, false);                              //离开地图
                player.PlanesInstance.LeavePlanes(player.Id);                                                  //离开位面
                var planes = Planes.MapInstanceManager.Instance.PlanesManager.GetPlanesInstance(planesData);
                planes.EnterPlanes(player);                                                                    //进位面

                Planes.MapInstanceManager.Instance.PlayerEnterMap(player, mapSourceId, instanceId, pos, true); //进地图
            }
            else
            {
                #region CreatePlayerInstance
                try
                {
                    player = Planes.PlayerInstance.CreatePlayerInstance(pd, connect as Iocp.TcpConnect, cltHandle);
                    if (player == null)//创建角色
                    {
                        RPC.PackageWriter pkg = new RPC.PackageWriter();
                        H_RPCRoot.smInstance.HGet_GateServer(pkg).DisconnectPlayer(pkg, pd.RoleDetail.AccountId, (sbyte)eServerType.Planes);
                        pkg.DoCommand(connect, RPC.CommandTargetType.DefaultType);

                        RPC.PackageWriter retPkg = new RPC.PackageWriter();
                        retPkg.Write((sbyte)eRet_GotoMap.CreatePlayerFailed);
                        retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);

                        Log.Log.Server.Print("DataServer1 force disconnect player!");
                        Log.Log.Server.Print(new System.Diagnostics.StackTrace(0, true).ToString());
                        return;
                    }
                }
                catch (System.Exception ex)
                {
                    Log.Log.Server.Print(ex.ToString());
                    Log.Log.Server.Print(ex.StackTrace.ToString());
                    RPC.PackageWriter pkg = new RPC.PackageWriter();
                    H_RPCRoot.smInstance.HGet_GateServer(pkg).DisconnectPlayer(pkg, pd.RoleDetail.AccountId, (sbyte)eServerType.Planes);
                    pkg.DoCommand(connect, RPC.CommandTargetType.DefaultType);
                    RPC.PackageWriter retPkg = new RPC.PackageWriter();
                    retPkg.Write((sbyte)eRet_GotoMap.CreatePlayerFailed);
                    retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);

                    Log.Log.Server.Print("PlanesServer2 force disconnect player!");
                    Log.Log.Server.Print(new System.Diagnostics.StackTrace(0, true).ToString());
                    return;
                }
                #endregion
                Planes.PlanesServerDataManager.Instance.AddPlayerInstance(player);                             //进服务器
                var planes = Planes.MapInstanceManager.Instance.PlanesManager.GetPlanesInstance(planesData);
                planes.EnterPlanes(player);                                                                    //进位面

                Planes.MapInstanceManager.Instance.PlayerEnterMap(player, mapSourceId, instanceId, pos, true); //进地图

                var overPkg = new RPC.PackageWriter();
                Wuxia.H_RpcRoot.smInstance.RPC_OnJumpMapOver(overPkg, (int)mapSourceId, pos.X, pos.Z);
                overPkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
            }

            {
                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                retPkg.Write((sbyte)eRet_GotoMap.EnterMap);
                retPkg.Write(pd.RoleDetail.LocationX);
                retPkg.Write(pd.RoleDetail.LocationY);
                retPkg.Write(pd.RoleDetail.LocationZ);
                //retPkg.Write(player.Id);
                retPkg.Write(player.PlayerData.RoleDetail.RoleHp);
                retPkg.Write(player.PlayerData.RoleDetail.RoleMaxHp);
                retPkg.Write(player.PlayerData.RoleDetail.RoleSpeed);
                retPkg.Write(player.IndexInMap);
                retPkg.Write(player.HostMap.IndexInServer);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
            }

            return;
        }
Beispiel #21
0
 public static void SendGift2Client(PlayerInstance player, int index, int count)
 {
     RPC.PackageWriter retpkg = new RPC.PackageWriter();
     Wuxia.H_RpcRoot.smInstance.RPC_AddGiftCount(retpkg, index, count);
     retpkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
 }
Beispiel #22
0
 public void SendSysMsg(string name)
 {
     RPC.PackageWriter pkg = new RPC.PackageWriter();
     //ExamplePlugins.ZeusGame.H_IGame.smInstance.RPC_PushBackSysMsg(pkg, name);
     pkg.DoCommandPlanes2Client(this.Planes2GateConnect, this.ClientLinkId);
 }
Beispiel #23
0
 public void TellToClientCopyCountDown(float second)
 {
     RPC.PackageWriter pkg = new RPC.PackageWriter();
     Wuxia.H_RpcRoot.smInstance.RPC_OnCopyCountDown(pkg, second);
     pkg.DoCommandPlanes2Client(this.Planes2GateConnect, this.ClientLinkId);
 }
Beispiel #24
0
        public void JumpToMap(ushort mapSourceId, float posX, float posY, float posZ, RPC.RPCForwardInfo fwd)
        {
            if (mapSourceId == this.HostMap.MapSourceId)
            {
//                 var retPkg = new RPC.PackageWriter();
//                 retPkg.Write((sbyte)eRet_GotoMap.SameMap);
//                 retPkg.DoReturnPlanes2Client(fwd);
                return;
            }

            ushort targetPlanesId = this.PlayerData.RoleDetail.PlanesId;

            if (AllMapManager.IsInstanceMap(mapSourceId))
            {
                targetPlanesId = 0;
            }

            SlimDX.Vector3 pos = new SlimDX.Vector3(posX, posY, posZ);
            var            pkg = new RPC.PackageWriter();

            H_RPCRoot.smInstance.HGet_DataServer(pkg).GotoMap(pkg, Id, targetPlanesId, mapSourceId, pos, fwd.Handle);
            pkg.WaitDoCommand(IPlanesServer.Instance.DataConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut)
            {
                sbyte successed = -1;
                _io.Read(out successed);
                switch ((eRet_GotoMap)successed)
                {
                case eRet_GotoMap.FailedEnterMap:
                case eRet_GotoMap.NoConnectInfo:
                case eRet_GotoMap.NoPlayerData:
                {
                    _JumpMapDoReturnClient(fwd, successed);
                    return;
                }
                break;

                case eRet_GotoMap.SamePlane:
                {
                    Planes.MapInstanceManager.Instance.PlayerLeaveMap(this, false);        //离开地图
                    if (this.PlanesInstance != null)
                    {
                        this.PlanesInstance.LeavePlanes(this.Id);        //离开位面
                    }
                    CSCommon.Data.PlanesData planesData = new CSCommon.Data.PlanesData();
                    _io.Read(planesData);
                    ulong mapInstanceId;
                    _io.Read(out mapInstanceId);
                    var planesInstance = Planes.MapInstanceManager.Instance.PlanesManager.GetPlanesInstance(planesData);
                    planesInstance.EnterPlanes(this);                                                               //进位面

                    Planes.MapInstanceManager.Instance.PlayerEnterMap(this, mapSourceId, mapInstanceId, pos, true); //进地图
                    var retPkg = new RPC.PackageWriter();
                    Wuxia.H_RpcRoot.smInstance.RPC_OnJumpMapOver(retPkg, (int)mapSourceId, pos.X, pos.Z);
                    retPkg.DoCommandPlanes2Client(this.Planes2GateConnect, this.ClientLinkId);
                }
                break;

                case eRet_GotoMap.OtherPlane:
                {
                    Planes.MapInstance    map    = HostMap;
                    Planes.PlanesInstance planes = PlanesInstance;
                    if (map == null || planes == null)
                    {
                        _JumpMapDoReturnClient(fwd, (sbyte)(eRet_GotoMap.NullMapOrNoPlane));
                        return;
                    }
                    else
                    {
                        map.PlayerLeaveMap(this, true);                                     //退出地图,这里已经存盘过了
                        planes.LeavePlanes(Id);                                             //退出位面
                        Planes.PlanesServerDataManager.Instance.RemovePlayerInstance(this); //退出服务器

                        var retPkg = new RPC.PackageWriter();
                        retPkg.Write("跳转成功2");
                        retPkg.DoReturnPlanes2Client(fwd);
                        return;
                    }
                }
                }
            };
        }
Beispiel #25
0
 public static void SendToLeaveTeamPlayerToClient(PlayerInstance player)
 {
     RPC.PackageWriter pkg = new RPC.PackageWriter();
     Wuxia.H_RpcRoot.smInstance.RPC_ReceiveLeaveTeam(pkg);
     pkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
 }