예제 #1
0
    public void TestFlipMiddle()
    {
        Debug.Log("Test flip middle");
        StackMeta stack = GetStackMetaOf5();

        Debug.Log("Before flip at top: " + stack.ToStringShort());
        stack.FlipStackAt(1);
        Debug.Log("After flip at top: " + stack.ToStringShort());

        TestManager.AssertTrue(stack.GetChipMetaAt(0).prefabId == 11, "Wrong prefabid");
        TestManager.AssertTrue(stack.GetChipMetaAt(0).orientation == ChipOrientation.UP, "Wrong orientation");
        TestManager.AssertTrue(stack.GetChipMetaAt(0).isOrientationImportant == false, "Orientation shouldn't be important");
        TestManager.AssertTrue(stack.GetChipMetaAt(0).stackPos == 0, "Wrong stackpos");

        TestManager.AssertTrue(stack.GetChipMetaAt(1).prefabId == 15, "Wrong prefabid");
        TestManager.AssertTrue(stack.GetChipMetaAt(1).orientation == ChipOrientation.DOWN, "Wrong orientation");
        TestManager.AssertTrue(stack.GetChipMetaAt(1).isOrientationImportant == false, "Orientation shouldn't be important");
        TestManager.AssertTrue(stack.GetChipMetaAt(1).stackPos == 1, "Wrong stackpos");

        TestManager.AssertTrue(stack.GetChipMetaAt(2).prefabId == 14, "Wrong prefabid");
        TestManager.AssertTrue(stack.GetChipMetaAt(2).orientation == ChipOrientation.DOWN, "Wrong orientation");
        TestManager.AssertTrue(stack.GetChipMetaAt(2).isOrientationImportant == false, "Orientation shouldn't be important");
        TestManager.AssertTrue(stack.GetChipMetaAt(2).stackPos == 2, "Wrong stackpos");

        TestManager.AssertTrue(stack.GetChipMetaAt(3).prefabId == 13, "Wrong prefabid");
        TestManager.AssertTrue(stack.GetChipMetaAt(3).orientation == ChipOrientation.DOWN, "Wrong orientation");
        TestManager.AssertTrue(stack.GetChipMetaAt(3).isOrientationImportant == false, "Orientation shouldn't be important");
        TestManager.AssertTrue(stack.GetChipMetaAt(3).stackPos == 3, "Wrong stackpos");

        TestManager.AssertTrue(stack.GetChipMetaAt(4).prefabId == 12, "Wrong prefabid");
        TestManager.AssertTrue(stack.GetChipMetaAt(4).orientation == ChipOrientation.DOWN, "Wrong orientation");
        TestManager.AssertTrue(stack.GetChipMetaAt(4).isOrientationImportant == false, "Orientation shouldn't be important");
        TestManager.AssertTrue(stack.GetChipMetaAt(4).stackPos == 4, "Wrong stackpos");
    }
예제 #2
0
    public void TestFlipStack()
    {
        Debug.Log("Test flip stack start");
        StackMeta stack = GetStackMetaOf5();

        Debug.Log("Before flip at 0: " + stack.ToStringShort());
        stack.FlipStackAt(0);
        Debug.Log("After flip at 0: " + stack.ToStringShort());
        TestManager.AssertEquals(stack.GetChipMetaAt(0).prefabId, 15, "");
        TestManager.AssertEquals(stack.GetChipMetaAt(1).prefabId, 14, "");
        TestManager.AssertEquals(stack.GetChipMetaAt(2).prefabId, 13, "");
        TestManager.AssertEquals(stack.GetChipMetaAt(3).prefabId, 12, "");
        TestManager.AssertEquals(stack.GetChipMetaAt(4).prefabId, 11, "");

        TestManager.AssertTrue(stack.GetChipMetaAt(0).orientation == ChipOrientation.DOWN, "");
        TestManager.AssertTrue(stack.GetChipMetaAt(1).orientation == ChipOrientation.DOWN, "");
        TestManager.AssertTrue(stack.GetChipMetaAt(2).orientation == ChipOrientation.DOWN, "");
        TestManager.AssertTrue(stack.GetChipMetaAt(3).orientation == ChipOrientation.DOWN, "");
        TestManager.AssertTrue(stack.GetChipMetaAt(4).orientation == ChipOrientation.DOWN, "");

        TestManager.AssertEquals(stack.GetChipMetaAt(0).stackPos, 0, "");
        TestManager.AssertEquals(stack.GetChipMetaAt(1).stackPos, 1, "");
        TestManager.AssertEquals(stack.GetChipMetaAt(2).stackPos, 2, "");
        TestManager.AssertEquals(stack.GetChipMetaAt(3).stackPos, 3, "");
        TestManager.AssertEquals(stack.GetChipMetaAt(4).stackPos, 4, "");
    }
예제 #3
0
    public void TestFlipStackJustTop()
    {
        Debug.Log("Test flip stack just top");
        StackMeta stack = GetStackMetaOf5();

        Debug.Log("Before flip at top: " + stack.ToStringShort());
        stack.FlipStackAt(stack.ChipCount() - 1);
        Debug.Log("After flip at top: " + stack.ToStringShort());
        TestManager.AssertTrue(stack.GetChipMetaAt(0).orientation == ChipOrientation.UP, "Wrong orientation for chip");
        TestManager.AssertTrue(stack.GetChipMetaAt(1).orientation == ChipOrientation.UP, "Wrong orientation for chip");
        TestManager.AssertTrue(stack.GetChipMetaAt(2).orientation == ChipOrientation.UP, "Wrong orientation for chip");
        TestManager.AssertTrue(stack.GetChipMetaAt(3).orientation == ChipOrientation.UP, "Wrong orientation for chip");

        TestManager.AssertTrue(stack.GetChipMetaAt(4).orientation == ChipOrientation.DOWN, "Wrong orientation for chip");
        TestManager.AssertEquals(stack.GetChipMetaAt(4).stackPos, 4, "Wrong stackpos for chip");
        TestManager.AssertEquals(stack.GetChipMetaAt(4).prefabId, 15, "Wrong prefabid");
    }
예제 #4
0
    public void TestRemoveChip()
    {
        StackMeta stack = GetStackMetaOf5();

        Debug.Log("stack: " + stack.ToStringShort());
        int      initalCount = 5;
        ChipMeta chip        = stack.GetChipMetaAt(initalCount - 1);

        stack.RemoveAt(stack.ChipCount() - 1);
        TestManager.AssertEquals(stack.ChipCount(), initalCount - 1, "TestRemoveChip");
        chip = stack.GetChipMetaAt(2);
        stack.RemoveAt(2);
        for (int i = 0; i < stack.ChipCount(); i++)
        {
            ChipMeta chipI = stack.GetChipMetaAt(i);
            stack.RemoveAt(i);
            TestManager.AssertEquals(i, chipI.stackPos, "TestRemoveChip stack pos is not the same");
        }
    }
예제 #5
0
    public void FlipAt(int position)
    {
        if (flipper.IsFlipping || faller.IsFalling)             //Extra insurance that the meta stack won't be flipped when the flipper isn't finished
        {
            return;
        }

        List <GameObject> chipsToFlip = new List <GameObject> ();

        for (int i = position; i < transform.childCount; i++)
        {
            chipsToFlip.Add(transform.GetChild(i).gameObject);
        }

        crushChipsMeta = meta.FlipStackAt(position);
        flipper.Flip(chipsToFlip, transform);

        Debug.LogFormat("<color=yellow>Flipping at {0}.</color> Updated stack: {1})", position, meta.ToStringShort());
    }