Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        beatCooldownLeft -= Time.deltaTime;
        totalTime        += Time.deltaTime;

        if (beat < beatDelay && beatCooldownLeft + buffer <= 0)
        {
            beatCooldownLeft = (beat * beatCooldown) - totalTime;
            beat++;

            //UI stuff for countdown
            countdown.text = (beatDelay - beat).ToString();
            if (beat == beatDelay)
            {
                countdown.text = "";
            }

            //Debug.Log("Delay");
            animate();
        }

        else if (beat >= beatDelay)
        {
            if (illegalMove)
            {
                // the player lost
                //Debug.Log("Illegal Move");
            }

            else if (recievedInput && !playerMoved)
            {
                player.move(laneToMove);
                playerMoved = true;
            }

            if (!animated && beatCooldownLeft - buffer <= 0)
            {
                animate();
                animated = true;
            }

            if (beatCooldownLeft + buffer <= 0)
            {
                if (!recievedInput)
                {
                    // the player lost
                    //Debug.Log("No Move");
                }
                else if (illegalMove)
                {
                }
                ;

                //Debug.Log("Beat");

                projectileScript.move();

                bool playerCol = projectileScript.collisions(player.getLane(), 0, 2);
                bool enemyCol  = projectileScript.collisions(enemy.getLane(), ApplicationModel.height - 1, 1);
                if (playerCol && enemyCol)
                {
                    Debug.Log("DRAW");
                    FindObjectOfType <Text>().text = "DRAW";
                    FindObjectOfType <LaneClick>().setGameOver();
                }
                else if (playerCol)
                {
                    Debug.Log("YOU LOSE");
                    FindObjectOfType <Text>().text = "YOU LOSE";
                    //FindObjectOfType<SyncClient>().MeGameOver();
                    FindObjectOfType <LaneClick>().setGameOver();
                }
                else if (enemyCol)
                {
                    Debug.Log("YOU WIN");
                    FindObjectOfType <Text>().text = "YOU WIN";
                    FindObjectOfType <LaneClick>().setGameOver();
                }
                beat++;
                beatCooldownLeft = (beat * beatCooldown) - totalTime;
                reset();
            }
        }
    }