Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        _levelManager = GameObject.Find("Mihir_LevelManager").GetComponent <Mihir_LevelManager>();
        StartCoroutine(SpawnRoutine());

        spawnY = screenEdgeHeight;
    }
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(this.gameObject);
        }
        else
        {
            Destroy(this.gameObject);
        }

        //setting the level + leveltime for the first level
        level     = 1;
        levelTime = 20f;

        //calculating the length and position of the bar
        float barScaleX = levelTime / 10;
        float barPosX   = (.5f * barScaleX) - 6;



        TotalDistance.transform.localScale = new Vector3(barScaleX, TotalDistance.transform.localScale.y, TotalDistance.transform.localScale.z);
        TotalDistance.transform.position   = new Vector3(barPosX, TotalDistance.transform.position.y, TotalDistance.transform.position.z);

        rend        = TotalDistance.GetComponent <Renderer>();
        barLeftEnd  = rend.bounds.min.x;
        barRightEnd = rend.bounds.max.x;

        //reseting the marker to the left end of the bar
        TravelledDistance.transform.position = new Vector3(barLeftEnd, TravelledDistance.transform.position.y, TravelledDistance.transform.position.z);

        TotalDistance.gameObject.SetActive(true);
        TravelledDistance.gameObject.SetActive(true);
    }
    // Start is called before the first frame update
    void Start()
    {
        _spawnManager = GameObject.Find("Mihir_Spawn_Manager").GetComponent <Mihir_SpawnManager>();
        _levelManager = GameObject.Find("Mihir_LevelManager").GetComponent <Mihir_LevelManager>();
        _spaceship    = GameObject.Find("Mihir_Spaceship").GetComponent <Mihir_Spaceship>();


        _livesText.text = "Lives: " + 3;

        _gameOverText.gameObject.SetActive(false);

        divider1.transform.position = new Vector3(dividerX, dividerY1, 0);
        divider2.transform.position = new Vector3(dividerX, dividerY2, 0);
    }