备份CatanBuilding瘦身独立工程
This commit is contained in:
87
Assets/Scripts/TravelMap/TraveMapItem.cs
Normal file
87
Assets/Scripts/TravelMap/TraveMapItem.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using asap.core;
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TraveMapItem : EnhancedScrollerCellView
|
||||
{
|
||||
public bool isRight;
|
||||
public Animation ani;
|
||||
public Image icon;
|
||||
public TMP_Text text_name;
|
||||
public Button btn_visit;
|
||||
public GameObject locked;
|
||||
public GameObject empty;
|
||||
public GameObject line;
|
||||
public GameObject bg_bra;
|
||||
public Image bar;
|
||||
public GameObject done;
|
||||
public GameObject ship;
|
||||
public TraveMapItemData data;
|
||||
public Action<TraveMapItemData> onClickAction;
|
||||
IUIService service;
|
||||
ShowImageData imageData = null;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
imageData = new ShowImageData(icon);
|
||||
service = GContext.container.Resolve<IUIService>();
|
||||
btn_visit.onClick.AddListener(OnClick);
|
||||
}
|
||||
private void OnClick()
|
||||
{
|
||||
onClickAction?.Invoke(data);
|
||||
}
|
||||
|
||||
public void PlayAni()
|
||||
{
|
||||
if (isRight)
|
||||
{
|
||||
ani.Play("ship_move");
|
||||
}
|
||||
else
|
||||
{
|
||||
ani.Play("ship_move_left");
|
||||
}
|
||||
}
|
||||
void SetIcon()
|
||||
{
|
||||
if (imageData == null)
|
||||
{
|
||||
imageData = new ShowImageData(icon);
|
||||
}
|
||||
imageData.SetName(data.icon);
|
||||
service.SetImageSprite(imageData);
|
||||
}
|
||||
public void SetData(TraveMapItemData _data)
|
||||
{
|
||||
data = _data;
|
||||
gameObject.SetActive(true);
|
||||
text_name.text = data.name;
|
||||
btn_visit.gameObject.SetActive(data.isVisit && data.type <= TraveMapType.current);
|
||||
SetIcon();
|
||||
if (data.index == 0)
|
||||
{
|
||||
locked.SetActive(false);
|
||||
empty.SetActive(false);
|
||||
line.SetActive(false);
|
||||
done.SetActive(false);
|
||||
ship.SetActive(false);
|
||||
bg_bra.SetActive(false);
|
||||
bar.fillAmount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
locked.SetActive(data.type == TraveMapType.locked);
|
||||
empty.SetActive(data.type == TraveMapType.comingSoon);
|
||||
line.SetActive(data.type > TraveMapType.current);
|
||||
done.SetActive(data.type <= TraveMapType.current);
|
||||
ship.SetActive(data.type == TraveMapType.current);
|
||||
bg_bra.SetActive(true);
|
||||
bar.fillAmount = data.type <= TraveMapType.current ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user