//发射子弹 public void Shoot() { if (acd <= 0) { acd = attribute.ACD; bulletManager.AddBullet(bullet, this, shootPosition.position, dir); } }
void Update() { //get axis inputs float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); //send inputs to ship engine if (horizontal != 0) { engine.Turn(horizontal); } if (vertical != 0) { engine.Thrust(vertical); } //send input to bullet manager if (Input.GetKey(KeyCode.Space)) { bulletManager.AddBullet(engine.Position, engine.Heading); } }
private void Update() { switch (state) { case State.Normal: float moveX = 0f; float moveY = 0f; if (Input.GetKey(KeyCode.W)) { moveY = +1f; } if (Input.GetKey(KeyCode.S)) { moveY = -1f; } if (Input.GetKey(KeyCode.A)) { moveX = -1f; } if (Input.GetKey(KeyCode.D)) { moveX = +1f; } if (Input.GetKeyDown(KeyCode.Space)) { if (bulletManager != null) { bulletManager.AddBullet(bullet); } } moveDir = new Vector3(moveX, moveY).normalized; if (moveX != 0 || moveY != 0) { // Not idle lastMoveDir = moveDir; isMoving = true; } else { isMoving = false; } if (Input.GetKeyDown(KeyCode.F)) { isDashButtonDown = true; } /* * if (Input.GetKeyDown(KeyCode.Space)) * { * rollDir = lastMoveDir; * rollSpeed = rollSpeedValue; * state = State.Rolling; * } */ break; case State.Rolling: float rollSpeedDropMultiplier = 5f; rollSpeed -= rollSpeed * rollSpeedDropMultiplier * Time.deltaTime; float rollSpeedMinimum = 50f; if (rollSpeed < rollSpeedMinimum) { state = State.Normal; } break; } }