public void Update() { //ユーザー入力情報の取得 GetUserInput(); //State別処理 switch (state) { case State.Idle: break; case State.Play: #region 移動 moveDir = new Vector2(horizontalInput, verticalInput); if (moveDir.magnitude > 1f) { moveDir = moveDir.normalized; } transform.Translate(Time.deltaTime * moveDir * moveSpeed * SlowSpeed, Space.World); var arrowDir = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position; var angle = Mathf.Atan2(arrowDir.y, arrowDir.x) * Mathf.Rad2Deg; attackOrigin.transform.eulerAngles = new Vector3(0f, 0f, angle); #endregion 移動 #region ロックオン //ロックオンボタンでロックオンする敵を更新 if (lockOnInput) { lockOnEnemy = LockOn(); } //敵がいなかったら元に戻す if (lockOnEnemy == null) { dirHelper.position = defaultDirHelper.position; cursor.SetNormalColor(); targetSprite.enabled = false; } //敵がいたらそこにロックオン設定する else { dirHelper.position = lockOnEnemy.transform.position; cursor.SetLockOnColor(); target.position = lockOnEnemy.transform.position; targetSprite.enabled = true; } #endregion ロックオン #region 攻撃 DebugExtension.DrawCircle(attackOrigin.position, attackRadius, Color.green); if (leftHandAttackInput && leftGage > MIN_ATTACK_GAGE) { animator.SetTrigger("LeftAttack"); Attack(WhichHand.Left); } if (rightHandAttackInput && rightGage > MIN_ATTACK_GAGE) { animator.SetTrigger("RightAttack"); Attack(WhichHand.Right); } #endregion 攻撃 //ゲージUP GageUP(); //死んだら状態をDeadに if (HP <= 0) { state = State.Dead; } break; case State.Attacked: if (rigidbody2D.velocity.magnitude < Vector2.one.magnitude) { state = State.Play; } break; case State.Dead: //ゲームオーバーへ移行 if (rigidbody2D.velocity.magnitude < Vector2.one.magnitude) { Instantiate(exprPrefab, transform.position, Quaternion.identity); GetComponentsInChildren <SpriteRenderer>().ToList().ForEach(s => { s.enabled = false; }); GetComponentsInChildren <Collider2D>().ToList().ForEach(s => { s.enabled = false; }); Invoke("LoadGameOverScene", 3f); state = State.Idle; } break; default: state = State.Play; break; } }