diff --git a/HOILAI_Galgame_Framework/.gitattributes b/HOILAI_Galgame_Framework/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/HOILAI_Galgame_Framework/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/HOILAI_Galgame_Framework/.gitignore b/HOILAI_Galgame_Framework/.gitignore new file mode 100644 index 0000000..58cbc82 --- /dev/null +++ b/HOILAI_Galgame_Framework/.gitignore @@ -0,0 +1,72 @@ +# This .gitignore file should be placed at the root of your Unity project directory +# +# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore +# +/[Ll]ibrary/ +/[Tt]emp/ +/[Oo]bj/ +/[Bb]uild/ +/[Bb]uilds/ +/[Ll]ogs/ +/[Uu]ser[Ss]ettings/ + +# MemoryCaptures can get excessive in size. +# They also could contain extremely sensitive data +/[Mm]emoryCaptures/ + +# Recordings can get excessive in size +/[Rr]ecordings/ + +# Uncomment this line if you wish to ignore the asset store tools plugin +# /[Aa]ssets/AssetStoreTools* + +# Autogenerated Jetbrains Rider plugin +/[Aa]ssets/Plugins/Editor/JetBrains* + +# Visual Studio cache directory +.vs/ + +# Gradle cache directory +.gradle/ + +# Autogenerated VS/MD/Consulo solution and project files +ExportedObj/ +.consulo/ +*.csproj +*.unityproj +*.sln +*.suo +*.tmp +*.user +*.userprefs +*.pidb +*.booproj +*.svd +*.pdb +*.mdb +*.opendb +*.VC.db + +# Unity3D generated meta files +*.pidb.meta +*.pdb.meta +*.mdb.meta + +# Unity3D generated file on crash reports +sysinfo.txt + +# Builds +*.apk +*.aab +*.unitypackage +*.app + +# Crashlytics generated file +crashlytics-build.properties + +# Packed Addressables +/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* + +# Temporary auto-generated Android Assets +/[Aa]ssets/[Ss]treamingAssets/aa.meta +/[Aa]ssets/[Ss]treamingAssets/aa/* diff --git a/HOILAI_Galgame_Framework/.vsconfig b/HOILAI_Galgame_Framework/.vsconfig new file mode 100644 index 0000000..f019fd0 --- /dev/null +++ b/HOILAI_Galgame_Framework/.vsconfig @@ -0,0 +1,6 @@ +{ + "version": "1.0", + "components": [ + "Microsoft.VisualStudio.Workload.ManagedGame" + ] +} diff --git a/HOILAI_Galgame_Framework/Assets/HGF/Scenes/Demo.unity b/HOILAI_Galgame_Framework/Assets/HGF/Scenes/Demo.unity index 8f197ee..5cb718e 100644 --- a/HOILAI_Galgame_Framework/Assets/HGF/Scenes/Demo.unity +++ b/HOILAI_Galgame_Framework/Assets/HGF/Scenes/Demo.unity @@ -38,7 +38,6 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.12731704, g: 0.13414727, b: 0.121078536, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -590,6 +589,7 @@ Canvas: m_OverrideSorting: 0 m_OverridePixelPerfect: 0 m_SortingBucketNormalizedSize: 0 + m_VertexColorAlwaysGammaSpace: 0 m_AdditionalShaderChannelsFlag: 0 m_SortingLayerID: 0 m_SortingOrder: 0 @@ -1083,7 +1083,7 @@ Camera: m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1} m_projectionMatrixMode: 1 m_GateFitMode: 2 m_FOVAxisMode: 0 @@ -1202,7 +1202,7 @@ RectTransform: m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 2136, y: 1068} + m_SizeDelta: {x: 1772, y: 886} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1218022793 MonoBehaviour: @@ -1449,6 +1449,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1534613768} + - component: {fileID: 1534613771} - component: {fileID: 1534613767} - component: {fileID: 1534613766} - component: {fileID: 1534613769} @@ -1623,6 +1624,18 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!114 &1534613771 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1534613765} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f230b36db320b794d835661011534427, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1699916270 GameObject: m_ObjectHideFlags: 0 diff --git a/HOILAI_Galgame_Framework/Assets/HGF/Scripts/Galgame/GalManager.cs b/HOILAI_Galgame_Framework/Assets/HGF/Scripts/Galgame/GalManager.cs index fd920fd..4300d24 100644 --- a/HOILAI_Galgame_Framework/Assets/HGF/Scripts/Galgame/GalManager.cs +++ b/HOILAI_Galgame_Framework/Assets/HGF/Scripts/Galgame/GalManager.cs @@ -9,67 +9,106 @@ using TetraCreations.Attributes; using UnityEngine; using UnityEngine.UI; using static HGF.GalManager.Struct_PlotData; + namespace HGF { public class GalManager : MonoBehaviour { + /// + /// 当前剧情的唯一标识符 + /// public static string PlotID; + /// + /// 当前对话的UI组件 + /// [Title("当前对话")] - /// public GalManager_Text Gal_Text; + /// + /// 当前角色立绘的UI组件 + /// [Title("当前角色部分")] public GalManager_CharacterImg Gal_CharacterImg; + /// + /// 控制选项的UI组件 + /// [Title("控制选项")] public GalManager_Choice Gal_Choice; + /// + /// 控制背景图片的UI组件 + /// [Title("控制背景图片的组件")] public GalManager_BackImg Gal_BackImg; /// - /// 当前场景角色数量 + /// 当前场景中角色的数量 /// [Title("当前场景角色数量")] public int CharacterNum; + /// + /// 音频系统模型,包含角色语音、背景音乐和文本音效的AudioSource + /// public class AudioSystemModel { - public AudioSource Character_Voice; - public AudioSource BackMix; - public AudioSource TextMix; + public AudioSource Character_Voice; // 角色语音的AudioSource + public AudioSource BackMix; // 背景音乐的AudioSource + public AudioSource TextMix; // 文本音效的AudioSource + + /// + /// 音频信息类,包含音频名称和路径 + /// public class AudioInfo { public string name; public string path; } - public List AudioList = new(); - /// - /// 背景音乐Clip - /// + /// + /// 音频列表,存储所有音频信息 + /// + public List AudioList = new(); } + + /// + /// 音频系统的静态实例 + /// public static AudioSystemModel AudioSystem = new(); + /// /// 存储整个剧本的XML文档 /// private XDocument PlotxDoc; + + /// + /// 剧情数据结构,包含角色信息、分支剧情、主剧情等 + /// [Serializable] public class Struct_PlotData { - public JObject ConfigCharacterInfo = new(); - public JObject ConfigDepartment = new(); - public string Title; - public string Synopsis; - public List BranchPlot = new(); - public Queue BranchPlotInfo = new(); - public Queue MainPlot = new(); + public JObject ConfigCharacterInfo = new(); // 角色配置信息 + public JObject ConfigDepartment = new(); // 部门配置信息 + public string Title; // 剧情标题 + public string Synopsis; // 剧情简介 + public List BranchPlot = new(); // 分支剧情列表 + public Queue BranchPlotInfo = new(); // 分支剧情信息队列 + public Queue MainPlot = new(); // 主剧情队列 + + /// + /// 选项结构,包含选项标题和跳转ID + /// public class Struct_Choice { public string Title; public string JumpID; } + + /// + /// 角色信息结构,包含角色ID、GameObject、名称、所属部门和来源ID + /// public class Struct_CharacterInfo { public string CharacterID; @@ -78,8 +117,10 @@ namespace HGF public string Affiliation; public string FromID; } - public List CharacterInfo = new(); - public List ChoiceText = new(); + + public List CharacterInfo = new(); // 角色信息列表 + public List ChoiceText = new(); // 选项文本列表 + /// /// 当前的剧情节点 /// @@ -89,11 +130,22 @@ namespace HGF /// 当前是否为分支剧情节点 /// public bool IsBranch = false; - public string NowJumpID; + /// + /// 当前跳转的ID + /// + public string NowJumpID; } + /// + /// 剧情数据的静态实例 + /// public static Struct_PlotData PlotData = new(); + + /// + /// 开始游戏,初始化剧情数据并加载剧本 + /// + /// 游戏启动模型,包含角色信息、部门信息和剧本文本 public void StartGame (HGFStartModel model) { PlotData = new Struct_PlotData(); @@ -103,21 +155,21 @@ namespace HGF StartCoroutine(LoadPlot(model.plotText)); return; } + /// - /// 解析框架文本 + /// 解析框架文本,加载剧本 /// - /// + /// 剧本文本内容 + /// 协程 public IEnumerator LoadPlot (string plotText) { yield return null; try { - GameAPI.Print($"游戏剧本:{plotText}"); PlotxDoc = XDocument.Parse(plotText); - //-----开始读取数据 - + // 开始读取数据 foreach (var item in PlotxDoc.Root.Elements()) { switch (item.Name.ToString()) @@ -149,7 +201,6 @@ namespace HGF { foreach (var item_name in item.Elements()) { - AudioSystem.AudioList.Add(new AudioSystemModel.AudioInfo { name = item_name.Value, @@ -169,7 +220,6 @@ namespace HGF default: { throw new Exception("无法识别的根标签"); - } } } @@ -178,35 +228,34 @@ namespace HGF { if (ex.Message != "无法识别的根标签") { - GameAPI.Print(ex.Message, "error"); } } GameAPI.Print(Newtonsoft.Json.JsonConvert.SerializeObject(PlotData)); Button_Click_NextPlot(); } + /// - /// 点击屏幕 下一句 + /// 点击屏幕,进入下一句剧情 /// public void Button_Click_NextPlot () { - if (PlotData.MainPlot.Count == 0) { GameAPI.Print("游戏结束!"); return; } - //IsCanJump这里有问题,如果一直点击会为false,而不是说true,这是因为没有点击按钮 ,没有添加按钮 + // 如果正在说话或不能跳转,则返回 if (GalManager_Text.IsSpeak || !GalManager_Text.IsCanJump) { return; } + if (!PlotData.IsBranch) { - PlotData.MainPlot.TryDequeue(out PlotData.NowPlotDataNode);//队列出队+内联 出一个temp节点 + PlotData.MainPlot.TryDequeue(out PlotData.NowPlotDataNode); // 队列出队,获取当前剧情节点 PlotData.BranchPlotInfo.Clear(); } - else//当前为分支节点 + else // 当前为分支节点 { - //这块得妥善处理 PlotData.NowPlotDataNode = GetBranchByID(PlotData.NowJumpID); } @@ -216,9 +265,11 @@ namespace HGF GameAPI.Print("无效的剧情结点", "error"); return; } + + // 根据当前剧情节点的类型进行处理 switch (PlotData.NowPlotDataNode.Name.ToString()) { - case "AddCharacter"://处理添加角色信息的东西 + case "AddCharacter": // 处理添加角色信息 { var _ = new Struct_CharacterInfo(); var _From = PlotData.NowPlotDataNode.Attribute("From").Value; @@ -229,7 +280,7 @@ namespace HGF _.FromID = _From; var _CameObj = Resources.Load("HGF/Img-Character"); - //首次添加角色,默认添加Normall立绘 + // 首次添加角色,默认添加Normal立绘 _CameObj.GetComponent().sprite = GetCharacterImg(_From, "Normall"); _.CharacterGameObject = Instantiate(_CameObj, Gal_CharacterImg.gameObject.transform); @@ -244,21 +295,19 @@ namespace HGF Button_Click_NextPlot(); break; } - case "Speak": //处理发言 + case "Speak": // 处理发言 { var _nodeinfo = GetCharacterObjectByName(PlotData.NowPlotDataNode.Attribute("CharacterID").Value); - if (PlotData.NowPlotDataNode.Elements().Count() != 0) //有选项,因为他有子节点数目了 + if (PlotData.NowPlotDataNode.Elements().Count() != 0) // 有选项,因为存在子节点 { GalManager_Text.IsCanJump = false; foreach (var ClildItem in PlotData.NowPlotDataNode.Elements()) { if (ClildItem.Name.ToString() == "Choice") PlotData.ChoiceText.Add(new Struct_Choice { Title = ClildItem.Value, JumpID = ClildItem.Attribute("JumpID").Value }); - } Gal_Text.StartTextContent(PlotData.NowPlotDataNode.Attribute("Content").Value, _nodeinfo.Name, _nodeinfo.Affiliation, () => { - foreach (var ClildItem in GalManager.PlotData.ChoiceText) { Gal_Choice.CreatNewChoice(ClildItem.JumpID, ClildItem.Title); @@ -267,103 +316,118 @@ namespace HGF } else Gal_Text.StartTextContent(PlotData.NowPlotDataNode.Attribute("Content").Value, _nodeinfo.Name, _nodeinfo.Affiliation); - //处理消息 + // 处理消息 if (PlotData.NowPlotDataNode.Attributes("SendMessage").Count() != 0) SendCharMessage(_nodeinfo.CharacterID, PlotData.NowPlotDataNode.Attribute("SendMessage").Value); if (PlotData.NowPlotDataNode.Attributes("AudioPath").Count() != 0) StartCoroutine(PlayCharacterVoice(AudioSystem.Character_Voice, _nodeinfo.FromID, PlotData.NowPlotDataNode.Attribute("AudioPath").Value)); break; } - case "ChangeBackImg"://更换背景图片 + case "ChangeBackImg": // 更换背景图片 { var _Path = PlotData.NowPlotDataNode.Attribute("Path").Value; Gal_BackImg.SetImage(GetBackImg(_Path)); Button_Click_NextPlot(); break; } - case "DeleteCharacter": + case "DeleteCharacter": // 删除角色 { DestroyCharacterByID(PlotData.NowPlotDataNode.Attribute("CharacterID").Value); break; } - case "ChangeCharacterImg": + case "ChangeCharacterImg": // 更换角色立绘 { var _CharacterID = PlotData.NowPlotDataNode.Attribute("CharacterID").Value; var _obj = GetCharacterObjectByName(_CharacterID); - - //Debug.Log(_obj.CharacterGameObject.GetComponent() is null); - - //ResourcesPath - - _obj.CharacterGameObject.GetComponent().SetImage(GetCharacterImg(_obj.FromID, PlotData.NowPlotDataNode.Attribute("KeyName").Value)); - - // _obj.CharacterGameObject.GetComponent().sprite = Resources.Load($"Texture2D/Menhera/Plot/character/{GameManager.ServerManager.Config.CharacterInfo.GetValue(_obj.FromID, "ResourcePath")}/{GameManager.ServerManager.Config.CharacterInfo.GetValue(_obj.FromID, PlotData.NowPlotDataNode.Attribute("Img").Value)}"); - // Debug.Log($"Texture2D/Menhera/Plot/character/{GameManager.ServerManager.Config.CharacterInfo.GetValue(, "ResourcePath")}/{GameManager.ServerManager.Config.CharacterInfo.GetValue(_obj.FromID, PlotData.NowPlotDataNode.Attribute("Img").Value)}"); Button_Click_NextPlot(); break; } - case "ChangeBackAudio": + case "ChangeBackAudio": // 更换背景音乐 { ChangeBackAudio(AudioSystem.BackMix, AudioSystem.AudioList.Find(e => e.name == PlotData.NowPlotDataNode.Value).path); Button_Click_NextPlot(); break; } - case "ExitGame": + case "ExitGame": // 退出游戏 { - foreach (var item in PlotData.CharacterInfo) - { - DestroyCharacterByID(item.CharacterID); - } PlotData.MainPlot.Clear(); PlotData.BranchPlot.Clear(); + foreach (var item in PlotData.CharacterInfo) + { + DestroyCharacterByID(item.CharacterID, false); + } + PlotData.CharacterInfo.Clear(); PlotData.IsBranch = false; break; } } + if (PlotData.BranchPlotInfo.Count == 0) { PlotData.IsBranch = false; } return; } + + /// + /// 进入快速模式 + /// public void Button_Click_FastMode () { GalManager_Text.IsFastMode = true; return; } + + /// + /// 根据角色ID获取角色对象 + /// + /// 角色ID + /// 角色信息 public Struct_CharacterInfo GetCharacterObjectByName (string ID) { return PlotData.CharacterInfo.Find(t => t.CharacterID == ID); } + + /// + /// 根据分支ID获取分支剧情节点 + /// + /// 分支ID + /// 分支剧情节点 public XElement GetBranchByID (string ID) { if (PlotData.BranchPlotInfo.Count == 0) foreach (var item in PlotData.BranchPlot.Find(t => t.Attribute("ID").Value == ID).Elements()) { PlotData.BranchPlotInfo.Enqueue(item); - } PlotData.BranchPlotInfo.TryDequeue(out XElement t); return t; } + /// - /// 销毁一个角色 + /// 销毁指定ID的角色 /// - /// - public void DestroyCharacterByID (string ID) + /// 角色ID + public void DestroyCharacterByID (string ID, bool removeCharacterInfo = true) { var _ = PlotData.CharacterInfo.Find(t => t.CharacterID == ID); SendCharMessage(ID, "Quit"); - PlotData.CharacterInfo.Remove(_); + if (removeCharacterInfo) + PlotData.CharacterInfo.Remove(_); } + + /// + /// 发送角色消息 + /// + /// 角色ID + /// 消息内容 public void SendCharMessage (string CharacterID, string Message) { var _t = GetCharacterObjectByName(CharacterID); _t.CharacterGameObject.GetComponent().HandleMessage(Message); } - /// /// 初始化音乐系统 /// @@ -374,34 +438,38 @@ namespace HGF AudioSystem.TextMix = GameObject.Find("AudioSystem/TextMix").GetComponent(); } + /// + /// 每帧更新角色数量 + /// private void FixedUpdate () { CharacterNum = PlotData.CharacterInfo.Count; } + private void Update () { - } #region 建议自己实现的部分 /// - /// 根据角色ID获取角色立绘,建议自己重新实现。 + /// 根据角色ID和立绘名称获取角色立绘 /// - /// + /// 角色ID + /// 立绘名称 + /// 角色立绘 private Sprite GetCharacterImg (string id, string imgName) { var _path = $"HGF/img/portrait/{id}/{PlotData.ConfigCharacterInfo[id]["Portraits"][imgName]}"; Debug.Log(_path); - return Resources.Load(_path); } /// - /// 获取背景图片,建议自己重新实现。 + /// 获取背景图片 /// - /// - /// + /// 背景图片路径 + /// 背景图片 private Sprite GetBackImg (string path) { Debug.Log($"HGF/img/back/{path}"); @@ -409,27 +477,29 @@ namespace HGF } /// - /// 播放语音,建议自己实现指定文件夹路径 + /// 播放角色语音 /// - /// - /// - /// + /// 音频源 + /// 角色ID + /// 音频文件名 + /// 协程 private IEnumerator PlayCharacterVoice (AudioSource audioSource, string id, string fileName) { - yield return null;//下一帧执行 + yield return null; // 下一帧执行 var _clip = Resources.Load($"HGF/audio/{id}/{fileName}"); audioSource.clip = _clip; audioSource.Play(); - //或者 - /* - * audioSource.PlayOneShot(_clip); - * - */ } + /// + /// 更换背景音乐 + /// + /// 音频源 + /// 背景音乐路径 + /// 协程 public IEnumerator ChangeBackAudio (AudioSource audioSource, string path) { - yield return null;//下一帧执行 + yield return null; // 下一帧执行 var _clip = Resources.Load($"HGF/audio/{path}"); audioSource.clip = _clip; audioSource.Play(); diff --git a/HOILAI_Galgame_Framework/Assets/HGF/Scripts/Galgame/GalManager_CharacterAnimate.cs b/HOILAI_Galgame_Framework/Assets/HGF/Scripts/Galgame/GalManager_CharacterAnimate.cs index 51a72ea..15cd769 100644 --- a/HOILAI_Galgame_Framework/Assets/HGF/Scripts/Galgame/GalManager_CharacterAnimate.cs +++ b/HOILAI_Galgame_Framework/Assets/HGF/Scripts/Galgame/GalManager_CharacterAnimate.cs @@ -5,37 +5,63 @@ using UnityEngine.UI; namespace HGF { + /// + /// 角色动画管理器,用于处理角色的入场、出场和即时动画 + /// public class GalManager_CharacterAnimate : MonoBehaviour { /// - /// 出入场出场动画 + /// 出入场动画类型 + /// ToShow:逐渐显示 + /// Outside-ToLeft:从屏幕左侧滑入 + /// Outside-ToRight:从屏幕右侧滑入 /// - [StringInList("ToShow", "Outside-ToLeft", "Outside-ToRight")] public string Animate_StartOrOutside = "ToShow"; + [StringInList("ToShow", "Outside-ToLeft", "Outside-ToRight")] + public string Animate_StartOrOutside = "ToShow"; + /// - /// 动画 + /// 即时动画类型 /// Shake:颤抖 /// Shake-Y-Once:向下抖动一次 - /// ToGrey:变灰 - /// To - :不解释了,移动到指定位置 + /// ToLeft:移动到左侧 + /// ToCenter:移动到中间 + /// ToRight:移动到右侧 /// - [StringInList("Shake", "Shake-Y-Once", "ToLeft", "ToCenter", "ToRight")] public string Animate_type = "Shake"; + [StringInList("Shake", "Shake-Y-Once", "ToLeft", "ToCenter", "ToRight")] + public string Animate_type = "Shake"; + /// /// 角色立绘 /// private Image CharacterImg; + + /// + /// 主画布,注意主画布的名称必须是MainCanvas + /// [Title("注意,主画布的名称必须是MainCanvas")] public Canvas MainCanvas; + + /// + /// 初始化,获取角色立绘和主画布 + /// private void Awake () { CharacterImg = gameObject.GetComponent(); if (MainCanvas == null) MainCanvas = GameObject.Find("MainCanvas").GetComponent(); } + + /// + /// 重新执行入场动画 + /// [Button(nameof(Start), "重新执行入场动画")] private void Start () { HandleInOrOutsideMessgae(Animate_StartOrOutside); - } + + /// + /// 处理即时动画消息 + /// [Button(nameof(Start), "重新执行及时动画")] public void HandleMessgae () { @@ -85,34 +111,31 @@ namespace HGF } } } + /// /// 处理出场动画消息 /// - /// + /// 动画消息类型 public void HandleInOrOutsideMessgae (string Messgae) { - - CharacterImg.color = new Color32(255, 255, 255, 0);//完全透明 + CharacterImg.color = new Color32(255, 255, 255, 0); // 完全透明 var rect = gameObject.GetComponent(); switch (Messgae) { - - //逐渐显示 + // 逐渐显示 case "ToShow": { - PositionImageOutside(gameObject.GetComponent(), 0); break; } - //从屏幕边缘滑到左侧 + // 从屏幕左侧滑入 case "Outside-ToLeft": { - PositionImageOutside(gameObject.GetComponent(), -1); DOTween.To(() => rect.anchoredPosition, x => rect.GetComponent().anchoredPosition = x, new Vector2(rect.anchoredPosition.x + CharacterImg.sprite.texture.width, rect.anchoredPosition.y), 1f); break; } - //从屏幕边缘滑到右侧 + // 从屏幕右侧滑入 case "Outside-ToRight": { PositionImageOutside(gameObject.GetComponent(), 1); @@ -124,21 +147,18 @@ namespace HGF GameAPI.Print("当前剧情文本受损,请重新安装游戏尝试", "error"); break; } - - } - //都需要指定的 - { - CharacterImg.DOFade(1, 0.7f); } + // 都需要指定的 + CharacterImg.DOFade(1, 0.7f); } + /// - /// 设置image的位置到屏幕之外 + /// 设置Image的位置到屏幕之外 /// - /// - /// -1:左侧 0:中间 1:右侧 + /// Image的RectTransform + /// 位置类型:-1:左侧 0:中间 1:右侧 private void PositionImageOutside (RectTransform ImageGameObject, int Position) { - // 获取Image的Rect Transform switch (Position) { case -1: @@ -153,26 +173,23 @@ namespace HGF default: break; } } + /// - /// 获取image的位置到屏幕之内的位置 + /// 获取Image的位置到屏幕之内的位置 /// - /// - /// -1:左侧 0:中间 1:右侧 + /// Image的RectTransform + /// 位置类型:-1:左侧 0:中间 1:右侧 + /// 目标位置 private Vector2 PositionImageInside (RectTransform ImageGameObject, int Position) { - // 获取Image的Rect Transform - switch (Position) { case -1: return new Vector2((-MainCanvas.GetComponent().sizeDelta.x / 2) + (ImageGameObject.gameObject.GetComponent().sprite.texture.width / 2), ImageGameObject.anchoredPosition.y); - case 1: return new Vector2((MainCanvas.GetComponent().sizeDelta.x / 2) - (ImageGameObject.gameObject.GetComponent().sprite.texture.width / 2), ImageGameObject.anchoredPosition.y); - case 0: return new Vector2(0, ImageGameObject.anchoredPosition.y); - default: { GameAPI.Print("当前剧情文本受损,请重新安装游戏尝试", "error"); @@ -181,5 +198,4 @@ namespace HGF } } } - -} +} \ No newline at end of file diff --git a/HOILAI_Galgame_Framework/Assets/HGF/Scripts/StringInList.cs b/HOILAI_Galgame_Framework/Assets/HGF/Scripts/StringInList.cs index f7a37b6..656fd24 100644 --- a/HOILAI_Galgame_Framework/Assets/HGF/Scripts/StringInList.cs +++ b/HOILAI_Galgame_Framework/Assets/HGF/Scripts/StringInList.cs @@ -1,125 +1,92 @@ using System; - using UnityEngine; #if UNITY_EDITOR - using UnityEditor; - #endif namespace HGF { + /// + /// ַбԣInspectorʾһб + /// public class StringInList : PropertyAttribute - { - + /// + /// ȡַбί + /// public delegate string[] GetStringList (); - - + /// + /// ʹַָбʼ + /// + /// ַб public StringInList (params string[] list) - { - List = list; - } - - + /// + /// ʹָ͵ķȡַбʼ + /// + /// + /// public StringInList (Type type, string methodName) - { - var method = type.GetMethod(methodName); - if (method != null) - { - List = method.Invoke(null, null) as string[]; - } - else - { - Debug.LogError("NO SUCH METHOD " + methodName + " FOR " + type); - } - } - - + /// + /// ȡַб + /// public string[] List - { - get; - private set; - } - } - - #if UNITY_EDITOR - + /// + /// ַбԻInspectorлб + /// [CustomPropertyDrawer(typeof(StringInList))] - public class StringInListDrawer : PropertyDrawer - { - - // Draw the property inside the given rect - + /// + /// Inspectorл + /// + /// λ + /// л + /// Աǩ public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) - { - var stringInList = attribute as StringInList; - var list = stringInList.List; - if (property.propertyType == SerializedPropertyType.String) - { - int index = Mathf.Max(0, Array.IndexOf(list, property.stringValue)); - index = EditorGUI.Popup(position, property.displayName, index, list); - - property.stringValue = list[index]; - } - else if (property.propertyType == SerializedPropertyType.Integer) - { - property.intValue = EditorGUI.Popup(position, property.displayName, property.intValue, list); - } - else - { - base.OnGUI(position, property, label); - } - } - } - #endif - -} +} \ No newline at end of file diff --git a/HOILAI_Galgame_Framework/ProjectSettings/ProjectSettings.asset b/HOILAI_Galgame_Framework/ProjectSettings/ProjectSettings.asset index 1d2822b..6a6457f 100644 --- a/HOILAI_Galgame_Framework/ProjectSettings/ProjectSettings.asset +++ b/HOILAI_Galgame_Framework/ProjectSettings/ProjectSettings.asset @@ -785,7 +785,8 @@ PlayerSettings: scriptingDefineSymbols: {} additionalCompilerArguments: {} platformArchitecture: {} - scriptingBackend: {} + scriptingBackend: + Standalone: 1 il2cppCompilerConfiguration: {} managedStrippingLevel: EmbeddedLinux: 1