Ejemplo n.º 1
0
    float gameOverRange = 15F;             //X Position the card should be in to cause game over.

    // Use this for initialization
    void Start()
    {
        cardScene   = this;
        gameState   = GameState.StartingUp;
        energyBalls = 1;

        tools = Tools.Me;
        if (tools == null)
        {
            Debug.LogWarning("Tools reference in GameManager is null");
        }

        guiMan = CardSceneGui.Me;
        if (guiMan == null)
        {
            Debug.LogWarning("GuiMan reference in GameManager is null");
        }

        cardMan = CardMan.Me;
        if (cardMan == null)
        {
            Debug.LogWarning("CardMan reference in GameManager is null");
        }

        StartCoroutine(InitiateWave_cr());
    }
Ejemplo n.º 2
0
    public IEnumerator GameWon_cr()
    {
        SFXMan.StopSong();
        SFXMan.sfx_CardWaveCleared.Play();
        CardSceneGui.DisplayGuiMessage("Wave cleared! ", Color.white);
        gameState = GameState.GameWon;
        MainGame.Wave++;
        yield return(new WaitForSeconds(4));

        StartCoroutine(InitiateWave_cr());
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Checks if both cards flipped are a match and removes them if so.
    /// </summary>
    /// <returns>The cards_cr.</returns>
    /// <param name="cardClicked">Card clicked.</param>
    IEnumerator MatchCards_cr(Card cardClicked)
    {
        canCardBeFlipped = false;

        StartCoroutine(cardClicked.FlipToFront_cr());

        if (SelectedCard == null)
        {
            SelectedCard = cardClicked;
        }
        else
        {
            if (SelectedCard != null && SelectedCard != cardClicked)
            {
                yield return(new WaitForSeconds(0.5F));

                if (SelectedCard.cardName == cardClicked.cardName)
                {
                    //REPORT SCORE AND DESTROY CARDS
                    SelectedCard.RemoveCardCardAfterDelay();
                    cardClicked.RemoveCardCardAfterDelay();
                    SelectedCard               = null;
                    CardSceneGui.Me.Score      = 100;
                    CardScene.GravityStrength -= 0.3f;                                                             //Slow speed
                    CardSceneGui.DisplayGuiMessage("Speed -30", Color.yellow);


                    // REALIGN CARDS
                    yield return(StartCoroutine(RealignCards_cr()));

                    //Check For Game Win
                    if (Card.Cards.Count < 1 && CardScene.cardScene.gameState == CardScene.GameState.GameOn)
                    {
                        StartCoroutine(CardScene.cardScene.GameWon_cr());
                    }
                }
                else
                {
                    SFXMan.sfx_Error.Play();
                    CardSceneGui.DisplayGuiMessage("Speed +10", Color.white);
                    CardScene.GravityStrength += 0.1f;
                    unselectCardsNextClick     = true;
                }
            }
        }
        canCardBeFlipped = true;
    }
Ejemplo n.º 4
0
    IEnumerator PauseGravity_cr()
    {
        IsGravityPaused = true;

        var isSlowingDown     = true;
        var normalGravity     = GravityStrength;
        var lerpStartTime     = Time.time;
        var timeLerping       = Time.time - lerpStartTime;
        var startStopDuration = 1f;
        var progress          = timeLerping / startStopDuration;

        //SLOW DOWN
        CardSceneGui.DisplayGuiMessage("GRAVITY PAUSE!", Color.cyan);
        while (isSlowingDown && progress < startStopDuration)
        {
            GravityStrength = Mathf.Lerp(normalGravity, 0, progress);
            timeLerping    += Time.deltaTime;
            progress        = timeLerping / startStopDuration;
            yield return(null);
        }
        isSlowingDown = false;
        lerpStartTime = Time.time;
        timeLerping   = Time.time - lerpStartTime;
        progress      = timeLerping / startStopDuration;

        yield return(new WaitForSeconds(GravityPauseDuration));

        //RESUME SPEED
        CardSceneGui.DisplayGuiMessage("HERE WE GO AGAIN!", Color.cyan);
        while (!isSlowingDown && progress < startStopDuration)
        {
            GravityStrength = Mathf.Lerp(0, normalGravity, progress);
            timeLerping    += Time.deltaTime;
            progress        = timeLerping / startStopDuration;
            yield return(null);
        }



        IsGravityPaused = false;
    }
Ejemplo n.º 5
0
    IEnumerator InitiateWave_cr()
    {
        //Present wave
        SFXMan.sfx_StartWave.Play();
        var wave = MainGame.Wave;

        CardSceneGui.DisplayGuiMessage(string.Format("Clear {1} cards!", wave, wave * (CardMan.cardPairsPerWave * 2)), Color.white);

        yield return(new WaitForSeconds(3));

        SFXMan.PlayAsSong(SFXMan.sng_CardSong);

        dangerState = DangerState.VerySafe;

        GravityStrength = 1f;

        InvokeRepeating("SlowUpdate", 0, 1F);

        CardMan.SetupWave();

        gameState = GameState.GameOn;
    }
Ejemplo n.º 6
0
 public void Awake()
 {
     Me = this;
 }