Ejemplo n.º 1
0
    public bool CheckForVictory(Transform gameBoardParent, Transform solutionBoardParent)
    {
        // Setting the storage vars
        GameSlot  slot1 = null, slot2 = null;
        GameShape shape1 = null, shape2 = null;

        // Check each square
        for (int i = 0; i < gameBoardParent.childCount; i++)
        {
            // Getting each slot reference
            slot1 = gameBoardParent.GetChild(i).GetComponent <GameSlot>();
            slot2 = solutionBoardParent.GetChild(i).GetComponent <GameSlot>();

            // Getting Shape References
            shape1 = slot1 != null?slot1.GetSlotShape() : null;

            shape2 = slot2 != null?slot2.GetSlotShape() : null;

            // Comparing the two shapes from each slot, return false if shapes aren't equal
            if ((shape1 == null && shape2 != null) || (shape1 != null && shape2 == null))
            {
                return(false);
            }
            else if (shape1 != null && shape2 != null)
            {
                if (!slot1.GetSlotShape().Equals(slot2.GetSlotShape()))
                {
                    return(false);
                }
            }
        }

        // All the slots evaluate as true, trigger Complete Level
        CompleteLevel();
        return(true);
    }
Ejemplo n.º 2
0
    public void SwitchSolutionShapes(GameSlot s1, int s1Index, GameSlot s2, int s2Index)
    {
        // Setting the parents
        GameShape s = s1.GetSlotShape();

        s.transform.SetParent(s2.transform);
        s.transform.localPosition = new Vector3(0.5f, -0.5f);

        s = s2.GetSlotShape();
        s.transform.SetParent(s1.transform);
        s.transform.localPosition = new Vector3(0.5f, -0.5f);

        // Triggering Shape Destruction(s)
        TriggerShapeDestruction(s1Index, solutionBoardParent);
        TriggerShapeDestruction(s2Index, solutionBoardParent);
    }
Ejemplo n.º 3
0
    public ShapeData GetBoardShapeData(int slotIndex, Transform boardParent)
    {
        GameSlot slot = GetGameSlot(slotIndex, boardParent);

        if (slot.CheckCanInteract())
        {
            GameShape shape = slot.GetSlotShape();
            if (shape != null)
            {
                return(shape.GetShapeData() ?? null);
            }
            else
            {
                return(null);
            }
        }
        else
        {
            return(null);
        }
    }
Ejemplo n.º 4
0
    private void DrawGameShapeOptions(GameSlot slot)
    {
        GameShape shapeData = slot.GetSlotShape();

        if (shapeData != null)
        {
            EditorGUILayout.LabelField($"Shape Info", EditorStyles.boldLabel);
            EditorGUILayout.LabelField($"Shape Color: {shapeData.colorType}");
            EditorGUILayout.LabelField($"Shape Type: {shapeData.GetShapeType()}");
        }
        else
        {
            EditorGUILayout.LabelField("Shape Info: No Shape Available");
        }

        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Lock Options", EditorStyles.boldLabel);

        desiredLockType  = (SlotLock.LockType)EditorGUILayout.EnumPopup("Lock Type", desiredLockType);
        desiredLockTimer = EditorGUILayout.IntField("Lock Timer", desiredLockTimer);
        desiredLockSize  = EditorGUILayout.FloatField("Lock Size", desiredLockSize);

        EditorGUILayout.BeginHorizontal();
        if (slot.GetSlotLock() != null)
        {
            if (GUILayout.Button("Edit Lock", GUILayout.MaxWidth(150f)))
            {
                GameSlotTools.EditSlotLock(slot.transform, desiredLockType, desiredLockTimer, desiredLockSize);
                EditorUtility.SetDirty(slot.GetComponent <GameSlot>().GetSlotLock());
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }
        else
        {
            if (GUILayout.Button("Create Lock", GUILayout.MaxWidth(150f)))
            {
                GameSlotTools.CreateSlotLock(slot.transform, desiredLockType, desiredLockTimer, desiredLockSize);
                EditorUtility.SetDirty(slot.GetComponent <GameSlot>().GetSlotLock());
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }

        SlotLock slotLock = slot.GetSlotLock();

        if (slotLock != null && GUILayout.Button("Destroy Lock", GUILayout.Width(150f)))
        {
            DestroyImmediate(slotLock.gameObject);
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("Shape Options", EditorStyles.boldLabel);

        desiredShapeType  = (GameShape.ShapeType)EditorGUILayout.EnumPopup("Shape Type", desiredShapeType);
        desiredShapeColor = (GameShape.ColorType)EditorGUILayout.EnumPopup("Shape Color", desiredShapeColor);
        desiredShapeSize  = EditorGUILayout.FloatField("Shape Scale", desiredShapeSize);

        EditorGUILayout.BeginHorizontal();
        if (slot.GetSlotShape() != null)
        {
            if (GUILayout.Button("Edit Shape", GUILayout.MaxWidth(150f)))
            {
                GameSlotTools.EditSlotShape(slot.transform, desiredShapeType, desiredShapeColor, desiredShapeSize);
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }
        else
        {
            if (GUILayout.Button("Create Shape", GUILayout.MaxWidth(150f)))
            {
                GameSlotTools.CreateSlotShape(slot.transform, desiredShapeType, desiredShapeColor, desiredShapeSize);
                EditorUtility.SetDirty(slot.GetComponent <GameSlot>());
                EditorUtility.SetDirty(slot.GetComponent <GameSlot>().GetSlotShape());
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }

        if (shapeData != null && GUILayout.Button("Destroy Shape", GUILayout.Width(150f)))
        {
            DestroyImmediate(shapeData.gameObject);
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Separator();
    }