void Awake() { Time.timeScale = 1; trans_GamePlayMusic = Instantiate(trans_GamePlayMusic) as Transform; script_GamePlayMusic = trans_GamePlayMusic.gameObject.GetComponent<StayAwakeSound>(); trans_EnterTheFocus = Instantiate(trans_EnterTheFocus) as Transform; script_EnterTheFocus = trans_EnterTheFocus.gameObject.GetComponent<StayAwakeSound>(); trans_FocusMode = Instantiate(trans_FocusMode) as Transform; script_FocusMode = trans_FocusMode.gameObject.GetComponent<StayAwakeSound>(); trans_SpeedBackUp = Instantiate(trans_SpeedBackUp) as Transform; script_SpeedBackUp = trans_SpeedBackUp.gameObject.GetComponent<StayAwakeSound>(); trans_PowerUpSpawn1 = Instantiate(trans_PowerUpSpawn1) as Transform; script_PowerUpSpawn1 = trans_PowerUpSpawn1.gameObject.GetComponent<PowerUpSpawn>(); trans_PowerUpSpawn2 = Instantiate(trans_PowerUpSpawn2) as Transform; script_PowerUpSpawn2 = trans_PowerUpSpawn2.gameObject.GetComponent<PowerUpSpawn>(); groundSpawnScript = groundSpawn.gameObject.GetComponent<SpawnScript>(); playerScript = player.gameObject.GetComponent<PlatformerCharacter2D>(); }
protected virtual void Awake() { if (manager == null) { manager = FindObjectOfType <PowerUpSpawn>(); } }
void Awake() { if (instance) { Debug.Log("There is two PowerUpSpawn Instances"); return; } instance = this; }
//overrides abstract method in parent public override void OnTriggerEnter2D(Collider2D col) { //destroys current gameObject during collision with playera if (col.CompareTag("Player")) { PowerUpSpawn.play(); DestroyAndMakeFalse(); player.PowerUp("Score", 10); } }
//virtual used so it can be called from child //auto called by child classes public virtual void Start() { player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>(); powerScript = GameObject.FindGameObjectWithTag("Powerup Spawn System").GetComponent <PowerUpSpawn>(); //sets value between min and max seconds that powerup can exist for minTime = 8f; maxTime = 12f; timer = Random.Range(minTime, maxTime); setTime = Time.time + timer; }
//how the function handles the power up action void SpawnPointHandler(PowerUpSpawn _p) { //adding to list SpawnList.Add(_p); }