// IEnumerator CamMoveToTips() // { // yield return new WaitForSeconds(1); // Ray ray = Camera.main.ScreenPointToRay(new Vector2(200, 100)); // RaycastHit hitInfo = new RaycastHit(); // if (Physics.Raycast(ray, out hitInfo)) // if (hitInfo.collider.tag == "Terrain" || hitInfo.collider.tag == "Piece" || hitInfo.collider.tag == "Wall") // { // cameraController.SetTarget(hitInfo.point); // playManager.SendEvent(PlayEventType.CONTROL_NAVIGATE); // } // } void FixedUpdate() { // controller Vector3 force = new Vector3(0, 0, 0); // force += new Vector3(1, 0, -1) * Input.GetAxis("Horizontal"); // force += new Vector3(1, 0, 1) * Input.GetAxis("Vertical"); if (Input.GetKey(KeyCode.W)) { force += new Vector3(1, 0, 1); } if (Input.GetKey(KeyCode.S)) { force -= new Vector3(1, 0, 1); } if (Input.GetKey(KeyCode.A)) { force -= new Vector3(1, 0, -1); } if (Input.GetKey(KeyCode.D)) { force += new Vector3(1, 0, -1); } if (speed.magnitude > 0) { cameraController.SetTarget(transform.position); } speed += acc * Vector3.Normalize(force) * Time.deltaTime * (onMist || onWall ? mistCost : 1); if (!onGround) { speedY += -1 * 3 * Time.deltaTime; speedY = Mathf.Clamp(speedY, -maxSpeed, 2 * maxSpeed); } else { // rigidbodyComponent.velocity -= new Vector3(0, rigidbodyComponent.velocity.y, 0); speedY = 0; if (!onWall && Input.GetButton("Jump")) { // speedY = 3.3f * (onMist ? mistCost : 1); speedY = 3.3f; } } speed = Vector3.ClampMagnitude(speed, maxSpeed * (onMist || onWall ? mistCost : 1)); transform.position += (speed + new Vector3(0, speedY, 0)) * Time.deltaTime; if (force.magnitude <= 0) { speed = Vector3.ClampMagnitude(speed, Mathf.Clamp(speed.magnitude - drag * Time.deltaTime, 0, speed.magnitude)); } else { playManager.SendEvent(PlayEventType.PLAYER_MOVE); transform.rotation = Quaternion.LookRotation(force, Vector3.up); } // damage if (onMist) { mistHurtingTime += Time.fixedDeltaTime; if (mistHurtingTime > mistHurtingPeriod) { //do damage if (playerStatsManager.curHP > mistDamage) { playerStatsManager.TakeDamage(mistDamage); } else { playerStatsManager.TakeDamage(mistDamage / 10); } mistHurtingTime -= mistHurtingPeriod; } } else { mistHurtingTime = 0; } if (!playerStatsManager.IsAlive()) { transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(Vector3.down, Vector3.forward), Time.fixedUnscaledDeltaTime * 10); } else { transform.rotation = Quaternion.identity; } }