コード例 #1
0
        public override bool Verify(Message message)
        {
            m_Request           = message.Packet as CREntitySwitchHero;
            m_Response.SerialId = m_Request.SerialId;
            int playerId = message.Session.UserId;

            if (DateTime.UtcNow.Ticks - m_Room.StartTime < GameConfigs.GetInt("Room_Battle_Start_Protection_Time", 3) * TimeSpan.TicksPerSecond)
            {
                return(false);
            }
            if (m_Request.OldEntityId != m_Room.Players[playerId].InBattleEntity)
            {
                return(false);
            }
            var newhero = m_Room.Players[playerId].Heros.Find(t => t.EntityId == m_Request.NewEntityId);

            if (newhero == null)
            {
                return(false);
            }
            if (newhero.HP <= 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #2
0
 public override bool Verify(Message message)
 {
     m_OriginHero        = null;
     m_TargetHero        = null;
     m_Request           = message.Packet as CREntityImpact;
     m_Response.SerialId = m_Request.SerialId;
     if (DateTime.UtcNow.Ticks - m_Room.StartTime < GameConfigs.GetInt("Room_Battle_Start_Protection_Time", 3) * TimeSpan.TicksPerSecond)
     {
         return(false);
     }
     m_OriginHero = m_Room.Players[m_UserId].Heros.Find(t => t.EntityId == m_Request.OriginOwnerEntityId);
     foreach (var player in m_Room.Players)
     {
         if (player.Value.InBattleEntity == m_Request.TargetEntityId)
         {
             m_TargetHero = m_Room.Players[player.Key].Heros.Find(t => t.EntityId == m_Request.TargetEntityId);
         }
     }
     if (m_OriginHero == null || m_TargetHero == null)
     {
         return(false);
     }
     if (m_OriginHero.HP <= 0 || m_TargetHero.HP <= 0)
     {
         return(false);
     }
     return(true);
 }
コード例 #3
0
 public override bool Verify(Message message)
 {
     m_Request           = message.Packet as CREntityMove;
     m_Response.SerialId = m_Request.SerialId;
     if (DateTime.UtcNow.Ticks - m_Room.StartTime < GameConfigs.GetInt("Room_Battle_Start_Protection_Time", 3) * TimeSpan.TicksPerSecond)
     {
         return(false);
     }
     if (!m_Request.IsKey && DateTime.UtcNow.Ticks - m_LastPushTime < m_PushInterval)
     {
         TraceLog.WriteError("too frequency");
         return(false);
     }
     if (m_Room.Players[message.Session.UserId].InBattleEntity != m_Request.EntityId)
     {
         TraceLog.WriteError("wrong entityId, true entity is:{0}, receive:{1}", m_Room.Players[message.Session.UserId].InBattleEntity, m_Request.EntityId);
         return(false);
     }
     TraceLog.WriteInfo("verify success");
     return(true);
 }