115 lines
3.3 KiB
C#
115 lines
3.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using utils;
|
|
|
|
public class teamSettingPanel : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
public GameObject teamSettingPanelObj;
|
|
[SerializeField]
|
|
public GameObject[] teamElementsObj;
|
|
[SerializeField]
|
|
public GameObject[] teamCharactersObj;
|
|
|
|
private TeamManager teamManager;
|
|
|
|
|
|
public static teamSettingPanel Instance{get;private set;}
|
|
|
|
void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
Instance = this;
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
teamManager = TeamManager.Instance;
|
|
if(teamManager!=null)
|
|
{
|
|
teamManager.OnSelectedCharacterChanged += updateTeamCharacterSelectedStatus;
|
|
}
|
|
}
|
|
void OnDestroy()
|
|
{
|
|
if (teamManager != null)
|
|
{
|
|
teamManager.OnSelectedCharacterChanged -= updateTeamCharacterSelectedStatus;
|
|
}
|
|
}
|
|
public void openTeamSettingPanel()
|
|
{
|
|
updateTeamSettingElements();
|
|
//根据获取的队伍信息处理ui组件
|
|
//可在此补充ui动画信息
|
|
teamSettingPanelObj.SetActive(true);
|
|
}
|
|
public void closeTeamSettingPanel()=>teamSettingPanelObj.SetActive(false);
|
|
|
|
public void updateTeamSettingElements()
|
|
{
|
|
//todo:向保存编队信息的类获取编队信息,然后重新处理teamElementsObj的信息
|
|
List<Character> currentTeam = teamManager.getCurrentSelectedTeam();
|
|
for (int i = 0; i < teamElementsObj.Length && i < currentTeam.Count; i++)
|
|
{
|
|
if(teamElementsObj[i]!=null && currentTeam[i]!=null)
|
|
{
|
|
teamCharacterView t = teamElementsObj[i].GetComponent<teamCharacterView>();
|
|
if(t!=null)
|
|
{
|
|
t.charcterImg.sprite = FileUtils.getImage("TeamCharacters/TeamCharacterImg/" + currentTeam[i].name);
|
|
t.levelIcon.sprite = FileUtils.getImage("TeamCharacters/levelIcon/level" + currentTeam[i].boundaryLevel);
|
|
t.isLeader.SetActive(currentTeam[i].isLeader);
|
|
t.notLeader.SetActive(!currentTeam[i].isLeader);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 将当前角色向下交换位置
|
|
/// </summary>
|
|
public void downChangeCharcterIndex()
|
|
{
|
|
|
|
}
|
|
public void upChangeCharcterIndex()
|
|
{
|
|
|
|
}
|
|
/// <summary>
|
|
/// 用于保证team内对象的选中状态一致
|
|
/// </summary>
|
|
public void updateTeamCharacterSelectedStatus()
|
|
{
|
|
int currentSelectedCharacter = teamManager.currentSelectedCharacter;
|
|
Debug.Log(currentSelectedCharacter+" "+$"{teamElementsObj.Length}");
|
|
for (int i = 0; i < teamElementsObj.Length; i++)
|
|
{
|
|
if (i != currentSelectedCharacter)
|
|
{
|
|
teamCharacterView teamCharacterView = teamElementsObj[i].GetComponent<teamCharacterView>();
|
|
if(teamCharacterView!=null)
|
|
{
|
|
teamCharacterView.SetUnSelected();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 若玩家更换了team成员或调整了team成员顺序,则使用此方法更新view
|
|
/// </summary>
|
|
public void updateTeamStatus()
|
|
{
|
|
|
|
}
|
|
|
|
}
|