设置scriptable存储角色信息,调整编队系统部分代码逻辑

This commit is contained in:
2025-06-13 01:11:41 +08:00
parent 5c20a1e935
commit 5728adc919
42 changed files with 553 additions and 1156 deletions
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 1d4a3fcc2d2f7ec44a2bfa912a0b2904 guid: d5bd7209fbae23e46924c2911c444eac
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
@@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5976726b6b1585d4bae159d4a817b84e, type: 3}
m_Name: 1001001_YUETAO
m_EditorClassIdentifier:
CharacterID: 1001001
CharacterSkillName: pure dissidents
CharacterCardSprite: {fileID: 21300000, guid: 4cfddbb3f863ce7438489672608b52e7, type: 3}
CharacterTeamSprite: {fileID: 21300000, guid: cd700eadb08fd5a4289093677d9414ff, type: 3}
CharacterRoleSprite: {fileID: 21300000, guid: 723b47d046dd2e644a87c48049c6cd7b, type: 3}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bc37529925b6b414f801a85c12c80f6d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

@@ -0,0 +1,114 @@
fileFormatVersion: 2
guid: 723b47d046dd2e644a87c48049c6cd7b
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 95465072ce16290438ddc7e63bbd869d guid: 5a0f05813786f074cb3266c66bc83aa2
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
@@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5976726b6b1585d4bae159d4a817b84e, type: 3}
m_Name: 1001002_AYANO
m_EditorClassIdentifier:
CharacterID: 1001002
CharacterSkillName: default skill
CharacterCardSprite: {fileID: 21300000, guid: 84ef05cda680d7a40a5108f0a5bcc1c9, type: 3}
CharacterTeamSprite: {fileID: 21300000, guid: 63011e948d89eac418c08986d70e15cb, type: 3}
CharacterRoleSprite: {fileID: 21300000, guid: d43848ae23ea61941bafe55e1a6fd78f, type: 3}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8e5e7d1ca158e7c498293a6518a09163
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b6283ed431b50f749a644d480b0bc324, type: 3}
m_Name: CharacterLevelData
m_EditorClassIdentifier:
LevelCSprite: {fileID: 21300000, guid: cc6dc195a4e12f74e93a76d0a812c100, type: 3}
LevelSSprite: {fileID: 21300000, guid: c27f07a6da5b8fb43ac4078c5b2ef709, type: 3}
LevelASprite: {fileID: 21300000, guid: c38c5a615d5391a47addbe393458a6b6, type: 3}
LevelBSprite: {fileID: 21300000, guid: 2b45e5a0ca8df1642bc994c53374988a, type: 3}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c36bd33a1b5f5f34d9b0d2750119d910
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
+4
View File
@@ -2318,6 +2318,10 @@ PrefabInstance:
propertyPath: m_Name propertyPath: m_Name
value: Button value: Button
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1198053886828452625, guid: ce2cc510e6c307947a5dbf185318777e, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4974503315116154840, guid: ce2cc510e6c307947a5dbf185318777e, type: 3} - target: {fileID: 4974503315116154840, guid: ce2cc510e6c307947a5dbf185318777e, type: 3}
propertyPath: m_Type propertyPath: m_Type
value: 0 value: 0
@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 4725964d70c69894abd8b20964959113 guid: e9cbffecea956fa4b871657753680026
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
@@ -0,0 +1,17 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: eaf4c7edaf0b74e49a85771b8c5b85eb, type: 3}
m_Name: CharacterList
m_EditorClassIdentifier:
characters:
- {fileID: 11400000, guid: bc37529925b6b414f801a85c12c80f6d, type: 2}
- {fileID: 11400000, guid: 8e5e7d1ca158e7c498293a6518a09163, type: 2}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 74a349c5a048ac54da419a61dabd9ab6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7f082104af4ec4746b41b380d085972c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 该sobj仅适用于编队系统,角色系统的详细信息需要另外设计
/// </summary>
[CreateAssetMenu(fileName = "CharacterDataInfo", menuName = "TeamCharacter/TeamCharacterDataInfo")]
public class TeamCharacterDataInfo :ScriptableObject
{
/// <summary>
/// 角色系统请以此id为准来查找数据
/// </summary>
public int CharacterID;
public string CharacterSkillName;
public Sprite CharacterCardSprite;
public Sprite CharacterTeamSprite;
public Sprite CharacterRoleSprite;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5976726b6b1585d4bae159d4a817b84e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "CharacterLevelData", menuName = "Character/CharacterLevelData")]
public class TeamCharacterLevelData : ScriptableObject
{
public Sprite LevelCSprite;
public Sprite LevelSSprite;
public Sprite LevelASprite;
public Sprite LevelBSprite;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b6283ed431b50f749a644d480b0bc324
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "CharacterList", menuName = "TeamCharacter/TeamCharacterList")]
public class TeamCharacterList : ScriptableObject
{
public List<TeamCharacterDataInfo> characters=new List<TeamCharacterDataInfo>();
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eaf4c7edaf0b74e49a85771b8c5b85eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -65,7 +65,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 21300000, guid: 84ef05cda680d7a40a5108f0a5bcc1c9, type: 3} m_Sprite: {fileID: 0}
m_Type: 0 m_Type: 0
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1
@@ -86,7 +86,6 @@ GameObject:
- component: {fileID: 3228097016014596376} - component: {fileID: 3228097016014596376}
- component: {fileID: 4065988666777179856} - component: {fileID: 4065988666777179856}
- component: {fileID: 2921092759260112579} - component: {fileID: 2921092759260112579}
- component: {fileID: 2111168341660587780}
m_Layer: 5 m_Layer: 5
m_Name: levelIcon m_Name: levelIcon
m_TagString: Untagged m_TagString: Untagged
@@ -141,7 +140,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 21300000, guid: cc6dc195a4e12f74e93a76d0a812c100, type: 3} m_Sprite: {fileID: 0}
m_Type: 0 m_Type: 0
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1
@@ -151,50 +150,6 @@ MonoBehaviour:
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 m_PixelsPerUnitMultiplier: 1
--- !u!114 &2111168341660587780
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 227430959558785920}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 2921092759260112579}
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!1 &2949374534111508497 --- !u!1 &2949374534111508497
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -247,11 +202,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 31ac798fff192ba4b92574fbc38f7d35, type: 3} m_Script: {fileID: 11500000, guid: 31ac798fff192ba4b92574fbc38f7d35, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
characterID: 0
charactCard: {fileID: 2949374534111508497} charactCard: {fileID: 2949374534111508497}
characterImage: {fileID: 1068789348870044308} characterImage: {fileID: 1068789348870044308}
levelIcon: {fileID: 2921092759260112579} levelIcon: {fileID: 2921092759260112579}
occupationIcon: {fileID: 3273503338186152757} occupationIcon: {fileID: 3273503338186152757}
characterName:
--- !u!1 &3298850994316689979 --- !u!1 &3298850994316689979
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
-35
View File
@@ -1,35 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Character
{
/// <summary>
/// 角色名称
/// </summary>
public string name{get; set;}
/// <summary>
/// 职业
/// </summary>
public string occupation{get; set;}
/// <summary>
/// 突破等级
/// </summary>
public string boundaryLevel{get; set;}
/// <summary>
/// 技能名称
/// </summary>
public string SkillName{get; set;}
/// <summary>
/// 是否为队长
/// </summary>
public bool isLeader{get; set;}
public Character(string name, string occupation, string boundaryLevel, string skillName)
{
this.name = name;
this.occupation = occupation;
this.boundaryLevel = boundaryLevel;
this.SkillName = skillName;
}
}
+3 -8
View File
@@ -5,11 +5,11 @@ using UnityEngine.UI;
public class CharacterCardView : MonoBehaviour public class CharacterCardView : MonoBehaviour
{ {
public int characterID;
public GameObject charactCard; public GameObject charactCard;
public Image characterImage; public Image characterImage;
public Image levelIcon; public Image levelIcon;
public Image occupationIcon; public Image occupationIcon;
public string characterName;
void Start() void Start()
{ {
@@ -17,11 +17,6 @@ public class CharacterCardView : MonoBehaviour
characterImage.sprite = null; characterImage.sprite = null;
levelIcon.sprite = null; levelIcon.sprite = null;
} }
/// <summary>
/// 根据角色名称获取角色介绍信息
/// </summary>
void checkCharacterInformation()
{
Debug.Log("尝试获取角色介绍:"+characterName);
}
} }
+33 -28
View File
@@ -1,6 +1,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Unity.Collections;
using UnityEngine; using UnityEngine;
public class TeamManager : MonoBehaviour public class TeamManager : MonoBehaviour
@@ -9,13 +10,13 @@ public class TeamManager : MonoBehaviour
public teamSettingPanel teamSettingPanelInstance; public teamSettingPanel teamSettingPanelInstance;
/// <summary> /// <summary>
/// 当前玩家存档下的所有编队配置 /// 当前玩家存档下的所有编队配置,key为编队索引,value为该编队的角色列表,表内只有角色ID
/// </summary> /// </summary>
public Dictionary<int, List<Character>> currentTeamSettings = new Dictionary<int, List<Character>>(); public Dictionary<int, TeamSetting> currentTeamSettings = new Dictionary<int, TeamSetting>();
/// <summary> /// <summary>
/// 玩家存档下已经解锁的角色信息列表 /// 玩家存档下已经解锁的角色信息列表
/// </summary> /// </summary>
public List<Character> SelectableCharacterList = new List<Character>(); public List<CharacterView> SelectableCharacterList = new List<CharacterView>();
/// <summary> /// <summary>
/// 根据此字段来在编队信息页显示已有编队 /// 根据此字段来在编队信息页显示已有编队
/// </summary> /// </summary>
@@ -43,40 +44,44 @@ public class TeamManager : MonoBehaviour
void testTeamSetting() void testTeamSetting()
{ {
SelectableCharacterList.Add(new Character("YUETAO","default","C","pure dissidents")); SelectableCharacterList.Add(new CharacterView(1001001,"C"));
SelectableCharacterList.Add(new Character("AYANO","default","B","default skillName")); SelectableCharacterList.Add(new CharacterView(1001002,"S"));
SelectableCharacterList.Add(new Character("YUETAO","default","C","pure dissidents")); SelectableCharacterList.Add(new CharacterView(1001001,"C"));
SelectableCharacterList.Add(new Character("AYANO","default","S","default skillName")); SelectableCharacterList.Add(new CharacterView(1001002,"C"));
//手动向currentTeamSettings和SelectableCharacterList添加测试数据 //手动向currentTeamSettings和SelectableCharacterList添加测试数据
currentTeamSettings.Add(0,new List<Character>()); currentTeamSettings.Add(0,new TeamSetting(new List<CharacterView>(),1001001));
currentTeamSettings[0].Add(new Character("YUETAO","default","C","pure dissidents")); currentTeamSettings[0].teamIdList.Add(new CharacterView(1001001,"C"));
currentTeamSettings[0].Add(new Character("AYANO","default","B","default skillName")); currentTeamSettings[0].teamIdList.Add(new CharacterView(1001002,"S"));
currentTeamSettings[0].Add(new Character("YUETAO","default","C","pure dissidents")); currentTeamSettings[0].teamIdList.Add(new CharacterView(1001001,"C"));
currentTeamSettings[0].Add(new Character("YUETAO","default","C","pure dissidents")); currentTeamSettings[0].teamIdList.Add( new CharacterView(1001002,"C"));
currentTeamSettings.Add(1,new TeamSetting(new List<CharacterView>(),1001002));
currentTeamSettings[0].teamIdList.Add(new CharacterView(1001001,"C"));
currentTeamSettings[0].teamIdList.Add(new CharacterView(1001002,"B"));
currentTeamSettings[0].teamIdList.Add(new CharacterView(1001001,"C"));
currentTeamSettings[0].teamIdList.Add( new CharacterView(1001002,"A"));
currentTeamSettings[0].teamIdList.Add(new CharacterView(1001002,"A"));
currentTeamSettings.Add(1,new List<Character>());
currentTeamSettings[1].Add(new Character("YUETAO","default","C","pure dissidents"));
currentTeamSettings[1].Add(new Character("AYANO","default","B","default skillName"));
currentTeamSettings[1].Add(new Character("YUETAO","default","C","pure dissidents"));
currentTeamSettings[1].Add(new Character("YUETAO","default","C","pure dissidents"));
Debug.Log("testTeamSetting ready"); Debug.Log("testTeamSetting ready");
} }
public void openTeamSettingPanel()=> teamSettingPanelInstance.gameObject.SetActive(true);
public void closeTeamSettingPanel()=> teamSettingPanelInstance.gameObject.SetActive(false);
void Start() void Start()
{ {
if(teamSettingPanelInstance == null) // if(teamSettingPanelInstance == null)
{ // {
teamSettingPanelInstance = teamSettingPanel.Instance; // teamSettingPanelInstance = teamSettingPanel.Instance;
} // }
testTeamSetting();//接入玩家存档后请注释掉此行 testTeamSetting();//接入玩家存档后请注释掉此行
} }
/// <summary> /// <summary>
/// 读取玩家存档信息后可直接在此写入编队信息 /// 读取玩家存档信息后可直接在此写入编队信息
/// </summary> /// </summary>
/// <param name="playerTeamSettings"></param> /// <param name="playerTeamSettings"></param>
public void setcurrentTeamSettings(Dictionary<int,List<Character>> playerTeamSettings) public void setcurrentTeamSettings(Dictionary<int,TeamSetting> playerTeamSettings)
{ {
currentTeamSettings = playerTeamSettings; currentTeamSettings = playerTeamSettings;
} }
@@ -84,12 +89,12 @@ public class TeamManager : MonoBehaviour
/// 依据选定的队伍预设索引来获得队伍信息 /// 依据选定的队伍预设索引来获得队伍信息
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<Character> getCurrentSelectedTeam() public TeamSetting getCurrentSelectedTeam()
{ {
return currentTeamSettings[currentSelectedTeam]; return currentTeamSettings[currentSelectedTeam];
} }
public void setCurrentSelectedTeam(List<Character> newTeamData, int teamIndex) public void setCurrentSelectedTeam(TeamSetting newTeamData, int teamIndex)
{ {
currentTeamSettings[teamIndex] = newTeamData; currentTeamSettings[teamIndex] = newTeamData;
} }
@@ -108,11 +113,11 @@ public class TeamManager : MonoBehaviour
/// <param name="secondIndex"></param> /// <param name="secondIndex"></param>
public void swapTeamElements(int firstIndex, int secondIndex) public void swapTeamElements(int firstIndex, int secondIndex)
{ {
List<Character> newCurrentTeam = getCurrentSelectedTeam(); List<CharacterView> newCurrentTeam = getCurrentSelectedTeam().teamIdList;
Character temp = newCurrentTeam[firstIndex]; CharacterView temp = newCurrentTeam[firstIndex];
newCurrentTeam[firstIndex] = newCurrentTeam[secondIndex]; newCurrentTeam[firstIndex] = newCurrentTeam[secondIndex];
newCurrentTeam[secondIndex] = temp; newCurrentTeam[secondIndex] = temp;
currentTeamSettings[currentSelectedTeam] = newCurrentTeam; currentTeamSettings[currentSelectedTeam].teamIdList = newCurrentTeam;
} }
+35
View File
@@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 适用于编队系统数据层,存储单个队伍的信息
/// </summary>
public class TeamSetting
{
public TeamSetting(List<CharacterView> teamList, int leaderId)
{
this.teamIdList = teamIdList;
LeaderId = leaderId;
}
public List<CharacterView> teamIdList = new List<CharacterView>();
/// <summary>
/// 队长
/// </summary>
public int LeaderId{get; set;}
}
public class CharacterView
{
public CharacterView(int characterId, string currentBoundaryLevel)
{
this.characterId = characterId;
this.currentBoundaryLevel = currentBoundaryLevel;
}
public int characterId{get; set;}
public string currentBoundaryLevel{get; set;}
}
+3
View File
@@ -8,6 +8,7 @@ using UnityEngine.UI;
//适用于编队 列表 //适用于编队 列表
public class teamCharacterView : MonoBehaviour public class teamCharacterView : MonoBehaviour
{ {
public int characterID;
public GameObject character; public GameObject character;
public GameObject controlButton; public GameObject controlButton;
public Image levelIcon; public Image levelIcon;
@@ -24,7 +25,9 @@ public class teamCharacterView : MonoBehaviour
{ {
character = gameObject; character = gameObject;
levelIcon.sprite=null; levelIcon.sprite=null;
levelIcon.color = new Color(levelIcon.color.r, levelIcon.color.g, levelIcon.color.b, 0);
charcterImg.sprite=null; charcterImg.sprite=null;
charcterImg.color = new Color(charcterImg.color.r, charcterImg.color.g, charcterImg.color.b, 0);
controlButton.SetActive(isSelected); controlButton.SetActive(isSelected);
} }
/// <summary> /// <summary>
+125 -22
View File
@@ -1,7 +1,9 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
using utils; using utils;
using Transform = UnityEngine.Transform;
public class teamSettingPanel : MonoBehaviour public class teamSettingPanel : MonoBehaviour
{ {
@@ -16,6 +18,16 @@ public class teamSettingPanel : MonoBehaviour
[SerializeField] [SerializeField]
public GameObject[] teamElementsObj; public GameObject[] teamElementsObj;
/// <summary> /// <summary>
/// team用角色数据库总表
/// </summary>
[SerializeField]
public TeamCharacterList teamCharacterList;
/// <summary>
/// 等级贴图表
/// </summary>
[SerializeField]
public TeamCharacterLevelData teamCharacterLevelData;
/// <summary>
/// 左侧角色选择页组件 /// 左侧角色选择页组件
/// </summary> /// </summary>
[SerializeField] [SerializeField]
@@ -47,6 +59,9 @@ public class teamSettingPanel : MonoBehaviour
{ {
teamManager.OnSelectedCharacterChanged += updateTeamCharacterSelectedStatus; teamManager.OnSelectedCharacterChanged += updateTeamCharacterSelectedStatus;
} }
StartCoroutine(UpdateTeamSettingAfterOneFrame());
// updateTeamSettingElements();
StartCoroutine(UpdateSelectableCharacterAfterOneFrame());
} }
void OnDestroy() void OnDestroy()
{ {
@@ -57,27 +72,102 @@ public class teamSettingPanel : MonoBehaviour
} }
public void openTeamSettingPanel() public void openTeamSettingPanel()
{ {
updateTeamSettingElements();
getSelectableCharacterList();
//根据获取的队伍信息处理ui组件 //根据获取的队伍信息处理ui组件
//可在此补充ui动画信息 //可在此补充ui动画信息
StartCoroutine(UpdateTeamSettingAfterOneFrame());
// updateTeamSettingElements();
StartCoroutine(UpdateSelectableCharacterAfterOneFrame());
teamSettingPanelObj.SetActive(true); teamSettingPanelObj.SetActive(true);
// getSelectableCharacterList();
}
private IEnumerator UpdateTeamSettingAfterOneFrame()
{
yield return null;
updateTeamSettingElements();
foreach (var obj in teamElementsObj)
{
if (obj != null)
{
var t = obj.GetComponent<teamCharacterView>();
if (t != null && t.charcterImg != null)
{
LayoutRebuilder.ForceRebuildLayoutImmediate(t.charcterImg.rectTransform);
}
}
}
}
private IEnumerator UpdateSelectableCharacterAfterOneFrame()
{
yield return null;
updateSelectableCharacterViewList();
//获取content下的所有子对象,并重新布局
// foreach (Transform child in teamCharacterViewContent.transform)
// {
// if (child != null)
// {
// var t = child.GetComponent<CharacterCardView>();
// if (t != null && t.characterImage != null)
// {
// LayoutRebuilder.ForceRebuildLayoutImmediate(t.characterImage.rectTransform);
// }
// }
// }
RectTransform rt = teamCharacterViewContent.GetComponent<RectTransform>();
LayoutRebuilder.ForceRebuildLayoutImmediate(rt);
} }
public void closeTeamSettingPanel() public void closeTeamSettingPanel()
{ {
teamSettingPanelObj.SetActive(false); teamSettingPanelObj.SetActive(false);
Transform transform; }
for (int i = 0; i < teamCharacterViewContent.transform.childCount; i++) public TeamCharacterDataInfo getCharacterViewInfo(int characterID)
{
if (teamCharacterList == null)
{ {
transform = teamCharacterViewContent.transform.GetChild(i); Debug.LogError("teamCharacterList 缺失");
GameObject.Destroy(transform.gameObject); return null;
}
foreach (TeamCharacterDataInfo tcdi in teamCharacterList.characters)
{
if(tcdi.CharacterID==characterID)
{
return tcdi;
}
}
Debug.LogWarning($"未找到{characterID}对应的角色信息");;
return null;
}
public Sprite getLevelSprite(string level)
{
if(level==null)
{
Debug.LogWarning("level为空,无法获取对应等级贴图");
return null;
}
switch (level)
{
case "S":
return teamCharacterLevelData.LevelSSprite;
case "A":
return teamCharacterLevelData.LevelASprite;
case "B":
return teamCharacterLevelData.LevelBSprite;
case "C":
return teamCharacterLevelData.LevelCSprite;
default:
Debug.LogWarning($"未找到对应等级贴图,当前等级为:{level}");
return null;
} }
} }
public void updateTeamSettingElements() public void updateTeamSettingElements()
{ {
List<Character> currentTeam = teamManager.getCurrentSelectedTeam(); TeamSetting currentSelectedTeam = teamManager.getCurrentSelectedTeam();
List<CharacterView> currentTeam = currentSelectedTeam.teamIdList;
for (int i = 0; i < teamElementsObj.Length && i < currentTeam.Count; i++) for (int i = 0; i < teamElementsObj.Length && i < currentTeam.Count; i++)
{ {
if(teamElementsObj[i]!=null && currentTeam[i]!=null) if(teamElementsObj[i]!=null && currentTeam[i]!=null)
@@ -85,13 +175,20 @@ public class teamSettingPanel : MonoBehaviour
teamCharacterView t = teamElementsObj[i].GetComponent<teamCharacterView>(); teamCharacterView t = teamElementsObj[i].GetComponent<teamCharacterView>();
if(t!=null) if(t!=null)
{ {
Sprite sprite; t.characterID= currentTeam[i].characterId;
sprite = FileUtils.getImage($"TeamCharacters/TeamCharacterImg/{currentTeam[i].name}"); TeamCharacterDataInfo tcdi = getCharacterViewInfo(t.characterID);
t.charcterImg.sprite = sprite;
sprite = FileUtils.getImage($"TeamCharacters/levelIcon/level{currentTeam[i].boundaryLevel}"); t.charcterImg.sprite = tcdi.CharacterTeamSprite;
t.levelIcon.sprite = sprite; t.charcterImg.color=new Color(t.charcterImg.color.r,t.charcterImg.color.g,t.charcterImg.color.b,255f);
t.isLeader.SetActive(currentTeam[i].isLeader);
t.notLeader.SetActive(!currentTeam[i].isLeader); t.levelIcon.sprite = getLevelSprite(currentTeam[i].currentBoundaryLevel);
t.levelIcon.color=new Color(t.levelIcon.color.r,t.levelIcon.color.g,t.levelIcon.color.b,255f);
if(currentSelectedTeam.LeaderId==currentTeam[i].characterId)
{
t.isLeader.SetActive(true);
t.notLeader.SetActive(false);
}
t.skillName.text = tcdi.CharacterSkillName;
} }
} }
} }
@@ -99,19 +196,25 @@ public class teamSettingPanel : MonoBehaviour
/// <summary> /// <summary>
/// 获取当前可选入队伍的角色列表,并显示在界面上 /// 获取当前可选入队伍的角色列表,并显示在界面上
/// </summary> /// </summary>
public void getSelectableCharacterList() public void updateSelectableCharacterViewList()
{ {
List<Character> selectAbleCharacters = teamManager.SelectableCharacterList; foreach (Transform child in teamCharacterViewContent.transform)
foreach (Character c in selectAbleCharacters) {
Destroy(child.gameObject);
}
List<CharacterView> selectAbleCharacters = teamManager.SelectableCharacterList;
foreach (CharacterView c in selectAbleCharacters) //id and level
{ {
GameObject characterObj = Instantiate(teamCharacterPrefab, teamCharacterViewContent.transform); GameObject characterObj = Instantiate(teamCharacterPrefab, teamCharacterViewContent.transform);
CharacterCardView ccv = characterObj.GetComponent<CharacterCardView>(); CharacterCardView ccv = characterObj.GetComponent<CharacterCardView>();
if (ccv != null) TeamCharacterDataInfo tcdi = getCharacterViewInfo(c.characterId);
if (ccv != null&& tcdi!=null)
{ {
ccv.characterName = c.name; ccv.characterID = tcdi.CharacterID;
ccv.characterImage.sprite = FileUtils.getImage($"TeamCharacters/CharacterImg/{c.name}"); ccv.characterImage.sprite =tcdi.CharacterCardSprite;
ccv.levelIcon.sprite = FileUtils.getImage($"TeamCharacters/levelIcon/level{c.boundaryLevel}"); ccv.levelIcon.sprite = getLevelSprite(c.currentBoundaryLevel);
ccv.occupationIcon.sprite = FileUtils.getImage($"TeamCharacters/OccupationIcon/{c.occupation}"); ccv.occupationIcon.sprite = tcdi.CharacterRoleSprite;
Debug.Log($"{ccv.characterID}--{ccv.characterImage.sprite.name}--{ccv.levelIcon.sprite.name}--{ccv.gameObject.name}");
} }
} }
} }
@@ -5,14 +5,14 @@ using UnityEngine.SceneManagement;
public class SongButton : MonoBehaviour public class SongButton : MonoBehaviour
{ {
public TextMeshProUGUI songNameText; // 歌曲名称文本 public TextMeshProUGUI songNameText; // 歌曲名称文本
public TextMeshProUGUI highestScoreText; // 个人最高分文本 public TextMeshProUGUI highestScoreText; // 个人最高分文本
public TextMeshProUGUI difficultyIDText; // 难度ID文本 public TextMeshProUGUI difficultyIDText; // 难度ID文本
public TextMeshProUGUI songIDText; public TextMeshProUGUI songIDText;
public Image buttonImage; // 按钮的 Image 组件,用于设置背景图像 public Image buttonImage; // 按钮的 Image 组件,用于设置背景图像
public int song_songSerialID; // 按钮对应的歌曲ID public int song_songSerialID; // 按钮对应的歌曲ID
// 设置按钮的数据 // 设置按钮的数据
public void Start() public void Start()
{ {
@@ -20,7 +20,7 @@ public class SongButton : MonoBehaviour
} }
public void SetButtonData(string songName, int highestScore, int difficultyID, Sprite songSprite, int songID) public void SetButtonData(string songName, int highestScore, int difficultyID, Sprite songSprite, int songID)
{ {
Debug.Log("SetButtonData 被调用, songID 参数: " + songID); Debug.Log("SetButtonData 被调用, songID 参数: " + songID);
songNameText.text = songName; songNameText.text = songName;
highestScoreText.text = "PR: " + highestScore.ToString(); highestScoreText.text = "PR: " + highestScore.ToString();
difficultyIDText.text = "" + difficultyID.ToString(); difficultyIDText.text = "" + difficultyID.ToString();
@@ -30,10 +30,10 @@ public class SongButton : MonoBehaviour
} }
// 按钮点击事件:根据 song_songSerialID 查找对应的 SongData,并传递到下个场景 // 按钮点击事件:根据 song_songSerialID 查找对应的 SongData,并传递到下个场景
public void OnSongButtonClick() public void OnSongButtonClick()
{ {
Debug.Log("点击按钮的 song_songSerialID: " + song_songSerialID); Debug.Log("点击按钮的 song_songSerialID: " + song_songSerialID);
SongData selectedSong = SongDataLibrary.Instance.GetSongDataByID(song_songSerialID); SongData selectedSong = SongDataLibrary.Instance.GetSongDataByID(song_songSerialID);
if (selectedSong != null) if (selectedSong != null)
{ {
@@ -42,7 +42,7 @@ public class SongButton : MonoBehaviour
} }
else else
{ {
Debug.LogError("未找到对应的 SongData, songID: " + song_songSerialID); Debug.LogError("未找到对应的 SongData, songID: " + song_songSerialID);
} }
} }