コード例 #1
0
    public void TriggerShapeTransform(GameShape.ShapeType shapeType, GameShape.ColorType colorType)
    {
        queuedTransformData = new ShapeData(colorType, shapeType);
        transforming        = true;

        anim.SetTrigger("Transform");
    }
コード例 #2
0
ファイル: GameSlot.cs プロジェクト: CGlesmann/ShapeShifter
 public void SetSlotShape(GameShape.ShapeType shapeType, GameShape.ColorType colorType)
 {
     if (slotShape != null)
     {
         slotShape.ConfigureShape(shapeType, colorType);
     }
 }
コード例 #3
0
    public Sprite GetElementData(GameShape.ShapeType key)
    {
        if (Contains(key, out int index))
        {
            return(shapeValues[index]);
        }

        return(null);
    }
コード例 #4
0
    public static void EditSlotShape(Transform slot, GameShape.ShapeType shapeType, GameShape.ColorType shapeColor, float shapeSize)
    {
        GameShape newShape = slot.GetComponent <GameSlot>().GetSlotShapeTransform().GetComponent <GameShape>();

        newShape.transform.localScale = new Vector3(shapeSize, shapeSize);

        GameShape shapeRef = newShape.GetComponent <GameShape>();

        shapeRef.SetShapeColor(shapeColor);
        shapeRef.SetShapeType(shapeType);
        EditorUtility.SetDirty(shapeRef);

        EditorUtility.SetDirty(shapeRef.GetComponent <Image>());
        EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
    }
コード例 #5
0
    public static void CreateSlotShape(Transform slot, GameShape.ShapeType shapeType, GameShape.ColorType shapeColor, float shapeSize)
    {
        GameObject shapePrefab = Resources.Load <GameObject>("Prefabs/GameShape");

        GameObject newShape = PrefabUtility.InstantiatePrefab(shapePrefab, slot) as GameObject;

        newShape.transform.localPosition = Vector3.zero;
        newShape.transform.localScale    = new Vector3(shapeSize, shapeSize);

        GameShape shapeRef = newShape.GetComponent <GameShape>();

        shapeRef.ConfigureShape(shapeType, shapeColor);

        GameSlot slotRef = slot.GetComponent <GameSlot>();

        slotRef.SetSlotShapeReference(newShape.transform);

        EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
    }
コード例 #6
0
    public bool Contains(GameShape.ShapeType targetKey, out int index)
    {
        if (shapeKeys == null || shapeValues == null)
        {
            index = -1;
            return(false);
        }

        for (int i = 0; i < shapeKeys.Count; i++)
        {
            if (shapeKeys[i] == targetKey)
            {
                index = i;
                return(true);
            }
        }

        index = -1;
        return(false);
    }
コード例 #7
0
    public void Add(GameShape.ShapeType key, Sprite value)
    {
        if (shapeKeys == null || shapeValues == null)
        {
            shapeKeys   = new List <GameShape.ShapeType>();
            shapeValues = new List <Sprite>();

            shapeKeys.Add(key);
            shapeValues.Add(value);

            return;
        }

        if (!Contains(key, out int index))
        {
            shapeKeys.Add(key);
            shapeValues.Add(value);
        }

        return;
    }
コード例 #8
0
    public void TransformSurroundingShapes()
    {
        Transform  gameBoardParent   = gameManager.gameBoardParent;
        List <int> surroundingShapes = boardManager.CheckForSurroundingShapes(transform.GetSiblingIndex(), gameBoardParent);

        if (surroundingShapes != null && surroundingShapes.Count > 0)
        {
            undoManager.PushBoardData(new BoardData(gameBoardParent, new Vector2Int(boardManager.GetBoardWidth(), boardManager.GetBoardHeight())));
            shapesToTransform = new List <GameShape>();

            foreach (int shapeIndex in surroundingShapes)
            {
                GameShape gameShape  = boardManager.GetGameSlot(shapeIndex, gameBoardParent)?.GetSlotShape();
                ShapeData shapeData  = boardManager.GetBoardShapeData(shapeIndex, gameBoardParent);
                Image     shapeImage = gameShape?.GetComponent <Image>();

                if (gameShape != null && shapeData != null && shapeImage != null)
                {
                    shapesToTransform.Add(gameShape);
                    GameShape.ShapeType shapeType = shapeData.shapeType;

                    int newShapeTypeIndex = (int)shapeType + 1;
                    if (newShapeTypeIndex > Enum.GetNames(typeof(GameShape.ShapeType)).Length - 1)
                    {
                        newShapeTypeIndex = 1;
                    }

                    GameShape.ShapeType newShapeType = (GameShape.ShapeType)newShapeTypeIndex;
                    gameShape.TriggerShapeTransform(newShapeType, gameShape.GetShapeColor());
                }
            }

            transformerData.transformerCounter--;
            UpdateCounterText();

            gameManager.CheckForVictory(gameManager.gameBoardParent, gameManager.solutionBoardParent);
        }

        transforming = false;
    }
コード例 #9
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();
    }