61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
using asap.core;
|
|
using DG.Tweening;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class AquariumDetectEgg : MonoBehaviour
|
|
{
|
|
RectTransform Content;
|
|
GameObject icon_item;
|
|
int allCount = 5;
|
|
float height;
|
|
int maIndex = 2;
|
|
int curAllCount;
|
|
IUIService uIService;
|
|
private void Init()
|
|
{
|
|
uIService = GContext.container.Resolve<IUIService>();
|
|
Content = transform.Find("Viewport/Content").GetComponent<RectTransform>();
|
|
icon_item = transform.Find("Viewport/Content/Item").gameObject;
|
|
height = icon_item.GetComponent<RectTransform>().rect.height;
|
|
icon_item.SetActive(false);
|
|
}
|
|
public void SetIcon(List<string> iconNameList, string curIcon, int index)
|
|
{
|
|
Init();
|
|
curAllCount = 0;
|
|
//List<string> 得到一个新的随机顺序的列表
|
|
string str;
|
|
string curStr = curIcon;
|
|
allCount += index;
|
|
for (int i = 0; i < allCount + maIndex; i++)
|
|
{
|
|
str = iconNameList[Random.Range(0, iconNameList.Count)];
|
|
SetMapBg(str);
|
|
}
|
|
SetMapBg(curStr);
|
|
SetMapBg(iconNameList[Random.Range(0, iconNameList.Count)]);
|
|
}
|
|
void SetMapBg(string bg)
|
|
{
|
|
GameObject go = Instantiate(icon_item, Content);
|
|
Image image = go.transform.GetChild(0).GetComponent<Image>();
|
|
go.SetActive(true);
|
|
uIService.SetImageSprite(image, bg);
|
|
curAllCount++;
|
|
}
|
|
public void Play()
|
|
{
|
|
var sequence = DOTween.Sequence();
|
|
sequence.Append(Content.DOAnchorPosY(allCount * height, 0.08f * allCount).SetLoops(2, LoopType.Restart).SetEase(Ease.Linear));
|
|
|
|
//跑马灯动画
|
|
float index2 = allCount + maIndex + Random.Range(-0.5f, 0.5f);
|
|
sequence.Append(Content.DOAnchorPosY(index2 * height, 0.2f).SetEase(Ease.Linear));
|
|
sequence.Append(Content.DOAnchorPosY((allCount + maIndex) * height, 0.2f).SetEase(Ease.InSine));
|
|
sequence.Play();
|
|
}
|
|
|
|
}
|