Merge branch 'feature/addMiniGame' of bitbucket.org:usaya/popcorn into feature/addMiniGame

This commit is contained in:
koya_15 2022-06-28 15:02:33 +09:00
commit 77ff693410
4 changed files with 25 additions and 17 deletions

View File

@ -1494,6 +1494,7 @@ MonoBehaviour:
speed: 5 speed: 5
jumpTime: 1.25 jumpTime: 1.25
jumpHeight: 5 jumpHeight: 5
fallTime: 0.5
hitTime: 1.5 hitTime: 1.5
hitWaitTime: 1 hitWaitTime: 1
--- !u!61 &5804782809510212544 --- !u!61 &5804782809510212544

View File

@ -1115,7 +1115,7 @@ MonoBehaviour:
materialAmountText: {fileID: 5034752974931089885} materialAmountText: {fileID: 5034752974931089885}
detailOffset: 250 detailOffset: 250
progressDuration: 1.5 progressDuration: 1.5
waitButtonActive: 3 waitButtonActive: 1.5
waitProgress: 1.5 waitProgress: 1.5
--- !u!1 &5034752975247083714 --- !u!1 &5034752975247083714
GameObject: GameObject:

View File

@ -10,16 +10,20 @@ namespace MyGame.Scenes.MiniGame.Scripts
[SerializeField] private float speed = 5f; [SerializeField] private float speed = 5f;
[SerializeField] private float jumpTime = 1.25f; [SerializeField] private float jumpTime = 1.25f;
[SerializeField] private float jumpHeight = 5f; [SerializeField] private float jumpHeight = 5f;
[SerializeField] private float fallTime = 1f;
[SerializeField] private float hitTime = 1.5f; [SerializeField] private float hitTime = 1.5f;
[SerializeField] private float hitWaitTime = 1f; [SerializeField] private float hitWaitTime = 1f;
private bool isJump; private bool isJump;
private bool isPreHit; private bool isPreHit;
private readonly BoolReactiveProperty isHit = new BoolReactiveProperty(); private readonly BoolReactiveProperty isHit = new BoolReactiveProperty();
private IDisposable hitDisposable; private IDisposable hitDisposable;
private Coroutine jumpCoroutine;
private Vector3 basePos;
private void Start() private void Start()
{ {
isHit.AddTo(this); isHit.AddTo(this);
basePos = transform.localPosition;
} }
public void Move() public void Move()
@ -39,10 +43,9 @@ namespace MyGame.Scenes.MiniGame.Scripts
} }
isJump = true; isJump = true;
var cachePos = transform.localPosition; jumpCoroutine = this.CallLerp(jumpTime, t =>
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; isJump = false;
@ -58,9 +61,16 @@ namespace MyGame.Scenes.MiniGame.Scripts
} }
isPreHit = true; isPreHit = true;
hitDisposable?.Dispose(); 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 orgRotation = transform.localRotation;
var orgYAngle = orgRotation.eulerAngles.y; var orgYAngle = orgRotation.eulerAngles.y;
transform.rotation = Quaternion.identity; transform.rotation = Quaternion.identity;
@ -76,7 +86,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
isHit.Value = false; isHit.Value = false;
}); });
}); });
}).AddTo(this); });
} }
} }
} }

View File

@ -82,7 +82,9 @@ namespace MyGame.Scenes.MiniGame.Scripts
#if UNITY_EDITOR #if UNITY_EDITOR
recipePlaceData = prevPlaceScore < recipePlaceData.needScore ? recipePlaceData : null; recipePlaceData = prevPlaceScore < recipePlaceData.needScore ? recipePlaceData : null;
#endif #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)) if (!gameData.MyRecipes.Contains(recipePlaceData.recipeId))
{ {
@ -96,30 +98,25 @@ namespace MyGame.Scenes.MiniGame.Scripts
gameObject.SetActive(true); gameObject.SetActive(true);
titleObject.SetActive(true); titleObject.SetActive(true);
detailObject.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); meterObject.SetActive(true);
SetProgress((float)prevPlaceScore / recipePlaceData.needScore, false); SetProgress((float)prevPlaceScore / recipePlaceData.needScore, false);
this.CallWaitForSeconds(waitProgress, () => this.CallWaitForSeconds(waitProgress, () =>
{ {
SetProgress((float)placeScoreData.Score / recipePlaceData.needScore, true, () => 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)); 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); closeButton.gameObject.SetActive(true);
retryButton.gameObject.SetActive(true); retryButton.gameObject.SetActive(true);