// Update is called once per frame void Update() { if (Player.Staus == Staus.Win) { Win(); } else if (Player.Staus == Staus.Gaming) { int h = 0, v = 0; //处理位移矢量 { if (Input.GetKeyDown(KeyCode.D)) { h = 1; } else if (Input.GetKeyDown("a")) { h = -1; } else if (Input.GetKeyDown("w")) { v = 1; } else if (Input.GetKeyDown("s")) { v = -1; } } Player.Move(h, v); CameraMove.Move(h, v); //检测鼠标点击 if (Input.GetMouseButtonDown(1)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit2D hit = Physics2D.Raycast(new Vector2(ray.origin.x, ray.origin.y), Vector2.down); if (hit && hit.transform.tag == "Obs") { var item = hit.transform.name; Obs.Flag(item); } } } else if (Player.Staus == Staus.Lose) { Lose(); } }
// プレイヤーの移動 private void Move() { Vector3 inputVector = inputManager_.MoveInput(playerNumber_); Vector3 cameraForward = Vector3.Scale(camera_.transform.forward, new Vector3(1, 0, 1)).normalized; Vector3 moveForward = cameraForward * inputVector.z + camera_.transform.right * inputVector.x; moveDistance_ = moveForward * playerStatus_.MoveSpeed; rigidBody_.velocity = moveDistance_; camera_.Move(this.transform.position - lastPosition_); lastPosition_ = this.transform.position; }