备份CatanBuilding瘦身独立工程
This commit is contained in:
46
Assets/Scripts/UI/Rod/PeakItem.cs
Normal file
46
Assets/Scripts/UI/Rod/PeakItem.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
class PeakItem : PanelItemBase<PeakItemData>
|
||||
{
|
||||
public Button btn_item;
|
||||
public Perk perk;
|
||||
private void Awake()
|
||||
{
|
||||
btn_item = transform.GetComponent<Button>();
|
||||
perk = transform.GetComponent<Perk>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_item.onClick.AddListener(OnBtnItem);
|
||||
}
|
||||
|
||||
|
||||
public override void OnInit()
|
||||
{
|
||||
transform.localScale = Vector3.one * 0.75f;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public class PeakItemData
|
||||
{
|
||||
public int id;
|
||||
}
|
||||
Reference in New Issue
Block a user