예제 #1
0
 public void OnSerialize(NetMessage message)
 {
     message.Write(m_data.Talents.Count);
     foreach (var item in m_data.Talents)
     {
         message.Write((uint)item.Key);
         message.Write(item.Value.Exp);
         message.Write((uint)item.Value.Level);
         message.Write((uint)item.Value.Points);
         if (item.Value.Level == 0)
         {
             var exp = CharsMgr.GetExpForLevel(item.Value.Level + 1);
             message.Write(exp);
             message.Write(exp);
             message.Write(0u);
         }
         else if (item.Value.Level == CharsMgr.MaxLevel)
         {
             var exp = CharsMgr.GetExpForLevel(CharsMgr.MaxLevel);
             message.Write(exp);
             message.Write(0u);
             message.Write(exp);
         }
         else
         {
             var exp = CharsMgr.GetExpForLevel(item.Value.Level + 1);
             message.Write(item.Value.Exp);
             message.Write(exp);
             message.Write(0);
         }
     }
 }
예제 #2
0
        private bool CalculateTalentLevel(TalentData talent, uint exp)
        {
            if (talent.Level >= CharsMgr.MaxLevel)
            {
                return(false);
            }
            var cExp  = talent.Exp + exp;
            var level = (short)(talent.Level <= 0 ? 1 : talent.Level);

            while (level < CharsMgr.MaxLevel)
            {
                var nExp = CharsMgr.GetExpForLevel(level);
                if (cExp < nExp)
                {
                    break;
                }
                cExp -= nExp;
                level++;
            }
            talent.Exp = cExp;
            if (level != talent.Level)
            {
                talent.Points += (short)((level - talent.Level) * CharsMgr.TalentPointsPerLevel);
                talent.Level   = level;
                return(true);
            }
            return(false);
        }