예제 #1
0
        public bool HasSlotsForDecoration(ShopDecorationObject decorationObjectToTest)
        {
            bool result = allShopDecorationSlots.Count(x => x.IsFreeAndAssignableTo(decorationObjectToTest)) > 0;

            //Debug.Log("Has slots? " + result);
            return(result);
        }
예제 #2
0
 private void EndPlacementContext()
 {
     ResetSlotHighlights();
     currentDraggedDecoration = null;
     currentDraggedSlot       = null;
     startDragSlot            = null;
 }
예제 #3
0
        public void CreateAndStartDragPlacement(ShopDecorationObject prefab, int bonesCost)
        {
            CurrentDecorationCost = bonesCost;
            var newDeco = SpawnNewDecoration(prefab);

            StartDragPlacement(newDeco, true);
        }
예제 #4
0
 public void Free()
 {
     if (!assigned)
     {
         return;
     }
     assigned = false;
     _assignedDecorationObject = null;
 }
예제 #5
0
        private void DeleteDecoration(ShopDecorationObject decoToDelete)
        {
            var assignedSlot = allShopDecorationSlots.FirstOrDefault(x => x.HasCurrentlyAssigned(currentDraggedDecoration));

            if (assignedSlot != null)
            {
                assignedSlot.Free();
            }
            Destroy(decoToDelete.gameObject);
        }
예제 #6
0
        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);
        }
예제 #7
0
 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);
 }
예제 #8
0
        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);
            }
        }
예제 #9
0
 private void HandleDragStart(ShopDecorationObject decorationObject)
 {
     isDragging     = true;
     iconUI.texture = decorationObject.rawImage.texture;
 }
예제 #10
0
 public bool HasCurrentlyAssigned(ShopDecorationObject decorationObject)
 {
     return(_assignedDecorationObject == decorationObject);
 }
예제 #11
0
 public bool IsAssignableTo(ShopDecorationObject decorationObject)
 {
     return(slotType == decorationObject.slotType);
 }
예제 #12
0
 public bool IsFreeAndAssignableTo(ShopDecorationObject decorationObject)
 {
     return(!assigned && IsAssignableTo(decorationObject));
 }