队伍次序交换 数据逻辑层方法完善
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34e2f32e0653f2e45b65f7266beb8ec4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -50,11 +50,19 @@ public class TeamManager : MonoBehaviour
|
||||
{
|
||||
currentTeamSettings = playerTeamSettings;
|
||||
}
|
||||
public List<Character> getCurrentTeam()
|
||||
/// <summary>
|
||||
/// 依据选定的队伍预设索引来获得队伍信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<Character> getCurrentSelectedTeam()
|
||||
{
|
||||
return currentTeamSettings[currentSelectedTeam];
|
||||
}
|
||||
|
||||
|
||||
public void setCurrentSelectedTeam(List<Character> newTeamData, int teamIndex)
|
||||
{
|
||||
currentTeamSettings[teamIndex] = newTeamData;
|
||||
}
|
||||
public void setCurrentSelectedCharacterInTeam(int characterIndex)
|
||||
{
|
||||
if (characterIndex != currentSelectedCharacter)
|
||||
@@ -63,6 +71,20 @@ public class TeamManager : MonoBehaviour
|
||||
OnSelectedCharacterChanged?.Invoke(); // 触发事件
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 交换指定索引中的两个队伍中元素的位置
|
||||
/// </summary>
|
||||
/// <param name="firstIndex"></param>
|
||||
/// <param name="secondIndex"></param>
|
||||
public void swapTeamElements(int firstIndex, int secondIndex)
|
||||
{
|
||||
List<Character> newCurrentTeam = getCurrentSelectedTeam();
|
||||
Character temp = newCurrentTeam[firstIndex];
|
||||
newCurrentTeam[firstIndex] = newCurrentTeam[secondIndex];
|
||||
newCurrentTeam[secondIndex] = temp;
|
||||
currentTeamSettings[currentSelectedTeam] = newCurrentTeam;
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
|
||||
Reference in New Issue
Block a user