142 lines
3.4 KiB
C#
142 lines
3.4 KiB
C#
![]() |
// ***********************************************************************
|
|||
|
// Assembly : Game
|
|||
|
// Author : Kimch
|
|||
|
// Created : 2021-02-20
|
|||
|
// Description :
|
|||
|
// Last Modified By :
|
|||
|
// Last Modified On :
|
|||
|
// ***********************************************************************
|
|||
|
// <copyright file= "KungfuPanel.GroupWidget" company="Kunpo"></copyright>
|
|||
|
// <summary></summary>
|
|||
|
// ***********************************************************************
|
|||
|
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using TMPro;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace G.UI
|
|||
|
{
|
|||
|
partial class KungfuPanel
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
class GroupWidget : KUIWidget
|
|||
|
{
|
|||
|
#region Field
|
|||
|
|
|||
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpGroupName;
|
|||
|
[KUIFlag]
|
|||
|
TextMeshProUGUI _tmpGroupGrade;
|
|||
|
[KUIFlag]
|
|||
|
GameObject _goSp;
|
|||
|
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|||
|
|
|||
|
KUIList _kungfuList;
|
|||
|
List<BookWidget> _kungfuBookItems = new List<BookWidget>();
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Method
|
|||
|
|
|||
|
public override void Refresh()
|
|||
|
{
|
|||
|
if (this.data is ItemKungfuGroup group)
|
|||
|
{
|
|||
|
_tmpGroupName.text = group.name;
|
|||
|
int curGrade = 0;
|
|||
|
int maxGrade = 0;
|
|||
|
_kungfuList.Clear();
|
|||
|
_kungfuBookItems.Clear();
|
|||
|
//List<Vector2> list = new List<Vector2>();
|
|||
|
foreach (var kungfu in group.kungfus)
|
|||
|
{
|
|||
|
var kungfuItem = ItemProxy.Instance.GetStaticItem<ItemKungfu>(kungfu);
|
|||
|
curGrade += kungfuItem.grade;
|
|||
|
maxGrade += kungfuItem.gradeMax;
|
|||
|
|
|||
|
var uiItem = _kungfuList.GetItem<BookWidget>();
|
|||
|
uiItem.SetData(kungfuItem);
|
|||
|
uiItem.GetComponent<RectTransform>().anchoredPosition = GlobalUtils.GetVector2(kungfuItem.position);
|
|||
|
_kungfuBookItems.Add(uiItem);
|
|||
|
//list.Add(GlobalUtils.GetVector2(kungfuItem.position));
|
|||
|
}
|
|||
|
|
|||
|
//var c = list.Count - _goSp.transform.childCount;
|
|||
|
//if (c > 0)
|
|||
|
//{
|
|||
|
// var child = _goSp.transform.GetChild(0);
|
|||
|
// for (int i = 0; i < c; i++)
|
|||
|
// {
|
|||
|
// Object.Instantiate(child, _goSp.transform);
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
//for (int i = 1; i < list.Count; i++)
|
|||
|
//{
|
|||
|
// var vector = list[i] - list[i - 1];
|
|||
|
|
|||
|
// _goSp.transform.GetChild(i - 1).right = vector;
|
|||
|
|
|||
|
//}
|
|||
|
_tmpGroupGrade.text = "等级:" + curGrade + "/" + maxGrade;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void ShowStudyFx(ItemKungfu kungfu)
|
|||
|
{
|
|||
|
StartCoroutine(StudyAnimCO(kungfu));
|
|||
|
}
|
|||
|
|
|||
|
public IEnumerator StudyAnimCO(ItemKungfu kungfu)
|
|||
|
{
|
|||
|
for (int i = 0; i < 6; i++)
|
|||
|
{
|
|||
|
if (i < 5)
|
|||
|
{
|
|||
|
int index = Random.Range(0, _kungfuBookItems.Count);
|
|||
|
_kungfuBookItems[index].ShowHighlight(true);
|
|||
|
yield return new WaitForSeconds(0.15f);
|
|||
|
_kungfuBookItems[index].ShowHighlight(false);
|
|||
|
yield return null;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
for (int j = 0; j < _kungfuBookItems.Count; j++)
|
|||
|
{
|
|||
|
var kungfuItem = _kungfuBookItems[j];
|
|||
|
if (kungfuItem.data == kungfu)
|
|||
|
{
|
|||
|
kungfuItem.ShowStudyFx(true);
|
|||
|
yield return new WaitForSeconds(0.3f);
|
|||
|
kungfuItem.ShowStudyFx(false);
|
|||
|
yield break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Unity
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
SetViewData();
|
|||
|
_kungfuList = GetComponent<KUIList>();
|
|||
|
_kungfuList.AddTemplate<BookWidget>(true);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
}
|