Beispiel #1
0
        public static InventoryStack[] SplitStack(Mine2D game, InventoryStack stack)
        {
            InventoryStack[] stacks = new InventoryStack[2];

            if (stack != null && stack.count >= 2)
            {
                int stack1Count = stack.count / 2;
                int stack2Count = stack.count - stack1Count;
                stacks[0] = stack.Clone(game) as InventoryStack;
                stacks[0].RemoveAmount(stack1Count);
                stacks[1] = stack.Clone(game) as InventoryStack;
                stacks[1].RemoveAmount(stack2Count);
            }

            return stacks;
        }
Beispiel #2
0
 public static InventoryStack SumTwoStacks(Mine2D game, InventoryStack stack1, InventoryStack stack2)
 {
     InventoryStack stack = stack1.Clone(game) as InventoryStack;
     stack.AddAmount(stack2.count);
     return stack;
 }