Пример #1
0
        private bool GetStartEndTime(int sceneId, out long StartTick, out long EndTick)
        {
            StartTick = 0L;
            EndTick   = 0L;
            ThemeBossScene sceneItem = null;
            DateTime       now       = TimeUtil.NowDateTime();

            lock (ThemeBoss.Mutex)
            {
                if (!this.SceneDict.TryGetValue(sceneId, out sceneItem))
                {
                    return(false);
                }
            }
            lock (ThemeBoss.Mutex)
            {
                for (int i = 0; i < sceneItem.BossConfigInfo.TimePoints.Count - 1; i += 2)
                {
                    if (now.TimeOfDay.TotalSeconds >= sceneItem.BossConfigInfo.SecondsOfDay[i] - 180.0 && now.TimeOfDay.TotalSeconds <= sceneItem.BossConfigInfo.SecondsOfDay[i + 1])
                    {
                        StartTick = now.Date.AddSeconds(sceneItem.BossConfigInfo.SecondsOfDay[i]).Ticks / 10000L;
                        EndTick   = now.Date.AddSeconds(sceneItem.BossConfigInfo.SecondsOfDay[i + 1]).Ticks / 10000L;
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #2
0
 public void OnProcessMonsterDead(GameClient client, Monster monster)
 {
     if (ThemeBoss.getInstance().IsThemeBoss(monster))
     {
         ThemeBossScene scene = null;
         if (this.SceneDict.TryGetValue(monster.CurrentMapCode, out scene))
         {
             int ownerRoleID = monster.GetAttackerFromList();
             if (ownerRoleID >= 0 && ownerRoleID != client.ClientData.RoleID)
             {
                 GameClient findClient = GameManager.ClientMgr.FindClient(ownerRoleID);
                 if (null != findClient)
                 {
                     client = findClient;
                 }
             }
             string broadMsg = string.Format(GLang.GetLang(4016, new object[0]), Global.FormatRoleNameWithZoneId2(client));
             Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.HintMsg, broadMsg, true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.HintAndBox, 0, 0, 100, 100);
             scene.AliveBossNum--;
             if (scene.AliveBossNum <= 0)
             {
                 scene.State = BattleStates.EndFight;
             }
         }
     }
 }
Пример #3
0
        private void GenerateThemeBossScene()
        {
            int curDayID = TimeUtil.GetOffsetDay(TimeUtil.NowDateTime());

            if (curDayID != this.SceneDayID)
            {
                this.SceneDict.Clear();
                string strcmd = StringUtil.substitute("{0}:{1}:{2}", new object[]
                {
                    0,
                    5,
                    100
                });
                PaiHangData paiHangData = Global.sendToDB <PaiHangData, string>(269, strcmd, 0);
                if (null != paiHangData)
                {
                    long NumOne = 0L;
                    long NumTwo = 0L;
                    List <PaiHangItemData> PaiHangList = paiHangData.PaiHangList;
                    if (null != PaiHangList)
                    {
                        int DivCalNum = Math.Min(PaiHangList.Count, 100);
                        for (int i = 0; i < DivCalNum; i++)
                        {
                            PaiHangItemData phData = PaiHangList[i];
                            NumOne += (long)phData.Val1;
                            NumTwo += (long)phData.Val2;
                        }
                        int TransNum = Global.GetUnionLevel2((int)NumTwo, (int)NumOne) / DivCalNum;
                        NumOne = (long)((TransNum - 1) / 100);
                        NumTwo = (long)((TransNum - 1) % 100 + 1);
                    }
                    int curAvgLev = Global.GetUnionLevel2((int)NumTwo, (int)NumOne);
                    foreach (ThemeBossConfig config in this.ThemeBossConfigDict.Values)
                    {
                        if (curAvgLev <= config.MaxUnionLevel)
                        {
                            ThemeBossScene scene = null;
                            if (!this.SceneDict.TryGetValue(config.MapCode, out scene))
                            {
                                scene                          = new ThemeBossScene();
                                scene.MapCode                  = config.MapCode;
                                scene.BossConfigInfo           = config;
                                scene.State                    = BattleStates.NoBattle;
                                this.SceneDict[config.MapCode] = scene;
                            }
                            if (scene.BossConfigInfo.MaxUnionLevel > config.MaxUnionLevel)
                            {
                                scene.BossConfigInfo = config;
                            }
                        }
                    }
                    this.SceneDayID = curDayID;
                }
            }
        }
Пример #4
0
 public bool JudgeCanTriggerActivity(ThemeBossScene scene, DateTime now)
 {
     lock (ThemeBoss.Mutex)
     {
         for (int i = 0; i < scene.BossConfigInfo.TimePoints.Count - 1; i += 2)
         {
             if (now.TimeOfDay.TotalSeconds >= scene.BossConfigInfo.SecondsOfDay[i] - 180.0 && now.TimeOfDay.TotalSeconds <= scene.BossConfigInfo.SecondsOfDay[i])
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #5
0
        public bool IsThemeBoss(Monster monster)
        {
            bool result;

            if (401 != monster.MonsterType)
            {
                result = false;
            }
            else
            {
                ThemeBossScene scene = null;
                result = (this.SceneDict.TryGetValue(monster.CurrentMapCode, out scene) && scene.BossConfigInfo.MonstersID == monster.MonsterInfo.ExtensionID);
            }
            return(result);
        }
Пример #6
0
 public bool ProcessThemeBossStateCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         int roleID    = Global.SafeConvertToInt32(cmdParams[0]);
         int actId     = 0;
         int bossState = 0;
         if (this.SceneDict.Count != 0)
         {
             ThemeBossScene scene = this.SceneDict.FirstOrDefault <KeyValuePair <int, ThemeBossScene> >().Value;
             if (scene.State == BattleStates.StartFight)
             {
                 if (scene.AliveBossNum > 0)
                 {
                     bossState = 1;
                 }
                 else
                 {
                     bossState = 2;
                 }
             }
             else
             {
                 bossState = 0;
             }
             actId = scene.BossConfigInfo.ID;
         }
         client.sendCmd(nID, string.Format("{0}:{1}", actId, bossState), false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(true);
 }