コード例 #1
0
        public override void Apply(IInventoryViewData data)
        {
            base.Apply(data);
            InitMap();
            playerEquipmentViewData = viewData as PlayerEquipmentViewData;

            if (itemViews == null || itemViews.Length != CellCount)
            {
                itemViews = new PlayerEquipmentCellView[CellCount];
                for (int i = 0; i < CellCount; i++)
                {
                    var itemView = GetCellBySlot(i);
                    itemViews[i] = itemView;
                    itemView.SetCellCallback(
                        onCellClick,
                        onCellOptionClick,
                        onCellEnter,
                        onCellExit,
                        null,
                        null);
                    itemView.Apply(null);
                }
            }

            for (var i = 0; i < playerEquipmentViewData.CellData.Length; i++)
            {
                itemViews[i].Apply(playerEquipmentViewData.CellData[i]);
            }
        }
コード例 #2
0
        private void UnEquip(PlayerEquipmentCellView cellView)
        {
            var nowEquipment = cellView.CellData as PlayerEquipmentCellData;

            if (nowEquipment != null)
            {
                GamePlayMgr.S.playerMgr.role.equipComponent.UnEquip(nowEquipment.equipment);
                GFrame.EventSystem.S.Send(EventID.OnAddInventory, new PlayerInventoryCellData(nowEquipment.item));
            }

            ApplyCell(cellView, (int)cellView.slot, null);
            GFrame.EventSystem.S.Send(EventID.OnRefeshAppearance, cellView.slot, null, nowEquipment?.equipment);
        }
コード例 #3
0
 public void HandleEvent(int key, params object[] args)
 {
     switch (key)
     {
     case (int)EventID.OnEquipInventroy:
         PlayerInventoryCellData cellData = (PlayerInventoryCellData)args[0];
         if (cellData.item is Equipment equipment)
         {
             PlayerEquipmentCellView equipmentCellView = GetCellByEquipmentType(equipment.equipmentType);
             Equip(equipmentCellView, equipment);
         }
         break;
     }
 }
コード例 #4
0
        private void Equip(PlayerEquipmentCellView cellView, Equipment equipment)
        {
            var nowEquipment = cellView.CellData as PlayerEquipmentCellData;

            if (nowEquipment != null)
            {
                GamePlayMgr.S.playerMgr.role.equipComponent.UnEquip(nowEquipment.equipment);
                GFrame.EventSystem.S.Send(EventID.OnAddInventory, new PlayerInventoryCellData(nowEquipment.item));
            }

            var equipCellData = new PlayerEquipmentCellData(equipment);

            ApplyCell(cellView, (int)cellView.slot, equipCellData);
            // Debug.LogError(equipment);
            GamePlayMgr.S.playerMgr.role.equipComponent.Equip(equipment);
            GFrame.EventSystem.S.Send(EventID.OnRefeshAppearance, cellView.slot, equipment, nowEquipment?.equipment);
        }