Beispiel #1
0
 void FillUnitItems(StateUnitModel unit, ClickAction <ItemModel> onClick, List <ItemModel> result)
 {
     foreach (var state in GetItemStates(unit))
     {
         result.Add(CreateModel(state, onClick));
     }
 }
Beispiel #2
0
        public List <ItemModel> GetAllUnitItems(StateUnitModel unit, ClickAction <ItemModel> onItem, ClickAction <ItemModel> onPlaceholder)
        {
            var result = new List <ItemModel>();

            FillUnitItems(unit, onItem, result);
            FillUnitPlaceholders(unit, onPlaceholder, result);
            return(result);
        }
Beispiel #3
0
        HashSet <ItemType> GetUsedTypes(StateUnitModel unit)
        {
            _usedTypes.Clear();
            var result = _usedTypes;

            foreach (var state in GetItemStates(unit))
            {
                var config = GetItemConfig(state);
                result.Add(config.Type);
            }
            return(result);
        }
Beispiel #4
0
        void FillUnitPlaceholders(StateUnitModel unit, ClickAction <ItemModel> onClick, List <ItemModel> result)
        {
            var usedTypes = GetUsedTypes(unit);

            foreach (var type in _allItemTypes)
            {
                if (usedTypes.Contains(type))
                {
                    continue;
                }
                result.Add(CreatePlaceholder(type, onClick));
            }
        }
Beispiel #5
0
        public void Init(
            GameStateUpdateService update, ItemService items, UnitService units,
            ItemFragment.Factory itemFragment, ItemsWindow.Factory itemsWindow,
            Canvas parent, StateUnitModel unit
            )
        {
            _update       = update;
            _items        = items;
            _units        = units;
            _itemFragment = itemFragment;
            _itemsWindow  = itemsWindow;
            _unit         = unit;

            update.AddHandler <EquipItemCommand>  (OnEquipItem);
            update.AddHandler <TakeOffItemCommand>(OnTakeOffItem);

            CloseButton.onClick.AddListener(Hide);

            CreateFragments();
            Refresh();

            ShowAt(parent);
        }
Beispiel #6
0
        public void TakeOff(StateUnitModel unit, ItemModel item)
        {
            var stateItem = (StateItemModel)item;

            _runner.TryAddCommand(new TakeOffItemCommand(stateItem.State.Id, unit.State.Id));
        }
Beispiel #7
0
        public void Equip(StateUnitModel unit, ItemModel item)
        {
            var stateItem = (StateItemModel)item;

            _runner.TryAddCommand(new EquipItemCommand(stateItem.State.Id, unit.State.Id));
        }
Beispiel #8
0
        public ItemModel CreateModel(StateUnitModel unit, ulong itemId, ClickAction <ItemModel> onClick)
        {
            var state = GetItemState(unit, itemId);

            return(CreateModel(state, onClick));
        }
Beispiel #9
0
 ItemState GetItemState(StateUnitModel unit, ulong itemId) => unit.State.Items.Find(it => it.Id == itemId);
Beispiel #10
0
 List <ItemState> GetItemStates(StateUnitModel unit) => unit.State.Items;