Exemple #1
0
    public void Answer(Game5Choice choice5)

    {
        int correctAnswer = currentRandomize;

        if (choice5.Answer == correctAnswer)
        {
            currentRound++;
            if (!WrongBefore)
            {
                ScoreAll.Score++;
            }
            if (currentRound > 2)
            {
                state = Game5State.Wait;
                StartCoroutine(ForwardRoutine());
            }
            else
            {
                state = Game5State.Wait;
                StartCoroutine(WinRoutine());
            }
        }
        else
        {
            WrongBefore = true;
            choice5.GetComponent <Animation>().Play();
        }
    }
Exemple #2
0
    public void Update()
    {
        if (gameState == Game5State.Feeding)
        {
            FeedingLogic();
        }
        else if (gameState == Game5State.Dropping)
        {
            DroppingLogic();
        }

        void DroppingLogic()
        {
            if (clouds.All(x => x.CloudState == CloudState.Success) && won == false)
            {
                winLoseSequence.StartSequence(SequenceType.Win);
                won = true;
            }
        }

        void FeedingLogic()
        {
            foreach (Candy candy in candies)
            {
                if (candy.State == CandyState.Dragging)
                {
                    PointerEventData ped = candy.CurrentPointerEventData;

                    foreach (Cloud cloud in clouds)
                    {
                        //Debug.Log($" {cloud.name} {CheckPedInRect(cloud.selfRect, ped)}");
                        if (
                            candy.candyType == cloud.acceptingCandyType &&
                            cloud.CloudState == CloudState.Accepting &&
                            CheckPedInRect(cloud.selfRect, ped)
                            )
                        {
                            cloud.GetCandy();
                            candy.InactiveState();
                        }
                    }
                }
            }

            if (candies.All(x => x.State == CandyState.Inactive))
            {
                gameState = Game5State.Waiting;
                StartCoroutine(WaitingRoutine());
            }
        }
    }
Exemple #3
0
    IEnumerator StartRoundRoutine()
    {
        yield return(new WaitForSeconds(0.2f));

        currentRandomize = bag[currentRound];
        currentChoice    = choices[currentRandomize];
        animator.SetTrigger("Instruction");

        yield return(new WaitForSeconds(2));

        state              = Game5State.Shake;
        currentShake       = 0;
        previousFrameShake = Input.acceleration;
    }
Exemple #4
0
    IEnumerator WaitingRoutine()
    {
        yield return(new WaitForSeconds(2.7f));

        bool enough = clouds.All(c => c.candyGot >= c.targetCandy);

        if (enough)
        {
            gameState = Game5State.Dropping;
            foreach (Cloud c in clouds)
            {
                c.EnterDroppingState();
            }
        }
        else
        {
            gameState = Game5State.Feeding;
            foreach (Candy c in candies)
            {
                c.RestoreToActive();
            }
            NewRound();
        }
    }