备份CatanBuilding瘦身独立工程
This commit is contained in:
87
Assets/Scripts/UI/Shop/FishCardMapSelectSlot.cs
Normal file
87
Assets/Scripts/UI/Shop/FishCardMapSelectSlot.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using PlayFab.Json;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishCardMapSelectSlot : MonoBehaviour
|
||||
{
|
||||
#region Field
|
||||
[SerializeField]
|
||||
GameObject
|
||||
go_selecting,
|
||||
go_lock;
|
||||
[SerializeField]
|
||||
Image img_bg;
|
||||
[SerializeField]
|
||||
TMP_Text
|
||||
txt_levelRequired,
|
||||
txt_mapSelectedName,
|
||||
txt_mapName;
|
||||
[SerializeField]
|
||||
Button btn_Select;
|
||||
|
||||
CompositeDisposable disposables = new CompositeDisposable();
|
||||
|
||||
private MapData
|
||||
_mapData;
|
||||
private bool _isSelecting;
|
||||
#endregion
|
||||
|
||||
|
||||
#region Func
|
||||
public void SetData(MapData mapData,int requiredLevel)
|
||||
{
|
||||
_isSelecting = false;
|
||||
_mapData = mapData;
|
||||
gameObject.SetActive(true);
|
||||
GContext.OnEvent<FishCardShopSlot.SChangeFishCardMapEvent>().Where(x=>x.MapData.ID==_mapData.ID||_isSelecting).Subscribe(OnMapSelected).AddTo(disposables);
|
||||
txt_mapName.text = LocalizationMgr.GetText(mapData.Name_l10n_key);
|
||||
txt_mapSelectedName.text=LocalizationMgr.GetText(mapData.Name_l10n_key);
|
||||
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(img_bg, mapData.Bg);
|
||||
|
||||
if (GContext.container.Resolve<PlayerData>().lv>=requiredLevel)
|
||||
{
|
||||
go_lock.SetActive(false);
|
||||
btn_Select.OnClickAsObservable().Where(_=>!_isSelecting).Subscribe(_ => OnSelectMap()).AddTo(disposables);
|
||||
}
|
||||
else
|
||||
{
|
||||
go_lock.SetActive(true);
|
||||
txt_levelRequired.text = requiredLevel.ToString();
|
||||
btn_Select.OnClickAsObservable().Subscribe(_ => OnMapLock());
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMapSelected(FishCardShopSlot.SChangeFishCardMapEvent data)
|
||||
{
|
||||
if(_isSelecting)
|
||||
{
|
||||
_isSelecting = false;
|
||||
go_selecting.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_isSelecting = true;
|
||||
go_selecting.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSelectMap()
|
||||
{
|
||||
GContext.Publish(new FishCardShopSlot.SChangeFishCardMapEvent { MapData = _mapData });
|
||||
}
|
||||
private void OnMapLock()
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_63"));
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
disposables.Dispose();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user