编队列表选中功能完善

This commit is contained in:
2025-06-08 23:16:07 +08:00
parent 4cedd7c17b
commit adac8dfe04
8 changed files with 268 additions and 30 deletions
@@ -0,0 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Character
{
public string name{get; set;}
public string occupation{get; set;}
public int boundaryLevel{get; set;}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bae42af9bcfec5f46a3025f40ce5bd7b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,72 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TeamManager : MonoBehaviour
{
public static TeamManager Instance {get; private set;}
public teamSettingPanel teamSettingPanelInstance= teamSettingPanel.Instance;
//当前玩家存档下的所有编队配置
public Dictionary<int, List<Character>> currentTeamSettings = new Dictionary<int, List<Character>>();
/// <summary>
/// 根据此字段来在编队信息页显示已有编队
/// </summary>
public int currentSelectedTeam = 0;
/// <summary>
/// 记录被选中的编队中角色的索引,用于处理队列位置交换的逻辑。-1表示无角色被选中
/// </summary>
public int currentSelectedCharacter = -1;
/// <summary>
/// 在修改被选中的编队中角色的索引时触发
/// </summary>
public event Action OnSelectedCharacterChanged;
void Awake()
{
if (Instance == null)
{
Instance = this;
}
else
{
Destroy(gameObject);
}
}
void Start()
{
if(teamSettingPanelInstance == null)
{
teamSettingPanelInstance = teamSettingPanel.Instance;
}
}
/// <summary>
/// 读取玩家存档信息后可直接在此写入编队信息
/// </summary>
/// <param name="playerTeamSettings"></param>
public void setcurrentTeamSettings(Dictionary<int,List<Character>> playerTeamSettings)
{
currentTeamSettings = playerTeamSettings;
}
public List<Character> getCurrentTeam()
{
return currentTeamSettings[currentSelectedTeam];
}
public void setCurrentSelectedCharacterInTeam(int characterIndex)
{
if (characterIndex != currentSelectedCharacter)
{
currentSelectedCharacter = characterIndex;
OnSelectedCharacterChanged?.Invoke(); // 触发事件
}
}
// Update is called once per frame
void Update()
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: debeba9c3c2f7334ab04c769534a1f85
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: