// Update is called once per frame void FixedUpdate() { if (count < 0) { count = Mathf.RoundToInt(fireRate / Time.fixedDeltaTime); if (Input_scr.OnFire()) { GameObject a = Instantiate(bulletPrefab); Vector3 offset = new Vector3(Mathf.Cos((transform.localEulerAngles.z + 90) * Mathf.Deg2Rad), Mathf.Sin((transform.localEulerAngles.z + 90) * Mathf.Deg2Rad), 0); a.transform.position = transform.position + offset; a.transform.localEulerAngles = transform.localEulerAngles + new Vector3(0, 0, Random.Range(-bulletSpread, bulletSpread)); a.GetComponent <Bullet_scr>().startVelocity = GetComponent <Rigidbody2D>().velocity; a.GetComponent <Bullet_scr>().owner = gameObject; a.GetComponent <Bullet_scr>().speed = bulletSpeed; cam.GetComponent <Camera_scr>().ShakePosition(0.5f, 0.4f, 0, 1); GetComponent <AudioSource>().Play(); transform.position -= new Vector3(Mathf.Cos((transform.localEulerAngles.z + 90) * Mathf.Deg2Rad), Mathf.Sin((transform.localEulerAngles.z + 90) * Mathf.Deg2Rad), 0) * 0.2f; } else { } } count--; }
// Update is called once per frame void Update() { if (player == null) { player = GameObject.FindWithTag("Player"); return; } if (Input_scr.OnUIForwardPressed() && gameover == true) { SceneManager.LoadScene("Level"); Camera_scr.timeScale = 1; Time.timeScale = 1; } if (txtGame.activeSelf) { txtGame.transform.localPosition = Vector3.Lerp(txtGame.transform.localPosition, Vector3.zero, 0.1f); } if (txtOver.activeSelf) { txtOver.transform.localPosition = Vector3.Lerp(txtOver.transform.localPosition, Vector3.zero, 0.1f); } if (txtNext.activeSelf) { txtNext.GetComponent <RectTransform>().anchoredPosition = Vector3.Lerp(txtNext.GetComponent <RectTransform>().anchoredPosition, Vector3.zero, 0.1f); } }
void Update() { if (Input_scr.OnUIBackwardPressed()) { SceneManager.LoadScene("Menu"); } }
// Update is called once per frame void Update() { if (Input_scr.OnUIBackwardPressed()) { SceneManager.LoadScene("Menu"); Camera_scr.timeScale = 1; Time.timeScale = 1; } }
// Update is called once per frame void Update() { mousePos.x += Input_scr.GetCameraXMovement() * sensitivity; mousePos.y += Input_scr.GetCameraYMovement() * sensitivity; mousePos.x = Mathf.Clamp(mousePos.x, -32, 31); mousePos.y = Mathf.Clamp(mousePos.y, -31, 32); transform.localPosition = mousePos; }
void Update() { targetRotX += -Input_scr.GetCameraYMovement() * mouseSensitivity * Time.deltaTime; targetRotX = Mathf.Clamp(targetRotX, -clampAngle, clampAngle); rotX = Mathf.LerpAngle(rotX, targetRotX, lerpSpeed); Quaternion localRotation = Quaternion.Euler(rotX, 0, 0.0f); transform.localRotation = localRotation; transform.localPosition = Vector3.Lerp(transform.localPosition, targetPos, 0.3f); }
void Update() { if (Input.GetKeyDown(KeyCode.G)) { godMode = !godMode; } if (Input.GetKeyDown(KeyCode.H)) { SceneManager.LoadScene("Level" + (PowerUp_scr.level + 1).ToString()); PowerUp_scr.level += 1; } if (Input_scr.OnUIBackwardPressed()) { Application.LoadLevel("Menu"); } // Weapon if (Input_scr.OnKnifePressed() && knife.activeSelf == false) { StartCoroutine(Knife()); } // Rotation targetRotY += Input_scr.GetCameraXMovement() * mouseSensitivity * Time.deltaTime; rotY = Mathf.LerpAngle(rotY, targetRotY, lerpSpeed); Quaternion localRotation = Quaternion.Euler(0, rotY, 0.0f); transform.localRotation = localRotation; // Movement cc.SimpleMove(transform.forward * Input_scr.GetPlayerMovement().y * 12); cc.SimpleMove(transform.right * Input_scr.GetPlayerMovement().x * 12); // Gravity cc.SimpleMove(Vector3.down); // Sound if (Vector3.Distance(transform.position, prevPos) > 0.5f) { if (stepCount < 0) { stepCount = 18; GetComponent <AudioSource>().Play(); } prevPos = transform.position; } stepCount--; }
// Update is called once per frame void Update() { base.Update(); if (active == false) { return; } if (Input_scr.OnFirePressed() && reloadCount < 0) { reloadCount = Mathf.RoundToInt(reloadTime / Time.deltaTime); ammo--; RaycastHit hit; GameObject a = Instantiate(rocketPrefab); a.transform.position = cam.transform.position + cam.transform.forward * 0.5f; a.transform.eulerAngles = cam.transform.eulerAngles; a.GetComponent <Rocket_scr>().speed = 30f; // Juice aud.Play(); transform.localEulerAngles += new Vector3(0, 0, 20); transform.localPosition += new Vector3(0, 0, -0.2f); StartCoroutine(Flash()); cam.GetComponent <Camera_scr>().Shake(0.4f); effects.Flash(Color.white * 0.4f, 0.4f); } if (reloadCount >= 10) { targetPosition = new Vector3(0.3f, -0.5f, 1); targetAngles = new Vector3(0, -100, -30); } else { targetPosition = new Vector3(0.3f, -0.3f, 1); targetAngles = new Vector3(0, -100, 0); } reloadCount--; }
void Update() { if (Input_scr.OnUIForwardPressed()) { StartCoroutine("MenuSelection"); } if (menuPos != menuPosBuffer) { menuPosBuffer = menuPos; for (int i = 0; i < menuText.Length; i++) { menuText[i].GetComponent <Text>().color = Color.white; } menuText[menuPos].GetComponent <Text>().color = Color.black; selectorTargetPos = new Vector3(0, selectorStartPos.y + menuPos * -35, 0); selectorTargetSize = new Vector2(menuText[menuPos].GetComponent <RectTransform>().sizeDelta.x, 35); GetComponent <AudioSource>().clip = navClip; GetComponent <AudioSource>().Play(); } selector.transform.localPosition = Vector3.Lerp(selector.transform.localPosition, selectorTargetPos, 0.3f); selector.GetComponent <RectTransform>().sizeDelta = Vector2.Lerp(selector.GetComponent <RectTransform>().sizeDelta, selectorTargetSize, 10 * Time.deltaTime); if (menuPos < menuText.Length - 1 && Input_scr.OnUIDownPressed()) { menuPos++; } if (menuPos > 0 && Input_scr.OnUIUpPressed()) { menuPos--; } // Visual Juice if (timer < 0) { selector.GetComponent <RectTransform>().sizeDelta *= 1.2f; timer = 0.5f; } timer -= Time.deltaTime; }
void Update() { if (Input.GetKeyDown(KeyCode.X)) { SetupDefaultHighScores(); SceneManager.LoadScene("Highscores"); } if (count < 0) { count = 12; newHighScoreTxt.transform.localScale *= 1.05f; } count--; newHighScoreTxt.transform.localScale = Vector3.Lerp(newHighScoreTxt.transform.localScale, Vector3.one, 0.1f); if (Input_scr.OnUIBackwardPressed()) { SceneManager.LoadScene("Menu"); } }
new void Update() { base.Update(); if (active == false) { return; } if (Input_scr.OnFire() && count < 0) { count = Mathf.RoundToInt(fireRate / Time.deltaTime); ammo--; RaycastHit hit; if (Physics.Raycast(cam.transform.position + cam.transform.forward * 1, cam.transform.forward, out hit)) { if (hit.transform.tag == "Solid") { GameObject a = Instantiate(hitSplashPrefab); a.transform.position = hit.point; } else if (hit.transform.tag == "Enemy") { hit.transform.GetComponent <Enemy_scr>().DoDamage(10); } } // Juice aud.Play(); transform.localEulerAngles += new Vector3(0, 0, 20); transform.localPosition += new Vector3(0, 0, -0.2f); StartCoroutine(Flash()); cam.GetComponent <Camera_scr>().Shake(0.4f); effects.Flash(Color.white * 0.5f, 0.5f); } count--; }
void FixedUpdate() { if (multiplierCooldown > 0) { multiplierCooldown--; } else { multiplier = 1; } multiplier = Mathf.Clamp(multiplier, 1, maxMultiplier); multiplierCooldown = Mathf.Clamp(multiplierCooldown, 0, maxMultiplierCooldown); if (healthRegenRateCount < 0) { healthRegenRateCount = Mathf.RoundToInt(healthRegenRate / Time.fixedDeltaTime); if (health < maxHealth && healthRegenCooldownCount < 0) { health++; } } healthRegenCooldownCount--; healthRegenRateCount--; particles.transform.localEulerAngles = new Vector3(0, 0, Mathf.LerpAngle(particles.transform.localEulerAngles.z, particlesAngle, 0.1f)); // Steering if (Input_scr.OnLeft()) { rigid.AddTorque(turnSpeed); particlesAngle = -30; } else if (Input_scr.OnRight()) { rigid.AddTorque(-turnSpeed); particlesAngle = 30; } else { rigid.angularVelocity = 0; particlesAngle = 0; } // Movement if (Input_scr.OnThrottle()) { rigid.AddForce(transform.up * acceleration); particlesEM.enabled = true; GetComponents <AudioSource>()[1].mute = false; if (GetComponents <AudioSource>()[1].pitch > 0.8f) { GetComponents <AudioSource>()[1].pitch -= 0.02f; } } else { turnSpeedMultiplier = 1; particlesEM.enabled = false; GetComponents <AudioSource>()[1].mute = true; GetComponents <AudioSource>()[1].pitch = 1.6f; } if (Input_scr.OnThrottle() == false && rigid.velocity.magnitude > 10) { rigid.AddForce(-rigid.velocity * 0.5f); } if (Input_scr.OnThrottle()) { turnSpeedMultiplier = turnMultiplier; } else if (Input_scr.OnFire()) { turnSpeedMultiplier = 0.8f; } else { turnSpeedMultiplier = 1f; } // Constraints rigid.angularVelocity = Mathf.Clamp(rigid.angularVelocity, -maxTurnSpeed * turnSpeedMultiplier, maxTurnSpeed * turnSpeedMultiplier); if (rigid.velocity.magnitude > maxSpeed) { rigid.AddForce(-rigid.velocity * deceleration); } }