Example #1
0
    UnitStatus CreateUnit(string member, string team, int place)
    {
        string path = $"Сharacters/{member}";

        if (member == "Empty")
        {
            return(null);
        }

        UnitStatus unit = new UnitStatus();

        GameObject unitGameObject = Instantiate(Resources.Load(path, typeof(GameObject)) as GameObject);
        Personage  unitClass      = unitGameObject.GetComponent <Personage>();

        /* Unit stats export */
        unit.gameObject     = unitGameObject;
        unit.gameObject.tag = team;
        unit.status         = "Live";
        unit.turn           = true;
        unit.team           = team;
        unit.place          = place;
        unit.level          = unitClass.level;
        unit.hp             = unitClass.hp;
        unit.currentHp      = unitClass.hp;
        unit.attack         = unitClass.attack;
        unit.attackType     = unitClass.attackType;
        unit.defence        = unitClass.defence;
        unit.initiative     = unitClass.initiative;
        unit.type           = unitClass.type;

        unitUI.HpIndicator(unit);

        return(unit);
    }