public override bool Shoot() { if (!canShoot) { return(false); } Vector3 pos = gameObject.transform.position; GameObject obj; float newAngleStart = transform.eulerAngles.y + angleStart; float newAngleEnd = transform.eulerAngles.y + angleEnd; for (int i = 0; i < numberBulletsPerBurst; ++i) { if ((Random.RandomRange(0f, 1f) > bulletTwoChance) && randomBullet) { obj = BulletManager2.GetNextBullet(); } else { obj = bulletManager.GetNextBullet(); } if (obj != null) { Vector3 velocity = MathG.DegreeToVector2D(((newAngleEnd - newAngleStart) / numberBulletsPerBurst * i) + newAngleStart, 1); obj.GetComponent <Bullet>().Reset(pos, new Vector3(velocity.x, 0, velocity.y)); } } timer = 0; canShoot = false; return(true); }
void Movement() { //print(charController.isGrounded); velocity.y += -gravity; if (bForward) { SetGFXRotation(); Vector2 norm = MathG.DegreeToVector2D(camPoint.transform.eulerAngles.y, 1); MoveByVelocity(norm); } else if (bBack) { SetGFXRotation(); Vector2 norm = MathG.DegreeToVector2D(camPoint.transform.eulerAngles.y - 180, 1); MoveByVelocity(norm); } else if (bRight) { SetGFXRotation(); Vector2 norm = MathG.DegreeToVector2D(camPoint.transform.eulerAngles.y + 90, 1); MoveByVelocity(norm); } else if (bLeft) { SetGFXRotation(); Vector2 norm = MathG.DegreeToVector2D(camPoint.transform.eulerAngles.y - 90, 1); MoveByVelocity(norm); } else { velocity = new Vector3(0, velocity.y, 0); } bJump = Input.GetKey(playerData.jump); if (bJump && charController.isGrounded) { velocity.y = playerData.jumpForce; } bool bSprint = Input.GetKey(playerData.sprint); if (bSprint) { Vector3 newVel = new Vector3(velocity.x, 0, velocity.z); newVel *= playerData.SprintMultiplier; newVel.y = velocity.y; velocity = newVel; } charController.Move(velocity * Time.fixedDeltaTime); if (charController.isGrounded) { velocity.y = 0; } if (velocity.x != 0 && velocity.z != 0) { animator.SetBool("IsRunning", true); } else { animator.SetBool("IsRunning", false); } }