Exemplo n.º 1
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);
                    }
                }
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
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);
                }
            }
        }