예제 #1
0
        private void SaveClientBattleSide(TianTiScene tianTiScene, GameClient client)
        {
            TianTiRoleMiniData tianTiRoleMiniData;

            if (!tianTiScene.RoleIdDuanWeiIdDict.TryGetValue(client.ClientData.RoleID, out tianTiRoleMiniData))
            {
                tianTiRoleMiniData = new TianTiRoleMiniData();
                tianTiScene.RoleIdDuanWeiIdDict[client.ClientData.RoleID] = tianTiRoleMiniData;
            }

            tianTiRoleMiniData.RoleId          = client.ClientData.RoleID;
            tianTiRoleMiniData.RoleName        = client.ClientData.RoleName;
            tianTiRoleMiniData.BattleWitchSide = client.ClientData.BattleWhichSide;
            tianTiRoleMiniData.ZoneId          = client.ClientData.ZoneID;
            tianTiRoleMiniData.DuanWeiId       = client.ClientData.TianTiData.DuanWeiId;
        }
예제 #2
0
        /// <summary>
        /// 给奖励
        /// </summary>
        public void GiveAwards(TianTiScene tianTiScene)
        {
            try
            {
                DateTime          now       = TimeUtil.NowDateTime();
                DateTime          startTime = now.Subtract(RuntimeData.RefreshTime); //后退刷新时间,这样来保证不跨天计次
                List <GameClient> objsList  = tianTiScene.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)) //确认角色仍然在线
                        {
                            RoleTianTiData     roleTianTiData    = client.ClientData.TianTiData;
                            bool               success           = client.ClientData.BattleWhichSide == tianTiScene.SuccessSide;
                            int                selfDuanWeiId     = roleTianTiData.DuanWeiId;
                            TianTiRoleMiniData enemyMiniData     = GetEnemyBattleSide(tianTiScene, client);
                            int                addDuanWeiJiFen   = 0;
                            int                addLianShengJiFen = 0;
                            int                addRongYao        = 0;

                            int dayId = Global.GetOffsetDay(startTime);
                            if (dayId != roleTianTiData.LastFightDayId)
                            {
                                roleTianTiData.LastFightDayId  = dayId;
                                roleTianTiData.TodayFightCount = 1;
                            }
                            else
                            {
                                roleTianTiData.TodayFightCount++;
                            }

                            //设置每日天梯积分获得上限为60万
                            if (roleTianTiData.DayDuanWeiJiFen < RuntimeData.MaxTianTiJiFen)
                            {
                                TianTiDuanWei tianTiDuanWei;
                                if (success)
                                {
                                    roleTianTiData.LianSheng++;
                                    roleTianTiData.SuccessCount++;
                                    if (RuntimeData.TianTiDuanWeiDict.TryGetValue(enemyMiniData.DuanWeiId, out tianTiDuanWei))
                                    {
                                        //连胜后积分=基础积分*(1+Min(2,((连续胜利次数-1)* 0.2)))
                                        addDuanWeiJiFen   = tianTiDuanWei.WinJiFen;
                                        addLianShengJiFen = (int)(tianTiDuanWei.WinJiFen * Math.Min(2, (roleTianTiData.LianSheng - 1) * 0.2));
                                        if (roleTianTiData.TodayFightCount <= tianTiDuanWei.RongYaoNum)
                                        {
                                            addRongYao = tianTiDuanWei.WinRongYu;
                                        }
                                    }
                                }
                                else
                                {
                                    roleTianTiData.LianSheng = 0;
                                    if (RuntimeData.TianTiDuanWeiDict.TryGetValue(roleTianTiData.DuanWeiId, out tianTiDuanWei))
                                    {
                                        addDuanWeiJiFen = tianTiDuanWei.LoseJiFen;
                                        if (roleTianTiData.TodayFightCount <= tianTiDuanWei.RongYaoNum)
                                        {
                                            addRongYao = tianTiDuanWei.LoseRongYu;
                                        }
                                    }
                                }

                                if (addDuanWeiJiFen != 0)
                                {
                                    roleTianTiData.DuanWeiJiFen += addDuanWeiJiFen + addLianShengJiFen;
                                    roleTianTiData.DuanWeiJiFen  = Math.Max(0, roleTianTiData.DuanWeiJiFen);

                                    roleTianTiData.DayDuanWeiJiFen += addDuanWeiJiFen + addLianShengJiFen;
                                    roleTianTiData.DayDuanWeiJiFen  = Math.Max(0, roleTianTiData.DayDuanWeiJiFen);
                                    Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.TianTiDayScore, roleTianTiData.DayDuanWeiJiFen, true);
                                }
                            }
                            else
                            {
                                GameManager.ClientMgr.NotifyHintMsg(client, Global.GetLang("今日获得段位积分已达上限!"));
                            }

                            if (addRongYao != 0)
                            {
                                GameManager.ClientMgr.ModifyTianTiRongYaoValue(client, addRongYao, "天梯系统获得荣耀", true);
                            }

                            roleTianTiData.FightCount++;
                            if (RuntimeData.DuanWeiJiFenRangeDuanWeiIdDict.TryGetValue(roleTianTiData.DuanWeiJiFen, out selfDuanWeiId))
                            {
                                roleTianTiData.DuanWeiId = selfDuanWeiId;
                            }

                            TianTiAwardsData awardsData = new TianTiAwardsData();
                            awardsData.DuanWeiJiFen   = addDuanWeiJiFen;
                            awardsData.LianShengJiFen = addLianShengJiFen;
                            awardsData.RongYao        = addRongYao;
                            awardsData.DuanWeiId      = roleTianTiData.DuanWeiId;
                            if (success)
                            {
                                awardsData.Success = 1;
                                GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 1, 0, (int)GameTypes.TianTi);
                            }
                            else
                            {
                                GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 0, 1, (int)GameTypes.TianTi);
                            }

                            client.sendCmd((int)TCPGameServerCmds.CMD_SPR_TIANTI_AWARD, awardsData);
                            Global.sendToDB <int, RoleTianTiData>((int)TCPGameServerCmds.CMD_DB_TIANTI_UPDATE_ROLE_DATA, roleTianTiData, client.ServerId);

                            TianTiLogItemData tianTiLogItemData = new TianTiLogItemData()
                            {
                                Success           = awardsData.Success,
                                ZoneId1           = client.ClientData.ZoneID,
                                RoleName1         = client.ClientData.RoleName,
                                ZoneId2           = enemyMiniData.ZoneId,
                                RoleName2         = enemyMiniData.RoleName,
                                DuanWeiJiFenAward = addDuanWeiJiFen + addLianShengJiFen,
                                RongYaoAward      = addRongYao,
                                RoleId            = client.ClientData.RoleID,
                                EndTime           = now,
                            };
                            Global.sendToDB <int, TianTiLogItemData>((int)TCPGameServerCmds.CMD_DB_TIANTI_ADD_ZHANBAO_LOG, tianTiLogItemData, client.ServerId);

                            TianTiPaiHangRoleData tianTiPaiHangRoleData = new TianTiPaiHangRoleData();
                            tianTiPaiHangRoleData.DuanWeiId    = roleTianTiData.DuanWeiId;
                            tianTiPaiHangRoleData.RoleId       = roleTianTiData.RoleId;
                            tianTiPaiHangRoleData.RoleName     = client.ClientData.RoleName;
                            tianTiPaiHangRoleData.Occupation   = client.ClientData.Occupation;
                            tianTiPaiHangRoleData.ZhanLi       = client.ClientData.CombatForce;
                            tianTiPaiHangRoleData.ZoneId       = client.ClientData.ZoneID;
                            tianTiPaiHangRoleData.DuanWeiJiFen = roleTianTiData.DuanWeiJiFen;
                            RoleData4Selector roleInfo = Global.sendToDB <RoleData4Selector, string>((int)TCPGameServerCmds.CMD_SPR_GETROLEUSINGGOODSDATALIST, string.Format("{0}", client.ClientData.RoleID), client.ServerId);
                            if (null != roleInfo || roleInfo.RoleID < 0)
                            {
                                tianTiPaiHangRoleData.RoleData4Selector = roleInfo;
                            }
                            PlayerJingJiData jingJiData = JingJiChangManager.getInstance().createJingJiData(client);

                            TianTiRoleInfoData tianTiRoleInfoData = new TianTiRoleInfoData();
                            tianTiRoleInfoData.RoleId                 = tianTiPaiHangRoleData.RoleId;
                            tianTiRoleInfoData.ZoneId                 = tianTiPaiHangRoleData.ZoneId;
                            tianTiRoleInfoData.ZhanLi                 = tianTiPaiHangRoleData.ZhanLi;
                            tianTiRoleInfoData.RoleName               = tianTiPaiHangRoleData.RoleName;
                            tianTiRoleInfoData.DuanWeiId              = tianTiPaiHangRoleData.DuanWeiId;
                            tianTiRoleInfoData.DuanWeiJiFen           = tianTiPaiHangRoleData.DuanWeiJiFen;
                            tianTiRoleInfoData.DuanWeiRank            = tianTiPaiHangRoleData.DuanWeiRank;
                            tianTiRoleInfoData.TianTiPaiHangRoleData  = DataHelper.ObjectToBytes(tianTiPaiHangRoleData);
                            tianTiRoleInfoData.PlayerJingJiMirrorData = DataHelper.ObjectToBytes(jingJiData);
                            TianTiClient.getInstance().UpdateRoleInfoData(tianTiRoleInfoData);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                DataHelper.WriteExceptionLogEx(ex, "天梯系统清场调度异常");
            }
        }