예제 #1
0
    public static BattleUnit Create(BattleUnitProto proto, EBattleFactionType factionType, SceneLoader loader)
    {
        GameObject go = new GameObject();
        GameMonoAgent agent = go.AddComponent<GameMonoAgent>();
        BattleUnit btUnit = agent.AddGameMonoComponent<BattleUnit>();
        btUnit.FactionType = factionType;
        btUnit.theTile = factionType == EBattleFactionType.FT_Player
            ? BattleField.instance.PlayerField.GetTile(proto.MainTileIndex)
            : BattleField.instance.EnemyField.GetTile(proto.MainTileIndex);

        btUnit.BindLoader = loader;
        btUnit.Parse(proto);

        return null;
    }
예제 #2
0
    private void Parse(BattleUnitProto proto)
    {
        Guid = proto.Guid;
        ProtoData = proto;
        Hp = proto.HP;
        PowerNum = proto.Power;

        if (Model != null)
            Model.Destroy();

        CommanderUnit model = GameUnit.Create<CommanderUnit>("", proto.TableID, BindLoader);
        Model = model;

        Utility.SetIdentityChild(gameObject, Model.gameObject);

        for (int i = 0; i < mSkillList.Count; i++)
        {
            BattleSkill bs = mSkillList[i];
            ObjectPool.Delete<BattleSkill>(bs);
        }
        mSkillList.Clear();

        for (int i = 0; i < ProtoData.SkillList.Count; ++i)
        {
            BattleSkill bs = ObjectPool.New<BattleSkill>();
            bs.OnInit(ProtoData.SkillList[i], this);
            mSkillList.Add(bs);
        }
    }