Skip to content

Commit

Permalink
Implement PAL3A task system
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7c13 committed Aug 5, 2023
1 parent d894cc8 commit ebcc8d8
Show file tree
Hide file tree
Showing 18 changed files with 515 additions and 8 deletions.
180 changes: 176 additions & 4 deletions Assets/Resources/Prefabs/Pal3.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,140 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_HorizontalFit: 2
m_VerticalFit: 0
--- !u!1 &1792442932885571784
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4245985783789320137}
- component: {fileID: 7254318039037877255}
- component: {fileID: 1158269877521751333}
m_Layer: 5
m_Name: TaskInfo
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4245985783789320137
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1792442932885571784}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 26898775255300359}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7254318039037877255
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1792442932885571784}
m_CullTransparentMesh: 1
--- !u!114 &1158269877521751333
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1792442932885571784}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 9e1d886e63529bb4ca3c95ece3e3189c, type: 2}
m_sharedMaterial: {fileID: 2847917559404452115, guid: 9e1d886e63529bb4ca3c95ece3e3189c, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 20
m_fontSizeBase: 20
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 4
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &1934532916208982931
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2792,6 +2926,42 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!1 &5340890608913273276
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 26898775255300359}
m_Layer: 5
m_Name: TaskInfoBar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &26898775255300359
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5340890608913273276}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4245985783789320137}
m_Father: {fileID: 5749901358741972170}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -35, y: -25}
m_SizeDelta: {x: 600, y: 100}
m_Pivot: {x: 1, y: 1}
--- !u!1 &5675362535211298766
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -3481,6 +3651,7 @@ RectTransform:
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 26898775255300359}
- {fileID: 2546561680202900797}
m_Father: {fileID: 8627381932629902483}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand All @@ -3507,7 +3678,7 @@ Canvas:
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 7
m_AdditionalShaderChannelsFlag: 31
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
m_SortingOrder: 1001
Expand All @@ -3529,7 +3700,7 @@ MonoBehaviour:
m_ScaleFactor: 1
m_ReferenceResolution: {x: 1920, y: 1080}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0.3
m_MatchWidthOrHeight: 0.75
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
Expand Down Expand Up @@ -3904,8 +4075,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e9d6f17a4e68481a9705f217be9b4156, type: 3}
m_Name:
m_EditorClassIdentifier:
maxThresholdRatio: 1.66667
minThresholdRatio: 1.4
maxThresholdRatio: 1.6
minThresholdRatio: 1.3
minWidth: 800
midWidth: 950
maxWidth: 1100
Expand Down Expand Up @@ -3997,6 +4168,7 @@ MonoBehaviour:
videoPlayer: {fileID: 4844794614659113022}
noteCanvasGroup: {fileID: 6941303344842138483}
noteText: {fileID: 7580806740173732748}
taskInfoText: {fileID: 1158269877521751333}
dialogueCanvasGroup: {fileID: 4450587676581078315}
dialogueBackgroundImage: {fileID: 3596785283706710040}
dialogueAvatarImageLeft: {fileID: 2858011271090605436}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RenderTexture:
m_UseDynamicScale: 0
m_BindMS: 0
m_EnableCompatibleFormat: 1
m_EnableRandomWrite: 0
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
Expand Down
8 changes: 8 additions & 0 deletions Assets/Scripts/Core/DataReader/Txt.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Assets/Scripts/Core/DataReader/Txt/TaskDefinitionFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Core.DataReader.Txt
{
using System;

public struct Task
{
public string TaskId;
public string TaskTitle;
public string TaskInfo;
public string TaskType;
public string IsLastOne;

public bool IsMainTask => string.Equals(TaskType, "0", StringComparison.Ordinal);
}

public sealed class TaskDefinitionFile
{
public Task[] Tasks { get; }

public TaskDefinitionFile(Task[] tasks)
{
Tasks = tasks;
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Core/DataReader/Txt/TaskDefinitionFile.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions Assets/Scripts/Core/DataReader/Txt/TaskDefinitionFileReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Core.DataReader.Txt
{
using System;
using System.Collections.Generic;
using System.Text;

public sealed class TaskDefinitionFileReader : IFileReader<TaskDefinitionFile>
{
private readonly int _codepage;

public TaskDefinitionFileReader(int codepage)
{
_codepage = codepage;
}

public TaskDefinitionFile Read(IBinaryReader reader)
{
throw new NotImplementedException();
}

public TaskDefinitionFile Read(byte[] data)
{
var content = Encoding.GetEncoding(_codepage).GetString(data, 0, data.Length);
var tasks = new List<Task>();
var taskLines = content.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
var currentTask = new Task();

foreach (var taskLine in taskLines)
{
if (taskLine.TrimStart().StartsWith(";")) continue;

var splitLine = taskLine.Split('$');
var tag = splitLine[0].Trim();
var value = splitLine.Length > 1 ? splitLine[1].Trim().Trim('$', '&') : string.Empty;

switch (tag)
{
case "tname":
currentTask.TaskId = value;
break;
case "title":
currentTask.TaskTitle = value;
break;
case "info":
currentTask.TaskInfo = value;
break;
case "type":
currentTask.TaskType = value;
break;
case "last":
currentTask.IsLastOne = value;
break;
case "#":
tasks.Add(currentTask);
currentTask = new Task(); // reset task for next one
break;
}
}

return new TaskDefinitionFile(tasks.ToArray());
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ebcc8d8

Please sign in to comment.