Exemple #1
0
    public Barrack CreateBarrack(int codBarrack, bool isEnemy, PhaseObjectives barrackObjective)
    {
        GameObject barrackGameObject        = GameObject.Instantiate(barrackPrefab);
        Barrack    barrack                  = new Barrack();
        BarrackScriptableObject barrackData = GetBarrackScriptableObject(codBarrack);

        barrack.CodBarrack        = barrackData.codBarrack;
        barrack.CodPart           = barrackData.codPart;
        barrack.CodTroop          = barrackData.codTroop;
        barrack.NamBarrack        = barrackData.namBarrack;
        barrack.DesBarrack        = barrackData.desBarrack;
        barrack.NumTroopLimit     = barrackData.numTroopLimit;
        barrack.ValCost           = barrackData.valCost;
        barrack.ValSpawnFrequency = barrackData.valSpawnFrequency;
        barrack.GameObject        = barrackGameObject;
        barrack.IsEnemy           = isEnemy;
        barrack.Objective         = barrackObjective;

        barrack.SetUpSpawner();
        barrack.GameObject.GetComponent <SpriteRenderer>().sprite = barrackData.sprite;
        barrack.GameObject.GetComponent <Animator>().runtimeAnimatorController = barrackData.animatorController;

        barrack.GameObject.GetComponent <RunTimeBarrackData>().SetData(barrack);

        return(barrack);
    }