public static void RemoveExperienceListCopyMap(int nID)
        {
            bool bRemve = false;

            lock (ExperienceCopySceneManager.m_ExperienceListCopyMaps)
            {
                CopyMap tmp = null;
                if (ExperienceCopySceneManager.m_ExperienceListCopyMaps.TryGetValue(nID, out tmp))
                {
                    ExperienceCopySceneManager.m_ExperienceListCopyMaps.Remove(nID);
                    bRemve = true;
                }
            }
            lock (ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo)
            {
                if (bRemve)
                {
                    ExperienceCopyScene ExperienceSceneInfo = null;
                    if (ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo.TryGetValue(nID, out ExperienceSceneInfo))
                    {
                        ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo.Remove(nID);
                    }
                }
            }
        }
        public static void ExperienceCopyMapCreateMonster(GameClient client, ExperienceCopyScene ExperienceMapInfo, ExperienceCopyMapDataInfo exMap, int nWave)
        {
            ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterFlag = 1;
            ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterWave++;
            GameMap gameMap = null;

            if (!GameManager.MapMgr.DictMaps.TryGetValue(ExperienceMapInfo.m_MapCodeID, out gameMap))
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("经验副本 地图配置 ID = {0}", ExperienceMapInfo.m_MapCodeID), null, true);
            }
            else
            {
                int        gridX    = gameMap.CorrectWidthPointToGridPoint(exMap.posX) / gameMap.MapGridWidth;
                int        gridY    = gameMap.CorrectHeightPointToGridPoint(exMap.posZ) / gameMap.MapGridHeight;
                int        gridNum  = gameMap.CorrectWidthPointToGridPoint(exMap.Radius);
                int        nTotal   = 0;
                List <int> nListID  = exMap.MonsterIDList[nWave];
                List <int> nListNum = exMap.MonsterNumList[nWave];
                for (int i = 0; i < nListID.Count; i++)
                {
                    int nID  = nListID[i];
                    int nNum = nListNum[i];
                    GameManager.MonsterZoneMgr.AddDynamicMonsters(ExperienceMapInfo.m_MapCodeID, nID, ExperienceMapInfo.m_CopyMapID, nNum, gridX, gridY, gridNum, 0, SceneUIClasses.Normal, null, null);
                    nTotal += nNum;
                    ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterNum += nNum;
                    ExperienceMapInfo.m_ExperienceCopyMapRemainMonsterNum += nNum;
                }
                ExperienceMapInfo.m_ExperienceCopyMapNeedKillMonsterNum = ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterNum * exMap.CreateNextWaveMonsterCondition[nWave] / 100;
                if (client != null)
                {
                    ExperienceCopySceneManager.SendMsgToClientForExperienceCopyMapInfo(client, ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterWave);
                }
            }
        }
        public static void AddExperienceListCopyMap(int nID, CopyMap mapInfo)
        {
            bool bInsert = false;

            lock (ExperienceCopySceneManager.m_ExperienceListCopyMaps)
            {
                CopyMap tmp = null;
                if (!ExperienceCopySceneManager.m_ExperienceListCopyMaps.TryGetValue(nID, out tmp))
                {
                    ExperienceCopySceneManager.m_ExperienceListCopyMaps.Add(nID, mapInfo);
                    bInsert = true;
                }
                else if (tmp == null)
                {
                    ExperienceCopySceneManager.m_ExperienceListCopyMaps[nID] = mapInfo;
                    bInsert = true;
                }
            }
            lock (ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo)
            {
                if (bInsert)
                {
                    ExperienceCopyScene ExperienceSceneInfo = null;
                    if (!ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo.TryGetValue(nID, out ExperienceSceneInfo))
                    {
                        ExperienceSceneInfo = new ExperienceCopyScene();
                        ExperienceSceneInfo.InitInfo(mapInfo.MapCode, mapInfo.CopyMapID, nID);
                        ExperienceSceneInfo.m_StartTimer = TimeUtil.NOW();
                        ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo.Add(nID, ExperienceSceneInfo);
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        // 通知客户端
        /// </summary>
        public static void SendMsgToClientForExperienceCopyMapInfo(GameClient client, int nWave)
        {
            ExperienceCopyScene tmpExSceneInfo = null;


            // 此处需要加锁
            lock (m_ExperienceListCopyMapsInfo)
            {
                m_ExperienceListCopyMapsInfo.TryGetValue(client.ClientData.FuBenSeqID, out tmpExSceneInfo);
            }

            if (tmpExSceneInfo == null)
            {
                return;
            }

            int nRealyWave = nWave;
            int nTotalWave = Data.ExperienceCopyMapDataInfoList[client.ClientData.MapCode].MonsterIDList.Count;

            if (nRealyWave > nTotalWave)
            {
                nRealyWave = nTotalWave;
            }

            string       strcmd       = string.Format("{0}:{1}:{2}", nRealyWave, nTotalWave, tmpExSceneInfo.m_ExperienceCopyMapRemainMonsterNum);
            TCPOutPacket tcpOutPacket = null;

            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(Global._TCPManager.TcpOutPacketPool, strcmd, (int)TCPGameServerCmds.CMD_SPR_EXPERIENCECOPYMAPINFO);
            Global._TCPManager.MySocketListener.SendData(client.ClientSocket, tcpOutPacket);
        }
        public static void HeartBeatExperienceCopyMap()
        {
            long nowTicks = TimeUtil.NOW();

            if (nowTicks - ExperienceCopySceneManager.LastHeartBeatTicks >= 1000L)
            {
                ExperienceCopySceneManager.LastHeartBeatTicks = ((ExperienceCopySceneManager.LastHeartBeatTicks < 86400000L) ? nowTicks : (ExperienceCopySceneManager.LastHeartBeatTicks + 1000L));
                List <CopyMap> CopyMapList = new List <CopyMap>();
                lock (ExperienceCopySceneManager.m_ExperienceListCopyMaps)
                {
                    foreach (CopyMap item in ExperienceCopySceneManager.m_ExperienceListCopyMaps.Values)
                    {
                        List <GameClient>         clientsList = item.GetClientsList();
                        ExperienceCopyMapDataInfo tmp         = null;
                        tmp = Data.ExperienceCopyMapDataInfoList[item.MapCode];
                        if (tmp != null)
                        {
                            ExperienceCopyScene tmpExSceneInfo = null;
                            lock (ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo)
                            {
                                if (!ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo.TryGetValue(item.FuBenSeqID, out tmpExSceneInfo))
                                {
                                    continue;
                                }
                            }
                            if (tmpExSceneInfo != null)
                            {
                                int nWave  = tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterWave;
                                int nCount = tmp.MonsterIDList.Count;
                                if (nWave < nCount)
                                {
                                    if (tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterFlag == 0)
                                    {
                                        if (clientsList.Count <GameClient>() != 0 && clientsList[0] != null)
                                        {
                                            ExperienceCopySceneManager.ExperienceCopyMapCreateMonster(clientsList[0], tmpExSceneInfo, tmp, nWave);
                                        }
                                        else
                                        {
                                            ExperienceCopySceneManager.ExperienceCopyMapCreateMonster(null, tmpExSceneInfo, tmp, nWave);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                for (int i = 0; i < CopyMapList.Count; i++)
                {
                    GameManager.CopyMapMgr.ProcessRemoveCopyMap(CopyMapList[i]);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        // 刷怪接口
        /// </summary>
        static public void ExperienceCopyMapCreateMonster(GameClient client, ExperienceCopyScene ExperienceMapInfo, ExperienceCopyMapDataInfo exMap, int nWave)
        {
            ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterFlag = 1;

            ++ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterWave;

            GameMap gameMap = null;

            if (!GameManager.MapMgr.DictMaps.TryGetValue(ExperienceMapInfo.m_MapCodeID, out gameMap))
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("经验副本 地图配置 ID = {0}", ExperienceMapInfo.m_MapCodeID));
                return;
            }

            int gridX = gameMap.CorrectWidthPointToGridPoint(exMap.posX) / gameMap.MapGridWidth;
            int gridY = gameMap.CorrectHeightPointToGridPoint(exMap.posZ) / gameMap.MapGridHeight;

            int gridNum = gameMap.CorrectWidthPointToGridPoint(exMap.Radius);

            int nID    = 0;
            int nNum   = 0;
            int nTotal = 0;

            //for (int i = 0; i < exMap.MonsterIDList.Count; ++i)
            {
                List <int> nListID  = exMap.MonsterIDList[nWave];
                List <int> nListNum = exMap.MonsterNumList[nWave];

                for (int j = 0; j < nListID.Count; ++j)
                {
                    nID  = nListID[j];
                    nNum = nListNum[j];

                    GameManager.MonsterZoneMgr.AddDynamicMonsters(ExperienceMapInfo.m_MapCodeID, nID, ExperienceMapInfo.m_CopyMapID, nNum, gridX, gridY, gridNum);

                    nTotal += nNum;

                    ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterNum += nNum;

                    ExperienceMapInfo.m_ExperienceCopyMapRemainMonsterNum += nNum;
                }
            }

            // 计数要杀死怪的数量
            ExperienceMapInfo.m_ExperienceCopyMapNeedKillMonsterNum = ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterNum * exMap.CreateNextWaveMonsterCondition[nWave] / 100;

            //System.Console.WriteLine("liaowei是帅哥  经验副本 {0} 里 刷怪了 数量是 {1} !!!", exMap.MapCodeID, ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterNum);

            if (client != null)
            {
                SendMsgToClientForExperienceCopyMapInfo(client, ExperienceMapInfo.m_ExperienceCopyMapCreateMonsterWave);
            }
        }
        public static void ExperienceCopyMapKillMonster(GameClient client, Monster monster)
        {
            ExperienceCopyMapDataInfo TmpExInfo = null;

            if (Data.ExperienceCopyMapDataInfoList.TryGetValue(client.ClientData.MapCode, out TmpExInfo))
            {
                ExperienceCopyScene tmpExSceneInfo = null;
                lock (ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo)
                {
                    if (!ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo.TryGetValue(client.ClientData.FuBenSeqID, out tmpExSceneInfo))
                    {
                        return;
                    }
                }
                if (tmpExSceneInfo != null)
                {
                    CopyMap TmpCopyMapInfo = null;
                    if (ExperienceCopySceneManager.m_ExperienceListCopyMaps.TryGetValue(client.ClientData.FuBenSeqID, out TmpCopyMapInfo))
                    {
                        if (TmpCopyMapInfo != null)
                        {
                            tmpExSceneInfo.m_ExperienceCopyMapKillMonsterNum++;
                            tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum++;
                            tmpExSceneInfo.m_ExperienceCopyMapRemainMonsterNum--;
                            if (tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterFlag == 1 && tmpExSceneInfo.m_ExperienceCopyMapKillMonsterNum == tmpExSceneInfo.m_ExperienceCopyMapNeedKillMonsterNum)
                            {
                                tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterFlag = 0;
                                tmpExSceneInfo.m_ExperienceCopyMapKillMonsterNum    = 0;
                                tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterNum  = 0;
                            }
                            if (tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterWave == TmpExInfo.MonsterIDList.Count && tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum == TmpExInfo.MonsterSum)
                            {
                                ExperienceCopySceneManager.SendMsgToClientForExperienceCopyMapAward(client);
                            }
                            int nWave = tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterWave;
                            if (tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum == TmpExInfo.MonsterSum || tmpExSceneInfo.m_ExperienceCopyMapRemainMonsterNum == 0)
                            {
                                nWave++;
                            }
                            ExperienceCopySceneManager.SendMsgToClientForExperienceCopyMapInfo(client, nWave);
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        public static Dictionary <int, ExperienceCopyScene> m_ExperienceListCopyMapsInfo = new Dictionary <int, ExperienceCopyScene>(); // key: 副本流水ID 即DB生成  Value: ExperienceCopyScene信息

        /// <summary>
        /// 添加一个场景
        /// </summary>
        public static void AddExperienceListCopyMap(int nID, CopyMap mapInfo)
        {
            bool bInsert = false;

            lock (m_ExperienceListCopyMaps)
            {
                CopyMap tmp = null;

                if (!m_ExperienceListCopyMaps.TryGetValue(nID, out tmp))
                {
                    m_ExperienceListCopyMaps.Add(nID, mapInfo);
                    bInsert = true;
                }
                else
                {
                    if (tmp == null)
                    {
                        m_ExperienceListCopyMaps[nID] = mapInfo;
                        bInsert = true;
                    }
                }
            }

            lock (m_ExperienceListCopyMapsInfo)
            {
                if (bInsert == true)
                {
                    ExperienceCopyScene ExperienceSceneInfo = null;//new ExperienceCopyScene();

                    if (!m_ExperienceListCopyMapsInfo.TryGetValue(nID, out ExperienceSceneInfo))
                    {
                        ExperienceSceneInfo = new ExperienceCopyScene();

                        ExperienceSceneInfo.InitInfo(mapInfo.MapCode, mapInfo.CopyMapID, nID);

                        ExperienceSceneInfo.m_StartTimer = DateTime.Now.Ticks / 10000;

                        m_ExperienceListCopyMapsInfo.Add(nID, ExperienceSceneInfo);
                    }
                }
            }
        }
        public static void SendMsgToClientForExperienceCopyMapInfo(GameClient client, int nWave)
        {
            ExperienceCopyScene tmpExSceneInfo = null;

            lock (ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo)
            {
                ExperienceCopySceneManager.m_ExperienceListCopyMapsInfo.TryGetValue(client.ClientData.FuBenSeqID, out tmpExSceneInfo);
            }
            if (tmpExSceneInfo != null)
            {
                int nRealyWave = nWave;
                int nTotalWave = Data.ExperienceCopyMapDataInfoList[client.ClientData.MapCode].MonsterIDList.Count;
                if (nRealyWave > nTotalWave)
                {
                    nRealyWave = nTotalWave;
                }
                string       strcmd       = string.Format("{0}:{1}:{2}", nRealyWave, nTotalWave, tmpExSceneInfo.m_ExperienceCopyMapRemainMonsterNum);
                TCPOutPacket tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(Global._TCPManager.TcpOutPacketPool, strcmd, 565);
                Global._TCPManager.MySocketListener.SendData(client.ClientSocket, tcpOutPacket, true);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        // 杀怪接口
        /// </summary>
        static public void ExperienceCopyMapKillMonster(GameClient client, Monster monster)
        {
            ExperienceCopyMapDataInfo TmpExInfo = null;

            if (!Data.ExperienceCopyMapDataInfoList.TryGetValue(client.ClientData.MapCode, out TmpExInfo))
            {
                return;
            }

            ExperienceCopyScene tmpExSceneInfo = null;

            // 此处需要加锁
            lock (m_ExperienceListCopyMapsInfo)
            {
                if (!m_ExperienceListCopyMapsInfo.TryGetValue(client.ClientData.FuBenSeqID, out tmpExSceneInfo))
                {
                    return;
                }
                //tmpExSceneInfo = m_ExperienceListCopyMapsInfo[client.ClientData.FuBenSeqID];
            }

            if (tmpExSceneInfo == null)
            {
                return;
            }

            CopyMap TmpCopyMapInfo = null;

            //TmpCopyMapInfo = m_ExperienceListCopyMaps[client.ClientData.FuBenSeqID];

            if (m_ExperienceListCopyMaps.TryGetValue(client.ClientData.FuBenSeqID, out TmpCopyMapInfo))
            {
                if (TmpCopyMapInfo == null)
                {
                    return;
                }
            }
            else
            {
                return;
            }

            ++tmpExSceneInfo.m_ExperienceCopyMapKillMonsterNum;

            ++tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum;

            --tmpExSceneInfo.m_ExperienceCopyMapRemainMonsterNum;

            if (tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterFlag == 1 && tmpExSceneInfo.m_ExperienceCopyMapKillMonsterNum == tmpExSceneInfo.m_ExperienceCopyMapNeedKillMonsterNum)
            {
                tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterFlag = 0;
                tmpExSceneInfo.m_ExperienceCopyMapKillMonsterNum    = 0;
                tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterNum  = 0;
            }

            //if (tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum == TmpExInfo.MonsterSum)
            {
                if (tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterWave == TmpExInfo.MonsterIDList.Count && tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum == TmpExInfo.MonsterSum)
                {
                    SendMsgToClientForExperienceCopyMapAward(client);
                }

                int nWave = tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterWave;
                if (tmpExSceneInfo.m_ExperienceCopyMapKillMonsterTotalNum == TmpExInfo.MonsterSum || tmpExSceneInfo.m_ExperienceCopyMapRemainMonsterNum == 0)
                {
                    nWave++;
                }
                SendMsgToClientForExperienceCopyMapInfo(client, nWave);
            }

            //System.Console.WriteLine("liaowei是帅哥  经验副本 {0} 里 杀怪了 剩余数量是 {1}!!!", TmpCopyMapInfo.FuBenSeqID, tmpExSceneInfo.m_ExperienceCopyMapRemainMonsterNum);
        }
Exemplo n.º 11
0
        /// <summary>
        // 心跳处理
        /// </summary>
        public static void HeartBeatExperienceCopyMap()
        {
            long nowTicks = DateTime.Now.Ticks / 10000;

            if (nowTicks - LastHeartBeatTicks < (1000))
            {
                return;
            }

            LastHeartBeatTicks = nowTicks;

            List <CopyMap> CopyMapList = new List <CopyMap>();

            // lock住!!!
            lock (m_ExperienceListCopyMaps)
            {
                foreach (var item in m_ExperienceListCopyMaps.Values)
                {
                    List <GameClient> clientsList = item.GetClientsList();

                    /*if (null != clientsList && clientsList.Count <= 0)
                     * {
                     *  CopyMapList.Add(item);
                     *  continue;
                     * }*/

                    ExperienceCopyMapDataInfo tmp = null;
                    tmp = Data.ExperienceCopyMapDataInfoList[item.MapCode];

                    if (tmp == null)
                    {
                        continue;
                    }

                    ExperienceCopyScene tmpExSceneInfo = null;

                    lock (m_ExperienceListCopyMapsInfo)
                    {
                        if (!m_ExperienceListCopyMapsInfo.TryGetValue(item.FuBenSeqID, out tmpExSceneInfo))
                        {
                            continue;
                        }

                        //tmpExSceneInfo = m_ExperienceListCopyMapsInfo[item.FuBenSeqID];
                    }

                    if (tmpExSceneInfo == null)
                    {
                        continue;
                    }

                    /*int fuBenID = FuBenManager.FindFuBenIDByMapCode(item.MapCode);
                     * FuBenMapItem fuBenMapItem = FuBenManager.FindMapCodeByFuBenID(fuBenID, item.MapCode);
                     * if (null == fuBenMapItem)
                     *  continue;
                     *
                     * //是否超时
                     * if (nowTicks - tmpExSceneInfo.m_StartTimer >= (fuBenMapItem.MaxTime * 60L * 1000L))
                     * {
                     *  CopyMapList.Add(item);
                     *  continue;
                     * }*/

                    int nWave  = tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterWave;
                    int nCount = tmp.MonsterIDList.Count; // 一共有几波

                    if (nWave >= nCount)                  // 已经刷完了
                    {
                        continue;
                    }

                    if (tmpExSceneInfo.m_ExperienceCopyMapCreateMonsterFlag == 0)
                    {
                        if (clientsList.Count() != 0 && clientsList[0] != null)
                        {
                            ExperienceCopyMapCreateMonster(clientsList[0], tmpExSceneInfo, tmp, nWave);
                        }
                        else
                        {
                            ExperienceCopyMapCreateMonster(null, tmpExSceneInfo, tmp, nWave);
                        }
                    }
                }
            }

            for (int i = 0; i < CopyMapList.Count; ++i)
            {
                GameManager.CopyMapMgr.ProcessRemoveCopyMap(CopyMapList[i]);
            }
        }