47 lines
1.0 KiB
C#
47 lines
1.0 KiB
C#
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;
|
|
}
|