示例#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));
 }