Exemple #1
0
        public enEnterMapResult PlayerEnterMap(PlayerInstance role, SlimDX.Vector3 pos, bool bTellClient)
        {
            if (mPlayerPool == null)
            {
                return(enEnterMapResult.Error_InvalidMap);
            }

            if (mFreeSlot.Count == 0)
            {
                return(enEnterMapResult.Error_PlayerFull);
            }

            role.Placement.SetLocation(ref pos);

            if (role.HostMap != this)
            {
                if (!role.HostMap.IsNullMap)
                {
                    role.HostMap.PlayerLeaveMap(role, false);
                }
                role._SetIndexInMap(mFreeSlot.Pop());
                System.Diagnostics.Debug.Assert(mPlayerPool[role.IndexInMap] == null);
                mPlayerPool[role.IndexInMap] = role;
                mPlayerDictionary[role.Id]   = role;

                if (AllMapManager.IsInstanceMap(this.MapSourceId) == false)
                {
                    //role.PlayerData.RoleDetail.MapName = this.MapName;
                    role.PlayerData.RoleDetail.DungeonID   = 0;
                    role.PlayerData.RoleDetail.MapSourceId = this.MapSourceId;
                }
                else
                {
                    role.PlayerData.RoleDetail.DungeonID = this.MapInstanceId;
                }

                role.OnEnterMap(this);
            }

            OnRoleEnterMap(role);

            RPC.PackageWriter pkg = new RPC.PackageWriter();
            H_RPCRoot.smInstance.HGet_GateServer(pkg).PlayerEnterMapInPlanes(pkg, role.Id, role.ClientLinkId, role.IndexInMap, this.IndexInServer);
            pkg.DoCommand(role.Planes2GateConnect, RPC.CommandTargetType.DefaultType);

            role.HostMap = this;
            return(enEnterMapResult.Success);
        }
Exemple #2
0
        public override void OnEnterMap(MapInstance map)
        {
            if (!AllMapManager.IsInstanceMap(map.MapSourceId))
            {
                var loc = new SlimDX.Vector3(PlayerData.RoleDetail.LocationX, PlayerData.RoleDetail.LocationY, PlayerData.RoleDetail.LocationZ);
                Placement.SetLocation(ref loc);
            }
            else
            {
                var loc = new SlimDX.Vector3(map.MapInfo.MapData.startX, PlayerData.RoleDetail.LocationY, map.MapInfo.MapData.startY);
                Placement.SetLocation(ref loc);
            }

            //// 角色默认只有Y方向旋转量
            //var rot = SlimDX.Quaternion.RotationYawPitchRoll(PlayerData.RoleDetail.Direction, 0, 0);
            Placement.SetDirection(PlayerData.RoleDetail.Direction);

            base.OnEnterMap(map);
            mPlayerData.RoleDetail.RoleMaxHp = FinalRoleValue.MaxHP;
            mPlayerData.RoleDetail.RoleMaxMp = FinalRoleValue.MaxMP;
            mPlayerData.RoleDetail.DungeonID = 0;
        }
Exemple #3
0
        public void PlayerEnterMap(PlayerInstance player, ushort mapSourceId, ulong mapInstanceId, SlimDX.Vector3 pos, bool bSaveRole)
        {
            MapInstance map;

            lock (this)
            {
                if (AllMapManager.IsInstanceMap(mapSourceId))
                {
                    if (false == mInstanceMaps.TryGetValue(mapInstanceId, out map))
                    {
                        map = CreateMapInstance(PlanesInstance.NullPlanesInstance, mapInstanceId, mapSourceId, player);
                        if (map == null)
                        {
                            map = GetDefaultMapInstance(player.PlanesInstance);
                        }
                        mInstanceMaps.Add(mapInstanceId, map);
                    }
                }
                else
                {
                    var planes = player.PlanesInstance;
                    map = planes.GetGlobalMap(mapSourceId);
                    if (map == null)
                    {
                        map = CreateMapInstance(planes, 0, mapSourceId, player);
                        if (map == null)
                        {
                            map = GetDefaultMapInstance(planes);
                        }
                        planes.AddGlobalMap(mapSourceId, map);
                    }
                }
            }

            if (MapInstance.enEnterMapResult.Success != map.PlayerEnterMap(player, pos, true))
            {
            }
        }
Exemple #4
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;
                    }
                }
                }
            };
        }