コード例 #1
0
        public static int getAwardRate(int FuBenID, int FuBenSeqID)
        {
            int result;

            if (FuBenID != LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID)
            {
                result = 1;
            }
            else
            {
                SingleLuoLanFaZhenFubenData fubenData = LuoLanFaZhenCopySceneManager.GetFubenData(FuBenSeqID);
                if (null == fubenData)
                {
                    result = 1;
                }
                else if (fubenData.SpecailBossLeftNum == 0)
                {
                    result = LuoLanFaZhenCopySceneManager.SpecialAwardRate;
                }
                else
                {
                    result = 1;
                }
            }
            return(result);
        }
コード例 #2
0
        public static TCPProcessCmdResults ProcessFazhenBossCMD(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false)), null, true);
                return(TCPProcessCmdResults.RESULT_FAILED);
            }
            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                if (fields.Length != 1)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), fields.Length), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                int        roleID = Convert.ToInt32(fields[0]);
                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleID))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), roleID), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                if (client.ClientData.FuBenID != LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }
                SingleLuoLanFaZhenFubenData fubenData = LuoLanFaZhenCopySceneManager.GetFubenData(client.ClientData.FuBenSeqID);
                if (null == fubenData)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }
                string strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
                {
                    LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID,
                    LuoLanFaZhenCopySceneManager.FinalBossID,
                    fubenData.FinalBossLeftNum,
                    LuoLanFaZhenCopySceneManager.SpecialBossID,
                    fubenData.SpecailBossLeftNum
                });
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, 760);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessFazhenBossCMD", false, false);
            }
            return(TCPProcessCmdResults.RESULT_FAILED);
        }
コード例 #3
0
        //客户端请求法阵boss信息
        public static TCPProcessCmdResults ProcessFazhenBossCMD(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception) //解析错误
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket)));
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            try
            {
                string[] fields = cmdData.Split(':');
                if (fields.Length != 1)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}",
                                                                      (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), fields.Length));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                int roleID = Convert.ToInt32(fields[0]);

                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (null == client || client.ClientData.RoleID != roleID)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), roleID));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                if (client.ClientData.FuBenID != LuoLanFaZhenFubenID)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }

                SingleLuoLanFaZhenFubenData fubenData = GetFubenData(client.ClientData.FuBenSeqID);
                if (null == fubenData)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }

                string strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", LuoLanFaZhenFubenID, FinalBossID, fubenData.FinalBossLeftNum, SpecialBossID, fubenData.SpecailBossLeftNum);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, (int)TCPGameServerCmds.CMD_SPR_FAZHEN_BOSS);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessFazhenBossCMD", false);
            }

            return(TCPProcessCmdResults.RESULT_FAILED);
        }
コード例 #4
0
        protected static bool TryAddFubenData(int _FubenSeqID, int _FubenID, int _MapID, int _MapCode)
        {
            bool result;

            if (_FubenSeqID <= 0 || _FubenID <= 0 || _MapID <= 0 || _MapCode <= 0)
            {
                result = false;
            }
            else
            {
                FazhenMapData mapdata = null;
                SingleLuoLanFaZhenFubenData fubenData = null;
                lock (LuoLanFaZhenCopySceneManager.AllFazhenFubenData)
                {
                    if (!LuoLanFaZhenCopySceneManager.AllFazhenFubenData.TryGetValue(_FubenSeqID, out fubenData) || null == fubenData)
                    {
                        fubenData = new SingleLuoLanFaZhenFubenData
                        {
                            FubenID    = _FubenID,
                            FubenSeqID = _FubenSeqID
                        };
                        mapdata = new FazhenMapData
                        {
                            CopyMapID = _MapID,
                            MapCode   = _MapCode
                        };
                        LuoLanFaZhenCopySceneManager.CreateRandomGates(_MapCode, mapdata);
                        fubenData.MapDatas[_MapID] = mapdata;
                        LuoLanFaZhenCopySceneManager.AllFazhenFubenData[_FubenSeqID] = fubenData;
                    }
                    else
                    {
                        lock (fubenData.MapDatas)
                        {
                            if (!fubenData.MapDatas.TryGetValue(_MapID, out mapdata) || null == mapdata)
                            {
                                mapdata = new FazhenMapData
                                {
                                    CopyMapID = _MapID,
                                    MapCode   = _MapCode
                                };
                                LuoLanFaZhenCopySceneManager.CreateRandomGates(_MapCode, mapdata);
                                fubenData.MapDatas[_MapID] = mapdata;
                            }
                        }
                    }
                }
                result = true;
            }
            return(result);
        }
コード例 #5
0
        //获取某个副本的数据
        public static SingleLuoLanFaZhenFubenData GetFubenData(int FubenSeqID)
        {
            if (FubenSeqID <= 0)
            {
                return(null);
            }

            SingleLuoLanFaZhenFubenData fubenData = null;

            lock (AllFazhenFubenData)
            {
                if (!AllFazhenFubenData.TryGetValue(FubenSeqID, out fubenData))
                {
                    return(null);
                }
            }

            return(fubenData);
        }
コード例 #6
0
        public static SingleLuoLanFaZhenFubenData GetFubenData(int FubenSeqID)
        {
            SingleLuoLanFaZhenFubenData result;

            if (FubenSeqID <= 0)
            {
                result = null;
            }
            else
            {
                SingleLuoLanFaZhenFubenData fubenData = null;
                lock (LuoLanFaZhenCopySceneManager.AllFazhenFubenData)
                {
                    if (!LuoLanFaZhenCopySceneManager.AllFazhenFubenData.TryGetValue(FubenSeqID, out fubenData))
                    {
                        return(null);
                    }
                }
                result = fubenData;
            }
            return(result);
        }
コード例 #7
0
        protected static int SpecialAwardRate = 0;  //奖励倍数

        public static int getAwardRate(int FuBenID, int FuBenSeqID)
        {
            if (FuBenID != LuoLanFaZhenFubenID)
            {
                return(1);
            }

            SingleLuoLanFaZhenFubenData fubenData = GetFubenData(FuBenSeqID);

            if (null == fubenData)
            {
                return(1);
            }

            if (fubenData.SpecailBossLeftNum == 0)
            {
                return(SpecialAwardRate);
            }
            else
            {
                return(1);
            }
        }
コード例 #8
0
        public static TCPProcessCmdResults ProcessFazhenTeleportCMD(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false)), null, true);
                return(TCPProcessCmdResults.RESULT_FAILED);
            }
            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                if (fields.Length != 2)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), fields.Length), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                int roleID  = Convert.ToInt32(fields[0]);
                int MapCode = 0;
                if (!int.TryParse(fields[1], out MapCode))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("ProcessFazhenTeleportCMD, roleID={0}, MapCode={1}", roleID, fields[1]), null, true);
                    return(TCPProcessCmdResults.RESULT_OK);
                }
                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleID))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), roleID), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                if (client.ClientData.MapCode != MapCode)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }
                if (client.ClientData.FuBenID != LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }
                SingleLuoLanFaZhenFubenData fubenData = LuoLanFaZhenCopySceneManager.GetFubenData(client.ClientData.FuBenSeqID);
                if (null == fubenData)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }
                FazhenMapData mapData = null;
                lock (fubenData.MapDatas)
                {
                    fubenData.MapDatas.TryGetValue(client.ClientData.CopyMapID, out mapData);
                    if (null == mapData)
                    {
                        return(TCPProcessCmdResults.RESULT_OK);
                    }
                }
                FazhenMapProtoData senddata = new FazhenMapProtoData();
                senddata.listTelegate = new List <FazhenTelegateProtoData>();
                senddata.SrcMapCode   = mapData.MapCode;
                lock (mapData.Telegates)
                {
                    List <int> listGateID = mapData.Telegates.Keys.ToList <int>();
                    if (null != listGateID)
                    {
                        foreach (int gateid in listGateID)
                        {
                            SingleFazhenTelegateData gatedata = mapData.Telegates[gateid];
                            if (null != gatedata)
                            {
                                FazhenTelegateProtoData gatedata_s = new FazhenTelegateProtoData();
                                gatedata_s.gateId = gateid;
                                if (gatedata.usedAlready || LuoLanFaZhenCopySceneManager.GM_OpenState == 1)
                                {
                                    gatedata_s.DestMapCode = gatedata.destMapCode;
                                }
                                else
                                {
                                    gatedata_s.DestMapCode = 0;
                                }
                                senddata.listTelegate.Add(gatedata_s);
                            }
                        }
                    }
                }
                byte[] bytes = DataHelper.ObjectToBytes <FazhenMapProtoData>(senddata);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, bytes, 0, bytes.Length, 685);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessFazhenTeleportCMD", false, false);
            }
            return(TCPProcessCmdResults.RESULT_FAILED);
        }
コード例 #9
0
        public static bool OnKillMonster(GameClient client, Monster monster)
        {
            bool result;

            if (client.ClientData.FuBenID != LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID)
            {
                result = false;
            }
            else
            {
                SingleLuoLanFaZhenFubenData fubenData = LuoLanFaZhenCopySceneManager.GetFubenData(client.ClientData.FuBenSeqID);
                if (null == fubenData)
                {
                    result = false;
                }
                else
                {
                    List <int> listMapCodes = null;
                    bool       bKillBoss    = false;
                    if (monster.MonsterInfo.ExtensionID == LuoLanFaZhenCopySceneManager.FinalBossID)
                    {
                        fubenData.FinalBossLeftNum = 0;
                        bKillBoss = true;
                    }
                    else if (monster.MonsterInfo.ExtensionID == LuoLanFaZhenCopySceneManager.SpecialBossID)
                    {
                        FuBenInfoItem fuBenInfoItem = FuBenManager.FindFuBenInfoBySeqID(client.ClientData.FuBenSeqID);
                        if (null == fuBenInfoItem)
                        {
                            return(false);
                        }
                        fubenData.SpecailBossLeftNum = 0;
                        string msg = StringUtil.substitute(GLang.GetLang(98, new object[0]), new object[]
                        {
                            client.ClientData.RoleName
                        });
                        listMapCodes = SingletonTemplate <CopyTeamManager> .Instance().GetTeamCopyMapCodes(LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID);

                        if (null == listMapCodes)
                        {
                            return(false);
                        }
                        foreach (int mapCode in listMapCodes)
                        {
                            LuoLanFaZhenCopySceneManager.BroadMapMessage(msg, mapCode, client.ClientData.FuBenSeqID);
                        }
                        bKillBoss = true;
                    }
                    if (bKillBoss)
                    {
                        if (null == listMapCodes)
                        {
                            listMapCodes = SingletonTemplate <CopyTeamManager> .Instance().GetTeamCopyMapCodes(LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID);
                        }
                        if (null == listMapCodes)
                        {
                            return(false);
                        }
                        string cmdData = string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
                        {
                            LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID,
                            LuoLanFaZhenCopySceneManager.FinalBossID,
                            fubenData.FinalBossLeftNum,
                            LuoLanFaZhenCopySceneManager.SpecialBossID,
                            fubenData.SpecailBossLeftNum
                        });
                        foreach (int mapCode in listMapCodes)
                        {
                            LuoLanFaZhenCopySceneManager.BroadMapData(760, cmdData, mapCode, client.ClientData.FuBenSeqID);
                        }
                    }
                    result = true;
                }
            }
            return(result);
        }
コード例 #10
0
        public static TCPProcessCmdResults OnTeleport(GameClient client, int teleportID, TCPOutPacketPool pool, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            TCPProcessCmdResults result;

            if (client.ClientData.FuBenID != LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID || client.ClientData.FuBenSeqID <= 0)
            {
                result = TCPProcessCmdResults.RESULT_FAILED;
            }
            else
            {
                SingleLuoLanFaZhenFubenData fubenData = LuoLanFaZhenCopySceneManager.GetFubenData(client.ClientData.FuBenSeqID);
                if (null == fubenData)
                {
                    result = TCPProcessCmdResults.RESULT_FAILED;
                }
                else
                {
                    FazhenMapData            mapdata  = null;
                    SingleFazhenTelegateData teledata = null;
                    lock (fubenData.MapDatas)
                    {
                        if (!fubenData.MapDatas.TryGetValue(client.ClientData.CopyMapID, out mapdata) || null == mapdata)
                        {
                            return(TCPProcessCmdResults.RESULT_FAILED);
                        }
                    }
                    if (mapdata.MapCode != client.ClientData.MapCode || mapdata.CopyMapID != client.ClientData.CopyMapID)
                    {
                        result = TCPProcessCmdResults.RESULT_FAILED;
                    }
                    else
                    {
                        lock (mapdata.Telegates)
                        {
                            if (!mapdata.Telegates.TryGetValue(teleportID, out teledata) || null == teledata)
                            {
                                return(TCPProcessCmdResults.RESULT_FAILED);
                            }
                        }
                        if (teledata.destMapCode <= 0)
                        {
                            result = TCPProcessCmdResults.RESULT_FAILED;
                        }
                        else
                        {
                            bool TeleToSpecial = false;
                            if (teledata.SpecialDestMapCode > 0)
                            {
                                if (0 != fubenData.SpecailBossLeftNum)
                                {
                                    int rand = Global.GetRandomNumber(0, 100);
                                    if (rand < LuoLanFaZhenCopySceneManager.SpecialTeleRate)
                                    {
                                        TeleToSpecial = true;
                                    }
                                }
                            }
                            if (TeleToSpecial)
                            {
                                GameManager.ClientMgr.ChangeMap(TCPManager.getInstance().MySocketListener, TCPOutPacketPool.getInstance(), client, teleportID, teledata.SpecialDestMapCode, teledata.SpecialDestX, teledata.SpecialDestY, client.ClientData.RoleDirection, 123);
                            }
                            else
                            {
                                bool NeedSend = false;
                                lock (teledata)
                                {
                                    if (!teledata.usedAlready)
                                    {
                                        teledata.usedAlready = true;
                                        NeedSend             = true;
                                    }
                                }
                                if (NeedSend)
                                {
                                    FazhenMapProtoData senddata = new FazhenMapProtoData();
                                    senddata.listTelegate = new List <FazhenTelegateProtoData>();
                                    senddata.SrcMapCode   = mapdata.MapCode;
                                    FazhenTelegateProtoData gatedata_s = new FazhenTelegateProtoData();
                                    gatedata_s.gateId      = teledata.gateId;
                                    gatedata_s.DestMapCode = teledata.destMapCode;
                                    senddata.listTelegate.Add(gatedata_s);
                                    LuoLanFaZhenCopySceneManager.BroadMapData <FazhenMapProtoData>(685, senddata, mapdata.MapCode, client.ClientData.FuBenSeqID);
                                }
                                GameManager.ClientMgr.ChangeMap(TCPManager.getInstance().MySocketListener, TCPOutPacketPool.getInstance(), client, teleportID, teledata.destMapCode, teledata.destX, teledata.destY, client.ClientData.RoleDirection, 123);
                            }
                            result = TCPProcessCmdResults.RESULT_OK;
                        }
                    }
                }
            }
            return(result);
        }
コード例 #11
0
        //客户端请求罗兰法阵地图数据
        public static TCPProcessCmdResults ProcessFazhenTeleportCMD(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception) //解析错误
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket)));
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            try
            {
                string[] fields = cmdData.Split(':');
                if (fields.Length != 2)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}",
                                                                      (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), fields.Length));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                int roleID = Convert.ToInt32(fields[0]);

                // 206发现这个字段解析异常
                int MapCode = 0;
                if (int.TryParse(fields[1], out MapCode) == false)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("ProcessFazhenTeleportCMD, roleID={0}, MapCode={1}", roleID, fields[1]));
                    return(TCPProcessCmdResults.RESULT_OK);
                }

                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (null == client || client.ClientData.RoleID != roleID)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), roleID));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                if (client.ClientData.MapCode != MapCode)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }

                if (client.ClientData.FuBenID != LuoLanFaZhenFubenID)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }

                SingleLuoLanFaZhenFubenData fubenData = GetFubenData(client.ClientData.FuBenSeqID);
                if (null == fubenData)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }

                FazhenMapData mapData = null;
                lock (fubenData.MapDatas)
                {
                    fubenData.MapDatas.TryGetValue(client.ClientData.CopyMapID, out mapData);
                    if (null == mapData)
                    {
                        return(TCPProcessCmdResults.RESULT_OK);
                    }
                }

                //发送此地图内的传送门数据
                FazhenMapProtoData senddata = new FazhenMapProtoData();
                senddata.listTelegate = new List <FazhenTelegateProtoData>();
                senddata.SrcMapCode   = mapData.MapCode;

                //遍历此地图内所有传送门
                lock (mapData.Telegates)
                {
                    List <int> listGateID = mapData.Telegates.Keys.ToList();

                    if (null != listGateID)
                    {
                        foreach (var gateid in listGateID)
                        {
                            SingleFazhenTelegateData gatedata = mapData.Telegates[gateid];
                            if (null == gatedata)
                            {
                                continue;
                            }

                            FazhenTelegateProtoData gatedata_s = new FazhenTelegateProtoData();
                            gatedata_s.gateId = gateid;
                            if (gatedata.usedAlready || GM_OpenState == 1)
                            {
                                gatedata_s.DestMapCode = gatedata.destMapCode;
                            }
                            else
                            {
                                gatedata_s.DestMapCode = 0;
                            }

                            senddata.listTelegate.Add(gatedata_s);
                        }
                    }
                }

                //发送此地图内的传送门数据
                byte[] bytes = DataHelper.ObjectToBytes <FazhenMapProtoData>(senddata);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, bytes, 0, bytes.Length, (int)TCPGameServerCmds.CMD_MAP_TELEPORT);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessFazhenTeleportCMD", false);
            }

            return(TCPProcessCmdResults.RESULT_FAILED);
        }
コード例 #12
0
        //玩家杀死特殊BOSS
        public static bool OnKillMonster(GameClient client, Monster monster)
        {
            if (client.ClientData.FuBenID != LuoLanFaZhenFubenID)
            {
                return(false);
            }

            SingleLuoLanFaZhenFubenData fubenData = GetFubenData(client.ClientData.FuBenSeqID);

            if (null == fubenData)
            {
                return(false);
            }

            List <int> listMapCodes = null;

            bool bKillBoss = false;

#if ___CC___FUCK___YOU___BB___
            if (monster.XMonsterInfo.MonsterId == FinalBossID)     //杀死的是否罗兰法阵的通关Boss
            {
                fubenData.FinalBossLeftNum = 0;
                bKillBoss = true;
            }
            else if (monster.XMonsterInfo.MonsterId == SpecialBossID)  //杀死的是否罗兰法阵的特殊Boss
            {
                //是
                FuBenInfoItem fuBenInfoItem = FuBenManager.FindFuBenInfoBySeqID(client.ClientData.FuBenSeqID);
                if (null == fuBenInfoItem)
                {
                    return(false);
                }

                fubenData.SpecailBossLeftNum = 0;

                //改变奖励系数
                //fuBenInfoItem.AwardRate = SpecialAwardRate;

                //广播消息给副本内所有玩家
                string msg = StringUtil.substitute(Global.GetLang("『{0}』击杀了时空盗贼,令本次通关奖励翻倍!"), client.ClientData.RoleName);

                listMapCodes = CopyTeamManager.Instance().GetTeamCopyMapCodes(LuoLanFaZhenFubenID);
                if (null == listMapCodes)
                {
                    return(false);
                }
                foreach (var mapCode in listMapCodes)
                {
                    BroadMapMessage(msg, mapCode, client.ClientData.FuBenSeqID);
                }

                bKillBoss = true;
            }
#else
            if (monster.MonsterInfo.ExtensionID == FinalBossID)     //杀死的是否罗兰法阵的通关Boss
            {
                fubenData.FinalBossLeftNum = 0;
                bKillBoss = true;
            }
            else if (monster.MonsterInfo.ExtensionID == SpecialBossID)  //杀死的是否罗兰法阵的特殊Boss
            {
                //是
                FuBenInfoItem fuBenInfoItem = FuBenManager.FindFuBenInfoBySeqID(client.ClientData.FuBenSeqID);
                if (null == fuBenInfoItem)
                {
                    return(false);
                }

                fubenData.SpecailBossLeftNum = 0;

                //改变奖励系数
                //fuBenInfoItem.AwardRate = SpecialAwardRate;

                //广播消息给副本内所有玩家
                string msg = StringUtil.substitute(Global.GetLang("『{0}』击杀了时空盗贼,令本次通关奖励翻倍!"), client.ClientData.RoleName);

                listMapCodes = CopyTeamManager.Instance().GetTeamCopyMapCodes(LuoLanFaZhenFubenID);
                if (null == listMapCodes)
                {
                    return(false);
                }
                foreach (var mapCode in listMapCodes)
                {
                    BroadMapMessage(msg, mapCode, client.ClientData.FuBenSeqID);
                }

                bKillBoss = true;
            }
#endif
            //通知副本内所有玩家boss数量改变
            if (bKillBoss)
            {
                //杀死了boss
                if (null == listMapCodes)
                {
                    listMapCodes = CopyTeamManager.Instance().GetTeamCopyMapCodes(LuoLanFaZhenFubenID);
                }

                if (null == listMapCodes)
                {
                    return(false);
                }

                //通知副本内所有玩家boss数量改变
                string cmdData = string.Format("{0}:{1}:{2}:{3}:{4}", LuoLanFaZhenFubenID, FinalBossID, fubenData.FinalBossLeftNum, SpecialBossID, fubenData.SpecailBossLeftNum);
                foreach (var mapCode in listMapCodes)
                {
                    BroadMapData((int)TCPGameServerCmds.CMD_SPR_FAZHEN_BOSS, cmdData, mapCode, client.ClientData.FuBenSeqID);
                }
            }

            return(true);
        }
コード例 #13
0
        //玩家使用传送门
        public static TCPProcessCmdResults OnTeleport(GameClient client, int teleportID, TCPOutPacketPool pool, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;

            if (client.ClientData.FuBenID != LuoLanFaZhenFubenID || client.ClientData.FuBenSeqID <= 0)
            {
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            SingleLuoLanFaZhenFubenData fubenData = GetFubenData(client.ClientData.FuBenSeqID);

            if (null == fubenData)
            {
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            FazhenMapData            mapdata  = null;
            SingleFazhenTelegateData teledata = null;

            lock (fubenData.MapDatas)
            {
                if (!fubenData.MapDatas.TryGetValue(client.ClientData.CopyMapID, out mapdata) || null == mapdata)
                {
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
            }

            if (mapdata.MapCode != client.ClientData.MapCode || mapdata.CopyMapID != client.ClientData.CopyMapID)
            {
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            lock (mapdata.Telegates)
            {
                //如果找不到这个传送门,说明这是个普通的传送点
                if (!mapdata.Telegates.TryGetValue(teleportID, out teledata) || null == teledata)
                {
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
            }

            if (teledata.destMapCode <= 0)
            {
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            //判断是否随机传到特殊地图
            bool TeleToSpecial = false;

            if (teledata.SpecialDestMapCode > 0)
            {
                //[bing] 有些人进入特殊地图时 该地图怪物已经被杀了 导致进入地图后又要返回 所以预先判断有无怪物 没怪物则不传送特殊地
                if (0 != fubenData.SpecailBossLeftNum)
                {
                    int rand = Global.GetRandomNumber(0, 100);
                    //是否随机传送到特殊地图
                    if (rand < SpecialTeleRate)
                    {
                        //传送到特殊地图
                        TeleToSpecial = true;
                    }
                }
            }

            if (TeleToSpecial)
            {
                //传送到特殊地图teledata.SpecialDestMapCode
                GameManager.ClientMgr.ChangeMap(TCPManager.getInstance().MySocketListener, TCPOutPacketPool.getInstance(), client, teleportID,
                                                teledata.SpecialDestMapCode, teledata.SpecialDestX, teledata.SpecialDestY, client.ClientData.RoleDirection,
                                                (int)TCPGameServerCmds.CMD_SPR_MAPCHANGE);
            }
            else   //传送到普通地图
            {
                //是否已经用过?
                bool NeedSend = false;
                lock (teledata)
                {
                    if (!teledata.usedAlready)
                    {
                        //没用过
                        teledata.usedAlready = true;
                        NeedSend             = true;
                    }
                }

                if (NeedSend)
                {
                    //通知副本内所有玩家传送门被用过后的数据
                    FazhenMapProtoData senddata = new FazhenMapProtoData();
                    senddata.listTelegate = new List <FazhenTelegateProtoData>();
                    senddata.SrcMapCode   = mapdata.MapCode;

                    FazhenTelegateProtoData gatedata_s = new FazhenTelegateProtoData();
                    gatedata_s.gateId      = teledata.gateId;
                    gatedata_s.DestMapCode = teledata.destMapCode;
                    senddata.listTelegate.Add(gatedata_s);

                    //发送此传送门数据给地图内所有玩家
                    BroadMapData <FazhenMapProtoData>((int)TCPGameServerCmds.CMD_MAP_TELEPORT, senddata, mapdata.MapCode, client.ClientData.FuBenSeqID);
                }

                //传送到普通地图
                GameManager.ClientMgr.ChangeMap(TCPManager.getInstance().MySocketListener, TCPOutPacketPool.getInstance(), client, teleportID,
                                                teledata.destMapCode, teledata.destX, teledata.destY, client.ClientData.RoleDirection,
                                                (int)TCPGameServerCmds.CMD_SPR_MAPCHANGE);
            }

            return(TCPProcessCmdResults.RESULT_OK);
        }
コード例 #14
0
        //创建和增加副本地图数据
        protected static bool TryAddFubenData(int _FubenSeqID, int _FubenID, int _MapID, int _MapCode)
        {
            if (_FubenSeqID <= 0 || _FubenID <= 0 || _MapID <= 0 || _MapCode <= 0)
            {
                return(false);
            }

            FazhenMapData mapdata = null;
            SingleLuoLanFaZhenFubenData fubenData = null;

            lock (AllFazhenFubenData)
            {
                //是否已经有这个副本了?
                if (!AllFazhenFubenData.TryGetValue(_FubenSeqID, out fubenData) || null == fubenData)
                {
                    //没这个副本的数据,现在创建一份
                    fubenData = new SingleLuoLanFaZhenFubenData()
                    {
                        FubenID    = _FubenID,
                        FubenSeqID = _FubenSeqID
                    };
                    //地图数据
                    mapdata = new FazhenMapData()
                    {
                        CopyMapID = _MapID,
                        MapCode   = _MapCode
                    };
                    //随机产生各个传送门的目标地图
                    CreateRandomGates(_MapCode, mapdata);

                    fubenData.MapDatas[_MapID] = mapdata;

                    //加入到数据集合中
                    AllFazhenFubenData[_FubenSeqID] = fubenData;
                }
                else
                {
                    lock (fubenData.MapDatas)
                    {
                        //已经有这个副本的数据了
                        if (!fubenData.MapDatas.TryGetValue(_MapID, out mapdata) || null == mapdata)
                        {
                            //没有这个地图的数据
                            mapdata = new FazhenMapData()
                            {
                                CopyMapID = _MapID,
                                MapCode   = _MapCode
                            };
                            //随机产生各个传送门的目标地图
                            CreateRandomGates(_MapCode, mapdata);

                            //修改数据
                            fubenData.MapDatas[_MapID] = mapdata;
                        }
                        else
                        {
                            //已经有这个地图的数据,什么都不用做
                        }
                    }
                }
            }
            return(true);
        }