调整编队页面UI组件结构,完善更新ui视图方法
This commit is contained in:
@@ -1,20 +1,37 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
//适用于编队 列表
|
||||
public class teamCharacterView : MonoBehaviour
|
||||
{
|
||||
public GameObject character;
|
||||
public GameObject controlButton;
|
||||
public Image levelIcon;
|
||||
public Image charcterImg;
|
||||
public Image leaderStatusIcon;
|
||||
public TMP_Text skillName;
|
||||
|
||||
public GameObject isLeader;
|
||||
public GameObject notLeader;
|
||||
|
||||
public bool isSelected =false;
|
||||
public int listIndex;
|
||||
// private TeamManager teamManager= TeamManager.Instance;
|
||||
|
||||
void Start()
|
||||
{
|
||||
{
|
||||
character = gameObject;
|
||||
controlButton = transform.Find("move").gameObject;
|
||||
levelIcon = transform.Find("Level").GetComponent<Image>();
|
||||
charcterImg = transform.Find("Character").GetComponent<Image>();
|
||||
skillName = transform.Find("SkillName").GetComponent<TMP_Text>();
|
||||
isLeader = transform.Find("isLeader").gameObject;
|
||||
notLeader = transform.Find("notLeader").gameObject;
|
||||
controlButton.SetActive(isSelected);
|
||||
Debug.Log("teamCharacterView Start,"+isSelected+","+listIndex);
|
||||
//Debug.Log("teamCharacterView Start,"+isSelected+","+listIndex);
|
||||
}
|
||||
/// <summary>
|
||||
/// 单机team列表内对象时触发选定
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using utils;
|
||||
|
||||
public class teamSettingPanel : MonoBehaviour
|
||||
{
|
||||
@@ -13,6 +14,7 @@ public class teamSettingPanel : MonoBehaviour
|
||||
|
||||
private TeamManager teamManager;
|
||||
|
||||
|
||||
public static teamSettingPanel Instance{get;private set;}
|
||||
|
||||
void Awake()
|
||||
@@ -54,11 +56,21 @@ public class teamSettingPanel : MonoBehaviour
|
||||
public void updateTeamSettingElements()
|
||||
{
|
||||
//todo:向保存编队信息的类获取编队信息,然后重新处理teamElementsObj的信息
|
||||
List<Character> currentTeam = teamManager.getCurrentTeam();
|
||||
// foreach (Character character in currentTeam)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
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>
|
||||
|
||||
@@ -4,7 +4,24 @@ using UnityEngine;
|
||||
|
||||
public class Character
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色名称
|
||||
/// </summary>
|
||||
public string name{get; set;}
|
||||
/// <summary>
|
||||
/// 职业
|
||||
/// </summary>
|
||||
public string occupation{get; set;}
|
||||
/// <summary>
|
||||
/// 突破等级
|
||||
/// </summary>
|
||||
public int boundaryLevel{get; set;}
|
||||
/// <summary>
|
||||
/// 技能名称
|
||||
/// </summary>
|
||||
public string SkillName{get; set;}
|
||||
/// <summary>
|
||||
/// 是否为队长
|
||||
/// </summary>
|
||||
public bool isLeader{get; set;}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ using UnityEngine;
|
||||
public class TeamManager : MonoBehaviour
|
||||
{
|
||||
public static TeamManager Instance {get; private set;}
|
||||
|
||||
public teamSettingPanel teamSettingPanelInstance= teamSettingPanel.Instance;
|
||||
|
||||
public teamSettingPanel teamSettingPanelInstance;
|
||||
//当前玩家存档下的所有编队配置
|
||||
public Dictionary<int, List<Character>> currentTeamSettings = new Dictionary<int, List<Character>>();
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1a4239c5b4f49cd9945179d2ae14e48
|
||||
timeCreated: 1749568542
|
||||
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace utils
|
||||
{
|
||||
public class FileUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// 在unity resource内路径读取Img对象
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
public static Sprite getImage(string path)
|
||||
{
|
||||
// 从 Resources 加载 Sprite
|
||||
Sprite sprite = Resources.Load<Sprite>(path);
|
||||
if (sprite == null)
|
||||
{
|
||||
Debug.LogError($"无法在 Resources/{path} 下找到 Sprite!");
|
||||
return null;
|
||||
}
|
||||
return sprite;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1160493d9e864b9987b216240f34db5d
|
||||
timeCreated: 1749568567
|
||||
Reference in New Issue
Block a user