先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
113 lines
3.1 KiB
C#
113 lines
3.1 KiB
C#
using asap.core;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class FishMapItem : PanelItemBase<FishMapItemData>
|
|
{
|
|
Transform root;
|
|
Image img_map;
|
|
private GameObject mask;
|
|
Image bar;
|
|
private TMP_Text text_bar;
|
|
GameObject newGo;
|
|
private GameObject redpoint;
|
|
Button btn_item;
|
|
private GameObject mask_empty;
|
|
private TMP_Text text_require;
|
|
ShowImageData imageData = null;
|
|
private void Awake()
|
|
{
|
|
root = transform.Find("p_icon_item/icon_item1/btn_green");
|
|
img_map = root.Find("mask_map/img_map").GetComponent<Image>();
|
|
bar = root.Find("mask_empty/bg_bar/bar").GetComponent<Image>();
|
|
text_bar = root.Find("mask_empty/bg_bar/text_progress").GetComponent<TMP_Text>();
|
|
newGo = root.Find("new").gameObject;
|
|
redpoint = root.Find("redpoint").gameObject;
|
|
btn_item = root.GetComponent<Button>();
|
|
mask_empty = root.Find("mask_empty").gameObject;
|
|
text_require = root.Find("mask_empty/text_require").GetComponent<TMP_Text>();
|
|
imageData = new ShowImageData(img_map);
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
btn_item.onClick.AddListener(OnBtnItem);
|
|
}
|
|
|
|
public override void OffsetX(float _offsetX, float width)
|
|
{
|
|
transform.localScale = Vector3.one * Mathf.Clamp(1 - Mathf.Abs(_offsetX) / width * 0.2f, 0.75f, 1);
|
|
float offset;
|
|
if (transform.localScale.x < 0.8f)
|
|
{
|
|
offset = (0.8f - transform.localScale.x) * width * 3;
|
|
}
|
|
else
|
|
{
|
|
offset = 0;
|
|
}
|
|
|
|
transform.GetChild(0).localPosition = _offsetX > 0 ? Vector3.left * offset : Vector3.right * offset;
|
|
|
|
if (Mathf.Abs(_offsetX) < width / 2)
|
|
{
|
|
//即将选中
|
|
OnCenter();
|
|
}
|
|
}
|
|
|
|
//当靠近中心时回调
|
|
public void OnCenter()
|
|
{
|
|
data.ChangeMapName(data.index, data.name);
|
|
}
|
|
public void SetRed()
|
|
{
|
|
redpoint.SetActive(data.isRedPoint);
|
|
}
|
|
public override void OnInit()
|
|
{
|
|
transform.localScale = Vector3.one * 0.75f;
|
|
SetRed();
|
|
SetIsNew();
|
|
bar.fillAmount = data.progress;
|
|
text_bar.text = data.progressText;
|
|
mask_empty.SetActive(!data.unLock);
|
|
text_require.text = data.levelRequired.ToString();
|
|
SetIcon();
|
|
}
|
|
void SetIcon()
|
|
{
|
|
if (imageData == null)
|
|
{
|
|
img_map = root.Find("mask_map/img_map").GetComponent<Image>();
|
|
imageData = new ShowImageData(img_map);
|
|
}
|
|
imageData.SetName(data.icon);
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(imageData);
|
|
}
|
|
public void SetIsNew()
|
|
{
|
|
newGo.SetActive(data.isNew);
|
|
}
|
|
}
|
|
|
|
public class FishMapItemData
|
|
{
|
|
public int ID;
|
|
public List<int> fishList;
|
|
public string name;
|
|
public float progress;
|
|
public string icon;
|
|
public string progressText;
|
|
public bool unLock;
|
|
public bool isNew;
|
|
public bool isRedPoint;
|
|
public int index;
|
|
public Action<int, string> ChangeMapName;
|
|
public int levelRequired;
|
|
}
|