void Awake() { if (instance) { Destroy(this); } else { instance = this; } }
private void Awake() { if (_instance == null) // burada bir bug var. AudioController da oluyor ama burada işlemiyor... { _instance = this; DontDestroyOnLoad(this.gameObject); } else { //Destroy(gameObject); } scoreText = GameObject.Find("ScoreText").GetComponent <TextMeshProUGUI>(); highScoreText = GameObject.Find("HighScoreText").GetComponent <TextMeshProUGUI>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>(); unityAds = GetComponent <InitializeAdsScript>(); DontDestroyOnLoad(this.gameObject); // }
private void Update() { PlayerPosition = transform.position; if (_colorsCollected.Count > 0) { TrailNeonies(); } if (CanMove) { if (Input.GetKeyDown(KeyCode.UpArrow)) { MovingDown = false; MovingUp = true; MovingLeft = false; MovingRight = false; } if (Input.GetKeyDown(KeyCode.DownArrow)) { MovingDown = true; MovingUp = false; MovingLeft = false; MovingRight = false; } if (Input.GetKeyDown(KeyCode.LeftArrow)) { MovingDown = false; MovingUp = false; MovingLeft = true; MovingRight = false; } if (Input.GetKeyDown(KeyCode.RightArrow)) { MovingDown = false; MovingUp = false; MovingLeft = false; MovingRight = true; } Move(Direction.Up); Move(Direction.Down); Move(Direction.Left); Move(Direction.Right); Teleport(); } if (!_canBoost) { BoostCooldown(); } if (GameOver) { CanMove = false; MovingDown = false; MovingUp = false; MovingLeft = false; MovingRight = false; SaveStats(); DestroyTail(); transform.position = Vector3.zero; foreach (var chaser in _chaserObjects) { Destroy(chaser); } _chaserObjects.Clear(); if (GamesPlayed > 0 && GamesPlayed % 3 == 0 && adWasPlayed == false) { InitializeAdsScript.ShowInterstitialAd(); adWasPlayed = true; } } }