示例#1
0
        /// <summary>
        // 心跳处理
        /// </summary>
        public void HeartBeatAngelTempleScene()
        {
            long ticks = TimeUtil.NOW();

            AngelTempleStatus newStatus;

            if (ChangeToNextStatus(out newStatus))
            {
                switch (newStatus)
                {
                case AngelTempleStatus.FIGHT_STATUS_PREPARE:
                {
                    //不需要做什么
                    Global.AddFlushIconStateForAll((ushort)ActivityTipTypes.AngelTemple, true);
                }
                break;

                case AngelTempleStatus.FIGHT_STATUS_BEGIN:
                {
                    lock (m_AngelTempleScene)
                    {
                        bBossKilled = false;
                        m_AngelTempleScene.m_bEndFlag = 0;
                    }

                    // 战斗结束倒计时
                    SendTimeInfoToAll(ticks);

                    // 把天使BOSS刷出来
                    int monsterID = m_AngelTempleData.BossID;

                    GameMap gameMap = null;
                    if (!GameManager.MapMgr.DictMaps.TryGetValue(m_AngelTempleData.MapCode, out gameMap))
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("天使神殿报错 地图配置 ID = {0}", m_AngelTempleData.MapCode));
                        return;
                    }

                    int gridX = gameMap.CorrectWidthPointToGridPoint(m_AngelTempleData.BossPosX) / gameMap.MapGridWidth;
                    int gridY = gameMap.CorrectHeightPointToGridPoint(m_AngelTempleData.BossPosY) / gameMap.MapGridHeight;
                    AngelTempleMonsterUpgradePercent = Global.SafeConvertToDouble(GameManager.GameConfigMgr.GetGameConifgItem(GameConfigNames.AngelTempleMonsterUpgradeNumber));
                    GameManager.MonsterZoneMgr.AddDynamicMonsters(m_AngelTempleData.MapCode, monsterID, -1, 1, gridX, gridY, 1);
                }
                break;

                case AngelTempleStatus.FIGHT_STATUS_END:
                {
                    Global.AddFlushIconStateForAll((ushort)ActivityTipTypes.AngelTemple, false);

                    // 清场倒计时
                    SendTimeInfoToAll(ticks);

                    // 如果BOSS没死 KILL掉
                    if (!bBossKilled && m_AngelTempleBoss != null)
                    {
                        //BOSS未被击杀,下次比例=本次血量*(总伤害/总血量)*80%,下限=当前比例/10
                        MonsterData md     = m_AngelTempleBoss.GetMonsterData();
                        double      damage = 0;
                        if (md.MaxLifeV != md.LifeV)
                        {
                            damage = Global.Clamp(md.MaxLifeV - md.LifeV, md.MaxLifeV / 10, md.MaxLifeV);
                            AngelTempleMonsterUpgradePercent *= damage * 0.8 / md.MaxLifeV;
                            Global.UpdateDBGameConfigg(GameConfigNames.AngelTempleMonsterUpgradeNumber, AngelTempleMonsterUpgradePercent.ToString("0.00"));
                        }

                        GameManager.MonsterMgr.AddDelayDeadMonster(m_AngelTempleBoss);
                        GameManager.ClientMgr.NotifyAngelTempleMsgBossDisappear(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, m_AngelTempleData.MapCode);
                        LogManager.WriteLog(LogTypes.SQL, string.Format("天使神殿Boss未死亡,血量减少百分比{0:P} ,Boss生命值比例成长为{1}", damage / md.MaxLifeV, AngelTempleMonsterUpgradePercent));
                        m_AngelTempleBoss = null;
                    }

                    // 天使神殿结束战斗,如果杀死了Boss,客户端显示奖励界面(倒计时界面)
                    GiveAwardAngelTempleScene(bBossKilled);
                }
                break;

                case AngelTempleStatus.FIGHT_STATUS_NULL:
                {
                    // 清场
                    List <Object> objsList = GameManager.ClientMgr.GetMapClients(m_AngelTempleData.MapCode);
                    if (objsList != null)
                    {
                        for (int n = 0; n < objsList.Count; ++n)
                        {
                            GameClient c = objsList[n] as GameClient;
                            if (c == null)
                            {
                                continue;
                            }

                            if (c.ClientData.MapCode != m_AngelTempleData.MapCode)
                            {
                                continue;
                            }

                            // 根据公式和积分奖励经验
                            //GiveAwardAngelTempleScene(c);

                            // 退出场景
                            int toMapCode = GameManager.MainMapCode;            //主城ID 防止意外
                            int toPosX    = -1;
                            int toPosY    = -1;
                            if (MapTypes.Normal == Global.GetMapType(c.ClientData.LastMapCode))
                            {
                                if (GameManager.BattleMgr.BattleMapCode != c.ClientData.LastMapCode || GameManager.ArenaBattleMgr.BattleMapCode != c.ClientData.LastMapCode)
                                {
                                    toMapCode = c.ClientData.LastMapCode;
                                    toPosX    = c.ClientData.LastPosX;
                                    toPosY    = c.ClientData.LastPosY;
                                }
                            }

                            GameMap gameMap = null;
                            if (GameManager.MapMgr.DictMaps.TryGetValue(toMapCode, out gameMap))
                            {
                                c.ClientData.bIsInAngelTempleMap = false;
                                GameManager.ClientMgr.NotifyChangeMap(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, c, toMapCode, toPosX, toPosY, -1);
                            }
                        }
                    }

                    CleanUpAngelTempleScene();
                    if (ticks >= (m_AngelTempleScene.m_lEndTime + (m_AngelTempleData.LeaveTime * 20000)))
                    {
                        m_AngelTempleScene.m_eStatus = AngelTempleStatus.FIGHT_STATUS_NULL;
                    }
                }
                break;
                }
            }
            if (newStatus == AngelTempleStatus.FIGHT_STATUS_BEGIN)
            {
                //如果需要在这期间进行一些定时操作,写在这里
            }
        }
        public void HeartBeatAngelTempleScene()
        {
            long ticks = TimeUtil.NOW();
            AngelTempleStatus newStatus;

            if (this.ChangeToNextStatus(out newStatus))
            {
                switch (newStatus)
                {
                case AngelTempleStatus.FIGHT_STATUS_NULL:
                {
                    List <object> objsList = GameManager.ClientMgr.GetMapClients(this.m_AngelTempleData.MapCode);
                    if (objsList != null)
                    {
                        for (int i = 0; i < objsList.Count; i++)
                        {
                            GameClient c = objsList[i] as GameClient;
                            if (c != null)
                            {
                                if (c.ClientData.MapCode == this.m_AngelTempleData.MapCode)
                                {
                                    int toMapCode = GameManager.MainMapCode;
                                    int toPosX    = -1;
                                    int toPosY    = -1;
                                    if (MapTypes.Normal == Global.GetMapType(c.ClientData.LastMapCode))
                                    {
                                        if (GameManager.BattleMgr.BattleMapCode != c.ClientData.LastMapCode || GameManager.ArenaBattleMgr.BattleMapCode != c.ClientData.LastMapCode)
                                        {
                                            toMapCode = c.ClientData.LastMapCode;
                                            toPosX    = c.ClientData.LastPosX;
                                            toPosY    = c.ClientData.LastPosY;
                                        }
                                    }
                                    GameMap gameMap = null;
                                    if (GameManager.MapMgr.DictMaps.TryGetValue(toMapCode, out gameMap))
                                    {
                                        c.ClientData.bIsInAngelTempleMap = false;
                                        GameManager.ClientMgr.NotifyChangeMap(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, c, toMapCode, toPosX, toPosY, -1, 0);
                                    }
                                }
                            }
                        }
                    }
                    this.CleanUpAngelTempleScene();
                    if (ticks >= this.m_AngelTempleScene.m_lEndTime + (long)(this.m_AngelTempleData.LeaveTime * 20000))
                    {
                        this.m_AngelTempleScene.m_eStatus = AngelTempleStatus.FIGHT_STATUS_NULL;
                    }
                    break;
                }

                case AngelTempleStatus.FIGHT_STATUS_PREPARE:
                    Global.AddFlushIconStateForAll(1007, true);
                    break;

                case AngelTempleStatus.FIGHT_STATUS_BEGIN:
                {
                    lock (this.m_AngelTempleScene)
                    {
                        this.bBossKilled = false;
                        this.m_AngelTempleScene.m_bEndFlag = 0;
                    }
                    this.SendTimeInfoToAll(ticks);
                    int     monsterID = this.m_AngelTempleData.BossID;
                    GameMap gameMap   = null;
                    if (!GameManager.MapMgr.DictMaps.TryGetValue(this.m_AngelTempleData.MapCode, out gameMap))
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("天使神殿报错 地图配置 ID = {0}", this.m_AngelTempleData.MapCode), null, true);
                        return;
                    }
                    int gridX = gameMap.CorrectWidthPointToGridPoint(this.m_AngelTempleData.BossPosX) / gameMap.MapGridWidth;
                    int gridY = gameMap.CorrectHeightPointToGridPoint(this.m_AngelTempleData.BossPosY) / gameMap.MapGridHeight;
                    this.AngelTempleMonsterUpgradePercent = Global.SafeConvertToDouble(GameManager.GameConfigMgr.GetGameConifgItem("AngelTempleMonsterUpgradeNumber"));
                    GameManager.MonsterZoneMgr.AddDynamicMonsters(this.m_AngelTempleData.MapCode, monsterID, -1, 1, gridX, gridY, 1, 0, SceneUIClasses.Normal, null, null);
                    break;
                }

                case AngelTempleStatus.FIGHT_STATUS_END:
                    Global.AddFlushIconStateForAll(1007, false);
                    this.SendTimeInfoToAll(ticks);
                    if (!this.bBossKilled && this.m_AngelTempleBoss != null)
                    {
                        MonsterData md     = this.m_AngelTempleBoss.GetMonsterData();
                        double      damage = 0.0;
                        if (md.MaxLifeV != md.LifeV)
                        {
                            damage = Global.Clamp(md.MaxLifeV - md.LifeV, md.MaxLifeV / 10.0, md.MaxLifeV);
                            this.AngelTempleMonsterUpgradePercent *= damage * 0.8 / md.MaxLifeV;
                            Global.UpdateDBGameConfigg("AngelTempleMonsterUpgradeNumber", this.AngelTempleMonsterUpgradePercent.ToString("0.00"));
                        }
                        GameManager.MonsterMgr.AddDelayDeadMonster(this.m_AngelTempleBoss);
                        GameManager.ClientMgr.NotifyAngelTempleMsgBossDisappear(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, this.m_AngelTempleData.MapCode);
                        LogManager.WriteLog(LogTypes.SQL, string.Format("天使神殿Boss未死亡,血量减少百分比{0:P} ,Boss生命值比例成长为{1}", damage / md.MaxLifeV, this.AngelTempleMonsterUpgradePercent), null, true);
                        this.m_AngelTempleBoss = null;
                    }
                    this.GiveAwardAngelTempleScene(this.bBossKilled);
                    break;
                }
            }
            if (newStatus == AngelTempleStatus.FIGHT_STATUS_BEGIN)
            {
            }
        }