diff --git a/popcorn/Assets/MyGame/Scenes/MiniGame/Prefabs/ProtoGame.prefab b/popcorn/Assets/MyGame/Scenes/MiniGame/Prefabs/ProtoGame.prefab index ffc32a6a..02dd243e 100644 --- a/popcorn/Assets/MyGame/Scenes/MiniGame/Prefabs/ProtoGame.prefab +++ b/popcorn/Assets/MyGame/Scenes/MiniGame/Prefabs/ProtoGame.prefab @@ -1494,6 +1494,7 @@ MonoBehaviour: speed: 5 jumpTime: 1.25 jumpHeight: 5 + fallTime: 0.5 hitTime: 1.5 hitWaitTime: 1 --- !u!61 &5804782809510212544 diff --git a/popcorn/Assets/MyGame/Scenes/MiniGame/Prefabs/Result.prefab b/popcorn/Assets/MyGame/Scenes/MiniGame/Prefabs/Result.prefab index 1624f3c5..fa7921a1 100644 --- a/popcorn/Assets/MyGame/Scenes/MiniGame/Prefabs/Result.prefab +++ b/popcorn/Assets/MyGame/Scenes/MiniGame/Prefabs/Result.prefab @@ -1115,7 +1115,7 @@ MonoBehaviour: materialAmountText: {fileID: 5034752974931089885} detailOffset: 250 progressDuration: 1.5 - waitButtonActive: 3 + waitButtonActive: 1.5 waitProgress: 1.5 --- !u!1 &5034752975247083714 GameObject: diff --git a/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs b/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs index 7522b17b..114c3918 100644 --- a/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs +++ b/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/Player.cs @@ -10,16 +10,20 @@ namespace MyGame.Scenes.MiniGame.Scripts [SerializeField] private float speed = 5f; [SerializeField] private float jumpTime = 1.25f; [SerializeField] private float jumpHeight = 5f; + [SerializeField] private float fallTime = 1f; [SerializeField] private float hitTime = 1.5f; [SerializeField] private float hitWaitTime = 1f; private bool isJump; private bool isPreHit; private readonly BoolReactiveProperty isHit = new BoolReactiveProperty(); private IDisposable hitDisposable; + private Coroutine jumpCoroutine; + private Vector3 basePos; private void Start() { isHit.AddTo(this); + basePos = transform.localPosition; } public void Move() @@ -39,10 +43,9 @@ namespace MyGame.Scenes.MiniGame.Scripts } isJump = true; - var cachePos = transform.localPosition; - this.CallLerp(jumpTime, t => + jumpCoroutine = this.CallLerp(jumpTime, t => { - transform.SetLocalPositionY(cachePos.y + Mathf.Sin(Mathf.PI * t) * jumpHeight); + transform.SetLocalPositionY(basePos.y + Mathf.Sin(Mathf.PI * t) * jumpHeight); }, () => { isJump = false; @@ -58,9 +61,16 @@ namespace MyGame.Scenes.MiniGame.Scripts } isPreHit = true; hitDisposable?.Dispose(); - // ジャンプが終わるのを待つ - hitDisposable = this.UpdateAsObservable().First(_ => !isJump).Subscribe(_ => + + StopCoroutine(jumpCoroutine); + var diffHeight = transform.localPosition.y - basePos.y; + jumpCoroutine = this.CallLerp(diffHeight == 0f ? 0f : fallTime, t => { + var half = 0.5f + t / 2; + transform.SetLocalPositionY(basePos.y + Mathf.Sin(Mathf.PI * half) * diffHeight); + }, () => + { + isJump = false; var orgRotation = transform.localRotation; var orgYAngle = orgRotation.eulerAngles.y; transform.rotation = Quaternion.identity; @@ -76,7 +86,7 @@ namespace MyGame.Scenes.MiniGame.Scripts isHit.Value = false; }); }); - }).AddTo(this); + }); } } } \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/ResultManager.cs b/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/ResultManager.cs index 70c0af5a..c3ddbab8 100644 --- a/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/ResultManager.cs +++ b/popcorn/Assets/MyGame/Scenes/MiniGame/Scripts/ResultManager.cs @@ -82,7 +82,9 @@ namespace MyGame.Scenes.MiniGame.Scripts #if UNITY_EDITOR recipePlaceData = prevPlaceScore < recipePlaceData.needScore ? recipePlaceData : null; #endif - if (recipePlaceData != null && placeScoreData.Score >= recipePlaceData.needScore) + var hasRecipeData = recipePlaceData != null; + var achievedRecipe = hasRecipeData && placeScoreData.Score >= recipePlaceData.needScore; + if (achievedRecipe) { if (!gameData.MyRecipes.Contains(recipePlaceData.recipeId)) { @@ -96,30 +98,25 @@ namespace MyGame.Scenes.MiniGame.Scripts gameObject.SetActive(true); titleObject.SetActive(true); detailObject.SetActive(true); + detailObject.transform.SetLocalPositionY(hasRecipeData ? defaultDetailObjectPos.y : detailOffset); // 商品獲得済みならレシピ非表示 - if (recipePlaceData is null) + if (hasRecipeData) { - // detailの表示位置変更 - detailObject.transform.SetLocalPositionY(detailOffset); - } - else - { - detailObject.transform.SetLocalPositionY(defaultDetailObjectPos.y); meterObject.SetActive(true); SetProgress((float)prevPlaceScore / recipePlaceData.needScore, false); this.CallWaitForSeconds(waitProgress, () => { SetProgress((float)placeScoreData.Score / recipePlaceData.needScore, true, () => { - if (placeScoreData.Score >= recipePlaceData.needScore) + if (achievedRecipe) { ShopItemExchangeView.ShowDialog(shopDataList.FirstOrDefault(data => data.itemId == recipePlaceData.recipeId && data.Category == ItemCategory.Recipe)); } }); }); } - this.CallWaitForSeconds(waitButtonActive, () => + this.CallWaitForSeconds(hasRecipeData ? waitProgress + waitButtonActive : waitButtonActive, () => { closeButton.gameObject.SetActive(true); retryButton.gameObject.SetActive(true);