/// <summary> /// Update is called once per frame /// Calls the GameOver method if the game is over /// </summary void Update() { if (IsGameOver()) { GameOver(); } else { frames += 1; string action = CortexFacade.GetAction(); if (action != "neutral") { attentionFrames += 1; IncreaseHealth(0.1f); attentionButton.GetComponent <Image>().color = new Color(0f, 200f / 255f, 0f, 175 / 255f); neutralButton.GetComponent <Image>().color = new Color(106f / 255f, 106f / 255f, 106f / 255f, 175 / 255f); // Update button color } else { attentionButton.GetComponent <Image>().color = new Color(106f / 255f, 106f / 255f, 106f / 255f, 175 / 255f); neutralButton.GetComponent <Image>().color = new Color(200f / 255f, 0f, 0f, 175 / 255f); // Update button color } } }
/// <summary> /// Controls the shooting mechanism of the game using Raycasts /// </summary> void Shoot() { RaycastHit hit; if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit)) { Target target = hit.transform.GetComponent <Target>(); if (target != null) { string Action = CortexFacade.GetAction(); float damage = baseDamage; if (Action != "neutral") { damage *= 5.0f; } target.TakeDamage(damage); } GameObject tempFlash; GameObject impactEffect; tempFlash = Instantiate(muzzleFlash, barrelLocation.position, barrelLocation.rotation); impactEffect = Instantiate(impactFlash, hit.point, Quaternion.LookRotation(hit.normal)); audioData = GetComponent <AudioSource>(); if (audioData != null) { audioData.Play(0); } Destroy(tempFlash, 2); Destroy(impactEffect, 2); } }
// Update is called once per frame void Update() { string Action = CortexFacade.GetAction(); if (Action != "neutral") { float x = box.transform.position.x + 0.01f; float y = 0; float z = 0; box.transform.position = new Vector3(x, y, z); } }