コイン追加エフェクト処理追加
This commit is contained in:
parent
2936d81823
commit
04d9ed3e90
|
|
@ -176,9 +176,10 @@ public class MarketManager : MonoBehaviour
|
|||
market.SellObservable.Subscribe(coin =>
|
||||
{
|
||||
// コイン獲得エフェクト
|
||||
CoinEffect(coin);
|
||||
CoinManager.Instance.AddCoinWithEffect(coin, () => { });
|
||||
|
||||
CoinEffect(coin, pos =>
|
||||
{
|
||||
CoinManager.Instance.AddCoinWithEffect(coin, pos);
|
||||
});
|
||||
blueView.SellAction();
|
||||
}).AddTo(this);
|
||||
|
||||
|
|
@ -269,11 +270,16 @@ public class MarketManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private void CoinEffect(int count)
|
||||
private void CoinEffect(int count, Action<Vector3> onComplete = null)
|
||||
{
|
||||
var effect = Instantiate(coinPrefab, Vector3.zero, Quaternion.identity, rootTransform);
|
||||
effect.GetComponentInChildren<TextMeshProUGUI>().text = count.ToString();
|
||||
Destroy(effect.gameObject, 1f);
|
||||
this.CallWaitForSeconds(1f, () =>
|
||||
{
|
||||
onComplete?.Invoke(effect.GetChild(0).position);
|
||||
Destroy(effect.gameObject);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void GenerateCustomer(CustomerController controller)
|
||||
|
|
|
|||
|
|
@ -42,28 +42,36 @@ public class CoinManager : SingletonMonoBehaviour<CoinManager>
|
|||
coinCountText.CountUpAnimation(coinTextFormat, ownCoin, duration);
|
||||
}
|
||||
|
||||
public void AddCoinWithEffect(int count, Action callback = null)
|
||||
public void AddCoinWithEffect(int count, Vector3 pos, Action onComplete = null)
|
||||
{
|
||||
ownCoin += count;
|
||||
// 生成枚数決定
|
||||
// 生成ポジション決め、生成
|
||||
InstantiateEffeect(coinPrefab, count, Vector3.zero, coinIconTransform.position, () =>
|
||||
InstantiateEffect(coinPrefab, count, pos, coinIconTransform.position, () =>
|
||||
{
|
||||
coinCountText.CountUpAnimation(coinTextFormat, ownCoin, duration);
|
||||
callback?.Invoke();
|
||||
onComplete?.Invoke();
|
||||
});
|
||||
}
|
||||
|
||||
private void InstantiateEffeect(RectTransform prefab, int count, Vector3 from, Vector3 to, Action callback)
|
||||
private void InstantiateEffect(RectTransform prefab, int count, Vector3 from, Vector3 to, Action callback)
|
||||
{
|
||||
var coinEffect = Instantiate(prefab, from, Quaternion.identity, rootTransform);
|
||||
var animator = coinEffect.GetComponent<Animator>();
|
||||
this.CallLerp(1f, f =>
|
||||
{
|
||||
coinEffect.position = Vector3.Lerp(from, to, f * f);
|
||||
}, () =>
|
||||
{
|
||||
this.CallWaitForSeconds(0f, () =>
|
||||
{
|
||||
// アニメ50フレーム
|
||||
this.CallWaitForSeconds(1.0f, () => {
|
||||
// コインが到着したらSEとバイブ再生。コインはずみアニメーションを再生
|
||||
animator.SetTrigger("Effect");
|
||||
Destroy(coinEffect.gameObject, 1f);
|
||||
VibrationManager.Instance.PlayVibrationOnceWeak();
|
||||
coinAnimator.SetTrigger(Add);
|
||||
// coinAnimator.SetTrigger(Add);
|
||||
SoundManager.Instance.PlaySE("se_coin_get");
|
||||
callback.Invoke();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void SubCoin(int coin){
|
||||
|
|
|
|||
Loading…
Reference in New Issue