void ApplyExperience(Entity attacker)
        {
            if (attacker == null || attacker == ParentObject)
            {
                return;
            }
            LevelComponent level_cmp = ParentObject.GetComponent(LevelComponent.ID) as LevelComponent;

            if (level_cmp == null)
            {
                return;
            }
            int xp = level_cmp.BeKilledExperience;

            if (xp == 0)
            {
                return;
            }
            level_cmp = attacker.GetComponent(LevelComponent.ID) as LevelComponent;
            if (level_cmp == null)
            {
                return;
            }
            level_cmp.AddExperience(xp);
        }
示例#2
0
 public static int GetLevel(Object obj)
 {
     while (obj != null)
     {
         LevelComponent level_component = obj.GetComponent(LevelComponent.ID) as LevelComponent;
         if (level_component != null)
         {
             return(level_component.CurrentLevel);
         }
         else
         {
             obj = obj.GetOwnerObject();
         }
     }
     return(0);
 }