コード例 #1
0
 private void InitScene(KingOfBattleScene scene, GameClient client)
 {
     foreach (var item in RuntimeData.NPCID2QiZhiConfigDict.Values)
     {
         scene.NPCID2QiZhiConfigDict.Add(item.NPCID, item.Clone() as KingOfBattleQiZhiConfig);
     }
 }
コード例 #2
0
        /// <summary>
        /// 给奖励
        /// </summary>
        public void GiveAwards(KingOfBattleScene scene)
        {
            try
            {
                KingOfBattleStatisticalData gameResultData = scene.GameStatisticalData;
                foreach (var contextData in scene.ClientContextDataDict.Values)
                {
                    gameResultData.AllRoleCount++;
                    int success;
                    if (contextData.BattleWhichSide == scene.SuccessSide)
                    {
                        success = 1;
                        gameResultData.WinRoleCount++;
                    }
                    else
                    {
                        success = 0;
                        gameResultData.LoseRoleCount++;
                    }

                    GameClient client     = GameManager.ClientMgr.FindClient(contextData.RoleId);
                    string     awardsInfo = string.Format("{0},{1},{2},{3},{4}", scene.SceneInfo.Id, success, contextData.TotalScore, scene.ScoreData.Score1, scene.ScoreData.Score2);
                    if (client != null) //确认角色仍然在线
                    {
                        int score = contextData.TotalScore;
                        contextData.TotalScore = 0;
                        if (score >= RuntimeData.KingOfBattleLowestJiFen)
                        {
                            Global.SaveRoleParamsStringToDB(client, RoleParamName.KingOfBattleAwards, awardsInfo, true);
                        }
                        else
                        {
                            Global.SaveRoleParamsStringToDB(client, RoleParamName.KingOfBattleAwards, RuntimeData.RoleParamsAwardsDefaultString, true);
                        }

                        NtfCanGetAward(client, success, score, scene.SceneInfo, scene.ScoreData.Score1, scene.ScoreData.Score2);
                    }
                    else if (contextData.TotalScore >= RuntimeData.KingOfBattleLowestJiFen)
                    {
                        Global.UpdateRoleParamByNameOffline(contextData.RoleId, RoleParamName.KingOfBattleAwards, awardsInfo, contextData.ServerId);
                    }
                    else
                    {
                        Global.UpdateRoleParamByNameOffline(contextData.RoleId, RoleParamName.KingOfBattleAwards, RuntimeData.RoleParamsAwardsDefaultString, contextData.ServerId);
                    }
                }

                YongZheZhanChangClient.getInstance().PushGameResultData(gameResultData);
            }
            catch (System.Exception ex)
            {
                DataHelper.WriteExceptionLogEx(ex, "王者战场系统清场调度异常");
            }
        }
コード例 #3
0
        /// <summary>
        /// 结束战斗
        /// </summary>
        private void ProcessEnd(KingOfBattleScene scene, int successSide, long nowTicks)
        {
            CompleteScene(scene, successSide);
            scene.m_eStatus    = GameSceneStatuses.STATUS_END;
            scene.m_lLeaveTime = nowTicks + scene.SceneInfo.ClearRolesSecs * TimeUtil.SECOND;

            scene.StateTimeData.GameType = (int)GameTypes.KingOfBattle;
            scene.StateTimeData.State    = (int)GameSceneStatuses.STATUS_CLEAR;
            scene.StateTimeData.EndTicks = scene.m_lLeaveTime;
            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMap);
        }
コード例 #4
0
        private void AddDelayCreateMonster(KingOfBattleScene scene, long ticks, object monster)
        {
            lock (RuntimeData.Mutex)
            {
                List <object> list = null;
                if (!scene.CreateMonsterQueue.TryGetValue(ticks, out list))
                {
                    list = new List <object>();
                    scene.CreateMonsterQueue.Add(ticks, list);
                }

                list.Add(monster);
            }
        }
コード例 #5
0
        /// <summary>
        /// 玩家离开王者战场
        /// </summary>
        public void LeaveFuBen(GameClient client)
        {
            lock (RuntimeData.Mutex)
            {
                KingOfBattleScene scene = null;
                if (SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene))
                {
                    scene.m_nPlarerCount--;

                    // 卸载王者战场内Buff
                    RemoveBattleSceneBuffForRole(scene, client);
                }
            }
        }
コード例 #6
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);
                        }
                    }
                }
            }
        }
コード例 #7
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);
                    }
                }
            }
        }
コード例 #8
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);
                    }
                }
            }
        }
コード例 #9
0
        private void InitCreateDynamicMonster(KingOfBattleScene scene)
        {
            lock (RuntimeData.Mutex)
            {
                // 刷军旗
                foreach (var item in scene.NPCID2QiZhiConfigDict.Values)
                {
                    item.Alive = true;
                    if (item.QiZhiMonsterID == RuntimeData.BattleQiZhiMonsterID1)
                    {
                        item.BattleWhichSide = 1;
                    }
                    else if (item.QiZhiMonsterID == RuntimeData.BattleQiZhiMonsterID2)
                    {
                        item.BattleWhichSide = 2;
                    }
                    GameManager.MonsterZoneMgr.AddDynamicMonsters(scene.m_nMapCode, item.QiZhiMonsterID, scene.CopyMapId, 1,
                                                                  item.PosX / scene.MapGridWidth, item.PosY / scene.MapGridHeight, 0, 0, SceneUIClasses.KingOfBattle, item);
                }

                // 刷水晶怪
                foreach (var crystal in RuntimeData.BattleCrystalMonsterDict.Values)
                {
                    AddDelayCreateMonster(scene, scene.m_lPrepareTime, crystal);
                }

                List <KingOfBattleDynamicMonsterItem> dynMonsterList = null;
                if (RuntimeData.SceneDynMonsterDict.TryGetValue(scene.m_nMapCode, out dynMonsterList))
                {
                    foreach (var item in dynMonsterList)
                    {
                        if (item.RebornBirth == false) // 初始生成
                        {
                            AddDelayCreateMonster(scene, scene.m_lPrepareTime + item.DelayBirthMs, item);
                        }
                    }
                }
            }
        }
コード例 #10
0
        /// </summary>
        /// 传送门
        /// </summary>
        public bool ClientChangeMap(GameClient client, int teleportID, ref int toNewMapCode, ref int toNewPosX, ref int toNewPosY)
        {
            KingOfBattleScene scene = client.SceneObject as KingOfBattleScene;

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

            int OpenGateSide = teleportID % 10;

            if (client.ClientData.BattleWhichSide != OpenGateSide)
            {
                return(false);
            }

            if (!scene.SceneOpenTeleportList.Contains(teleportID))
            {
                return(false);
            }

            return(true);
        }
コード例 #11
0
 public void CompleteScene(KingOfBattleScene scene, int successSide)
 {
     scene.SuccessSide = successSide;
 }
コード例 #12
0
        /// <summary>
        /// 添加一个场景
        /// </summary>
        public bool AddCopyScenes(GameClient client, CopyMap copyMap, SceneUIClasses sceneType)
        {
            if (sceneType == SceneUIClasses.KingOfBattle)
            {
                GameMap gameMap = null;
                if (!GameManager.MapMgr.DictMaps.TryGetValue(client.ClientData.MapCode, out gameMap))
                {
                    return(false);
                }

                int      fuBenSeqId = copyMap.FuBenSeqID;
                int      mapCode    = copyMap.MapCode;
                int      roleId     = client.ClientData.RoleID;
                int      gameId     = (int)Global.GetClientKuaFuServerLoginData(client).GameId;
                DateTime now        = TimeUtil.NowDateTime();
                lock (RuntimeData.Mutex)
                {
                    KingOfBattleScene scene = null;
                    if (!SceneDict.TryGetValue(fuBenSeqId, out scene))
                    {
                        KingOfBattleSceneInfo     sceneInfo = null;
                        YongZheZhanChangFuBenData fuBenData;
                        if (!RuntimeData.FuBenItemData.TryGetValue(gameId, out fuBenData))
                        {
                            LogManager.WriteLog(LogTypes.Error, "王者战场没有为副本找到对应的跨服副本数据,GameID:" + gameId);
                        }

                        if (!RuntimeData.SceneDataDict.TryGetValue(fuBenData.GroupIndex, out sceneInfo))
                        {
                            LogManager.WriteLog(LogTypes.Error, "王者战场没有为副本找到对应的档位数据,ID:" + fuBenData.GroupIndex);
                        }

                        scene         = new KingOfBattleScene();
                        scene.CopyMap = copyMap;
                        scene.CleanAllInfo();
                        scene.GameId         = gameId;
                        scene.m_nMapCode     = mapCode;
                        scene.CopyMapId      = copyMap.CopyMapID;
                        scene.FuBenSeqId     = fuBenSeqId;
                        scene.m_nPlarerCount = 1;
                        scene.SceneInfo      = sceneInfo;
                        scene.MapGridWidth   = gameMap.MapGridWidth;
                        scene.MapGridHeight  = gameMap.MapGridHeight;
                        DateTime startTime = now.Date.Add(GetStartTime(sceneInfo.Id));
                        scene.StartTimeTicks = startTime.Ticks / 10000;
                        InitScene(scene, client);
                        scene.GameStatisticalData.GameId = gameId;

                        SceneDict[fuBenSeqId] = scene;
                    }
                    else
                    {
                        scene.m_nPlarerCount++;
                    }

                    KingOfBattleClientContextData clientContextData;
                    if (!scene.ClientContextDataDict.TryGetValue(roleId, out clientContextData))
                    {
                        clientContextData = new KingOfBattleClientContextData()
                        {
                            RoleId = roleId, ServerId = client.ServerId, BattleWhichSide = client.ClientData.BattleWhichSide
                        };
                        scene.ClientContextDataDict[roleId] = clientContextData;
                    }
                    else
                    {
                        clientContextData.KillNum = 0;
                    }

                    client.SceneObject       = scene;
                    client.SceneGameId       = scene.GameId;
                    client.SceneContextData2 = clientContextData;

                    copyMap.IsKuaFuCopy = true;
                    copyMap.SetRemoveTicks(TimeUtil.NOW() + scene.SceneInfo.TotalSecs * TimeUtil.SECOND);
                }

                //更新状态
                YongZheZhanChangClient.getInstance().GameFuBenRoleChangeState(roleId, (int)KuaFuRoleStates.StartGame);
                return(true);
            }
            return(false);
        }
コード例 #13
0
        /// <summary>
        /// 伤害或击杀Boss的处理
        /// </summary>
        /// <param name="client"></param>
        /// <param name="monster"></param>
        /// <param name="injure"></param>
        public void OnInjureMonster(GameClient client, Monster monster, long injure)
        {
            if (monster.MonsterType != (int)MonsterTypes.BOSS /*&& monster.MonsterType != (int)MonsterTypes.XianFactionGuard
                                                               * && monster.MonsterType != (int)MonsterTypes.MoFactionGuard && monster.MonsterType != (int)MonsterTypes.CampNoAttack*/)
            {
                return;
            }

            KingOfBattleClientContextData contextData = client.SceneContextData2 as KingOfBattleClientContextData;

            if (null == contextData)
            {
                return;
            }

            KingOfBattleDynamicMonsterItem tagInfo = monster.Tag as KingOfBattleDynamicMonsterItem;

            if (null == tagInfo)
            {
                return;
            }

            KingOfBattleScene scene = null;
            int addScore            = 0;

            if (monster.HandledDead && monster.WhoKillMeID == client.ClientData.RoleID)
            {
                addScore += tagInfo.JiFenKill;
            }

#if ___CC___FUCK___YOU___BB___
            double jiFenInjure = RuntimeData.KingBattleBossAttackPercent * monster.XMonsterInfo.MaxHP;
#else
            double jiFenInjure = RuntimeData.KingBattleBossAttackPercent * monster.MonsterInfo.VLifeMax;
#endif

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

                    double InjureBossDelta = 0.0d;
#if ___CC___FUCK___YOU___BB___
                    contextData.InjureBossDeltaDict.TryGetValue(monster.XMonsterInfo.MonsterId, out InjureBossDelta);
#else
                    contextData.InjureBossDeltaDict.TryGetValue(monster.MonsterInfo.ExtensionID, out InjureBossDelta);
#endif

                    InjureBossDelta += injure;
                    if (InjureBossDelta >= jiFenInjure && jiFenInjure > 0.0)
                    {
                        // 求出达成的伤害倍数
                        int calcRate = (int)(InjureBossDelta / jiFenInjure);
                        InjureBossDelta -= jiFenInjure * calcRate;
                        addScore        += tagInfo.JiFenDamage * calcRate;
                    }
#if ___CC___FUCK___YOU___BB___
                    contextData.InjureBossDeltaDict[monster.XMonsterInfo.MonsterId] = InjureBossDelta;
#else
                    contextData.InjureBossDeltaDict[monster.MonsterInfo.ExtensionID] = InjureBossDelta;
#endif
                    contextData.TotalScore += addScore;

                    // 处理Boss死亡重生
                    if (monster.HandledDead)
                    {
                        KingOfBattleDynamicMonsterItem RebornItem = null;
                        if (tagInfo.RebornID != -1 && RuntimeData.DynMonsterDict.TryGetValue(tagInfo.RebornID, out RebornItem))
                        {
                            long ticks = TimeUtil.NOW();
                            AddDelayCreateMonster(scene, ticks + RebornItem.DelayBirthMs, RebornItem);
                        }

                        // Buff
                        TryAddBossKillRandomBuff(client, tagInfo);
                    }

                    // 积分
                    if (client.ClientData.BattleWhichSide == 1)
                    {
                        scene.ScoreData.Score1 += addScore;
                    }
                    else if (client.ClientData.BattleWhichSide == 2)
                    {
                        scene.ScoreData.Score2 += addScore;
                    }

                    scene.GameStatisticalData.BossScore += addScore;
                }
            }

            if (addScore > 0 && scene != null)
            {
                GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_KINGOFBATTLE_SIDE_SCORE, scene.ScoreData, scene.CopyMap);
                NotifyTimeStateInfoAndScoreInfo(client, false, false, true);
            }
        }
コード例 #14
0
        /// <summary>
        /// 怪物死亡时
        /// </summary>
        /// <param name="npcID"></param>
        /// <param name="bhid"></param>
        public void OnProcessMonsterDead(GameClient client, Monster monster)
        {
#if ___CC___FUCK___YOU___BB___
            // 战旗
            if (null != client && (monster.XMonsterInfo.MonsterId == RuntimeData.BattleQiZhiMonsterID1 ||
                                   monster.XMonsterInfo.MonsterId == RuntimeData.BattleQiZhiMonsterID2))
            {
                KingOfBattleScene       scene       = client.SceneObject as KingOfBattleScene;
                KingOfBattleQiZhiConfig qizhiConfig = monster.Tag as KingOfBattleQiZhiConfig;
                if (null != scene && null != qizhiConfig)
                {
                    lock (RuntimeData.Mutex)
                    {
                        qizhiConfig.DeadTicks       = TimeUtil.NOW();
                        qizhiConfig.Alive           = false;
                        qizhiConfig.BattleWhichSide = client.ClientData.BattleWhichSide;
                        CalculateTeleportGateState(scene);
                    }
                }
            }
#else
            // 战旗
            if (null != client && (monster.MonsterInfo.ExtensionID == RuntimeData.BattleQiZhiMonsterID1 ||
                                   monster.MonsterInfo.ExtensionID == RuntimeData.BattleQiZhiMonsterID2))
            {
                KingOfBattleScene       scene       = client.SceneObject as KingOfBattleScene;
                KingOfBattleQiZhiConfig qizhiConfig = monster.Tag as KingOfBattleQiZhiConfig;
                if (null != scene && null != qizhiConfig)
                {
                    lock (RuntimeData.Mutex)
                    {
                        qizhiConfig.DeadTicks       = TimeUtil.NOW();
                        qizhiConfig.Alive           = false;
                        qizhiConfig.BattleWhichSide = client.ClientData.BattleWhichSide;
                        CalculateTeleportGateState(scene);
                    }
                }
            }
#endif

            // 杀塔
            KingOfBattleDynamicMonsterItem monsterConfig = monster.Tag as KingOfBattleDynamicMonsterItem;
            if (null != monsterConfig && (monsterConfig.MonsterType == (int)KingOfBattleMonsterType.KingOfBattle_TowerFirst ||
                                          monsterConfig.MonsterType == (int)KingOfBattleMonsterType.KingOfBattle_TowerSecond))
            {
                KingOfBattleScene scene = null; // 尝试开本方光幕
                if (SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene))
                {
                    CopyMap copyMap = scene.CopyMap;
                    string  msgText = string.Format(Global.GetLang("【{0}】摧毁了敌方箭塔,激活了本方密道!"), Global.FormatRoleName4(client));
                    if (client.ClientData.BattleWhichSide == 1 && scene.GuangMuNotify1 == false)
                    {
                        scene.GuangMuNotify1 = true;
                        GameManager.CopyMapMgr.AddGuangMuEvent(copyMap, client.ClientData.BattleWhichSide, 0);
                        GameManager.ClientMgr.BroadSpecialCopyMapMsg(copyMap, msgText);
                    }
                    else if (client.ClientData.BattleWhichSide == 2 && scene.GuangMuNotify2 == false)
                    {
                        scene.GuangMuNotify2 = true;
                        GameManager.CopyMapMgr.AddGuangMuEvent(copyMap, client.ClientData.BattleWhichSide, 0);
                        GameManager.ClientMgr.BroadSpecialCopyMapMsg(copyMap, msgText);
                    }
                    msgText = string.Format(Global.GetLang("【{0}】摧毁了敌方箭塔!"), Global.FormatRoleName4(client));
                    GameManager.ClientMgr.BroadSpecialCopyMapMsg(copyMap, msgText);
                }
            }

            // 杀水晶堡垒
            if (null != monsterConfig && monsterConfig.MonsterType == (int)KingOfBattleMonsterType.KingOfBattle_BaoLei)
            {
                KingOfBattleScene scene = null;
                if (SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene))
                {
                    ProcessEnd(scene, client.ClientData.BattleWhichSide, TimeUtil.NOW());
                }
            }

            // 杀Boss
            if (null != monsterConfig && monsterConfig.MonsterType == (int)KingOfBattleMonsterType.KingOfBattle_Boss)
            {
                KingOfBattleScene scene = null;
                if (SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene))
                {
                    string msgText = string.Format(Global.GetLang("【{0}】击杀了BOSS!"), Global.FormatRoleName4(client));
                    GameManager.ClientMgr.BroadSpecialCopyMapMsg(scene.CopyMap, msgText);
                }
            }
        }