Exemplo n.º 1
0
    public ulong GetNextExpBySkillType(int skillType)
    {
        SkillTreeUnit skill = FindSkillUnit(skillType);
        SkillTreeUnit nextSkill;

        if (skill != null)
        {
            int nextLevel = skill._level + 1;
            nextSkill = SkillTreeInfo.GetSkillUnit(skillType, nextLevel);
            if (nextSkill != null)
            {
                return(nextSkill._exp);
            }
            else
            {
                return(0);
            }
        }
        else
        {
            nextSkill = SkillTreeInfo.GetMinLevelSkillByType(skillType);
            if (nextSkill != null)
            {
                return(nextSkill._exp);
            }
            else
            {
                return(0);
            }
        }
    }
Exemplo n.º 2
0
    public SKTLearnResult SKTLearn(int skillType)
    {
        SkillTreeUnit skill = FindSkillUnit(skillType);
        SkillTreeUnit nextSkill;

        if (skill != null)
        {
            int nextLevel = skill._level + 1;
            nextSkill = SkillTreeInfo.GetSkillUnit(skillType, nextLevel);
            if (nextSkill != null)
            {
                SKTLearnResult result = CheckLevelUpCondition(nextSkill);
                if (result != SKTLearnResult.SKTLearnResult_Success)
                {
                    return(result);
                }
                if (!DecExp(nextSkill._exp))
                {
                    return(SKTLearnResult.SKTLearnResult_DontHaveEnoughExp);
                }
                RemoveSkillUnit(skill);
                AddSkillUnit(nextSkill);
            }
            else
            {
                return(SKTLearnResult.SKTLearnResult_DataError);
            }
        }
        else
        {
            nextSkill = SkillTreeInfo.GetMinLevelSkillByType(skillType);
            if (nextSkill != null)
            {
                SKTLearnResult result = CheckLevelUpCondition(nextSkill);
                if (result != SKTLearnResult.SKTLearnResult_Success)
                {
                    return(result);
                }
                if (!DecExp(nextSkill._exp))
                {
                    return(SKTLearnResult.SKTLearnResult_DontHaveEnoughExp);
                }
                ;
                AddSkillUnit(nextSkill);
            }
            else
            {
                return(SKTLearnResult.SKTLearnResult_DataError);
            }
        }
        SkillTreeInfo.RefreshUI(nextSkill._mainType);
        if (GameConfig.IsMultiMode && _net != null)
        {
            _net.RPCServer(EPacketType.PT_InGame_SKTLevelUp, skillType, PlayerNetwork.mainPlayerId);
        }
        return(SKTLearnResult.SKTLearnResult_Success);
    }
Exemplo n.º 3
0
 void RPC_S2C_InitLearntSkills(uLink.BitStream stream, uLink.NetworkMessageInfo info)
 {
     int[] ids = stream.Read <int[]>();
     for (int i = 0; i < ids.Length; i++)
     {
         SkillTreeUnit skillUnit = SkillTreeInfo.GetSkillUnit(ids[i]);
         if (skillUnit != null)
         {
             _learntSkills.AddSkillUnit(skillUnit);
         }
     }
     _learntSkills.InitDefaultSkill();
 }
Exemplo n.º 4
0
 public void ChangeSkillState(SkillTreeUnit skill)
 {
     skill._state = SkillState.Lock;
     if (_learntSkills.Contains(skill))
     {
         skill._state = SkillState.learnt;
         return;
     }
     string[] args = skill._parent.Split(';');
     for (int i = 0; i < args.Length; i++)
     {
         SkillTreeUnit skillUnit = SkillTreeInfo.GetSkillUnit(System.Int32.Parse(args[i]));
         if (skillUnit == null)
         {
             if (args[i] == "0")
             {
                 skill._state = SkillState.unLock;
             }
             else
             {
                 skill._state = SkillState.Lock;
                 Debug.LogError("parent skill is not exsit");
             }
             return;
         }
         else
         {
             SkillTreeUnit skilllearnt = FindSkillUnit(skillUnit._skillType);
             if (skilllearnt != null)
             {
                 if (skilllearnt._level >= skillUnit._level)
                 {
                     if (i == args.Length - 1)
                     {
                         skill._state = SkillState.unLock;
                     }
                 }
                 else
                 {
                     skill._state = SkillState.Lock;
                     return;
                 }
             }
             else
             {
                 skill._state = SkillState.Lock;
                 return;
             }
         }
     }
 }
Exemplo n.º 5
0
 SKTLearnResult CheckLevelUpCondition(SkillTreeUnit skill)
 {
     if (_ske == null)
     {
         return(SKTLearnResult.SKTLearnResult_SkAliveEntityIsNULL);
     }
     if (skill != null)
     {
         if (_ske.GetAttribute((int)AttribType.Exp) < skill._exp)
         {
             return(SKTLearnResult.SKTLearnResult_DontHaveEnoughExp);
         }
         if (skill._parent != "0")
         {
             string[] args = skill._parent.Split(';');
             for (int i = 0; i < args.Length; i++)
             {
                 SkillTreeUnit skillunit = SkillTreeInfo.GetSkillUnit(System.Int32.Parse(args[i]));
                 if (skillunit == null)
                 {
                     return(SKTLearnResult.SKTLearnResult_DataError);
                 }
                 else
                 {
                     SkillTreeUnit skilllearnt = FindSkillUnit(skillunit._skillType);
                     if (skilllearnt != null)
                     {
                         if (skilllearnt._level >= skillunit._level)
                         {
                             if (i == args.Length - 1)
                             {
                                 return(SKTLearnResult.SKTLearnResult_Success);
                             }
                         }
                         else
                         {
                             return(SKTLearnResult.SKTLearnResult_NeedLearntParentSkill);
                         }
                     }
                 }
             }
             return(SKTLearnResult.SKTLearnResult_DataError);
         }
         return(SKTLearnResult.SKTLearnResult_Success);
     }
     return(SKTLearnResult.SKTLearnResult_DataError);
 }
Exemplo n.º 6
0
    public override void Deserialize(BinaryReader _in)
    {
        if (_net != null)
        {
            return;
        }
        int count = _in.ReadInt32();

        for (int i = 0; i < count; i++)
        {
            int           id        = _in.ReadInt32();
            SkillTreeUnit skillUnit = SkillTreeInfo.GetSkillUnit(id);
            if (skillUnit != null)
            {
                AddSkillUnit(skillUnit);
            }
        }
    }
Exemplo n.º 7
0
    void RPC_S2C_SKTLevelUp(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        int levelUpType = stream.Read <int>();
        int level       = stream.Read <int> ();
        int playerid    = stream.Read <int> ();

        if (playerid == PlayerNetwork.mainPlayerId || _learntSkills == null)
        {
            return;
        }
        SkillTreeUnit skillUnit = _learntSkills.FindSkillUnit(levelUpType);

        if (skillUnit != null)
        {
            _learntSkills.RemoveSkillUnit(skillUnit);
        }
        SkillTreeUnit nextSkillUnit = SkillTreeInfo.GetSkillUnit(levelUpType, level);

        if (nextSkillUnit != null)
        {
            _learntSkills.AddSkillUnit(nextSkillUnit);
        }
    }