void Awake() { _spriteRenderer = GetComponent<SpriteRenderer>(); OnLeftTeam = transform.position.x <= 14.5 ? true : false; _leftPlayerScript = GameObject.FindGameObjectWithTag("LeftPlayer").GetComponent<BasePlayer>(); _levelManagerScript = Camera.main.GetComponent<LevelManager>(); }
private void Awake() { //Check if Instance already exists if (Instance == null) { //if not, set Instance to this Instance = this; } //If Instance already exists and it's not this: else { if (Instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one Instance of a GameManager. Destroy(this.gameObject); } } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(this.gameObject); this._levelManager = this.GetComponent<LevelManager>(); this._uiManager = this.GetComponent<UIManager>(); this.InitGame(); }
// Use this for initialization void Start() { _slider = GameObject.FindObjectOfType<Slider>(); _slider.maxValue = 1; _slider.minValue = 0; _levelManager = GameObject.FindObjectOfType<LevelManager>(); _audioSource = GetComponent<AudioSource>(); _winLabel = GameObject.Find("WinBanner") as GameObject; _winLabel.SetActive(false); }
void Start() { _levelManager = FindObjectOfType<LevelManager>(); }
void OnTriggerEnter2D(Collider2D collider) { //Debug.Log("Trigger"); LevelManager.LoadLoseLevel(); }