Exemplo n.º 1
0
        public void BossNext(WorldBoss _this)
        {
            ResetData(_this);

            _this.State = eActivityState.WaitNext;
            NotifyActivityState(_this);
        }
Exemplo n.º 2
0
        private IEnumerator SetDbBossLevelCoroutine(Coroutine co, WorldBoss _this)
        {
            var data = new DBInt();

            data.Value = _this.BossLevel;
            var dbBossLevel = ActivityServer.Instance.DB.Set(co, DataCategory.SceneWorldBoss, DbKey + _this.ServerId,
                                                             data);

            yield return(dbBossLevel);

            if (dbBossLevel.Status != DataStatus.Ok)
            {
                Logger.Fatal("SetDbBossLevel set data to db faild!");
                yield return(ActivityServer.Instance.ServerControl.Wait(co, TimeSpan.FromMilliseconds(100)));

                if (++_this.SetDbFailCounter < 3)
                {
                    SetDbBossLevel(_this);
                }
                else
                {
                    _this.SetDbFailCounter = 0;
                }
            }
        }
Exemplo n.º 3
0
 private void PrintDamageList(WorldBoss _this)
 {
     Logger.Info("Boss Level = {0}", _this.BossLevel);
     for (int i = 0, imax = _this.DamageList.Count; i < imax; i++)
     {
         var unit = _this.DamageList[i];
         Logger.Info("No.{0}, player id = {1}, name = {2}, damage = {3}", i + 1, unit.CharacterId, unit.Name,
                     unit.Damage);
     }
 }
Exemplo n.º 4
0
        private void ResetData(WorldBoss _this)
        {
            _this.mBossAlive    = true;
            _this.TotalDamage   = 0;
            _this.ServerPlayers = new Dictionary <ulong, List <ulong> >();
            _this.PlayerDamages = new Dictionary <ulong, DamageUnit>();
            _this.DamageList    = new List <DamageUnit>();

            _this.mBossNpcId = 90000 + _this.BossLevel;
            var tbCharBase = Table.GetCharacterBase(_this.mBossNpcId);

            _this.BossMaxHp = tbCharBase.Attr[13];
        }
Exemplo n.º 5
0
        public void BossStop(WorldBoss _this)
        {
            if (!_this.mBossAlive)
            {
                return;
            }

            PrintDamageList(_this);

            _this.State      = eActivityState.WillEnd;
            _this.mBossAlive = false;
            SetBossLevel(_this, _this.BossLevel - 1);
            SendFirstPlayerNotify(_this);
        }
Exemplo n.º 6
0
        public void SetBossLevel(WorldBoss _this, int level)
        {
            if (_this.BossLevel == level)
            {
                return;
            }
            var newLevel = level;

            newLevel = Math.Min(29, newLevel);
            newLevel = Math.Max(0, newLevel);
            if (_this.BossLevel == newLevel)
            {
                return;
            }
            _this.BossLevel = newLevel;
            SetDbBossLevel(_this);
        }
Exemplo n.º 7
0
        private DamageListForServer GetServerDamageList(WorldBoss _this, List <ulong> players, ulong lastPlayer = 0)
        {
            var ret        = new DamageListForServer();
            var retData    = ret.Data;
            var topPlayers = ret.TopPlayers;

            for (int i = 0, imax = _this.DamageList.Count > 5 ? 5 : _this.DamageList.Count; i < imax; ++i)
            {
                topPlayers.Add(_this.DamageList[i]);
            }
            foreach (var playerId in players)
            {
                retData.Add(_this.PlayerDamages[playerId]);
            }
            retData.Sort(_this.DuComparer);
            ret.TotalDamage = _this.TotalDamage;
            ret.LastPlayer  = lastPlayer;
            return(ret);
        }
Exemplo n.º 8
0
        //发公告,谁谁是第一名
        private void SendFirstPlayerNotify(WorldBoss _this)
        {
            var damageList = _this.DamageList;

            if (damageList.Count == 0)
            {
                return;
            }
            var args = new List <string>();

            args.Add(Utils.AddCharacter(damageList[0].CharacterId, damageList[0].Name));
            var content = Utils.WrapDictionaryId(215003, args);

            ActivityServer.Instance.ChatAgent.BroadcastWorldMessage((uint)_this.ServerId,
                                                                    (int)eChatChannel.SystemScroll, 0,
                                                                    string.Empty, new ChatMessageContent {
                Content = content
            });
        }
Exemplo n.º 9
0
        private void OnBossDie(WorldBoss _this)
        {
            PrintDamageList(_this);

            _this.State      = eActivityState.WillEnd;
            _this.mBossAlive = false;

            var trigger = WorldBossManager.StartTrigger as Trigger;
            var nowTime = DateTime.Now;
            var dueTime = trigger.Time;
            var restSec = (nowTime - dueTime).TotalMinutes;

            if (restSec <= 7)
            {//七分钟内完成boss级别+1
                SetBossLevel(_this, _this.BossLevel + 1);
            }

            NotifyActivityState(_this);
            SendFirstPlayerNotify(_this);
        }
Exemplo n.º 10
0
        private IEnumerator GetDbBossLevelCoroutine(Coroutine co, WorldBoss _this)
        {
            var dbBossLevel = ActivityServer.Instance.DB.Get <DBInt>(co, DataCategory.SceneWorldBoss,
                                                                     DbKey + _this.ServerId);

            yield return(dbBossLevel);

            if (dbBossLevel.Status != DataStatus.Ok)
            {
                Logger.Fatal("GetDbBossLevel get data from db faild!");
                yield break;
            }
            if (dbBossLevel.Data != null)
            {
                SetBossLevel(_this, dbBossLevel.Data.Value);
            }
            else
            {
                SetBossLevel(_this, 0);
            }
            ResetData(_this);
        }
Exemplo n.º 11
0
 public void Construct(WorldBoss _this, int serverId, eActivityState state)
 {
     _this.ServerId = serverId;
     _this.State    = state;
     GetDbBossLevel(_this);
 }
Exemplo n.º 12
0
 //通知全服,boss挂了,活动已经结束了
 private void NotifyActivityState(WorldBoss _this)
 {
     ActivityServer.Instance.ServerControl.NotifyActivityState((uint)_this.ServerId, (int)eActivity.WorldBoss,
                                                               (int)_this.State);
 }
Exemplo n.º 13
0
 public void BossWillStart(WorldBoss _this)
 {
     _this.State = eActivityState.WillStart;
 }
Exemplo n.º 14
0
 private void NotifyBossDie(WorldBoss _this)
 {
     CoroutineFactory.NewCoroutine(NotifyBossDieCoroutine, _this).MoveNext();
 }
Exemplo n.º 15
0
 public void BossStart(WorldBoss _this)
 {
     _this.State      = eActivityState.Start;
     _this.mBossAlive = true;
     Logger.Info("BossStart,Level = {0}", _this.BossLevel);
 }
Exemplo n.º 16
0
 private void SetDbBossLevel(WorldBoss _this)
 {
     CoroutineFactory.NewCoroutine(SetDbBossLevelCoroutine, _this).MoveNext();
 }
Exemplo n.º 17
0
        private IEnumerator NotifyBossDieCoroutine(Coroutine co, WorldBoss _this)
        {
            var msg = ActivityServer.Instance.SceneAgent.BossDie((uint)_this.ServerId, _this.ServerId);

            yield return(msg.SendAndWaitUntilDone(co));
        }
Exemplo n.º 18
0
        public DamageListForServer ApplyDamage(WorldBoss _this, ulong sceneGuid, DamageList damage)
        {
            //本服玩家 guids
            List <ulong> players;

            if (!_this.ServerPlayers.TryGetValue(sceneGuid, out players))
            {
                players = new List <ulong>();
                _this.ServerPlayers.Add(sceneGuid, players);
            }
            //如果boss已经死了,或者时间已经结束,不再计算伤害,直接返回该服务器对应的DamageList
            if (!_this.mBossAlive)
            {
                return(GetServerDamageList(_this, players));
            }


            var restMin = 0;

            {
                var trigger = WorldBossManager.StopTrigger as Trigger;
                var nowTime = DateTime.Now;
                var dueTime = trigger.Time;
                restMin = (int)(dueTime - nowTime).Minutes;
            }


            //boss没死,计算伤害
            //最后一击的player id
            ulong lastPlayerId = 0;
            var   damageDatas  = damage.Data;

            foreach (var damageUnit in damageDatas)
            {
                var charId    = damageUnit.CharacterId;
                var maxDamage = _this.BossMaxHp - _this.TotalDamage;
                damageUnit.Damage = Math.Min(maxDamage, damageUnit.Damage);
                DamageUnit playerDamage;
                if (_this.PlayerDamages.TryGetValue(charId, out playerDamage))
                {
                    playerDamage.Damage += damageUnit.Damage;
                }
                else
                {
                    players.Add(charId);
                    _this.PlayerDamages.Add(charId, damageUnit);
                    _this.DamageList.Add(damageUnit);
                }
                _this.TotalDamage += damageUnit.Damage;
                if (_this.TotalDamage > _this.BossMaxHp * 0.7)
                {//世界Boss血回复
                    if (restMin >= 5 && restMin <= 7)
                    {
                        _this.TotalDamage -= (int)(_this.BossMaxHp * 0.3);
                    }
                    else if (restMin >= 7 && restMin <= 9)
                    {
                        _this.TotalDamage -= (int)(_this.BossMaxHp * 0.5);
                    }
                    else if (restMin > 9)
                    {
                        _this.TotalDamage -= (int)(_this.BossMaxHp * 0.7);
                    }
                }
                if (_this.TotalDamage >= _this.BossMaxHp)
                {
                    _this.TotalDamage = _this.BossMaxHp;
                    lastPlayerId      = damageUnit.CharacterId;
                    //通知所有Scene服务器,世界boss已经死了
                    NotifyBossDie(_this);
                    OnBossDie(_this);
                    break;
                }
            }
            //排序并赋予名次
            _this.DamageList.Sort(_this.DuComparer);
            var idx = 1;

            foreach (var unit in _this.DamageList)
            {
                unit.Rank = idx++;
            }
            return(GetServerDamageList(_this, players, lastPlayerId));
        }