コード例 #1
0
        public void NotifyTimeStateInfoAndScoreInfo(GameClient client, bool timeState = true, bool sideScore = true, bool selfScore = true)
        {
            lock (RuntimeData.Mutex)
            {
                YongZheZhanChangScene scene;
                if (SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene))
                {
                    if (timeState)
                    {
                        client.sendCmd((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData);
                    }

                    if (sideScore)
                    {
                        client.sendCmd((int)TCPGameServerCmds.CMD_SPR_YONGZHEZHANCHANG_SIDE_SCORE, scene.ScoreData);
                    }

                    if (selfScore)
                    {
                        YongZheZhanChangClientContextData clientContextData = client.SceneContextData2 as YongZheZhanChangClientContextData;
                        if (null != clientContextData)
                        {
                            client.sendCmd((int)TCPGameServerCmds.CMD_SPR_YONGZHEZHANCHANG_SELF_SCORE, clientContextData.TotalScore);
                        }
                    }
                }
            }
        }
コード例 #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)
            {
                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);
                    }
                }
            }
        }
コード例 #3
0
        public void OnCaiJiFinish(GameClient client, Monster monster)
        {
            YongZheZhanChangScene    scene;
            BattleCrystalMonsterItem monsterItem;
            int addScore = 0;

            lock (RuntimeData.Mutex)
            {
                if (!SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene))
                {
                    return;
                }

                if (scene.m_eStatus != GameSceneStatuses.STATUS_BEGIN)
                {
                    return;
                }

                monsterItem = monster.Tag as BattleCrystalMonsterItem;
                if (monsterItem == null)
                {
                    return;
                }

                /*
                 * if (!RuntimeData.BattleCrystalMonsterDict.TryGetValue(monster.MonsterInfo.ExtensionID, out monsterItem))
                 * {
                 *  return;
                 * }*/

                YongZheZhanChangClientContextData contextData = client.SceneContextData2 as YongZheZhanChangClientContextData;
                if (null != contextData)
                {
                    addScore = monsterItem.BattleJiFen;
                    contextData.TotalScore += addScore;
                    scene.GameStatisticalData.CaiJiScore += addScore;
                    if (client.ClientData.BattleWhichSide == 1)
                    {
                        scene.ScoreData.Score1 += addScore;
                    }
                    else if (client.ClientData.BattleWhichSide == 2)
                    {
                        scene.ScoreData.Score2 += addScore;
                    }
                }

                AddDelayCreateMonster(scene, TimeUtil.NOW() + monsterItem.FuHuoTime, monsterItem);
            }

            if (addScore > 0)
            {
                GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_YONGZHEZHANCHANG_SIDE_SCORE, scene.ScoreData, scene.CopyMap);
                NotifyTimeStateInfoAndScoreInfo(client, false, false, true);
            }
        }
コード例 #4
0
        public void OnKillRole(GameClient client, GameClient other)
        {
            lock (RuntimeData.Mutex)
            {
                YongZheZhanChangScene scene;
                if (SceneDict.TryGetValue(client.ClientData.FuBenSeqID, out scene))
                {
                    if (scene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                    {
                        int addScore    = 0;
                        int addScoreDie = RuntimeData.WarriorBattleDie;
                        YongZheZhanChangClientContextData clientLianShaContextData  = client.SceneContextData2 as YongZheZhanChangClientContextData;
                        YongZheZhanChangClientContextData otherLianShaContextData   = other.SceneContextData2 as YongZheZhanChangClientContextData;
                        HuanYingSiYuanLianSha             huanYingSiYuanLianSha     = null;
                        HuanYingSiYuanLianshaOver         huanYingSiYuanLianshaOver = null;
                        HuanYingSiYuanAddScore            huanYingSiYuanAddScore    = new HuanYingSiYuanAddScore();

                        huanYingSiYuanAddScore.Name         = Global.FormatRoleName4(client);
                        huanYingSiYuanAddScore.ZoneID       = client.ClientData.ZoneID;
                        huanYingSiYuanAddScore.Side         = client.ClientData.BattleWhichSide;
                        huanYingSiYuanAddScore.ByLianShaNum = 1;
                        huanYingSiYuanAddScore.RoleId       = client.ClientData.RoleID;
                        huanYingSiYuanAddScore.Occupation   = client.ClientData.Occupation;

                        //addScore += RuntimeData.WarriorBattlePk; //
                        scene.GameStatisticalData.KillScore += RuntimeData.WarriorBattleUltraKillParam1;
                        if (null != clientLianShaContextData)
                        {
                            clientLianShaContextData.KillNum++;
                            int lianShaScore = RuntimeData.WarriorBattleUltraKillParam1 + clientLianShaContextData.KillNum * RuntimeData.WarriorBattleUltraKillParam2;
                            lianShaScore = Math.Min(RuntimeData.WarriorBattleUltraKillParam4, Math.Max(RuntimeData.WarriorBattleUltraKillParam3, lianShaScore));

                            huanYingSiYuanAddScore.ByLianShaNum = 1;
                            huanYingSiYuanLianSha            = new HuanYingSiYuanLianSha();
                            huanYingSiYuanLianSha.Name       = huanYingSiYuanAddScore.Name;
                            huanYingSiYuanLianSha.ZoneID     = huanYingSiYuanAddScore.ZoneID;
                            huanYingSiYuanLianSha.Occupation = huanYingSiYuanAddScore.Occupation;
                            // 每杀5人,连杀公告就更暴力,所以除以5,计算属于哪个连杀类型,最大为30 / 5
                            huanYingSiYuanLianSha.LianShaType = Math.Min(clientLianShaContextData.KillNum, 30) / 5;
                            huanYingSiYuanLianSha.ExtScore    = lianShaScore;
                            huanYingSiYuanLianSha.Side        = huanYingSiYuanAddScore.Side;
                            addScore += lianShaScore;
                            scene.GameStatisticalData.LianShaScore += lianShaScore;

                            //只在连杀数为5的倍数时推送消息
                            if ((clientLianShaContextData.KillNum % 5) != 0)
                            {
                                huanYingSiYuanLianSha = null;
                            }
                        }

                        if (null != otherLianShaContextData)
                        {
                            int overScore = RuntimeData.WarriorBattleShutDownParam1 + otherLianShaContextData.KillNum * RuntimeData.WarriorBattleShutDownParam2;
                            overScore = Math.Min(RuntimeData.WarriorBattleShutDownParam4, Math.Max(RuntimeData.WarriorBattleShutDownParam3, overScore));
                            addScore += overScore;
                            scene.GameStatisticalData.ZhongJieScore += overScore;
                            if (otherLianShaContextData.KillNum >= 10)
                            {
                                huanYingSiYuanLianshaOver                  = new HuanYingSiYuanLianshaOver();
                                huanYingSiYuanLianshaOver.KillerName       = huanYingSiYuanAddScore.Name;
                                huanYingSiYuanLianshaOver.KillerZoneID     = huanYingSiYuanAddScore.ZoneID;
                                huanYingSiYuanLianshaOver.KillerOccupation = client.ClientData.Occupation;
                                huanYingSiYuanLianshaOver.KillerSide       = huanYingSiYuanAddScore.Side;
                                huanYingSiYuanLianshaOver.KilledName       = Global.FormatRoleName4(other);
                                huanYingSiYuanLianshaOver.KilledZoneID     = other.ClientData.ZoneID;
                                huanYingSiYuanLianshaOver.KilledOccupation = other.ClientData.Occupation;
                                huanYingSiYuanLianshaOver.KilledSide       = other.ClientData.BattleWhichSide;
                                huanYingSiYuanLianshaOver.ExtScore         = overScore;
                            }

                            otherLianShaContextData.KillNum      = 0;
                            otherLianShaContextData.TotalScore  += addScoreDie;
                            scene.GameStatisticalData.KillScore += addScoreDie;
                        }

                        huanYingSiYuanAddScore.Score = addScore;
                        if (client.ClientData.BattleWhichSide == 1)
                        {
                            scene.ScoreData.Score1 += addScore;
                            scene.ScoreData.Score2 += addScoreDie;
                        }
                        else
                        {
                            scene.ScoreData.Score2 += addScore;
                            scene.ScoreData.Score1 += addScoreDie;
                        }

                        if (null != clientLianShaContextData)
                        {
                            clientLianShaContextData.TotalScore += addScore;
                        }

                        //GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_HYSY_ADD_SCORE, huanYingSiYuanAddScore, huanYingSiYuanScene.CopyMap);
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_YONGZHEZHANCHANG_SIDE_SCORE, scene.ScoreData, scene.CopyMap);
                        if (null != huanYingSiYuanLianSha)
                        {
                            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_YONGZHEZHANCHANG_LIANSHA, huanYingSiYuanLianSha, scene.CopyMap);
                        }

                        if (null != huanYingSiYuanLianshaOver)
                        {
                            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_YONGZHEZHANCHANG_STOP_LIANSHA, huanYingSiYuanLianshaOver, scene.CopyMap);
                        }

                        NotifyTimeStateInfoAndScoreInfo(client, false, false, true);
                        NotifyTimeStateInfoAndScoreInfo(other, false, false, true);
                    }
                }
            }
        }
コード例 #5
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);
        }