public void AddSlot(ModuleItem moduleItem) { GameObject activeTierCollectionList; GameObject tierActiveCollectionViewPrefab; SubCollectionView view = (moduleItem.TankPartModuleType != TankPartModuleType.WEAPON) ? this.hullCollectionView : this.turretCollectionView; if (moduleItem.ModuleBehaviourType == ModuleBehaviourType.ACTIVE) { activeTierCollectionList = view.activeTierCollectionList; tierActiveCollectionViewPrefab = this.tierActiveCollectionViewPrefab; } else { activeTierCollectionList = view.passiveTierCollectionList; tierActiveCollectionViewPrefab = this.tierPassiveCollectionViewPrefab; } for (int i = activeTierCollectionList.transform.childCount; i <= moduleItem.TierNumber; i++) { this.AddTierCollectionViewToList(activeTierCollectionList, tierActiveCollectionViewPrefab); } TierCollectionView component = activeTierCollectionList.transform.GetChild(moduleItem.TierNumber).GetComponent <TierCollectionView>(); GameObject obj4 = Instantiate <GameObject>(this.collectionSlotPrefab); obj4.transform.SetParent(component.slotList.transform, false); CollectionSlotView componentInChildren = obj4.GetComponentInChildren <CollectionSlotView>(); componentInChildren.Init(moduleItem); slots.Add(moduleItem, componentInChildren); }
private void HighlightPossibleSlots() { ModuleItem moduleItem = DragAndDropItem.draggedItem.GetComponent <SlotItemView>().ModuleItem; this.hullCollectionView.TurnOffSlots(); this.turretCollectionView.TurnOffSlots(); if (moduleItem.TankPartModuleType == TankPartModuleType.WEAPON) { this.turretCollectionView.TurnOnSlotsByTypeAndHighlightForDrop(moduleItem.ModuleBehaviourType); } else { this.hullCollectionView.TurnOnSlotsByTypeAndHighlightForDrop(moduleItem.ModuleBehaviourType); } foreach (KeyValuePair <ModuleItem, CollectionSlotView> pair in CollectionView.slots) { CollectionSlotView view = pair.Value; if (pair.Key == moduleItem) { view.TurnOnRenderAboveAll(); continue; } view.GetComponent <DragAndDropCell>().enabled = false; } }
private void OnAnyItemDragEnd(DragAndDropItem item, PointerEventData eventData) { this.background.SetActive(false); this.turretCollectionView.CancelHighlightForDrop(); this.hullCollectionView.CancelHighlightForDrop(); foreach (KeyValuePair <ModuleItem, CollectionSlotView> pair in CollectionView.slots) { CollectionSlotView view = pair.Value; view.GetComponent <DragAndDropCell>().enabled = true; view.TurnOffRenderAboveAll(); } }
public void Select(SlotItemView slotItem) { if (this.selectedSlotItem != slotItem) { if (this.selectedSlot != null) { this.selectedSlot.Deselect(); this.selectedSlot = null; } if (this.selectedSlotItem != null) { this.selectedSlotItem.Deselect(); } slotItem.Select(); this.selectedSlotItem = slotItem; if (this.onSelectionChange != null) { this.onSelectionChange(slotItem.ModuleItem); } } }
public void Select(CollectionSlotView slot) { if (this.selectedSlot != slot) { if (this.selectedSlotItem != null) { this.selectedSlotItem.Deselect(); this.selectedSlotItem = null; } if (this.selectedSlot != null) { this.selectedSlot.Deselect(); } slot.Select(); this.selectedSlot = slot; if (this.onSelectionChange != null) { this.onSelectionChange(slotToModuleItem[this.selectedSlot]); } } }
public void Clear() { if (this.selectedSlot != null) { this.selectedSlot.Deselect(); this.selectedSlot = null; if (this.onSelectionChange != null) { this.onSelectionChange(null); } } else if (this.selectedSlotItem != null) { this.selectedSlotItem.Deselect(); this.selectedSlotItem = null; if (this.onSelectionChange != null) { this.onSelectionChange(null); } } }
public void Update(Dictionary <ModuleItem, CollectionSlotView> collectionViewSlots, Dictionary <ModuleItem, SlotItemView> slotItems) { if (slotToModuleItem == null) { slotToModuleItem = new Dictionary <SlotView, ModuleItem>(); foreach (KeyValuePair <ModuleItem, CollectionSlotView> pair in collectionViewSlots) { CollectionSlotView key = pair.Value; key.onClick += new Action <CollectionSlotView>(this.OnSlotClick); slotToModuleItem.Add(key, pair.Key); } } foreach (KeyValuePair <ModuleItem, SlotItemView> pair2 in slotItems) { if (!registeredSlotItems.Contains(pair2.Key)) { SlotItemView view2; registeredSlotItems.Add(pair2.Key); pair2.Value.onClick = view2.onClick + new Action <SlotItemView>(this.OnItemClick); } } }
private void OnSlotClick(CollectionSlotView slot) { this.Select(slot); }