コード例 #1
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)
            {
                YongZheZhanChangClientContextData contextData = client.SceneContextData2 as YongZheZhanChangClientContextData;
                if (null != contextData)
                {
                    YongZheZhanChangScene scene = null;
                    int addScore = 0;
                    if (monster.HandledDead && monster.WhoKillMeID == client.ClientData.RoleID)
                    {
                        addScore += RuntimeData.WarriorBattleBOssLastAttack;
                    }
#if ___CC___FUCK___YOU___BB___
                    double jiFenInjure = RuntimeData.WarriorBattleBossAttackPercent * monster.XMonsterInfo.MaxHP;
#else
                    double jiFenInjure = RuntimeData.WarriorBattleBossAttackPercent * monster.MonsterInfo.VLifeMax;
#endif
                    contextData.InjureBossDelta += injure;
                    if (contextData.InjureBossDelta >= jiFenInjure && jiFenInjure > 0.0)
                    {
                        // 求出达成的伤害倍数
                        int calcRate = (int)(contextData.InjureBossDelta / jiFenInjure);
                        contextData.InjureBossDelta -= jiFenInjure * calcRate;
                        addScore += RuntimeData.WarriorBattleBossAttackScore * calcRate;
                    }

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

                            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_YONGZHEZHANCHANG_SIDE_SCORE, scene.ScoreData, scene.CopyMap);
                        NotifyTimeStateInfoAndScoreInfo(client, false, false, true);
                    }
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// 玩家离开血色堡垒
 /// </summary>
 public void LeaveFuBen(GameClient client)
 {
     lock (RuntimeData.Mutex)
     {
         YongZheZhanChangScene scene = null;
         if (SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene))
         {
             scene.m_nPlarerCount--;
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// 给奖励
        /// </summary>
        public void GiveAwards(YongZheZhanChangScene scene)
        {
            try
            {
                YongZheZhanChangStatisticalData 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.WarriorBattleLowestJiFen)
                        {
                            Global.SaveRoleParamsStringToDB(client, RoleParamName.YongZheZhanChangAwards, awardsInfo, true);
                        }
                        else
                        {
                            Global.SaveRoleParamsStringToDB(client, RoleParamName.YongZheZhanChangAwards, RuntimeData.RoleParamsAwardsDefaultString, true);
                        }

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

                YongZheZhanChangClient.getInstance().PushGameResultData(gameResultData);
            }
            catch (System.Exception ex)
            {
                DataHelper.WriteExceptionLogEx(ex, "天梯系统清场调度异常");
            }
        }
コード例 #4
0
        private void AddDelayCreateMonster(YongZheZhanChangScene 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
        private void InitCreateDynamicMonster(YongZheZhanChangScene scene)
        {
            lock (RuntimeData.Mutex)
            {
                // 刷水晶怪
                foreach (var crystal in RuntimeData.BattleCrystalMonsterDict.Values)
                {
                    AddDelayCreateMonster(scene, scene.m_lBeginTime, crystal);
                }

                List <BattleDynamicMonsterItem> dynMonsterList = null;
                if (RuntimeData.SceneDynMonsterDict.TryGetValue(scene.m_nMapCode, out dynMonsterList))
                {
                    foreach (var item in dynMonsterList)
                    {
                        AddDelayCreateMonster(scene, scene.m_lBeginTime + item.DelayBirthMs, item);
                    }
                }
            }
        }
コード例 #6
0
        public void CheckCreateDynamicMonster(YongZheZhanChangScene 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 BattleDynamicMonsterItem)
                            {
                                BattleDynamicMonsterItem crystal = obj as BattleDynamicMonsterItem;
                                GameManager.MonsterZoneMgr.AddDynamicMonsters(scene.m_nMapCode, crystal.MonsterID, scene.CopyMapId, 1,
                                                                              crystal.PosX / scene.MapGridWidth, crystal.PosY / scene.MapGridHeight, 0, 0, SceneUIClasses.YongZheZhanChang, crystal);
                            }
                            else if (obj is BattleCrystalMonsterItem)
                            {
                                BattleCrystalMonsterItem item = obj as BattleCrystalMonsterItem;
                                GameManager.MonsterZoneMgr.AddDynamicMonsters(scene.m_nMapCode, item.MonsterID, scene.CopyMap.CopyMapID, 1, item.PosX / scene.MapGridWidth, item.PosY / scene.MapGridHeight, 0, 0, SceneUIClasses.YongZheZhanChang, item);
                            }
                        }
                    }
                    finally
                    {
                        scene.CreateMonsterQueue.RemoveAt(0);
                    }
                }
            }
        }
コード例 #7
0
 public void CompleteScene(YongZheZhanChangScene scene, int successSide)
 {
     scene.SuccessSide = successSide;
 }
コード例 #8
0
        /// <summary>
        /// 添加一个场景
        /// </summary>
        public bool AddCopyScenes(GameClient client, CopyMap copyMap, SceneUIClasses sceneType)
        {
            if (sceneType == SceneUIClasses.YongZheZhanChang)
            {
                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)
                {
                    YongZheZhanChangScene scene = null;
                    if (!SceneDict.TryGetValue(fuBenSeqId, out scene))
                    {
                        YongZheZhanChangSceneInfo 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 YongZheZhanChangScene();
                        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;

                        scene.GameStatisticalData.GameId = gameId;

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

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

                    client.SceneContextData2 = clientContextData;

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

                    // 非首次进来的人会有旧的积分信息需要通知
                    // 改为进入的时候,让客户端来主动查询
                    //NotifyTimeStateInfoAndScoreInfo(client, false, true, true);
                }

                //更新状态
                YongZheZhanChangClient.getInstance().GameFuBenRoleChangeState(roleId, (int)KuaFuRoleStates.StartGame);
                return(true);
            }

            return(false);
        }
コード例 #9
0
 // 刷勇者战场水晶采集物
 private void CreateCrystalMonster(YongZheZhanChangScene scene, BattleCrystalMonsterItem crystal)
 {
     GameManager.MonsterZoneMgr.AddDynamicMonsters(scene.m_nMapCode, crystal.MonsterID, scene.CopyMapId, 1,
                                                   crystal.PosX / scene.MapGridWidth, crystal.PosY / scene.MapGridHeight, 0, 0, SceneUIClasses.YongZheZhanChang, crystal);
 }