예제 #1
0
        public override void OnJumpToMap()
        {
            if (null == mTrigger)
            {
                return;
            }

            PlanesInstance planes = mHostMap.Planes;

            OnLeaveMap();
            MapInstance map   = null;
            ushort      mapId = (ushort)mTrigger.TriggerData.mapId;

            map = planes.GetGlobalMap(mapId);
            if (map == null)
            {
                map = Planes.MapInstanceManager.Instance.CreateMapInstance(planes, 0, mapId, null);
                if (map == null)
                {
                    map = Planes.MapInstanceManager.Instance.GetDefaultMapInstance(planes);
                }
                planes.AddGlobalMap(mapId, map);
            }
            SlimDX.Vector3 newPos = new SlimDX.Vector3(mTrigger.TriggerData.targetX, 0, mTrigger.TriggerData.targetZ);
            Placement.SetLocation(ref newPos);
            OnEnterMap(map);
        }
예제 #2
0
        public MapInstance GetDefaultMapInstance(PlanesInstance planes)
        {
            MapInstance map;
            ulong       mapId = 0;

            if (mInstanceMaps.TryGetValue(mapId, out map))
            {
                return(map);
            }
            for (UInt16 i = 0; i < UInt16.MaxValue; i++)
            {
                if (mAllMaps[i] == null)
                {
                    var info = MapInstanceManager.GetMapInitBySourceId(GameSet.Instance.DefaultMapId);
                    if (info == null)
                    {
                        continue;
                    }
                    ;

                    map = new WolrdMap();
                    if (map.InitMap(planes, i, 0, info, null))
                    {
                        mAllMaps[i] = map;
                        LogicProcessorManager.Instance.PushMap(map);
                        return(map);
                    }
                }
            }

            return(null);
        }
예제 #3
0
        public bool InitMap(PlanesInstance planes, ushort index, ulong mapInstanceId, TableWrap.MapInfoData info, PlayerInstance creater)
        {
            mPlanes        = planes;
            mOwner         = creater;
            mIndexInServer = index;
            mMapInfo       = info;
            //             mMapInfo = MapInstanceManager.GetMapInitBySourceId(mapSourceId);
            //             if (mMapInfo == null)
            //                 return false;
            //mUUID = mapInstanceId;

            mMapInstanceId = mapInstanceId;
            mMapSourceId   = (ushort)info.MapData.id;// mapSourceId;
            InitPlayerPool((ushort)mMapInfo.MapData.maxPlayerCount);
            mNavigator = NavigatorMgr.Instance.InitNavigator(mMapSourceId, GetNavFilePath(mMapInfo.MapData.name));

            // 从地图数据中创建实例数据
            m_cellXCount = (int)(mMapInfo.MapData.sizeX / mServerMapCellWidth) + ((mMapInfo.MapData.sizeX % mServerMapCellWidth) > 0 ? 1 : 0);
            m_cellZCount = (int)(mMapInfo.MapData.sizeZ / mServerMapCellHeight) + ((mMapInfo.MapData.sizeZ % mServerMapCellHeight) > 0 ? 1 : 0);

            m_mapCells = new MapCellInstance[m_cellZCount, m_cellXCount];
            for (int i = 0; i < m_cellZCount; i++)
            {
                for (int j = 0; j < m_cellXCount; j++)
                {
                    MapCellInstance mapCell = new MapCellInstance(j, i);
                    m_mapCells[i, j] = mapCell;
                }
            }

            //LoadMapData();
            OnInit();
            return(true);
        }
예제 #4
0
        //如果PlanesId为Guid.Empty那么说明角色在副本,不在真正的位面内
        public PlanesInstance GetPlanesInstance(CSCommon.Data.PlanesData planesData)
        {
            PlanesInstance planes;

            if (AllPlanesInstance.TryGetValue(planesData.PlanesId, out planes))
            {
                return(planes);
            }
            planes = new PlanesInstance(planesData);
            AllPlanesInstance.Add(planesData.PlanesId, planes);
            return(planes);
        }
예제 #5
0
        private bool InitRoleInstance(PlanesInstance planes, CSCommon.Data.PlayerData pd, Iocp.TcpConnect p2gConnect, UInt16 linkId)
        {
            mPlanes2GateConnect = p2gConnect;
            mClientLinkId       = linkId;

            mPlayerData = pd;
            mPlayerData.RoleDetail._SetHostPlayer(this);
            Bag.InventoryType = CSCommon.eItemInventory.ItemBag;

            //var sp = CSCommon.RoleCommonData.Instance.SexProToTId.Find(x => ((byte)x.Sex == pd.RoleDetail.Sex && (byte)x.Pro == pd.RoleDetail.Profession));
            //if (sp == null)
            //{
            //    Log.Log.Common.Print("SexProToTId is Null sex={0},pro={1}", pd.RoleDetail.Sex, pd.RoleDetail.Profession);
            //    return false;
            //}

            mPlayerData.RoleDetail.TemplateId = CSCommon.CommonUtil.GetTemplateIDBySexAndPro(pd.RoleDetail.Sex, pd.RoleDetail.Profession);

            #region 背包初始化
            Bag.InitBag(this, mPlayerData.RoleDetail.BagSize, mPlayerData.BagItems);
            EquipBag.InitBag(this, (UInt16)CSCommon.eEquipType.MaxBagSize, mPlayerData.EquipedItems);
            FashionBag.InitBag(this, byte.MaxValue, mPlayerData.FashionItems);
            EquipGemBag.InitBag(this, (UInt16)CSCommon.eEquipType.MaxBagSize, mPlayerData.EquipGemItems);
            GemBag.InitBag(this, (UInt16)CSCommon.eEquipType.MaxBagSize, mPlayerData.GemItems);
            #endregion
            InitMartial();
            #region 任务初始化
            InitTask(mPlayerData.TaskData);
            mRecordMgr.Init(this, mPlayerData.AchieveData);
            #endregion
            mSkillMgr.InitBag(this, mPlayerData.SkillDatas);
            #region 状态机初始化
            InitState();
            #endregion
            CalcAllValues();

            //mPlayerData.RoleDetail.RoleMaxHp = FinalRoleValue.MaxHP;
            //暂时先这样,以后需要客户端操作复活
            //if (CurHP <= 0)
            //    Relive();

            //EventDispacth.Instance.AddListener(eGlobleEvent.Fight_KillActor, this);



            return(true);
        }
예제 #6
0
        public void ClientDisConnect(ulong roleId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            //清理干净角色后,返回给DS玩家的PlayerData
            Planes.PlayerInstance player = Planes.PlanesServerDataManager.Instance.FindPlayerInstance(roleId);
            if (player == null)
            {
                Log.Log.Server.Print("ClientDisConnect:找不到角色");
                return;
            }
            Planes.MapInstance    map    = player.HostMap;
            Planes.PlanesInstance planes = player.PlanesInstance;

            if (map != null)
            {
                planes = player.PlanesInstance;
                map.PlayerLeaveMap(player, true);//退出地图,并且存盘
            }
            else
            {
                Log.Log.Server.Print("ClientDisConnect:找不到地图");
                return;
            }

            if (planes != null)
            {
                planes.LeavePlanes(roleId);//退出位面
            }
            else
            {
                Log.Log.Server.Print("ClientDisConnect:位面ID不正确");
                return;
            }

            Planes.PlanesServerDataManager.Instance.RemovePlayerInstance(player);//退出服务器

            //客户端连接断开,需要告诉数据服务器,登出账号
            RPC.PackageWriter pkg0 = new RPC.PackageWriter();
            H_RPCRoot.smInstance.HGet_DataServer(pkg0).HGet_PlayerManager(pkg0).LogoutAccount(pkg0, player.AccountId, (sbyte)eServerType.Planes);
            pkg0.DoCommand(mDataConnect, RPC.CommandTargetType.DefaultType);

            return;
        }
예제 #7
0
        public MapInstance CreateMapInstance(PlanesInstance planes, ulong mapInstanceId, ushort mapSourceId, PlayerInstance creater)
        {
            for (UInt16 i = 0; i < UInt16.MaxValue; i++)
            {
                if (mAllMaps[i] == null)
                {
                    var info = MapInstanceManager.GetMapInitBySourceId(mapSourceId);
                    if (info == null)
                    {
                        return(new NullMapInstance());
                    }
                    var         mapType = (CSCommon.eMapType)info.MapData.mapType;
                    MapInstance map     = null;
                    switch (mapType)
                    {
                    case CSCommon.eMapType.World:
                        map = new WolrdMap();
                        break;

                    case CSCommon.eMapType.NULL:
                        map = new NullMapInstance();
                        break;

                    case CSCommon.eMapType.InstanceStart:
                        map = new NullMapInstance();
                        break;

                    case CSCommon.eMapType.Master:
                        map = new MasterInstance();
                        break;

                    case CSCommon.eMapType.Arena:
                        map = new ArenaInstance();
                        break;

                    case CSCommon.eMapType.Challenge:
                        map = new ChallengeInstance();
                        break;

                    case CSCommon.eMapType.BattelStart:
                        break;

                    default:
                        map = new NullMapInstance();
                        break;
                    }
                    if (map == null)
                    {
                        return(new NullMapInstance());
                    }

                    if (map.InitMap(planes, i, mapInstanceId, info, creater))
                    {
                        mAllMaps[i] = map;
                        LogicProcessorManager.Instance.PushMap(map);
                        return(map);
                    }
                    else
                    {
                        Log.FileLog.WriteLine("CreateMapInstance {0} Failed", mapSourceId);
                        return(null);
                    }
                }
            }
            return(null);
        }
예제 #8
0
 public RoleIdManager(PlanesInstance p)
 {
     mPlanes = p;
 }
예제 #9
0
        public void ReturnToRoleSelect(ulong planesId, ulong roleId, ulong accountId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {//这里的fwd只能用ReturnSerialId
            Planes.PlayerInstance player = Planes.PlanesServerDataManager.Instance.FindPlayerInstance(roleId);
            if (player == null)
            {
                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                retPkg.Write((sbyte)-1);//找不到角色
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            Planes.MapInstance    map    = player.HostMap;
            Planes.PlanesInstance planes = null;

            if (map != null)
            {
                planes = map.Planes;
                map.PlayerLeaveMap(player, true);//退出地图
            }
            else
            {
                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                retPkg.Write((sbyte)-2);//找不到地图
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            if (planes != null)
            {
                planes.LeavePlanes(roleId);//退出位面
            }
            else
            {
                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                retPkg.Write((sbyte)-3);//位面ID不正确
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            Planes.PlanesServerDataManager.Instance.RemovePlayerInstance(player);//退出服务器

            UInt16 SavedReturnSerialId = fwd.ReturnSerialId;

            RPC.PackageWriter pkg = new RPC.PackageWriter();
            H_RPCRoot.smInstance.HGet_DataServer(pkg).HGet_PlayerManager(pkg).LogoutRole(pkg, roleId, player.PlayerData);
            pkg.WaitDoCommand(mDataConnect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut)
            {
                sbyte successed = -1;
                _io.Read(out successed);

                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                switch (successed)
                {
                case -1:
                    retPkg.Write((sbyte)-2);    //数据服务器LogoutPlayer失败
                    retPkg.DoReturnCommand2(connect, SavedReturnSerialId);
                    break;

                case 1:
                case 2:
                    retPkg.Write((sbyte)1);
                    retPkg.DoReturnCommand2(connect, SavedReturnSerialId);
                    break;

                default:
                    retPkg.Write((sbyte)2);
                    retPkg.DoReturnCommand2(connect, SavedReturnSerialId);
                    break;
                }
            };
        }