备份CatanBuilding瘦身独立工程
This commit is contained in:
81
Assets/Scripts/UI/SmallGame/BombHeistTargetItem.cs
Normal file
81
Assets/Scripts/UI/SmallGame/BombHeistTargetItem.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using DG.Tweening;
|
||||
using GameCore;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class BombHeistTargetItem : MonoBehaviour
|
||||
{
|
||||
Button btn;
|
||||
GameObject aim;
|
||||
GameObject aim_disable;
|
||||
RewardItem rewardItem;
|
||||
Animation anim;
|
||||
int index;
|
||||
Action<int> action;
|
||||
bool isSelect = false;
|
||||
private void Awake()
|
||||
{
|
||||
btn = GetComponent<Button>();
|
||||
aim = transform.Find("aim").gameObject;
|
||||
aim_disable = transform.Find("aim_disable").gameObject;
|
||||
rewardItem = transform.Find("reward").GetComponent<RewardItem>();
|
||||
anim = transform.Find("reward").GetComponent<Animation>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn.onClick.AddListener(OnClick);
|
||||
}
|
||||
public void Init(int index, Action<int> action)
|
||||
{
|
||||
this.index = index;
|
||||
this.action = action;
|
||||
aim.SetActive(true);
|
||||
aim_disable.SetActive(false);
|
||||
rewardItem.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void OnSelect(bool value)
|
||||
{
|
||||
btn.onClick.RemoveAllListeners();
|
||||
isSelect = value;
|
||||
aim.SetActive(false);
|
||||
aim_disable.SetActive(false);
|
||||
}
|
||||
//轰炸目标
|
||||
public void MainShowData(ItemData itemData)
|
||||
{
|
||||
rewardItem.gameObject.SetActive(true);
|
||||
rewardItem.SetData(itemData);
|
||||
anim.Play("reward_show1");
|
||||
}
|
||||
//其他目标显示
|
||||
public void ShowData(ItemData itemData)
|
||||
{
|
||||
rewardItem.gameObject.SetActive(true);
|
||||
rewardItem.SetData(itemData);
|
||||
anim.Play("reward_show2");
|
||||
}
|
||||
public void Multiply(ItemData itemData, int multiple)
|
||||
{
|
||||
//翻倍特效
|
||||
anim.Play("reward_beilv");
|
||||
int count = itemData.count;
|
||||
int endCount = count * multiple;
|
||||
DOTween.To(() => count, x => count = x, endCount, 1f).OnUpdate(() =>
|
||||
{
|
||||
rewardItem.text_num.text = ConvertTools.GetNumberString(count, true);
|
||||
})
|
||||
.OnComplete
|
||||
(
|
||||
() =>
|
||||
{
|
||||
rewardItem.text_num.text = ConvertTools.GetNumberString(endCount);
|
||||
}
|
||||
);
|
||||
}
|
||||
void OnClick()
|
||||
{
|
||||
action(index);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user