処理追加 CityIcon.cs
This commit is contained in:
parent
e016e0e6ad
commit
9a2bfe931e
|
|
@ -130,7 +130,12 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 94d22fb4b30547a7a7d613555c1fd8da, type: 3}
|
m_Script: {fileID: 11500000, guid: 94d22fb4b30547a7a7d613555c1fd8da, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
icon: {fileID: 498716710821908371}
|
cityIcon: {fileID: 498716710821908371}
|
||||||
|
cityId: 1
|
||||||
|
pin: {fileID: 498716709849429620}
|
||||||
|
lockIcon: {fileID: 498716710438122542}
|
||||||
|
notifyIcon: {fileID: 8888824836673155761}
|
||||||
|
animator: {fileID: 2247642576509783911}
|
||||||
--- !u!1 &498716710438122542
|
--- !u!1 &498716710438122542
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -571,6 +576,12 @@ RectTransform:
|
||||||
type: 3}
|
type: 3}
|
||||||
m_PrefabInstance: {fileID: 498716710500312605}
|
m_PrefabInstance: {fileID: 498716710500312605}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!1 &8888824836673155761 stripped
|
||||||
|
GameObject:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 9056949049436837036, guid: f8587bb162250fa48947d648e934781e,
|
||||||
|
type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 498716710500312605}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
--- !u!1001 &1360594892428573506
|
--- !u!1001 &1360594892428573506
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -701,3 +712,9 @@ RectTransform:
|
||||||
type: 3}
|
type: 3}
|
||||||
m_PrefabInstance: {fileID: 1360594892428573506}
|
m_PrefabInstance: {fileID: 1360594892428573506}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!95 &2247642576509783911 stripped
|
||||||
|
Animator:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 995566939256566821, guid: 1dd4681cca844994eab02ced553ab174,
|
||||||
|
type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 1360594892428573506}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,11 @@ PrefabInstance:
|
||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: -59.7
|
value: -59.7
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2308183619134864621, guid: 68b944bf4894305448bb16375de74dbc,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: cityId
|
||||||
|
value: 2
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8503390566567986980, guid: 68b944bf4894305448bb16375de74dbc,
|
- target: {fileID: 8503390566567986980, guid: 68b944bf4894305448bb16375de74dbc,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchoredPosition.x
|
propertyPath: m_AnchoredPosition.x
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,11 @@ PrefabInstance:
|
||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: -60.2
|
value: -60.2
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2308183619134864621, guid: 68b944bf4894305448bb16375de74dbc,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: cityId
|
||||||
|
value: 3
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8888824836673155761, guid: 68b944bf4894305448bb16375de74dbc,
|
- target: {fileID: 8888824836673155761, guid: 68b944bf4894305448bb16375de74dbc,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,55 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace MyGame.Scenes.WorldMap.Scripts
|
namespace MyGame.Scenes.WorldMap.Scripts
|
||||||
{
|
{
|
||||||
|
public enum CityState
|
||||||
|
{
|
||||||
|
UnRelease,
|
||||||
|
Lock,
|
||||||
|
Release
|
||||||
|
}
|
||||||
public class CityIcon : MonoBehaviour
|
public class CityIcon : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private Transform icon;
|
[SerializeField] private Transform cityIcon;
|
||||||
[SerializeField] private int cityId;
|
[SerializeField] private int cityId;
|
||||||
|
private readonly ReactiveProperty<CityState> cityState = new();
|
||||||
public int CityId => cityId;
|
public int CityId => cityId;
|
||||||
public IObservable<Unit> OnClick =>
|
public IObservable<Unit> OnClick =>
|
||||||
(icon.GetComponent<ObservableEventTrigger>() ?? icon.gameObject.AddComponent<ObservableEventTrigger>())
|
(cityIcon.GetComponent<ObservableEventTrigger>() ?? cityIcon.gameObject.AddComponent<ObservableEventTrigger>())
|
||||||
.OnPointerClickAsObservable()
|
.OnPointerClickAsObservable()
|
||||||
.AsUnitObservable();
|
.AsUnitObservable();
|
||||||
|
|
||||||
|
[SerializeField] private GameObject pin;
|
||||||
|
[SerializeField] private GameObject lockIcon;
|
||||||
|
[SerializeField] private GameObject notifyIcon;
|
||||||
|
[SerializeField] private Animator animator;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
cityState.AddTo(this);
|
||||||
|
cityState.Subscribe(x =>
|
||||||
|
{
|
||||||
|
pin.SetActive(cityState.Value == Scripts.CityState.UnRelease);
|
||||||
|
lockIcon.SetActive(cityState.Value == Scripts.CityState.Lock);
|
||||||
|
cityIcon.gameObject.SetActive(cityState.Value is Scripts.CityState.Lock or Scripts.CityState.Release);
|
||||||
|
}).AddTo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetState(CityState state) => cityState.Value = state;
|
||||||
|
|
||||||
|
public void SetNotify(bool active) => notifyIcon.SetActive(active);
|
||||||
|
|
||||||
|
public void PlayAnimation(Action onComplete = null)
|
||||||
|
{
|
||||||
|
animator.gameObject.SetActive(true);
|
||||||
|
animator.Play("WorldMap_staging", 0, 0f);
|
||||||
|
Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(.3f))
|
||||||
|
.Select(_ => animator.GetCurrentAnimatorStateInfo(0))
|
||||||
|
.Where(state => state.normalizedTime >= 1f && state.IsName("WorldMap_staging"))
|
||||||
|
.Take(1)
|
||||||
|
.Subscribe(_ =>
|
||||||
|
{
|
||||||
|
onComplete?.Invoke();
|
||||||
|
}).AddTo(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue