Example #1
0
    public static bool HasMatch()
    {
        List <BaseComponent> matchableComponents = Pool.Instance.ComponentsForType(typeof(MatchableComponent));
        MatchableComponent   target = null;
        bool hasMatch = true;

        foreach (MatchableComponent mac in matchableComponents)
        {
            ColorableComponent cac = mac.GetComponent <ColorableComponent>();

            if (target == null)
            {
                target = mac;
                continue;
            }

            Color targetColor = target.GetComponent <ColorableComponent>().color;
            if (targetColor != cac.color)
            {
                hasMatch = false;
            }
        }

        return(hasMatch);
    }
Example #2
0
    /*
     * - Start, set last color and therefore set background
     * - game should exist but all game objects should be inactive
     * - on start, we initialize the game w/ prev color and next color, show game objects
     * - play
     * - on end game, we hide all the things and then turn off the game objects
     * - on restart, we start game again w/ prev color and next color, show game objects
     * - on end total, we hide all the things and then turn off the game objects
     *
     * - tutorial
     * - inherit from roundsystem with tutorialroundsystem, overriding some things
     * - use queue of colors, or hardcode them per level in color chooser function
     */

    public override void Update()
    {
        GameController gc = (Controller() as GameController);

        if (!gc.isPlaying)
        {
            return;
        }
        if (gc.initializeGame)
        {
            gc.initializeGame = false;
            GameObject.Destroy(RoundSystem.GetExistingMatch());
            ClearCubes();
            Reset(gc.round);
        }

        if (GetExistingMatch() != null)
        {
            return;
        }

        List <BaseComponent> matchableComponents = Pool.Instance.ComponentsForType(typeof(MatchableComponent));
        MatchableComponent   target = null;
        bool hasMatch = true;

        foreach (MatchableComponent mac in matchableComponents)
        {
            ColorableComponent cac = mac.GetComponent <ColorableComponent>();

            if (target == null)
            {
                target = mac;
                continue;
            }

            Color targetColor = target.GetComponent <ColorableComponent>().color;
            if (targetColor != cac.color)
            {
                hasMatch = false;
            }
        }

        if (target)
        {
            if (hasMatch)
            {
                BaseObject.AddComponent <MatchComponent>();
            }
        }
    }
Example #3
0
    public override void Update()
    {
        GameController gc = (Controller() as GameController);

        if (!IsPlaying())
        {
            return;
        }

        if (GetExistingMatch() != null)
        {
            return;
        }

        List <BaseComponent> matchableComponents = Pool.Instance.ComponentsForType(typeof(MatchableComponent));
        MatchableComponent   target = null;
        bool hasMatch = true;

        foreach (MatchableComponent mac in matchableComponents)
        {
            ColorableComponent cac = mac.GetComponent <ColorableComponent>();

            if (target == null)
            {
                target = mac;
                continue;
            }

            Color targetColor = target.GetComponent <ColorableComponent>().color;
            if (targetColor != cac.color)
            {
                hasMatch = false;
            }
        }

        if (target)
        {
            if (hasMatch)
            {
                BaseObject.AddComponent <MatchComponent>();
            }
        }
    }