72 lines
1.7 KiB
C#
72 lines
1.7 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2021-03-28
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "SwordWindow.SwordWidget" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
namespace G.UI
|
|
{
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
partial class SwordWindow
|
|
{
|
|
class SwordWidget : KUIWidget
|
|
{
|
|
Vector3 _position;
|
|
|
|
public override void Refresh()
|
|
{
|
|
if (this.data is SwordProxy.SwordInfo swordInfo)
|
|
{
|
|
this.transform.GetChild(1).gameObject.SetActive(swordInfo.isUnlock);
|
|
}
|
|
}
|
|
|
|
public void ResetPosition()
|
|
{
|
|
transform.localPosition = _position;
|
|
}
|
|
|
|
public void SetScale(float scale)
|
|
{
|
|
var childs = F.ListPool<Transform>.Get();
|
|
transform.GetComponentsInChildren(childs);
|
|
Vector3 uniformScale = Vector3.one * scale;
|
|
for (int i = 1; i < childs.Count; i++)
|
|
{
|
|
childs[i].localScale = uniformScale;
|
|
}
|
|
F.ListPool<Transform>.Release(childs);
|
|
}
|
|
|
|
void OnSwordClick()
|
|
{
|
|
if (this.data is SwordProxy.SwordInfo swordInfo)
|
|
{
|
|
if (swordInfo.isUnlock)
|
|
PostNotification(GlobalDefine.EVENT_SWORD_CLICK, swordInfo);
|
|
else
|
|
{
|
|
PostNotification(GlobalDefine.EVENT_SHOW_TOAST, swordInfo.unlockText);
|
|
}
|
|
}
|
|
}
|
|
|
|
void Awake()
|
|
{
|
|
GetComponent<Button>().onClick.AddListener(OnSwordClick);
|
|
|
|
_position = transform.localPosition;
|
|
}
|
|
}
|
|
}
|
|
}
|