Ejemplo n.º 1
0
        private void SubmitShengBei(GameClient client)
        {
            if (null == client.SceneContextData)
            {
                return;
            }

            HuanYingSiYuanShengBeiContextData contextData = client.SceneContextData as HuanYingSiYuanShengBeiContextData;

            if (null == contextData)
            {
                return;
            }

            //为了放止外挂加速移动导致游戏不平衡并影响产出量,这里限制提交时间不能少于13秒(正常采集后提交大约需要15秒)
            long nowTicks = TimeUtil.NOW();

            if (contextData.EndTicks - nowTicks > (RuntimeData.HoldShengBeiSecs - RuntimeData.MinSubmitShengBeiSecs) * TimeUtil.SECOND)
            {
                return;
            }

            Point clientPoint = new Point(client.ClientData.PosX, client.ClientData.PosY);

            lock (RuntimeData.Mutex)
            {
                HuanYingSiYuanBirthPoint huanYingSiYuanBirthPoint;
                if (!RuntimeData.MapBirthPointDict.TryGetValue(client.ClientData.BattleWhichSide, out huanYingSiYuanBirthPoint))
                {
                    return;
                }

                Point targetPoint = new Point(huanYingSiYuanBirthPoint.PosX, huanYingSiYuanBirthPoint.PosY);
                if (Global.GetTwoPointDistance(clientPoint, targetPoint) > 1000)
                {
                    return;
                }
            }

            CopyMap copyMap = null;

            lock (Mutex)
            {
                HuanYingSiYuanScene huanYingSiYuanScene;
                if (HuanYingSiYuanSceneDict.TryGetValue(client.ClientData.FuBenSeqID, out huanYingSiYuanScene) && huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                {
                    if (huanYingSiYuanScene.ShengBeiContextDict.Remove(contextData.UniqueId))
                    {
                        LostShengBei(client);
                        CreateMonster(huanYingSiYuanScene, contextData);
                        contextData.OwnerRoleId = 0;

                        if (client.ClientData.BattleWhichSide == 1)
                        {
                            huanYingSiYuanScene.ScoreInfoData.Score1 += contextData.Score;
                            if (huanYingSiYuanScene.ScoreInfoData.Score1 >= RuntimeData.TempleMirageWin)
                            {
                                CompleteHuanYingSiYuanScene(huanYingSiYuanScene, 1);
                            }
                        }
                        else
                        {
                            huanYingSiYuanScene.ScoreInfoData.Score2 += contextData.Score;
                            if (huanYingSiYuanScene.ScoreInfoData.Score2 >= RuntimeData.TempleMirageWin)
                            {
                                CompleteHuanYingSiYuanScene(huanYingSiYuanScene, 2);
                            }
                        }

                        HuanYingSiYuanLianShaContextData clientLianShaContextData = client.SceneContextData2 as HuanYingSiYuanLianShaContextData;
                        if (null != clientLianShaContextData)
                        {
                            clientLianShaContextData.TotalScore += contextData.Score;
                        }

                        HuanYingSiYuanAddScore huanYingSiYuanAddScore = new HuanYingSiYuanAddScore();
                        huanYingSiYuanAddScore.Name       = Global.FormatRoleName4(client);
                        huanYingSiYuanAddScore.ZoneID     = client.ClientData.ZoneID;
                        huanYingSiYuanAddScore.Side       = client.ClientData.BattleWhichSide;
                        huanYingSiYuanAddScore.Score      = contextData.Score;
                        huanYingSiYuanAddScore.RoleId     = client.ClientData.RoleID;
                        huanYingSiYuanAddScore.Occupation = client.ClientData.Occupation;
                        copyMap = huanYingSiYuanScene.CopyMap;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_HYSY_ADD_SCORE, huanYingSiYuanAddScore, copyMap);
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_HYSY_SCORE_INFO, huanYingSiYuanScene.ScoreInfoData, copyMap);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 给奖励
        /// </summary>
        public void GiveAwards(HuanYingSiYuanScene huanYingSiYuanScene)
        {
            try
            {
                List <GameClient> objsList = huanYingSiYuanScene.CopyMap.GetClientsList();
                if (objsList != null && objsList.Count > 0)
                {
                    int nowDayId = Global.GetOffsetDayNow();
                    for (int n = 0; n < objsList.Count; ++n)
                    {
                        GameClient client = objsList[n];
                        if (client != null && client == GameManager.ClientMgr.FindClient(client.ClientData.RoleID)) //确认角色仍然在线
                        {
                            bool   success    = false;
                            double nMultiple  = 0.5;
                            int    awardsRate = 1;
                            int    count      = 0;

                            HuanYingSiYuanLianShaContextData clientLianShaContextData = client.SceneContextData2 as HuanYingSiYuanLianShaContextData;
                            if (null != clientLianShaContextData && clientLianShaContextData.TotalScore >= RuntimeData.TempleMirageMinJiFen)
                            {
                                if (client.ClientData.BattleWhichSide == huanYingSiYuanScene.SuccessSide)
                                {
                                    success   = true;
                                    nMultiple = 1;

                                    //每日前3次享受10倍奖励
                                    int dayid = Global.GetRoleParamsInt32FromDB(client, RoleParamName.HysySuccessDayId);
                                    if (dayid == nowDayId)
                                    {
                                        count = Global.GetRoleParamsInt32FromDB(client, RoleParamName.HysySuccessCount);
                                        if (count < RuntimeData.TempleMirageWinExtraNum)
                                        {
                                            awardsRate = RuntimeData.TempleMirageWinExtraRate;
                                        }
                                    }
                                    else
                                    {
                                        awardsRate = RuntimeData.TempleMirageWinExtraRate;
                                    }
                                }
                            }
                            else
                            {
                                //达不到最低分数,无奖励,不计次
                                nMultiple  = 0;
                                awardsRate = 0;
                            }

                            // 公式
                            long nExp           = (long)(RuntimeData.TempleMirageEXPAward * nMultiple * client.ClientData.ChangeLifeCount);
                            int  chengJiuaward  = (int)(RuntimeData.TempleMirageAwardChengJiu * nMultiple);
                            int  shengWangaward = (int)(RuntimeData.TempleMirageAwardShengWang * nMultiple);

                            if (nExp > 0)
                            {
                                GameManager.ClientMgr.ProcessRoleExperience(client, nExp * awardsRate, false);
                                //GameManager.ClientMgr.NotifyAddExpMsg(client, nExp); //客户端自己提示,有显示"X10"的需求
                            }

                            if (chengJiuaward > 0)
                            {
                                ChengJiuManager.AddChengJiuPoints(client, "幻影寺院获得成就", chengJiuaward * awardsRate, true, true);
                            }

                            if (shengWangaward > 0)
                            {
                                GameManager.ClientMgr.ModifyShengWangValue(client, shengWangaward * awardsRate, "幻影寺院获得声望");
                            }

                            HuanYingSiYuanAwardsData awardsData = new HuanYingSiYuanAwardsData()
                            {
                                SuccessSide   = huanYingSiYuanScene.SuccessSide,
                                Exp           = nExp,
                                ShengWang     = shengWangaward,
                                ChengJiuAward = chengJiuaward,
                                AwardsRate    = awardsRate,
                            };

                            if (success)
                            {
                                if (nMultiple > 0)
                                {
                                    Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.HysySuccessDayId, nowDayId, true);
                                    Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.HysySuccessCount, count + 1, true);

                                    GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 1, 0, (int)GameTypes.HuanYingSiYuan);
                                    if (huanYingSiYuanScene.ScoreInfoData.Score1 >= 1000 || huanYingSiYuanScene.ScoreInfoData.Score2 >= 1000)
                                    {
                                        //FaildCount记录为获得够1000分而获胜的人次
                                        GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 0, 1, (int)GameTypes.HuanYingSiYuan);
                                    }
                                }
                            }
                            else
                            {
                                //FaildCount记录为失败人次
                                //GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 0, 1);
                            }

                            client.sendCmd((int)TCPGameServerCmds.CMD_SPR_HYSY_AWARD, awardsData);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                DataHelper.WriteExceptionLogEx(ex, "幻影寺院清场调度异常");
            }
        }
Ejemplo n.º 3
0
        public void OnKillRole(GameClient client, GameClient other)
        {
            TryLostShengBei(other);

            lock (Mutex)
            {
                HuanYingSiYuanScene huanYingSiYuanScene;
                if (HuanYingSiYuanSceneDict.TryGetValue(client.ClientData.FuBenSeqID, out huanYingSiYuanScene))
                {
                    if (huanYingSiYuanScene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                    {
                        int addScore = 0;
                        HuanYingSiYuanLianShaContextData clientLianShaContextData = client.SceneContextData2 as HuanYingSiYuanLianShaContextData;
                        HuanYingSiYuanLianShaContextData otherLianShaContextData  = other.SceneContextData2 as HuanYingSiYuanLianShaContextData;
                        ContinuityKillAward       continuityKillAward;
                        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;

                        if (null != clientLianShaContextData)
                        {
                            clientLianShaContextData.KillNum++;
                            if (RuntimeData.ContinuityKillAwardDict.TryGetValue(clientLianShaContextData.KillNum, out continuityKillAward))
                            {
                                huanYingSiYuanAddScore.ByLianShaNum = 1;
                                huanYingSiYuanLianSha             = new HuanYingSiYuanLianSha();
                                huanYingSiYuanLianSha.Name        = huanYingSiYuanAddScore.Name;
                                huanYingSiYuanLianSha.ZoneID      = huanYingSiYuanAddScore.ZoneID;
                                huanYingSiYuanLianSha.Occupation  = huanYingSiYuanAddScore.Occupation;
                                huanYingSiYuanLianSha.LianShaType = continuityKillAward.ID;
                                huanYingSiYuanLianSha.ExtScore    = continuityKillAward.Score;
                                huanYingSiYuanLianSha.Side        = huanYingSiYuanAddScore.Side;
                                addScore += huanYingSiYuanLianSha.ExtScore;
                            }
                        }

                        if (null != otherLianShaContextData)
                        {
                            if (otherLianShaContextData.KillNum >= 2)
                            {
                                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         = otherLianShaContextData.KillNum * 5;

                                addScore += huanYingSiYuanLianshaOver.ExtScore;
                            }

                            otherLianShaContextData.KillNum = 0;
                        }

                        addScore += RuntimeData.TempleMiragePK;
                        huanYingSiYuanAddScore.Score = addScore;
                        if (client.ClientData.BattleWhichSide == 1)
                        {
                            huanYingSiYuanScene.ScoreInfoData.Score1 += addScore;
                            if (huanYingSiYuanScene.ScoreInfoData.Score1 >= RuntimeData.TempleMirageWin)
                            {
                                CompleteHuanYingSiYuanScene(huanYingSiYuanScene, 1);
                            }
                        }
                        else
                        {
                            huanYingSiYuanScene.ScoreInfoData.Score2 += addScore;
                            if (huanYingSiYuanScene.ScoreInfoData.Score2 >= RuntimeData.TempleMirageWin)
                            {
                                CompleteHuanYingSiYuanScene(huanYingSiYuanScene, 2);
                            }
                        }

                        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_HYSY_SCORE_INFO, huanYingSiYuanScene.ScoreInfoData, huanYingSiYuanScene.CopyMap);
                        if (null != huanYingSiYuanLianSha)
                        {
                            GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_HYSY_LIANSHA, huanYingSiYuanLianSha, huanYingSiYuanScene.CopyMap);
                        }

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