Example #1
0
    private void Start()
    {
        lc = FindObjectOfType <LiquidCounter>();
        lc.waterCountChange.AddListener(UpdateWaterCountText);

        dm = FindObjectOfType <DistanceMeter>();
        dm.distanceCountChange.AddListener(UpdateDistanceProggres);

        cc = FindObjectOfType <CarController>();

        cc.flyTimeEvent.AddListener(FlyTimePopUp);

        CollectableItem.coinsCollected.AddListener(UpdateCoins);

        restartButton.onClick.AddListener(RestartGame);
        restartButton1.onClick.AddListener(RestartGame);
        pauseButton.onClick.AddListener(PauseGame);
        continueButton.onClick.AddListener(UnPauseGame);
        backToMenuButton.onClick.AddListener(BackToMainScreen);
        backToMenuButton1.onClick.AddListener(BackToMainScreen);
        backToMenuButton2.onClick.AddListener(BackToMainScreen);
        nextLevelButton.onClick.AddListener(RestartGame);

        endGamePanel.SetActive(false);

        currentLevelText.text = string.Format("Level {0}", GameController.Instance.gameData.currentLevel);

        UpdateCoins();
        StartGame();
    }
Example #2
0
    public void Start()
    {
        modulesParent = new GameObject("Map").transform;
        for (int i = 0; i < 3; i++)
        {
            GameObject mod = i == 1 ? startModule : ModulesPrefabs[0];

            var module = Instantiate(mod, modulesParent);
            module.transform.position = new Vector2(i * offsetX - offsetX, offsetY);
            modules.Add(module);
            modulesCounter++;
        }

        modulesCounter--;

        GameController.Instance.startGameEvent.AddListener(StartGame);
        player        = FindObjectOfType <CarController>().transform;
        distanceMeter = player.GetComponent <DistanceMeter>();

        //Calculate max modules in level
        distanceMeter.moduleFinishDistance = 100 + (GameController.Instance.gameData.currentLevel) * 25;
    }
Example #3
0
 public void Setup(DistanceMeter distanceMeter)
 {
     _distanceMetr = distanceMeter;
 }