// Start is called before the first frame update void Start() { objSys = GameObject.Find("HUD").GetComponent <ObjectivesSystem>(); jamBar.SetMax(timeNeeded); jamBar.SetHealth(0); towerJammed = false; timer = 0; }
// Start is called before the first frame update public void Awake() { // Grab rigidbody and healthbars rb = GetComponent <Rigidbody2D>(); foreach (Transform child in transform) { if (child.gameObject.GetComponent <Billboard>() != null) { enemyHealth = child.gameObject.GetComponent <Billboard>(); healthBar = enemyHealth.transform.GetChild(0).GetComponent <HealthBar>(); defenseBar = enemyHealth.transform.GetChild(1).GetComponent <HealthBar>(); } } // Set health and center of mass if (CenterOfMass != null) { rb.centerOfMass = CenterOfMass; } if (defenseBar != null) { defenseBar.SetMax(defense); Color defenseColor = defenseBar.transform.GetChild(0).GetComponent <Image>().color; defenseColor.a = 2f / (1f + Mathf.Exp(-defense / 2)) - 1f; defenseBar.transform.GetChild(0).GetComponent <Image>().color = defenseColor; } if (maxHealth > 0) { health = maxHealth; } else { maxHealth = health; } if (healthBar != null) { healthBar.SetMax(maxHealth); } // Register explosion chain as a death effect if (hasExplosionChain) { explosionChain = GetComponent <ExplosionChain>(); } if (transform.gameObject.GetComponent <Player>() == null) { objSys = GameObject.Find("HUD").GetComponent <ObjectivesSystem>(); } }
// Time-based enemy spawner protected IEnumerator BattleController() { // Start battle with checkpoint if there's a checkpoint reached. for (int i = checkpointAt; i < battles.Length; i++) { // Start battle after timer since previous battle started, but only if previous battle has been finished. Battle battle = battles[i]; if (i > checkpointAt) { yield return(new WaitForSeconds(battle.timer)); Battle prevBattle = battles[i - 1]; yield return(new WaitUntil(() => prevBattle.TestBattleOver())); } // If it's the boss battle, delay a little before starting for dramatic effect. if (i == bossBattleId && i != checkpointAt) { StartCoroutine(FadeMixerGroup.Fade(mixer, "levelVolume", 2f, 0f)); yield return(new WaitForSeconds(bossWait)); } battle.StartBattle(); // Play level music or boss music depending on the battle if (i == checkpointAt && i != bossBattleId) { levelMusic.Play(); } else if (i == bossBattleId) { bossMusic.Play(); mixer.SetFloat("bossVolume", 0f); StartCoroutine(FadeMixerGroup.Fade(mixer, "bossVolume", 2f, 1f)); } // Save a checkpoint if battle is specified to have a checkpoint before it. if (battle.checkpointBefore) { if (objSys == null) { objSys = GameObject.Find("HUD").GetComponent <ObjectivesSystem>(); } checkpointAt = i; objSys.CheckpointUpdate(); Debug.Log("Current Phase: " + checkpointAt); } } }
void Awake() { objSys = GameObject.Find("HUD").GetComponent <ObjectivesSystem>(); }
// Start is called before the first frame update protected void Start() { objSys = GameObject.Find("HUD").GetComponent <ObjectivesSystem>(); hud = GameObject.Find("HUD").GetComponent <Sidebars>(); mixer.SetFloat("volume", Mathf.Log(PlayerPrefs.GetFloat("musicVolume", 0.8f)) * 20f); }