void GameStart()
    {
        isGameRunning = true;

        config.speed = 4f;
        generator.GenerateObstacles();
    }
    public void GameStart()
    {
        isGameRunning = true;

        config.speed = 4f;
        generator.GenerateObstacles();
        score = 0;
        gameStartUI.Hide();
        player.SetActive();
    }
Beispiel #3
0
    public void GameStart()
    {
        currentLevelIndex = 0;
        SetCurrentLevelConfirguration();

        isGameRunning = true;

        generator.GenerateObstacles();
        score = 0;
        gameStartUI.Hide();
        player.SetActive();
    }
    void Update()
    {
        if (!gameHasStarted && Input.GetMouseButton(0))
        {
            gameHasStarted = true;
        }

        if (Input.GetMouseButton(1))
        {
            obstacleGenerator.GenerateObstacles(70f);
        }
    }
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        // GameObject player = GameObject.FindWithTag ("Player");
        // playerController = player.GetComponent<PlayerController> ();
        cloudSpawner = GetComponentInChildren <CloudSpawner> ();
        GameObject water = GameObject.FindWithTag("Water");

        waterController = water.GetComponent <WaterController>();

        obstacleGenerator = GetComponentInChildren <ObstacleGenerator>();
        obstacleGenerator.GenerateObstacles(70f);
    }
    // Update is called once per frame
    void Update()
    {
        // if the player touches the screen for the first time set gameplaystart to true
        if (/*Input.touchCount > 0*/ Input.GetMouseButtonDown(0) && gameplayStart == false)
        {
            song.Play();
            gameplayStart = true;

            // spawn the platforms
            platforms[0] = Instantiate(platform, new Vector3(0, -1, 10.5f), Quaternion.identity);
            platforms[1] = Instantiate(platform, new Vector3(0, -1, 31.5f), Quaternion.identity);
            platforms[2] = Instantiate(platform, new Vector3(0, -1, 52.5f), Quaternion.identity);
        }

        // check if the gameplay loop can start
        if (gameplayStart)
        {
            // gameplay loop
            MovePlatforms();
            MoveObstacles();
            gen.GenerateObstacles();
        }
    }