public Character GetCharacter(int index, FighterInfo data, int jobIndex, int depthBase)
    {
        var characterPoolManager = CharacterPoolManager.Instance;
        // convert from 1 based template id to 0 based programe id.
        if (index < 0 || index >= characterPoolManager.CharacterPoolList.Count)
        {
            Logger.LogError("Hero index should be in range [0, " + characterPoolManager.CharacterPoolList.Count + ")." + ", take index 0 as default error recovery.");
            // Fault recover, make unknown index as 0. 
            index = 0;
        }
        var character = characterPoolManager.Take(index).GetComponent<Character>();
        Utils.AddChild(Parent, character.gameObject);
        character.Data = data;
        character.IDIndex = index;
        character.JobIndex = jobIndex;
        character.DepthBase = depthBase;
        // set up depth base.
        character.SetupDepthBase(true);

        var faceObject = NGUITools.AddChild(character.gameObject, Face);
        faceObject.SetActive(true);
        character.FaceObject = faceObject;

        return character;
    }
Exemple #2
0
 /// <summary>
 /// Set inner data before using.
 /// </summary>
 /// <param name="data">Fighter infor.</param>
 /// <param name="character">Character reference.</param>
 /// <param name="leaderIndex">Leader index.</param>
 public void SetData(FighterInfo data, Character character, int leaderIndex)
 {
     figherData = data;
     Character = character;
     skillData = HeroModelLocator.Instance.GetLeaderSkillTemplateById(figherData.ActiveSkillId);
     if (skillData != null)
     {
         Data.BaseCd = skillData.CostMP;
         CostMP.text = skillData.CostMP.ToString();
         Logger.LogWarning("Leader base CD: " + Data.BaseCd + ", name: " + name);
     }
     Data.LeaderIndex = leaderIndex;
 }