// Start is called before the first frame update void Start() { //base start base.Start(); //Setup batteryscript references if (this.gameObject.tag != "Battery1") { otherBatteryRef = GameObject.FindGameObjectWithTag("Battery1").GetComponent <BatteryScript>(); } if (this.gameObject.tag != "Battery2") { otherBatteryRef = GameObject.FindGameObjectWithTag("Battery2").GetComponent <BatteryScript>(); } //Get the player script playerRef = GameObject.FindGameObjectWithTag("Player"); playerScript = playerRef.GetComponent <GameboyScript>(); //set the charging light to zero poweringLight = GetComponent <Light>(); poweringLight.intensity = 0f; SetEnergyDrainRate(0); }
// Start is called before the first frame update void Start() { base.Start(); batteryScriptRef1 = GameObject.FindGameObjectWithTag("Battery1").GetComponent <BatteryScript>(); batteryScriptRef2 = GameObject.FindGameObjectWithTag("Battery2").GetComponent <BatteryScript>(); screenLight = GetComponent <Light>(); screenLight.intensity = bScreenLightOn ? 30f : 0f; }
void OnTriggerStay (Collider other) { if (other.tag == "battery" && !player.isFrozen) { if (!hasBattery) { batteryScript = other.GetComponent<BatteryScript> (); hasBattery = true; } if (batteryScript.currentHealth < 100) { batteryScript.currentHealth += (healingRate * Time.deltaTime); batteryScript.healthHasChanged = true; } else { batteryScript.spanner.renderer.enabled = false; } if (batteryScript.isDestroyed) { hasBattery = false; } } }
void OnTriggerEnter (Collider other) { if (other.tag == "battery") { batteryScript = other.GetComponent<BatteryScript> (); batteryScript.FoW.enabled = true; if (batteryScript.currentHealth < 100) { batteryScript.spanner.renderer.enabled = true; } } if (other.gameObject == ally) { Mover m = other.GetComponent<Mover>(); if (m.isFrozen) { m.isFrozen = false; other.GetComponent<CharacterController>().enabled = true; m.electricity.enableEmission = false; ally.GetComponentInChildren<ShooterScript>().isFrozen = false; m.audio.Stop(); } } }
void OnTriggerStay(Collider other) { if (other.tag == "battery" && !isDead) { batteryScript = other.GetComponent<BatteryScript>(); if (batteryScript.currentHealth > 0) { batteryScript.currentHealth -= (damage * Time.deltaTime); if (!isQueen) { growthSlider.value += Time.deltaTime; if (growthSlider.value == growthRate) { if (isScout) { Instantiate(soldier, new Vector3(trans.position.x, trans.position.y + 0.6f, trans.position.z), trans.rotation); Destroy(gameObject); } else if (isSoldier) { Instantiate(queen, new Vector3(trans.position.x, trans.position.y + 0.6f, trans.position.z), trans.rotation); Destroy(gameObject); } growthSlider.value = 0; } } batteryScript.healthHasChanged = true; } else { if (isQueen) { batteryScript.Die(); } isChasingBattery = false; anim.Stop("Attack"); anim.Play("Walk"); } } }
// Use this for initialization void Start() { // Build the wall! mazeScale = wallBlockPrefab.transform.lossyScale.x; mazeOffset = new Vector3(-MazeArray.GetLength(0) * mazeScale / 2, -MazeArray.GetLength(1) * mazeScale / 2, 9.5f); startIndex = new Vector3(0, 1, 0); indexTracker = 0; TutorialMonster tutorialMonsterScript = tutorialMonster.GetComponent(typeof(TutorialMonster)) as TutorialMonster; bool useTutMon = false; for (int i = 0; i < MazeArray.GetLength(0); i++) { for (int j = 0; j < MazeArray.GetLength(1); j++) { switch (MazeArray[i, j]) { case '0': Vector3 wallPos = new Vector3(i * mazeScale, j * mazeScale, 0) + mazeOffset; Instantiate(wallBlockPrefab, wallPos, Quaternion.identity); break; case 'S': startIndex = new Vector3(i, j, 0); //Vector3 colliderPos = new Vector3(1 * mazeScale, j * mazeScale, 0) + mazeOffset; //GameObject trigger = Instantiate(colliderPrefab, colliderPos, Quaternion.identity); //trigger.GetComponent<DialogueTrigger>().dialogueIndex = indexTracker; //indexTracker++; break; case 'E': Vector3 goalPos = new Vector3(i * mazeScale, j * mazeScale, 0.15f) + mazeOffset; goal.transform.position = goalPos; break; case 'T': Vector3 colliderP = new Vector3(i * mazeScale, j * mazeScale, 0) + mazeOffset; GameObject trig = Instantiate(colliderPrefab, colliderP, Quaternion.identity); trig.GetComponent <DialogueTrigger>().dialogueIndex = indexTracker; indexTracker++; break; case 'B': Vector3 batteryPos = new Vector3(i * mazeScale, j * mazeScale, 0) + mazeOffset; GameObject newBattery = Instantiate(batteryPrefab, batteryPos, Quaternion.identity); BatteryScript batteryScript = newBattery.GetComponent(typeof(BatteryScript)) as BatteryScript; batteryScript.playerWithFlashlight = player.transform.parent.gameObject; break; case '*': Vector3 tutorialPos = new Vector3(i * mazeScale, j * mazeScale, 0) + mazeOffset; // Tell the monster to seek here and shift the lamp to this position; tutorialMonsterScript.positionToSeek = tutorialPos; tutorialPos.y += 1.5f; tutorialPos.x += 0.2f; tutorialLamp.transform.position = tutorialPos; break; case '!': Vector3 tutMonsterSpawn = new Vector3(i * mazeScale, j * mazeScale, 0) + mazeOffset; tutorialMonster.transform.position = tutMonsterSpawn; tutorialMonsterScript.positionToFlee = tutMonsterSpawn; useTutMon = true; Debug.Log("Tut mons start: " + tutMonsterSpawn); break; case 'M': Vector3 monsterSpawnTriggerLoc = new Vector3(i * mazeScale, j * mazeScale, 0) + mazeOffset; monsterSpawnTrigger.transform.position = monsterSpawnTriggerLoc; break; } //if (MazeArray[i, j] == '0') //{ // Vector3 wallPos = new Vector3(i * mazeScale, j * mazeScale, 0) + mazeOffset; // Instantiate(wallBlockPrefab, wallPos, Quaternion.identity); //} } } transform.position = (startIndex + mazeOffset); player.transform.Rotate(new Vector3(0, 0, -90f)); // Call this last if (useTutMon) { tutorialMonsterScript.SetCameraStartPosition(); } }
void Awake() { timeLeft = timeForTick; Battery = GameObject.Find("Battery"); batteryscript = Battery.GetComponent <BatteryScript> (); }
// Use this for initialization void Start() { Battery = GameObject.Find("Battery"); batteryscript = Battery.GetComponent <BatteryScript> (); }
void OnDestroy() { m_Instance = null; StopAllCoroutines(); }
void Awake() { m_Instance = this; }