先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
157 lines
4.9 KiB
C#
157 lines
4.9 KiB
C#
using GameCore;
|
|
using System.Collections;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class item_tips : MonoBehaviour
|
|
{
|
|
static item_tips _instance;
|
|
static bool isShowing = false;
|
|
public static async Task<item_tips> Show()
|
|
{
|
|
await ShowInit();
|
|
if (_instance == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
_instance.gameObject.SetActive(true);
|
|
_instance.transform.SetAsLastSibling();
|
|
return _instance;
|
|
}
|
|
|
|
private static async Task ShowInit()
|
|
{
|
|
if (!isShowing)
|
|
{
|
|
GameObject loading = await UIManager.Instance.GetUIAsync(UITypes.item_tips);
|
|
|
|
if (loading != null)
|
|
{
|
|
_instance = loading.GetComponent<item_tips>();
|
|
isShowing = true;
|
|
}
|
|
}
|
|
await Awaiters.NextFrame;
|
|
}
|
|
Button btn_close;
|
|
Animation ani;
|
|
RectTransform content;
|
|
public item_tips_fish_card item_fish_card;
|
|
public item_tips_box item_box;
|
|
public item_tips_box_2 item_box_2;
|
|
public item_tips_box_3 item_box_3;
|
|
public item_tips_item item_tips_item;
|
|
public buff_tips buff_Tips;
|
|
public buff_tips buff_target;
|
|
public item_perk item_Perk;
|
|
//public int clickInstanceID { get; set; }
|
|
private void Awake()
|
|
{
|
|
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
|
ani = GetComponent<Animation>();
|
|
}
|
|
private void Start()
|
|
{
|
|
btn_close.onClick.AddListener(OnClickClose);
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
isShowing = false;
|
|
}
|
|
public void OnClickClose()
|
|
{
|
|
StartCoroutine(Close());
|
|
}
|
|
IEnumerator Close()
|
|
{
|
|
btn_close.enabled = false;
|
|
ani.Play("tips_common_out");
|
|
var length = ani.GetClip("tips_common_out").length;
|
|
yield return new WaitForSeconds(length);
|
|
UIManager.Instance.HideUI(UITypes.item_tips);
|
|
}
|
|
void OnShow()
|
|
{
|
|
ani.Play("tips_common_show");
|
|
btn_close.enabled = true;
|
|
StopAllCoroutines();
|
|
}
|
|
public void Init(int clickInstanceID, Vector3 pos, cfg.Item item, double count, float inflate)
|
|
{
|
|
OnShow();
|
|
buff_Tips.gameObject.SetActive(false);
|
|
buff_target.gameObject.SetActive(false);
|
|
item_fish_card.gameObject.SetActive(item.Type == 5);
|
|
item_box.gameObject.SetActive(item.Type == 9 && item.SubType == 2);
|
|
item_box_2.gameObject.SetActive(item.Type == 9 && (item.SubType == 1 || item.SubType == 3));
|
|
item_box_3.gameObject.SetActive(item.Type == 9 && item.SubType == 9);
|
|
item_Perk.gameObject.SetActive(false);
|
|
item_tips_item.gameObject.SetActive(false);
|
|
|
|
if (item.Type == 5)
|
|
{
|
|
item_fish_card.Init(item);
|
|
content = item_fish_card.transform as RectTransform;
|
|
}
|
|
else if (item.Type == 9 && item.SubType == 2)
|
|
{
|
|
item_box.Show(item, count);
|
|
content = item_box.transform as RectTransform;
|
|
}
|
|
else if (item.Type == 9 && (item.SubType == 1 || item.SubType == 3))
|
|
{
|
|
item_box_2.Show(item, count);
|
|
content = item_box_2.transform as RectTransform;
|
|
}
|
|
else if (item.Type == 9 && item.SubType == 9)
|
|
{
|
|
item_box_3.Show(item, inflate);
|
|
content = item_box_3.transform as RectTransform;
|
|
}
|
|
else
|
|
{
|
|
item_tips_item.gameObject.SetActive(true);
|
|
item_tips_item.Init(item, count);
|
|
content = item_tips_item.transform as RectTransform;
|
|
}
|
|
SetContent(pos);
|
|
}
|
|
void SetContent(Vector3 pos)
|
|
{
|
|
content.position = pos;
|
|
RectTransform rectTransform = transform.GetComponent<RectTransform>();
|
|
//float limit = (rectTransform.rect.width - content.rect.width - 80) / 2;
|
|
//边界检测
|
|
var localPosition = content.transform.localPosition;
|
|
localPosition.x = 0;
|
|
|
|
float height = rectTransform.rect.height / 2;
|
|
if (localPosition.y < -height)
|
|
{
|
|
localPosition.y = -height;
|
|
}
|
|
else if (localPosition.y > height - 2 * content.rect.height)
|
|
{
|
|
localPosition.y = localPosition.y - content.rect.height;
|
|
}
|
|
content.transform.localPosition = localPosition;
|
|
}
|
|
public void ShowPerk(int rodID, int index, Vector3 pos, int addLevel = -1)
|
|
{
|
|
OnShow();
|
|
item_Perk.transform.position = pos;
|
|
item_Perk.transform.localPosition = new Vector3(0, item_Perk.transform.localPosition.y, 0);
|
|
item_fish_card.gameObject.SetActive(false);
|
|
item_box.gameObject.SetActive(false);
|
|
item_box_2.gameObject.SetActive(false);
|
|
item_box_3.gameObject.SetActive(false);
|
|
item_tips_item.gameObject.SetActive(false);
|
|
buff_Tips.gameObject.SetActive(false);
|
|
buff_target.gameObject.SetActive(false);
|
|
item_Perk.gameObject.SetActive(true);
|
|
item_Perk.Show(rodID, index, addLevel);
|
|
}
|
|
}
|