Exemple #1
0
        // Instantly moves card into slot
        public static void MoveStackIntoSlot(ElementStackToken elementStack, RecipeSlot slot)
        {
            // Make sure slot and stack are valid and empty and we have a match
            // Abort with feedback if we don't
            if (!(Validator.Available(elementStack) && Validator.Available(slot) && StackMatchesSlot(elementStack, slot)))
            {
                SoundManager.PlaySfx("CardDragFail");
                return;
            }

            // Remove glow so that it won't flicker when moved
            elementStack.ShowGlow(false, true);

            // Force stack to remember its last position
            elementStack.lastTablePos = new Vector2?(elementStack.RectTransform.anchoredPosition);

            if (elementStack.Quantity != 1)
            {
                IElementStack newStack = elementStack.SplitAllButNCardsToNewStack(elementStack.Quantity - 1, new Context(Context.ActionSource.PlayerDrag));
                slot.AcceptStack(newStack, new Context(Context.ActionSource.PlayerDrag));
            }
            else
            {
                slot.AcceptStack(elementStack, new Context(Context.ActionSource.PlayerDrag));
            }
        }
 void PopulateSlot(RecipeSlot slot, ElementStackToken stack)
 {
     stack.lastTablePos = new Vector2?(stack.RectTransform.anchoredPosition);
     if (stack.Quantity != 1)
     {
         var newStack = stack.SplitAllButNCardsToNewStack(stack.Quantity - 1, new Context(Context.ActionSource.PlayerDrag));
         slot.AcceptStack(newStack, new Context(Context.ActionSource.PlayerDrag));
     }
     else
     {
         slot.AcceptStack(stack, new Context(Context.ActionSource.PlayerDrag));
     }
 }