Ejemplo n.º 1
0
 public SlotOverlay(VirtualController.Button b, Rectangle m, Color c, SlotShape shape) :
     base(b)
 {
     Metrics = m;
     Color   = c;
     Shape   = shape;
 }
Ejemplo n.º 2
0
 public SlotOverlay(VirtualController.Axis a, bool isPos, Rectangle m, Color c, SlotShape shape) :
     base(a, isPos)
 {
     Metrics = m;
     Color   = c;
     Shape   = shape;
 }
Ejemplo n.º 3
0
    public void InventoryItemRotation()
    {
        SlotShape ss = new SlotShape(new int[, ]
        {
            { 1 },  // (0,0)
            { 1 },  // (0,1)
            { 1 }   // (0,2)
        });


        InventoryItem i = new InventoryItem(ss);

        // Rotate Pivot Origin (0,0) -> (0,0)(1,0)(2,0)
        i.Rotate(new Vector2(0, 0), 1);
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(0, 0)), i.ToString());
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(1, 0)), i.ToString());
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(2, 0)), i.ToString());
        // Rotate Pivot (0,1) -> (-1,1)(0,1)(1,1)
        i = new InventoryItem(ss);
        i.Rotate(new Vector2(0, 1), -1);
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(-1, 1)), i.ToString());
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(0, 1)), i.ToString());
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(1, 1)), i.ToString());
        // Rotate Pivot (0,2) -> (-2, 2)(-1, 2)(0,2)
        i = new InventoryItem(ss);
        i.Rotate(new Vector2(0, 2), 1);
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(-2, 2)), i.ToString());
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(-1, 2)), i.ToString());
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(0, 2)), i.ToString());
    }
Ejemplo n.º 4
0
 public void Init(SlotShape slotShape)
 {
     itemSlots = SlotShape.FilterPoints(slotShape);
     GetComponent <RectTransform>().sizeDelta =
         new Vector2(slotShape.Shape.GetLength(1) * 50, slotShape.Shape.GetLength(0) * 50);
     GetComponent <Image>().sprite = sprite;
 }
Ejemplo n.º 5
0
    public void SlotShapeTest_3Dimensions()
    {
        SlotShape ss = new SlotShape(new int[, , ]
        {
            { // Layer 1
                { 1, 1 },
                { 1, 1 }
            },
            { // Layer 2
                { 1, 1 },
                { 1, 1 }
            }
        });

        Assert.AreEqual(8, ss.slotPoints.Count);

        // Layer 1
        Assert.True(ss.slotPoints.Contains(new IntVector3(0, 0, 0)));
        Assert.True(ss.slotPoints.Contains(new IntVector3(1, 0, 0)));
        Assert.True(ss.slotPoints.Contains(new IntVector3(0, 1, 0)));
        Assert.True(ss.slotPoints.Contains(new IntVector3(1, 1, 0)));

        // Layer 2
        Assert.True(ss.slotPoints.Contains(new IntVector3(0, 0, 1)));
        Assert.True(ss.slotPoints.Contains(new IntVector3(1, 0, 1)));
        Assert.True(ss.slotPoints.Contains(new IntVector3(0, 1, 1)));
        Assert.True(ss.slotPoints.Contains(new IntVector3(1, 1, 1)));
    }
Ejemplo n.º 6
0
    public void SlotShapeTest_2Dimensions()
    {
        SlotShape ss = new SlotShape(new int[, , ]
        {
            {
                { 0, 0 },
                { 0, 0 }
            }
        });

        Assert.Zero(ss.slotPoints.Count);

        ss = new SlotShape(new int[, , ]
        {
            {
                { 1, 1 },
                { 1, 1 }
            }
        });

        Assert.AreEqual(4, ss.slotPoints.Count);
        Assert.True(ss.slotPoints.Contains(new IntVector3(0, 0, 0)));
        Assert.True(ss.slotPoints.Contains(new IntVector3(1, 0, 0)));
        Assert.True(ss.slotPoints.Contains(new IntVector3(0, 1, 0)));
        Assert.True(ss.slotPoints.Contains(new IntVector3(1, 1, 0)));
    }
Ejemplo n.º 7
0
    // Creates an inventory with the following slotShape
    public Inventory(SlotShape slotShape)
    {
        _inventorySlots =
            new InventorySlot[slotShape.Shape.GetLength(0), slotShape.Shape.GetLength(1)];

        PopulateInventory(slotShape);
    }
Ejemplo n.º 8
0
    public void InventoryItemRotation()
    {
        SlotShape ss = new SlotShape(new int[, ]
        {
            { 1 },  // (0,0)
            { 1 },  // (0,1)
            { 1 }   // (0,2)
        });


        var ii = new GameObject().AddComponent <InventoryItemUI>();

        ii.GetComponent <InventoryItemUI>().Init(ss);

        // Rotate Pivot Origin (0,0) -> (0,0)(1,0)(2,0)
        ii.Rotate(new Vector2(0, 0), 1);
        Assert.AreEqual(true, ii.itemSlots.Contains(new Vector2(0, 0)), ii.ToString());
        Assert.AreEqual(true, ii.itemSlots.Contains(new Vector2(1, 0)), ii.ToString());
        Assert.AreEqual(true, ii.itemSlots.Contains(new Vector2(2, 0)), ii.ToString());
        // Rotate Pivot (0,1) -> (-1,1)(0,1)(1,1)
        ii = new GameObject().AddComponent <InventoryItemUI>();
        ii.GetComponent <InventoryItemUI>().Init(ss);
        ii.Rotate(new Vector2(0, 1), -1);
        Assert.AreEqual(true, ii.itemSlots.Contains(new Vector2(-1, 1)), ii.ToString());
        Assert.AreEqual(true, ii.itemSlots.Contains(new Vector2(0, 1)), ii.ToString());
        Assert.AreEqual(true, ii.itemSlots.Contains(new Vector2(1, 1)), ii.ToString());
        // Rotate Pivot (0,2) -> (-2, 2)(-1, 2)(0,2)
        ii = new GameObject().AddComponent <InventoryItemUI>();
        ii.GetComponent <InventoryItemUI>().Init(ss);
        ii.Rotate(new Vector2(0, 2), 1);
        Assert.AreEqual(true, ii.itemSlots.Contains(new Vector2(-2, 2)), ii.ToString());
        Assert.AreEqual(true, ii.itemSlots.Contains(new Vector2(-1, 2)), ii.ToString());
        Assert.AreEqual(true, ii.itemSlots.Contains(new Vector2(0, 2)), ii.ToString());
    }
Ejemplo n.º 9
0
    public void InventoryItemClassTests()
    {
        SlotShape ss = new SlotShape(new int[, ]
        {
            { 1 },
            { 1 }
        });
        InventoryItem i = new InventoryItem(ss);

        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(0, 0)));
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(0, 1)));

        ss = new SlotShape(new int[, ]
        {
            { 0, 1 },
            { 1, 0 }
        });
        i = new InventoryItem(ss);

        Assert.AreEqual(2, i.itemSlots.Count);
        Assert.AreEqual(false, i.itemSlots.Contains(new Vector2(0, 0)));
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(1, 0)));
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(0, 1)));
        Assert.AreEqual(false, i.itemSlots.Contains(new Vector2(1, 1)));
    }
Ejemplo n.º 10
0
    public void CreatingInventoryItemUI()
    {
        SlotShape ss = new SlotShape(new int[, ]
        {
            { 1 },
            { 1 }
        });
        var i = new GameObject().AddComponent <InventoryItemUI>();

        i.GetComponent <InventoryItemUI>().Init(ss);

        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(0, 0)));
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(0, 1)));

        ss = new SlotShape(new int[, ]
        {
            { 0, 1 },
            { 1, 0 }
        });
        i = new GameObject().AddComponent <InventoryItemUI>();
        i.GetComponent <InventoryItemUI>().Init(ss);

        Assert.AreEqual(2, i.itemSlots.Count);
        Assert.AreEqual(false, i.itemSlots.Contains(new Vector2(0, 0)));
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(1, 0)));
        Assert.AreEqual(true, i.itemSlots.Contains(new Vector2(0, 1)));
        Assert.AreEqual(false, i.itemSlots.Contains(new Vector2(1, 1)));
    }
Ejemplo n.º 11
0
 private void Start()
 {
     slotShape = new SlotShape(new int[, ]
     {
         { 1 },
         { 1 }
     });
     Init(slotShape);
 }
Ejemplo n.º 12
0
    int CountSlotsAllStages(SlotColor color, SlotShape shape)
    {
        int count = 0;

        for (int i = 0; i <= mPreviousSlots.Count - 2; i++)
        {
            count += mPreviousSlots[i].Count(s => s.color == color && s.shape == shape);
        }
        return(count);
    }
Ejemplo n.º 13
0
    public void GenerateInventory(SlotShape slotShape)
    {
        inventorySlots = new InventorySlot[slotShape.slotShape.GetLength(0),
                                           slotShape.slotShape.GetLength(1),
                                           slotShape.slotShape.GetLength(2)];

        foreach (IntVector3 position in slotShape.slotPoints)
        {
            CreateInventorySlot(position);
        }
    }
Ejemplo n.º 14
0
 public void Init(SlotShape slotShape)
 {
     _inventorySlots =
         new InventorySlotUI[slotShape.Shape.GetLength(0), slotShape.Shape.GetLength(1)];
     slotSize = _inventorySlotPrefab.GetComponent <RectTransform>().sizeDelta.x;
     if (transform.GetComponent <RectTransform>() != null)
     {
         _dimensions = new Vector2(slotShape.Shape.GetLength(1) * slotSize, slotShape.Shape.GetLength(0) * slotSize);
         transform.GetComponent <RectTransform>().sizeDelta = _dimensions;
     }
     PopulateInventory(slotShape);
 }
Ejemplo n.º 15
0
    private void Start()
    {
        SlotShape ss = new SlotShape(new int[, ]
        {
            { 1, 0, 1, 1, 1, 1, 1 },
            { 1, 0, 1, 1, 1, 1, 1 },
            { 0, 0, 0, 1, 1, 1, 0 },
            { 1, 0, 0, 0, 0, 0, 0 },
            { 1, 1, 1, 1, 1, 1, 1 }
        });

        Init(ss);
    }
Ejemplo n.º 16
0
        private void SetupButton(VirtualController.Button button, Panel panel)
        {
            string    name  = button.ToString();
            SlotShape shape = SlotShape.Rounded;

            if (panel.Tag is string)
            {
                try {
                    shape = (SlotShape)Enum.Parse(typeof(SlotShape), panel.Tag as string);
                } catch (FormatException) { }
            }
            RegisterOverlay(button, panel.Bounds, panel.BackColor, shape);
            panel.Tag = button;
            panel.Hide();
        }
Ejemplo n.º 17
0
    // Gets necessary points from the slot shape to only include relevant points
    // ie) in the case of { 0, 0, 1} only  point (2, 0) is relevant 'cause the first two are empty
    // ---------------------------^ this point
    public static List <Vector2> FilterPoints(SlotShape slotShape)
    {
        List <Vector2> gridSlots = new List <Vector2>();

        for (int y = 0; y < slotShape.Shape.GetLength(0); y++)
        {
            for (int x = 0; x < slotShape.Shape.GetLength(1); x++)
            {
                if (slotShape.IsOpenSlot(x, y))
                {
                    gridSlots.Add(new Vector2(x, y));
                }
            }
        }
        return(gridSlots);
    }
Ejemplo n.º 18
0
    public void InventoryClassTests()
    {
        SlotShape ss = new SlotShape(new int[, ]
        {
            { 1, 0, 1 },
            { 0, 1, 0 },
            { 1, 0, 1 }
        });
        Inventory inv = new Inventory(ss);

        Assert.AreEqual(ss.ToString(), inv.ToString(), inv.ToString());

        Assert.AreNotEqual(null, inv.GetSlotAt(0, 0)); Assert.AreEqual(null, inv.GetSlotAt(1, 0)); Assert.AreNotEqual(null, inv.GetSlotAt(2, 0));
        Assert.AreEqual(null, inv.GetSlotAt(0, 1)); Assert.AreNotEqual(null, inv.GetSlotAt(1, 1)); Assert.AreEqual(null, inv.GetSlotAt(2, 1));
        Assert.AreNotEqual(null, inv.GetSlotAt(0, 2)); Assert.AreEqual(null, inv.GetSlotAt(1, 2)); Assert.AreNotEqual(null, inv.GetSlotAt(2, 2));
    }
Ejemplo n.º 19
0
    public void SlotShapeTests()
    {
        SlotShape ss = new SlotShape();

        Assert.AreEqual("[ ]\n", ss.ToString());

        ss = new SlotShape(new int[, ]
        {
            { 1, 0, 1 }
        });
        Assert.AreEqual("[ ]   [ ]\n", ss.ToString());

        ss = new SlotShape(new int[, ]
        {
            { 1 },
            { 0 },
            { 1 }
        });
        Assert.AreEqual("[ ]\n   \n[ ]\n", ss.ToString());

        ss = new SlotShape(new int[, ]
        {
            { 1, 1, 1 },
            { 1, 1, 1 },
            { 1, 1, 1 }
        });
        Assert.AreEqual("[ ][ ][ ]\n[ ][ ][ ]\n[ ][ ][ ]\n", ss.ToString());

        ss = new SlotShape(new int[, ]
        {
            { 0, 0, 0 },
            { 0, 0, 0 },
            { 0, 0, 0 }
        });
        Assert.AreEqual("         \n         \n         \n", ss.ToString());

        ss = new SlotShape(new int[, ]
        {
            { 1, 0, 1 },
            { 0, 1, 0 },
            { 1, 0, 1 }
        });
        Assert.AreEqual(true, ss.IsOpenSlot(0, 0)); Assert.AreEqual(false, ss.IsOpenSlot(1, 0)); Assert.AreEqual(true, ss.IsOpenSlot(2, 0));
        Assert.AreEqual(false, ss.IsOpenSlot(0, 1)); Assert.AreEqual(true, ss.IsOpenSlot(1, 1)); Assert.AreEqual(false, ss.IsOpenSlot(2, 1));
        Assert.AreEqual(true, ss.IsOpenSlot(0, 2)); Assert.AreEqual(false, ss.IsOpenSlot(1, 2)); Assert.AreEqual(true, ss.IsOpenSlot(2, 2));
    }
Ejemplo n.º 20
0
    // Populates Inventory with InventorySlots along the possible areas of the slotShape used.
    // Creating A Slot: SlotShape ---   InventorySlot
    //                 { 1 1 1 }      [ ] [ ] [ ]
    //                 { 1 1 1 } ---> [ ] [ ] [ ]   = 7 created Slots
    //                 { 0 1 0 }      ... [ ] ...
    private int PopulateInventory(SlotShape slotShape)
    {
        int slotsCreated = 0;

        for (int y = 0; y < _inventorySlots.GetLength(0); y++)
        {
            for (int x = 0; x < _inventorySlots.GetLength(1); x++)
            {
                if (slotShape.IsOpenSlot(x, y))
                {
                    if (CreateInventorySlot(x, y))
                    {
                        slotsCreated++;
                    }
                }
            }
        }
        return(slotsCreated);
    }
Ejemplo n.º 21
0
    private void Start()
    {
        endScale             = transform.localScale;
        transform.localScale = Vector3.zero;


        SlotShape ss = new SlotShape(new int[, , ]
        {
            { // Layer 1
                { 1, 1, 1 },
                { 1, 1, 1 },
            },
            { // Layer 2
                { 1, 1, 1 },
                { 1, 1, 1 },
            }
        });

        GenerateInventory(ss);
        gameObject.SetActive(false);
    }
Ejemplo n.º 22
0
    public void SlotShapeTest_NoDimensions()
    {
        SlotShape ss = new SlotShape(new int[, , ]
        {
            {}
        });

        Assert.Zero(ss.slotPoints.Count);

        /*
         * ss = new SlotShape(new int[,,]
         * {
         *  {{1,1}, {1,1}},
         *  {{1,1}, {1,1}}
         * });
         *
         *
         *
         * Assert.AreEqual(8, ss.slotPoints.Count);
         */
    }
Ejemplo n.º 23
0
        private void SetupAxisGesture(AxisGesture ag, Panel panel)
        {
            VirtualController.Axis
                stick       = Util.StickFromGesture(ag),
                axis        = Util.AxisFromGesture(ag);
            bool      pos   = Util.PoleFromGesture(ag);
            SlotShape shape = SlotShape.Rounded;

            if (panel.Tag is string)
            {
                try {
                    shape = (SlotShape)Enum.Parse(typeof(SlotShape), panel.Tag as string);
                } catch (FormatException) { }
            }

            AxisActions.Gestures axisGesture = pos ? AxisActions.Gestures.Positive : AxisActions.Gestures.Negative;
            RegisterOverlay(axis, pos, panel.Bounds, panel.BackColor, shape);

            panel.Hide();
            panel.Tag = ag;
        }
Ejemplo n.º 24
0
    public void CreatingInventoryManagerTests()
    {
        SlotShape ss = new SlotShape(new int[, ]
        {
            { 1, 0, 1 },
            { 0, 1, 0 },
            { 1, 0, 1 }
        });

        var inv = new GameObject().AddComponent <InventoryManager>();
        var inventorySlotPrefab = (GameObject)Resources.Load("Tests/InventorySlot");

        inv.Construct(inventorySlotPrefab);
        inv.GetComponent <InventoryManager>().Init(ss);

        Assert.AreEqual(ss.ToString(), inv.ToString(), inv.ToString());

        Assert.AreNotEqual(null, inv.GetSlotAt(0, 0)); Assert.AreEqual(null, inv.GetSlotAt(1, 0)); Assert.AreNotEqual(null, inv.GetSlotAt(2, 0));
        Assert.AreEqual(null, inv.GetSlotAt(0, 1)); Assert.AreNotEqual(null, inv.GetSlotAt(1, 1)); Assert.AreEqual(null, inv.GetSlotAt(2, 1));
        Assert.AreNotEqual(null, inv.GetSlotAt(0, 2)); Assert.AreEqual(null, inv.GetSlotAt(1, 2)); Assert.AreNotEqual(null, inv.GetSlotAt(2, 2));
    }
Ejemplo n.º 25
0
    public void InventorySpaceCheck()
    {
        SlotShape ss = new SlotShape(new int[, ]
        {
            { 1, 1, 1, 1, 1 },
            { 1, 1, 1, 1, 1 },
            { 1, 1, 1, 1, 1 }
        });

        var inv = new GameObject().AddComponent <InventoryManager>();
        var inventorySlotPrefab = (GameObject)Resources.Load("Tests/InventorySlot");

        inv.Construct(inventorySlotPrefab);
        inv.GetComponent <InventoryManager>().Init(ss);


        for (int y = 0; y < 3; y++)
        {
            for (int x = 0; x < 5; x++)
            {
                // Everything should be free
                Assert.AreEqual(true, inv.IsSlotFree(new Vector2(x, y)), inv.GetSlotAt(x, y).ToString());
            }
        }

        ss = new SlotShape(new int[, ]
        {
            { 1, 1, 1, 1, 1 },
            { 1, 1, 0, 1, 1 },
            { 1, 1, 1, 1, 1 }
        });

        inv = new GameObject().AddComponent <InventoryManager>();
        inv.Construct(inventorySlotPrefab);
        inv.GetComponent <InventoryManager>().Init(ss);

        // One space is unavailable therefore it should be null and return false
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(2, 1)));
    }
Ejemplo n.º 26
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        Inventory inventory = (Inventory)target;

        if (GUILayout.Button("Generate Inventory Slots"))
        {
            SlotShape ss = new SlotShape(new int[, , ]
            {
                { // Layer 1
                    { 1, 1 },
                    { 1, 1 },
                    { 1, 1 }
                },
                { // Layer 2
                    { 1, 1 },
                    { 1, 1 },
                    { 1, 1 }
                }
            });
            inventory.GenerateInventory(ss);
        }
    }
Ejemplo n.º 27
0
    public void SlotShapeTest_1Dimension()
    {
        SlotShape ss = new SlotShape(new int[, , ]
        {
            { { 0 } }
        });

        Assert.Zero(ss.slotPoints.Count);

        ss = new SlotShape(new int[, , ]
        {
            { { 1 } }
        });

        Assert.AreEqual(1, ss.slotPoints.Count);
        Assert.True(ss.slotPoints.Contains(new IntVector3(0, 0, 0)));

        ss = new SlotShape(new int[, , ]
        {
            { { 1, 1, 1 } }
        });

        Assert.AreEqual(3, ss.slotPoints.Count);
        Assert.True(ss.slotPoints.Contains(new IntVector3(0, 0, 0)));
        Assert.True(ss.slotPoints.Contains(new IntVector3(1, 0, 0)));
        Assert.True(ss.slotPoints.Contains(new IntVector3(2, 0, 0)));

        ss = new SlotShape(new int[, , ]
        {
            { { 1, 0, 1 } }
        });

        Assert.AreEqual(2, ss.slotPoints.Count);
        Assert.True(ss.slotPoints.Contains(new IntVector3(0, 0, 0)));
        Assert.False(ss.slotPoints.Contains(new IntVector3(1, 0, 0)));
        Assert.True(ss.slotPoints.Contains(new IntVector3(2, 0, 0)));
    }
Ejemplo n.º 28
0
    public void InventorySpaceCheck()
    {
        SlotShape ss = new SlotShape(new int[, ]
        {
            { 1, 1, 1, 1, 1 },
            { 1, 1, 1, 1, 1 },
            { 1, 1, 1, 1, 1 }
        });
        Inventory i = new Inventory(ss);


        List <Vector2> inventorySlotsToCheck = new List <Vector2>();

        for (int y = 0; y < 3; y++)
        {
            for (int x = 0; x < 5; x++)
            {
                inventorySlotsToCheck.Add(new Vector2(x, y));
            }
        }

        // Everything should be free
        Assert.AreEqual(true, i.AreSlotsFree(inventorySlotsToCheck));

        ss = new SlotShape(new int[, ]
        {
            { 1, 1, 1, 1, 1 },
            { 1, 1, 0, 1, 1 },
            { 1, 1, 1, 1, 1 }
        });

        i = new Inventory(ss);

        // One space is unavailable therefore it should be null and return false
        Assert.AreEqual(false, i.AreSlotsFree(inventorySlotsToCheck));
    }
Ejemplo n.º 29
0
 public SlotOverlay(VirtualController.Button b, Rectangle m, Color c, SlotShape shape)
     : base(b)
 {
     Metrics = m;
     Color = c;
     Shape = shape;
 }
Ejemplo n.º 30
0
 public void RegisterOverlay(VirtualController.Button b, Rectangle m, Color c, SlotShape shape)
 {
     slotOverlays.Add(new SlotOverlay(b, m, c, shape));
 }
Ejemplo n.º 31
0
    public void InventorySpaceAfterAddingItem()
    {
        SlotShape ss = new SlotShape(new int[, ]
        {
            { 1, 1, 1, 1, 1 },
            { 1, 1, 0, 1, 1 },
            { 1, 1, 1, 1, 1 }
        });

        var inv = new GameObject().AddComponent <InventoryManager>();
        var inventorySlotPrefab = (GameObject)Resources.Load("Tests/InventorySlot");

        inv.Construct(inventorySlotPrefab);
        inv.GetComponent <InventoryManager>().Init(ss);

        ss = new SlotShape(new int[, ]
        {
            { 1, 1 },
            { 1, 1 }
        });

        var ii = new GameObject().AddComponent <InventoryItemUI>();

        ii.GetComponent <InventoryItemUI>().Init(ss);

        // Attempt #1 = Add Success
        // Before Adding Item
        Assert.AreEqual(true, inv.IsSlotFree(new Vector2(0, 0)), "A1 Before Adding...");
        Assert.AreEqual(true, inv.IsSlotFree(new Vector2(1, 0)), "A1 Before Adding...");
        Assert.AreEqual(true, inv.IsSlotFree(new Vector2(0, 1)), "A1 Before Adding...");
        Assert.AreEqual(true, inv.IsSlotFree(new Vector2(1, 1)), "A1 Before Adding...");

        // Adding Item
        Assert.AreEqual(true, inv.AddItemAtSlot(ii, 0, 0), "A1 Adding...");

        // After Adding Item
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(0, 0)), "A1 After Adding...");
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(1, 0)), "A1 After Adding...");
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(0, 1)), "A1 After Adding...");
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(1, 1)), "A1 After Adding...");

        // Attempt #2 = Add Fail
        // Before Adding Item
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(1, 0)), "A2 Before Adding...");
        Assert.AreEqual(true, inv.IsSlotFree(new Vector2(2, 0)), "A2 Before Adding...");
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(1, 1)), "A2 Before Adding...");
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(2, 1)), "A2 Before Adding...");

        // Adding Item
        Assert.AreEqual(false, inv.AddItemAtSlot(ii, 1, 0), "A2 Adding...");

        // After Adding Item
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(1, 0)), "A2 After Adding...");
        Assert.AreEqual(true, inv.IsSlotFree(new Vector2(2, 0)), "A2 After Adding...");
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(1, 1)), "A2 After Adding...");
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(2, 1)), "A2 After Adding...");

        // Attempt #3 = Add At Different Location + Success
        // Before Adding Item
        Assert.AreEqual(true, inv.IsSlotFree(new Vector2(3, 0)), "A3 Before Adding...");
        Assert.AreEqual(true, inv.IsSlotFree(new Vector2(4, 0)), "A3 Before Adding...");
        Assert.AreEqual(true, inv.IsSlotFree(new Vector2(3, 1)), "A3 Before Adding...");
        Assert.AreEqual(true, inv.IsSlotFree(new Vector2(4, 1)), "A3 Before Adding...");

        // Adding Item
        Assert.AreEqual(true, inv.AddItemAtSlot(ii, 3, 0), "A3 Adding...");

        // After Adding Item
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(3, 0)), "A3 After Adding...");
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(4, 0)), "A3 After Adding...");
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(3, 1)), "A3 After Adding...");
        Assert.AreEqual(false, inv.IsSlotFree(new Vector2(4, 1)), "A3 After Adding...");

        // Attempt #4 = Add Index Out Of Range
        Assert.AreEqual(false, inv.AddItemAtSlot(ii, 3, 2), "A4 Adding...");

        // Attempt #5 = Adding More...
        ss = new SlotShape(new int[, ]
        {
            { 1, 1 }
        });
        ii = new GameObject().AddComponent <InventoryItemUI>();
        ii.GetComponent <InventoryItemUI>().Init(ss);
        Assert.AreEqual(true, inv.AddItemAtSlot(ii, 1, 2), "A5 Adding...");

        // Attempt #6 = Irregular Shape..
        // Reset Inventory
        ss = new SlotShape(new int[, ]
        {
            { 1, 1, 1, 1, 1 },
            { 1, 1, 0, 1, 1 },
            { 1, 1, 1, 1, 1 }
        });

        inv = new GameObject().AddComponent <InventoryManager>();
        inv.Construct(inventorySlotPrefab);
        inv.GetComponent <InventoryManager>().Init(ss);

        ss = new SlotShape(new int[, ]
        {
            { 1, 1, 0, 0, 0 },
            { 1, 1, 0, 0, 0 },
            { 1, 1, 1, 1, 0 }
        });
        ii = new GameObject().AddComponent <InventoryItemUI>();
        ii.GetComponent <InventoryItemUI>().Init(ss);
        Assert.AreEqual(false, inv.AddItemAtSlot(ii, 1, 0), "A6 Adding...");
        Assert.AreEqual(true, inv.AddItemAtSlot(ii, 0, 0), "A6 Adding...");
    }
Ejemplo n.º 32
0
 public void RegisterOverlay(VirtualController.Axis a, bool isPos, Rectangle m, Color c, SlotShape shape)
 {
     slotOverlays.Add(new SlotOverlay(a, isPos, m, c, shape));
 }
Ejemplo n.º 33
0
 public Slot(SlotShape shape, SlotColor color, float position)
 {
     this.shape    = shape;
     this.color    = color;
     this.position = position;
 }
Ejemplo n.º 34
0
 public SlotOverlay(VirtualController.Axis a, bool isPos, Rectangle m, Color c, SlotShape shape)
     : base(a, isPos)
 {
     Metrics = m;
     Color = c;
     Shape = shape;
 }