Ejemplo n.º 1
0
        public void OnCaiJiFinish(GameClient client, Monster monster)
        {
            KingOfBattleScene        scene;
            BattleCrystalMonsterItem monsterItem;
            int addScore = 0;

            lock (RuntimeData.Mutex)
            {
                if (!SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene))
                {
                    return;
                }

                if (scene.m_eStatus != GameSceneStatuses.STATUS_BEGIN)
                {
                    return;
                }

                monsterItem = monster.Tag as BattleCrystalMonsterItem;
                if (monsterItem == null)
                {
                    return;
                }

                // 水晶复活
                BattleCrystalMonsterItem crystalItem = client.SceneContextData as BattleCrystalMonsterItem;
                if (null != crystalItem)
                {
                    AddDelayCreateMonster(scene, TimeUtil.NOW() + crystalItem.FuHuoTime, crystalItem);
                }

                // 采集BUFF
                UpdateBuff4GameClient(client, monsterItem.BuffGoodsID, monsterItem, true);
            }
        }
Ejemplo n.º 2
0
        public int GetCaiJiMonsterTime(GameClient client, Monster monster)
        {
            BattleCrystalMonsterItem tag = monster != null ? monster.Tag as BattleCrystalMonsterItem : null;

            if (tag == null)
            {
                return(StdErrorCode.Error_Has_Get);
            }

            return(tag.GatherTime);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 提交采集BUFF
        /// </summary>
        public void SubmitCrystalBuff(GameClient client, int areaLuaID)
        {
            if (areaLuaID != client.ClientData.BattleWhichSide)
            {
                return;
            }

            BattleCrystalMonsterItem crystalItem = client.SceneContextData as BattleCrystalMonsterItem;

            if (null == crystalItem)
            {
                return;
            }

            lock (RuntimeData.Mutex)
            {
                KingOfBattleScene scene;
                if (!SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene))
                {
                    return;
                }

                // 加分
                KingOfBattleClientContextData contextData = client.SceneContextData2 as KingOfBattleClientContextData;
                if (null != contextData && scene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                {
                    int addScore = 0;
                    addScore = crystalItem.BattleJiFen;
                    contextData.TotalScore += addScore;
                    scene.GameStatisticalData.CaiJiScore += addScore;
                    if (client.ClientData.BattleWhichSide == 1)
                    {
                        scene.ScoreData.Score1 += addScore;
                    }
                    else if (client.ClientData.BattleWhichSide == 2)
                    {
                        scene.ScoreData.Score2 += addScore;
                    }

                    if (addScore > 0)
                    {
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_KINGOFBATTLE_SIDE_SCORE, scene.ScoreData, scene.CopyMap);
                        NotifyTimeStateInfoAndScoreInfo(client, false, false, true);
                    }
                }

                // 清除Buff
                UpdateBuff4GameClient(client, crystalItem.BuffGoodsID, crystalItem, false);

                // 水晶复活
                AddDelayCreateMonster(scene, TimeUtil.NOW() + crystalItem.FuHuoTime, crystalItem);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 检查场景BUFF
        /// </summary>
        private void CheckSceneBufferTime(KingOfBattleScene kingOfBattleScene, long nowTicks)
        {
            List <KingOfBattleSceneBuff> sceneBuffDeleteList = new List <KingOfBattleSceneBuff>();

            lock (RuntimeData.Mutex)
            {
                if (kingOfBattleScene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                {
                    if (kingOfBattleScene.SceneBuffDict.Count == 0)
                    {
                        return;
                    }

                    foreach (var contextData in kingOfBattleScene.SceneBuffDict.Values)
                    {
                        //处理超时情况
                        if (contextData.EndTicks < nowTicks)
                        {
                            sceneBuffDeleteList.Add(contextData);
                        }
                    }

                    if (sceneBuffDeleteList.Count == 0)
                    {
                        return;
                    }

                    foreach (var contextData in sceneBuffDeleteList)
                    {
                        if (contextData.RoleID != 0)
                        {
                            // 卸载Buff
                            GameClient client = GameManager.ClientMgr.FindClient(contextData.RoleID);
                            if (null != client)
                            {
                                UpdateBuff4GameClient(client, contextData.BuffID, contextData.tagInfo, false);
                            }
                        }

                        // 水晶复活
                        BattleCrystalMonsterItem CrystalItem = contextData.tagInfo as BattleCrystalMonsterItem;
                        if (null != CrystalItem)
                        {
                            AddDelayCreateMonster(kingOfBattleScene, TimeUtil.NOW() + CrystalItem.FuHuoTime, contextData.tagInfo);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void CheckCreateDynamicMonster(KingOfBattleScene scene, long nowMs)
        {
            lock (RuntimeData.Mutex)
            {
                while (scene.CreateMonsterQueue.Count > 0)
                {
                    KeyValuePair <long, List <object> > pair = scene.CreateMonsterQueue.First();
                    if (nowMs < pair.Key)
                    {
                        break;
                    }

                    try
                    {
                        foreach (var obj in pair.Value)
                        {
                            if (obj is KingOfBattleDynamicMonsterItem)
                            {
                                KingOfBattleDynamicMonsterItem item = obj as KingOfBattleDynamicMonsterItem;
                                GameManager.MonsterZoneMgr.AddDynamicMonsters(scene.m_nMapCode, item.MonsterID, scene.CopyMapId, 1,
                                                                              item.PosX / scene.MapGridWidth, item.PosY / scene.MapGridHeight, 0, item.PursuitRadius, SceneUIClasses.KingOfBattle, item);

                                if (item.MonsterType == (int)KingOfBattleMonsterType.KingOfBattle_Boss)
                                {
                                    string msgText = string.Format(Global.GetLang("【{0}】已刷新"), Global.GetMonsterNameByID(item.MonsterID));
                                    GameManager.ClientMgr.BroadSpecialCopyMapMsg(scene.CopyMap, msgText);
                                }
                            }
                            else if (obj is BattleCrystalMonsterItem)
                            {
                                BattleCrystalMonsterItem crystal = obj as BattleCrystalMonsterItem;
                                GameManager.MonsterZoneMgr.AddDynamicMonsters(scene.m_nMapCode, crystal.MonsterID, scene.CopyMap.CopyMapID, 1,
                                                                              crystal.PosX / scene.MapGridWidth, crystal.PosY / scene.MapGridHeight, 0, 0, SceneUIClasses.KingOfBattle, crystal);
                            }
                        }
                    }
                    finally
                    {
                        scene.CreateMonsterQueue.RemoveAt(0);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 删除角色身上的王者战场内Buff
        /// </summary>
        public void RemoveBattleSceneBuffForRole(KingOfBattleScene scene, GameClient client)
        {
            List <KingOfBattleSceneBuff> sceneBuffDeleteList = new List <KingOfBattleSceneBuff>();

            lock (RuntimeData.Mutex)
            {
                if (scene.SceneBuffDict.Count == 0)
                {
                    return;
                }

                foreach (var contextData in scene.SceneBuffDict.Values)
                {
                    if (contextData.RoleID == client.ClientData.RoleID)
                    {
                        sceneBuffDeleteList.Add(contextData);
                    }
                }

                if (sceneBuffDeleteList.Count == 0)
                {
                    return;
                }

                foreach (var contextData in sceneBuffDeleteList)
                {
                    if (contextData.RoleID != 0)
                    {
                        // 卸载Buff
                        UpdateBuff4GameClient(client, contextData.BuffID, contextData.tagInfo, false);
                    }

                    // 水晶复活
                    BattleCrystalMonsterItem CrystalItem = contextData.tagInfo as BattleCrystalMonsterItem;
                    if (null != CrystalItem)
                    {
                        AddDelayCreateMonster(scene, TimeUtil.NOW() + CrystalItem.FuHuoTime, contextData.tagInfo);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public void CheckCreateDynamicMonster(YongZheZhanChangScene scene, long nowMs)
        {
            lock (RuntimeData.Mutex)
            {
                while (scene.CreateMonsterQueue.Count > 0)
                {
                    KeyValuePair <long, List <object> > pair = scene.CreateMonsterQueue.First();
                    if (nowMs < pair.Key)
                    {
                        break;
                    }

                    try
                    {
                        foreach (var obj in pair.Value)
                        {
                            if (obj is BattleDynamicMonsterItem)
                            {
                                BattleDynamicMonsterItem crystal = obj as BattleDynamicMonsterItem;
                                GameManager.MonsterZoneMgr.AddDynamicMonsters(scene.m_nMapCode, crystal.MonsterID, scene.CopyMapId, 1,
                                                                              crystal.PosX / scene.MapGridWidth, crystal.PosY / scene.MapGridHeight, 0, 0, SceneUIClasses.YongZheZhanChang, crystal);
                            }
                            else if (obj is BattleCrystalMonsterItem)
                            {
                                BattleCrystalMonsterItem item = obj as BattleCrystalMonsterItem;
                                GameManager.MonsterZoneMgr.AddDynamicMonsters(scene.m_nMapCode, item.MonsterID, scene.CopyMap.CopyMapID, 1, item.PosX / scene.MapGridWidth, item.PosY / scene.MapGridHeight, 0, 0, SceneUIClasses.YongZheZhanChang, item);
                            }
                        }
                    }
                    finally
                    {
                        scene.CreateMonsterQueue.RemoveAt(0);
                    }
                }
            }
        }
Ejemplo n.º 8
0
 // 刷勇者战场水晶采集物
 private void CreateCrystalMonster(YongZheZhanChangScene scene, BattleCrystalMonsterItem crystal)
 {
     GameManager.MonsterZoneMgr.AddDynamicMonsters(scene.m_nMapCode, crystal.MonsterID, scene.CopyMapId, 1,
                                                   crystal.PosX / scene.MapGridWidth, crystal.PosY / scene.MapGridHeight, 0, 0, SceneUIClasses.YongZheZhanChang, crystal);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 初始化配置
        /// </summary>
        public bool InitConfig()
        {
            bool     success          = true;
            XElement xml              = null;
            string   fileName         = "";
            string   fullPathFileName = "";
            IEnumerable <XElement> nodes;

            lock (RuntimeData.Mutex)
            {
                try
                {
                    //采集怪配置
                    RuntimeData.BattleCrystalMonsterDict.Clear();

                    fileName         = "Config/BattleCrystalMonster.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        BattleCrystalMonsterItem item = new BattleCrystalMonsterItem();
                        item.Id          = (int)Global.GetSafeAttributeLong(node, "ID");
                        item.MonsterID   = (int)Global.GetSafeAttributeLong(node, "MonsterID");
                        item.GatherTime  = (int)Global.GetSafeAttributeLong(node, "GatherTime");
                        item.BattleJiFen = (int)Global.GetSafeAttributeLong(node, "BattleJiFen");
                        item.PosX        = (int)Global.GetSafeAttributeLong(node, "X");
                        item.PosY        = (int)Global.GetSafeAttributeLong(node, "Y");
                        item.FuHuoTime   = (int)Global.GetSafeAttributeLong(node, "FuHuoTime") * 1000;
                        //RuntimeData.BattleCrystalMonsterDict[item.MonsterID] = item;
                        RuntimeData.BattleCrystalMonsterDict[item.Id] = item;
                    }

                    //出生点配置
                    RuntimeData.MapBirthPointDict.Clear();

                    fileName         = "Config/ThroughServiceRebirth.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        YongZheZhanChangBirthPoint item = new YongZheZhanChangBirthPoint();
                        item.ID          = (int)Global.GetSafeAttributeLong(node, "ID");
                        item.PosX        = (int)Global.GetSafeAttributeLong(node, "PosX");
                        item.PosY        = (int)Global.GetSafeAttributeLong(node, "PosY");
                        item.BirthRadius = (int)Global.GetSafeAttributeLong(node, "BirthRadius");

                        RuntimeData.MapBirthPointDict[item.ID] = item;
                    }

                    //活动配置
                    RuntimeData.SceneDataDict.Clear();
                    RuntimeData.LevelRangeSceneIdDict.Clear();

                    fileName         = "Config/ThroughServiceBattle.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        YongZheZhanChangSceneInfo sceneItem = new YongZheZhanChangSceneInfo();
                        int id      = (int)Global.GetSafeAttributeLong(node, "Group");
                        int mapCode = (int)Global.GetSafeAttributeLong(node, "MapCode");

                        sceneItem.Id               = id;
                        sceneItem.MapCode          = mapCode;
                        sceneItem.MinLevel         = (int)Global.GetSafeAttributeLong(node, "MinLevel");
                        sceneItem.MaxLevel         = (int)Global.GetSafeAttributeLong(node, "MaxLevel");
                        sceneItem.MinZhuanSheng    = (int)Global.GetSafeAttributeLong(node, "MinZhuanSheng");
                        sceneItem.MaxZhuanSheng    = (int)Global.GetSafeAttributeLong(node, "MaxZhuanSheng");
                        sceneItem.PrepareSecs      = (int)Global.GetSafeAttributeLong(node, "PrepareSecs");
                        sceneItem.WaitingEnterSecs = (int)Global.GetSafeAttributeLong(node, "WaitingEnterSecs");
                        sceneItem.FightingSecs     = (int)Global.GetSafeAttributeLong(node, "FightingSecs");
                        sceneItem.ClearRolesSecs   = (int)Global.GetSafeAttributeLong(node, "ClearRolesSecs");

                        ConfigParser.ParseStrInt2(Global.GetSafeAttributeStr(node, "ApplyTime"), ref sceneItem.SignUpStartSecs, ref sceneItem.SignUpEndSecs);
                        sceneItem.SignUpStartSecs += sceneItem.SignUpEndSecs;

                        if (!ConfigParser.ParserTimeRangeListWithDay(sceneItem.TimePoints, Global.GetSafeAttributeStr(node, "TimePoints")))
                        {
                            success = false;
                            LogManager.WriteLog(LogTypes.Fatal, string.Format("读取{0}时间配置(TimePoints)出错", fileName));
                        }

                        for (int i = 0; i < sceneItem.TimePoints.Count; ++i)
                        {
                            TimeSpan ts = new TimeSpan(sceneItem.TimePoints[i].Hours, sceneItem.TimePoints[i].Minutes, sceneItem.TimePoints[i].Seconds);
                            sceneItem.SecondsOfDay.Add(ts.TotalSeconds);
                        }

                        GameMap gameMap = null;
                        if (!GameManager.MapMgr.DictMaps.TryGetValue(mapCode, out gameMap))
                        {
                            success = false;
                            LogManager.WriteLog(LogTypes.Fatal, string.Format("55地图配置中缺少{0}所需的地图:{1}", fileName, mapCode));
                        }

                        RangeKey range = new RangeKey(Global.GetUnionLevel(sceneItem.MinZhuanSheng, sceneItem.MinLevel), Global.GetUnionLevel(sceneItem.MaxZhuanSheng, sceneItem.MaxLevel));
                        RuntimeData.LevelRangeSceneIdDict[range] = sceneItem;
                        RuntimeData.SceneDataDict[id]            = sceneItem;
                    }

                    //活动奖励配置
                    fileName         = "Config/ThroughServiceBattleAward.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        int id = (int)Global.GetSafeAttributeLong(node, "MapCode");
                        YongZheZhanChangSceneInfo sceneItem;
                        if (RuntimeData.SceneDataDict.TryGetValue(id, out sceneItem))
                        {
                            sceneItem.Exp       = (int)Global.GetSafeAttributeLong(node, "Exp");
                            sceneItem.BandJinBi = (int)Global.GetSafeAttributeLong(node, "BandJinBi");
                            ConfigParser.ParseAwardsItemList(Global.GetSafeAttributeStr(node, "WinGoods"), ref sceneItem.WinAwardsItemList);
                            ConfigParser.ParseAwardsItemList(Global.GetSafeAttributeStr(node, "LoseGoods"), ref sceneItem.LoseAwardsItemList);
                        }
                    }

                    fileName         = "Config/BattleMonster.xml";
                    fullPathFileName = Global.GameResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        BattleDynamicMonsterItem item = new BattleDynamicMonsterItem();
                        item.Id           = (int)Global.GetSafeAttributeLong(node, "ID");
                        item.MapCode      = (int)Global.GetSafeAttributeLong(node, "CodeID");
                        item.MonsterID    = (int)Global.GetSafeAttributeLong(node, "MonsterID");
                        item.PosX         = (int)Global.GetSafeAttributeLong(node, "X");
                        item.PosY         = (int)Global.GetSafeAttributeLong(node, "Y");
                        item.DelayBirthMs = (int)Global.GetSafeAttributeLong(node, "Time");

                        List <BattleDynamicMonsterItem> itemList = null;
                        if (!RuntimeData.SceneDynMonsterDict.TryGetValue(item.MapCode, out itemList))
                        {
                            itemList = new List <BattleDynamicMonsterItem>();
                            RuntimeData.SceneDynMonsterDict[item.MapCode] = itemList;
                        }

                        itemList.Add(item);
                    }

                    //奖励配置
                    RuntimeData.WarriorBattleBOssLastAttack = (int)GameManager.systemParamsList.GetParamValueIntByName("WarriorBattleBOssLastAttack");
                    //RuntimeData.WarriorBattlePk = (int)GameManager.systemParamsList.GetParamValueIntByName("WarriorBattlePk");
                    RuntimeData.WarriorBattleLowestJiFen = (int)GameManager.systemParamsList.GetParamValueIntByName("WarriorBattleLowestJiFen");
                    double[] doubalArray = GameManager.systemParamsList.GetParamValueDoubleArrayByName("WarriorBattleBossAttack");
                    if (doubalArray.Length == 2)
                    {
                        RuntimeData.WarriorBattleBossAttackPercent = doubalArray[0];
                        RuntimeData.WarriorBattleBossAttackScore   = (int)doubalArray[1];
                    }
                    int[] intArray = GameManager.systemParamsList.GetParamValueIntArrayByName("WarriorBattleUltraKill");
                    if (doubalArray.Length == 2)
                    {
                        RuntimeData.WarriorBattleUltraKillParam1 = intArray[0];
                        RuntimeData.WarriorBattleUltraKillParam2 = intArray[1];
                        RuntimeData.WarriorBattleUltraKillParam3 = intArray[2];
                        RuntimeData.WarriorBattleUltraKillParam4 = intArray[3];
                    }
                    intArray = GameManager.systemParamsList.GetParamValueIntArrayByName("WarriorBattleShutDown");
                    if (doubalArray.Length == 2)
                    {
                        RuntimeData.WarriorBattleShutDownParam1 = intArray[0];
                        RuntimeData.WarriorBattleShutDownParam2 = intArray[1];
                        RuntimeData.WarriorBattleShutDownParam3 = intArray[2];
                        RuntimeData.WarriorBattleShutDownParam4 = intArray[3];
                    }
                }
                catch (System.Exception ex)
                {
                    success = false;
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。", fileName), ex);
                }
            }

            return(success);
        }