public void SaveUnits(bool isInit = false)
        {
            var unitsList = new List <UnitLoadObject>();

            foreach (var unit in _unitsController.GetUnits())
            {
                var unitObject = new UnitLoadObject
                {
                    key        = unit.Key,
                    experience = unit.Experience,
                    level      = unit.Level,
                    isLocked   = unit.IsLocked,
                    outfit     = unit.Outfit
                };

                unitsList.Add(unitObject);
            }

            var units = new UnitsLoadObject
            {
                groupCount = _unitsController.GroupCount,
                units      = unitsList
            };

            _saveObject.unitsInfo = units;

            if (!isInit)
            {
                Save();
            }
        }
        public void CreateUnits()
        {
            if (_cells.Count != 0)
            {
                RemoveUnits();
            }

            var battleSection = _partyMenuController.Battle;
            var attackTypes   = battleSection.ActiveCell.AttackTypes;
            var allyUnits     = battleSection.AllyUnits;
            var units         = _unitsController.GetUnits()
                                .Where(x => attackTypes.Any(y => x.AttackType == y))
                                .Where(x => allyUnits.All(y => x != y.Unit))
                                .OrderBy(x => x.UnitType)
                                .ToList();

            foreach (var unit in units)
            {
                var cell = _unitCellFactory.Create(parent);
                cell.SetProductData(unit);
            }

            var rectTransform = parent.GetComponent <RectTransform>();
            var width         = 240 * units.Count + 10 * (units.Count - 1);

            rectTransform.sizeDelta = new Vector2(width, 240);

            _cells[0].SetActiveItem();
        }
Esempio n. 3
0
        public void InitData()
        {
            foreach (var cell in _enemyUnits)
            {
                var unit = _unitsController.GetUnits().First();
                cell.SetData(unit);
            }

            ActiveCell = _allyUnits[0];
            ActiveCell.SetActiveCell();
        }
        public void SetUnitsData()
        {
            var units = _unitsController.GetUnits()
                        .Where(x => x.UnitType == ActiveType).ToList();

            for (var i = 0; i < units.Count; i++)
            {
                _units[i].SetProductData(units[i]);
            }

            _units[0].SetActiveItem();
        }