public bool HasSlotsForDecoration(ShopDecorationObject decorationObjectToTest) { bool result = allShopDecorationSlots.Count(x => x.IsFreeAndAssignableTo(decorationObjectToTest)) > 0; //Debug.Log("Has slots? " + result); return(result); }
private void EndPlacementContext() { ResetSlotHighlights(); currentDraggedDecoration = null; currentDraggedSlot = null; startDragSlot = null; }
public void CreateAndStartDragPlacement(ShopDecorationObject prefab, int bonesCost) { CurrentDecorationCost = bonesCost; var newDeco = SpawnNewDecoration(prefab); StartDragPlacement(newDeco, true); }
public void Free() { if (!assigned) { return; } assigned = false; _assignedDecorationObject = null; }
private void DeleteDecoration(ShopDecorationObject decoToDelete) { var assignedSlot = allShopDecorationSlots.FirstOrDefault(x => x.HasCurrentlyAssigned(currentDraggedDecoration)); if (assignedSlot != null) { assignedSlot.Free(); } Destroy(decoToDelete.gameObject); }
private ShopDecorationObject SpawnNewDecoration(ShopDecorationObject UnlockableDecorationPrefab) { if (!HasSlotsForDecoration(UnlockableDecorationPrefab)) { return(null); } var newDecoration = Instantiate(UnlockableDecorationPrefab); newDecoration.transform.localPosition = new Vector3(10000, 0, 0); newDecoration.Initialise(slotFeedbackPrefabGo); return(newDecoration); }
public void Assign(ShopDecorationObject assignedDecorationObject) { if (assigned) { return; } assigned = true; _assignedDecorationObject = assignedDecorationObject; _assignedDecorationObject.transform.SetParent(transform); _assignedDecorationObject.transform.localEulerAngles = Vector3.zero; _assignedDecorationObject.transform.localPosition = Vector3.zero; _assignedDecorationObject.transform.SetLocalScale(1); _assignedDecorationObject.gameObject.SetActive(true); }
public void StartDragPlacement(ShopDecorationObject decoToDrag, bool isNew) { if (isNew) { SetContextNewPlacement(); } else { SetContextMovingPlacement(); } currentDraggedSlot = null; currentDraggedDecoration = decoToDrag; currentDraggedDecoration.FocusHighlight(true); dragCoroutine = StartCoroutine(DragPlacementCO()); if (OnDragStart != null) { OnDragStart(decoToDrag); } }
private void HandleDragStart(ShopDecorationObject decorationObject) { isDragging = true; iconUI.texture = decorationObject.rawImage.texture; }
public bool HasCurrentlyAssigned(ShopDecorationObject decorationObject) { return(_assignedDecorationObject == decorationObject); }
public bool IsAssignableTo(ShopDecorationObject decorationObject) { return(slotType == decorationObject.slotType); }
public bool IsFreeAndAssignableTo(ShopDecorationObject decorationObject) { return(!assigned && IsAssignableTo(decorationObject)); }