You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

124 lines
3.0 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ProtoCSStruct;
using Sog;
namespace Game
{
public static class PlayerTickSvc
{
private static long m_oneSecondMs;
private static long m_5SecondMs;
private static long m_oneMinuteMs;
private static long nowSec;
public static void OnPlayerOnline(PlayerOnGame player)
{
for (int i = player.RoleData.ExchangeCodeData.BitMap.Count; i < player.RoleData.ExchangeCodeData.BitMap.GetMaxCount(); ++i)
{
player.RoleData.ExchangeCodeData.BitMap.Add(0);
}
}
public static void TickAllPlayer(long nowMs)
{
if(nowMs - m_oneSecondMs < 1000)
{
return;
}
nowSec = nowMs / 1000;
m_oneSecondMs = nowMs;
bool bTick5Second = false;
if(nowMs - m_5SecondMs >= 5000)
{
bTick5Second = true;
m_5SecondMs = nowMs;
}
bool bTickOneMinute = false;
if (nowMs - m_oneMinuteMs >= 60000)
{
bTickOneMinute = true;
m_oneMinuteMs = nowMs;
}
PlayerTableOp playerTableOp = GameServerUtils.GetPlayerTableOp();
//会不会tick太多? 后期要怎么优化下才行
foreach (PlayerOnGame player in playerTableOp.Table.m_uidTable.Values)
{
TickOneSecond(player, nowMs);
if(bTick5Second)
{
Tick5Second(player, nowMs);
}
if (bTickOneMinute)
{
TickOneMinute(player, nowMs);
}
}
}
private static void TickFast(PlayerOnGame player, long nowMs)
{
}
private static void TickOneSecond(PlayerOnGame player, long nowMs)
{
RankSvc.TickUpgradeRank(player);
//新活动表
}
private static void Tick5Second(PlayerOnGame player, long nowMs)
{
StatisticsOp.TickDailyReset(player, true);
PayCommSvc.OnTick(player, nowSec);
TickUpdatePower(player, nowSec);
RankSvc.TickRoleRankData(player, nowSec);
//AutoChallengeSvc.OnTickPlayer5Second(player, nowSec);
//5秒tick一次活动数据
ActivityTick.OnTick(player, nowMs / 1000);
MarketShopEvent.OnTick(player,nowSec);
//检测月卡是否过期
MonthlyCardSvc.CheckMonthCardOutTime(player, (int)nowSec);
ActorSvc.OnTick(player,nowSec);
}
private static void TickOneMinute(PlayerOnGame player, long nowMs)
{
}
/// <summary>
/// 定期更新英雄战力相关的数据
/// </summary>
/// <param name="player"></param>
/// <returns></returns>
public static void TickUpdatePower(PlayerOnGame player, long nowSec)
{
return;
}
}
}