Ejemplo n.º 1
0
        private void AddAbility(UnitStackBase unit, AbilityType ability)
        {
            if (!abilitiesMap.ContainsKey(ability))
            {
                Debug.LogError($"The factory doesn't have settings for the ability of type {ability}.");
                return;
            }

            Instantiate(abilitiesMap[ability], new Vector3(), Quaternion.identity, unit.transform);
        }
Ejemplo n.º 2
0
        public UnitStackBase Create(UnitStackRepresentation unit, bool playerUnit)
        {
            UnitSettings  settings      = unitSettingsMap[unit.type];
            GameObject    newUnit       = Instantiate(settings.basePrefab, transform.position, Quaternion.identity, transform);
            UnitStackBase unitBaseClass = newUnit.GetComponent <UnitStackBase>();

            if (unitBaseClass == null)
            {
                Debug.LogError("Prefab doesn't contain an instance of UnitStackBase class.");
                return(null);
            }
            unitBaseClass.SetBaseSettings(unit.type, unit.numberOfUnits,
                                          playerUnit, settings.baseData.maxHealth,
                                          settings.baseData.damage, settings.baseData.initiative,
                                          settings.baseData.unitName
                                          );

            if (settings.baseData.ability != AbilityType.None)
            {
                AddAbility(unitBaseClass, settings.baseData.ability);
            }

            return(unitBaseClass);
        }
Ejemplo n.º 3
0
 private void Start()
 {
     unitStackBase = GetComponentInParent <UnitStackBase>();
 }