大量注文達成後エフェクト追加
This commit is contained in:
parent
96b9fe0ecb
commit
c0188e8dc9
|
|
@ -1,5 +1,71 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &53576605555575286
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3810231873902644615}
|
||||
- component: {fileID: 7349043582791027687}
|
||||
- component: {fileID: 2603354116673325400}
|
||||
m_Layer: 0
|
||||
m_Name: Manager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &3810231873902644615
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 53576605555575286}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 137127163878687691}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &7349043582791027687
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 53576605555575286}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b717b0dc2b6a43acbc198782b772556f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
settingButton: {fileID: 137127162501263384}
|
||||
missionButton: {fileID: 7425175309417248097}
|
||||
informationButton: {fileID: 137127164298331678}
|
||||
missionIndicator: {fileID: 1937919369583800779}
|
||||
--- !u!114 &2603354116673325400
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 53576605555575286}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 645472548f1a479d8bd78b7934166f7f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
coinPrefab: {fileID: 6462833990326625811, guid: f41554a7122e9314ea6c22282d4c7be0,
|
||||
type: 3}
|
||||
heartPrefab: {fileID: 4993368112858175913, guid: 98690cb45240c4c4da24017b44a03e84,
|
||||
type: 3}
|
||||
coinCount: 5
|
||||
heartCount: 5
|
||||
--- !u!1 &137127162501263386
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -666,7 +732,6 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 137127163878687691}
|
||||
- component: {fileID: 252357910248425631}
|
||||
m_Layer: 5
|
||||
m_Name: Header
|
||||
m_TagString: Untagged
|
||||
|
|
@ -688,6 +753,7 @@ RectTransform:
|
|||
- {fileID: 137127164258565651}
|
||||
- {fileID: 137127164255914078}
|
||||
- {fileID: 137127162834349545}
|
||||
- {fileID: 3810231873902644615}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
|
@ -696,22 +762,6 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &252357910248425631
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 137127163878687690}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b717b0dc2b6a43acbc198782b772556f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
settingButton: {fileID: 137127162501263384}
|
||||
missionButton: {fileID: 7425175309417248097}
|
||||
informationButton: {fileID: 137127164298331678}
|
||||
missionIndicator: {fileID: 1937919369583800779}
|
||||
--- !u!1 &137127164225778479
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -840,6 +890,8 @@ MonoBehaviour:
|
|||
slider: {fileID: 137127162796222319}
|
||||
heartLevel: {fileID: 137127163584464916}
|
||||
maxObject: {fileID: 4558166201082566443}
|
||||
duration: 0.5
|
||||
bulkOrderAchievedEffect: {fileID: 2603354116673325400}
|
||||
--- !u!1 &137127164258565650
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -899,6 +951,7 @@ MonoBehaviour:
|
|||
coinAnimator: {fileID: 4683425562393467656}
|
||||
coinPrefab: {fileID: 6519287602467882899, guid: 283c4ac7154b55546841276b29f0e301,
|
||||
type: 3}
|
||||
bulkOrderAchievedEffect: {fileID: 2603354116673325400}
|
||||
coinUpDuration: 0.5
|
||||
coinMoveDuration: 0.5
|
||||
rootTransform: {fileID: 0}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,111 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using UniRx;
|
||||
using UniRx.Triggers;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace MyGame.Scenes.Main.Scripts
|
||||
{
|
||||
public class BulkOrderAchievedEffect : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform coinPrefab;
|
||||
[SerializeField] private Transform heartPrefab;
|
||||
[SerializeField] private int coinCount = 5;
|
||||
[SerializeField] private int heartCount = 5;
|
||||
[SerializeField] private float minCurve = 100f;
|
||||
[SerializeField] private float maxCurve = 400f;
|
||||
[SerializeField] private float waitTime = .3f;
|
||||
[SerializeField] private float curveTime = .5f;
|
||||
[SerializeField] private float linerTime = .5f;
|
||||
private readonly Subject<Unit> effectCompleteSubject = new Subject<Unit>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SetupDebugEffect();
|
||||
}
|
||||
|
||||
public void PlayCoinEffect(Vector3 beginPos, Vector3 goalPos, Action onComplete = null)
|
||||
{
|
||||
// 最後のeffectが終わった後1度だけonComplete
|
||||
effectCompleteSubject.Take(coinCount).Subscribe(_ => { }, () =>
|
||||
{
|
||||
onComplete?.Invoke();
|
||||
}).AddTo(this);
|
||||
for (int i = 0; i < coinCount; i++)
|
||||
{
|
||||
this.CallWaitForSeconds(.1f * i, () =>
|
||||
{
|
||||
var coin = Instantiate(coinPrefab, beginPos, Quaternion.identity, transform);
|
||||
coin.GetComponent<Animator>()?.Play("BulkOrde_EarnedCoins");
|
||||
Effect(coin, goalPos, () => effectCompleteSubject.OnNext(Unit.Default));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayHeartEffect(Vector3 beginPos, Vector3 goalPos, Action onComplete = null)
|
||||
{
|
||||
// 最後のeffectが終わった後1度だけonComplete
|
||||
effectCompleteSubject.Take(heartCount).Subscribe(_ => { }, () =>
|
||||
{
|
||||
onComplete?.Invoke();
|
||||
}).AddTo(this);
|
||||
Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(.1f))
|
||||
.Take(heartCount)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
var heart = Instantiate(heartPrefab, beginPos, Quaternion.identity, transform);
|
||||
Effect(heart, goalPos, () => effectCompleteSubject.OnNext(Unit.Default));
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
private void Effect(Transform target, Vector3 goalPos, Action onComplete = null)
|
||||
{
|
||||
// localPosじゃなくて worldでやりたい
|
||||
var animator = target.GetComponent<Animator>();
|
||||
var direction = Random.value <= .5f ? -1 : 1;
|
||||
var depth = Random.Range(minCurve, maxCurve);
|
||||
this.CallWaitForSeconds(waitTime, () =>
|
||||
{
|
||||
animator.speed = 0f;
|
||||
var initPos = target.localPosition;
|
||||
this.CallLerp(curveTime, f =>
|
||||
{
|
||||
var x = Mathf.Lerp(-1, 1, f) * direction;
|
||||
target.localPosition = initPos + new Vector3(f * direction * depth, x * x * depth - depth);
|
||||
}, () =>
|
||||
{
|
||||
this.CallLerp(linerTime, f =>
|
||||
{
|
||||
var pos = target.position;
|
||||
target.position = Vector2.Lerp(pos, goalPos, f);
|
||||
}, () =>
|
||||
{
|
||||
animator.speed = 1f;
|
||||
onComplete?.Invoke();
|
||||
Destroy(target.gameObject, 5f);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
[Conditional("UNITY_EDITOR")]
|
||||
private void SetupDebugEffect()
|
||||
{
|
||||
var beginPos = Vector3.zero;
|
||||
this.UpdateAsObservable()
|
||||
.Where(_ => Input.GetKey(KeyCode.E))
|
||||
.ThrottleFirst(TimeSpan.FromSeconds(.5f))
|
||||
.Subscribe(
|
||||
_ =>
|
||||
{
|
||||
CoinManager.Instance.AddCoinForBulkOrder(100, beginPos);
|
||||
GameDataManager.GameData.WaitAddHeart += 0;
|
||||
HeartMeter.Instance.AddHeartForBulkOrder(beginPos, () =>
|
||||
{
|
||||
GameDataManager.GameData.MoveHeart(0);
|
||||
});
|
||||
}).AddTo(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 645472548f1a479d8bd78b7934166f7f
|
||||
timeCreated: 1644328146
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using MyGame.Scenes.Main.Scripts;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
|
@ -15,7 +16,8 @@ public class CoinManager : SingletonMonoBehaviour<CoinManager>
|
|||
[SerializeField] private Animator coinAnimator;
|
||||
|
||||
[SerializeField] private RectTransform coinPrefab;
|
||||
|
||||
[SerializeField] private BulkOrderAchievedEffect bulkOrderAchievedEffect;
|
||||
|
||||
// Animation
|
||||
[SerializeField] private float coinUpDuration = 0.5f;
|
||||
[SerializeField] private float coinMoveDuration = 0.5f;
|
||||
|
|
@ -75,6 +77,15 @@ public class CoinManager : SingletonMonoBehaviour<CoinManager>
|
|||
});
|
||||
}
|
||||
|
||||
public void AddCoinForBulkOrder(int count, Vector3 beginPos)
|
||||
{
|
||||
ownCoin += count;
|
||||
bulkOrderAchievedEffect.PlayCoinEffect(beginPos, coinIconTransform.position, () =>
|
||||
{
|
||||
coinCountText.CountUpAnimation(coinTextFormat, ownCoin, coinUpDuration);
|
||||
});
|
||||
}
|
||||
|
||||
public void SubCoin(int coin){
|
||||
ownCoin -= coin;
|
||||
if(coinCountText.gameObject.activeInHierarchy){
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MyGame.Scenes.Main.Scripts;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UniRx.Triggers;
|
||||
|
|
@ -13,6 +14,8 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
|||
[SerializeField] private TextMeshProUGUI heartLevel;
|
||||
[SerializeField] private GameObject maxObject;
|
||||
[SerializeField] private float duration = .5f;
|
||||
[Space]
|
||||
[SerializeField] private BulkOrderAchievedEffect bulkOrderAchievedEffect;
|
||||
|
||||
private Coroutine coroutine;
|
||||
private List<ShopLevelData> shopLevelList = new List<ShopLevelData>();
|
||||
|
|
@ -116,4 +119,9 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
|||
fulledHeart.Value = currentHeartCount >= maxHeart && shopLevel.Value < maxLevel;
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
public void AddHeartForBulkOrder(Vector3 beginPos, Action onComplete = null)
|
||||
{
|
||||
bulkOrderAchievedEffect.PlayHeartEffect(beginPos, transform.position, onComplete);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue