diff --git a/Assets/Default/Sprites/UI/SpeechBubbles/leftlarge.xml b/Assets/Default/Sprites/UI/SpeechBubbles/leftlarge.xml index a0f6b63ed..3d73b4ea5 100644 --- a/Assets/Default/Sprites/UI/SpeechBubbles/leftlarge.xml +++ b/Assets/Default/Sprites/UI/SpeechBubbles/leftlarge.xml @@ -1,7 +1,7 @@ - - + + 156 \ No newline at end of file diff --git a/Assets/Default/Sprites/UI/SpeechBubbles/leftlargeminus.xml b/Assets/Default/Sprites/UI/SpeechBubbles/leftlargeminus.xml index a2b7b6c5d..3e6c6b8fa 100644 --- a/Assets/Default/Sprites/UI/SpeechBubbles/leftlargeminus.xml +++ b/Assets/Default/Sprites/UI/SpeechBubbles/leftlargeminus.xml @@ -3,5 +3,5 @@ - 165 + 170 \ No newline at end of file diff --git a/Assets/Default/Sprites/UI/SpeechBubbles/leftwide.xml b/Assets/Default/Sprites/UI/SpeechBubbles/leftwide.xml index f14046f53..c31953852 100644 --- a/Assets/Default/Sprites/UI/SpeechBubbles/leftwide.xml +++ b/Assets/Default/Sprites/UI/SpeechBubbles/leftwide.xml @@ -3,5 +3,5 @@ - 194 + 190 \ No newline at end of file diff --git a/Assets/Default/Sprites/UI/SpeechBubbles/leftwideminus.xml b/Assets/Default/Sprites/UI/SpeechBubbles/leftwideminus.xml index 51d81411c..1e57e5e1f 100644 --- a/Assets/Default/Sprites/UI/SpeechBubbles/leftwideminus.xml +++ b/Assets/Default/Sprites/UI/SpeechBubbles/leftwideminus.xml @@ -3,5 +3,5 @@ - 150 + 140 \ No newline at end of file diff --git a/Assets/Default/Sprites/UI/SpeechBubbles/rightlarge.xml b/Assets/Default/Sprites/UI/SpeechBubbles/rightlarge.xml index a32daef3c..f6ad04154 100644 --- a/Assets/Default/Sprites/UI/SpeechBubbles/rightlarge.xml +++ b/Assets/Default/Sprites/UI/SpeechBubbles/rightlarge.xml @@ -1,7 +1,7 @@ - + 160 \ No newline at end of file diff --git a/Assets/Default/Sprites/UI/SpeechBubbles/rightlargeminus.xml b/Assets/Default/Sprites/UI/SpeechBubbles/rightlargeminus.xml index f3513d0d6..390337f10 100644 --- a/Assets/Default/Sprites/UI/SpeechBubbles/rightlargeminus.xml +++ b/Assets/Default/Sprites/UI/SpeechBubbles/rightlargeminus.xml @@ -1,7 +1,7 @@ - + 165 \ No newline at end of file diff --git a/Assets/Default/Sprites/UI/SpeechBubbles/rightlong.png b/Assets/Default/Sprites/UI/SpeechBubbles/rightlong.png index 412372cca..7312f9b15 100644 Binary files a/Assets/Default/Sprites/UI/SpeechBubbles/rightlong.png and b/Assets/Default/Sprites/UI/SpeechBubbles/rightlong.png differ diff --git a/Assets/Default/Sprites/UI/SpeechBubbles/rightlong.xml b/Assets/Default/Sprites/UI/SpeechBubbles/rightlong.xml index 5d684c2d7..ba1c54737 100644 --- a/Assets/Default/Sprites/UI/SpeechBubbles/rightlong.xml +++ b/Assets/Default/Sprites/UI/SpeechBubbles/rightlong.xml @@ -3,5 +3,5 @@ - 76 + 77 \ No newline at end of file diff --git a/Assets/Default/Sprites/UI/SpeechBubbles/rightwide.xml b/Assets/Default/Sprites/UI/SpeechBubbles/rightwide.xml index 0ad7b3757..3f4d7517d 100644 --- a/Assets/Default/Sprites/UI/SpeechBubbles/rightwide.xml +++ b/Assets/Default/Sprites/UI/SpeechBubbles/rightwide.xml @@ -3,5 +3,5 @@ - 194 + 188 \ No newline at end of file diff --git a/Assets/Default/Sprites/UI/SpeechBubbles/rightwideminus.xml b/Assets/Default/Sprites/UI/SpeechBubbles/rightwideminus.xml index e643fe9ac..100e6bf3a 100644 --- a/Assets/Default/Sprites/UI/SpeechBubbles/rightwideminus.xml +++ b/Assets/Default/Sprites/UI/SpeechBubbles/rightwideminus.xml @@ -3,5 +3,5 @@ - 150 + 145 \ No newline at end of file diff --git a/Assets/Default/Sprites/spr_chestbox_0.png b/Assets/Default/Sprites/spr_chestbox_0.png new file mode 100644 index 000000000..d3f68217e Binary files /dev/null and b/Assets/Default/Sprites/spr_chestbox_0.png differ diff --git a/Assets/Default/Sprites/spr_chestbox_0.png.meta b/Assets/Default/Sprites/spr_chestbox_0.png.meta new file mode 100644 index 000000000..0f66d9638 --- /dev/null +++ b/Assets/Default/Sprites/spr_chestbox_0.png.meta @@ -0,0 +1,88 @@ +fileFormatVersion: 2 +guid: 0acd4547315eb914f93ba1859fa4f79b +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 7 + 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 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + 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 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 9187d3978fa87f6438d5679a9fd4af33 + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mods/@0.5.0_SEE_CRATE/Lua/Waves/bullettest_touhou.lua b/Assets/Mods/@0.5.0_SEE_CRATE/Lua/Waves/bullettest_touhou.lua index d1a405d65..1017857d6 100644 --- a/Assets/Mods/@0.5.0_SEE_CRATE/Lua/Waves/bullettest_touhou.lua +++ b/Assets/Mods/@0.5.0_SEE_CRATE/Lua/Waves/bullettest_touhou.lua @@ -5,8 +5,8 @@ bg.y = 240 bg.color = {0,0,0} if enemies[1]["name"] ~= "Punderbolt" then local buttoncover = CreateSprite("UI/sq_white", "BelowArena") - buttoncover.Scale(640/4,49/4) - buttoncover.MoveTo(320,24.5) + buttoncover.Scale(640/4,50/4) + buttoncover.MoveTo(320,25) buttoncover.color = {0,0,0} local namecover = CreateSprite("UI/sq_white", "BelowArena") namecover.SetPivot(0,0.5) diff --git a/Assets/Mods/Examples/Lua/Events/BoxTest.lua b/Assets/Mods/Examples/Lua/Events/BoxTest.lua new file mode 100644 index 000000000..dc4e898d2 --- /dev/null +++ b/Assets/Mods/Examples/Lua/Events/BoxTest.lua @@ -0,0 +1,6 @@ +function EventPage1() + General.SetChoice({"Yes", "No"}, "Use the box?") + if lastChoice == 0 then + Inventory.SpawnBoxMenu() + end +end \ No newline at end of file diff --git a/Assets/Mods/Examples/Lua/Events/BoxTest.lua.meta b/Assets/Mods/Examples/Lua/Events/BoxTest.lua.meta new file mode 100644 index 000000000..5272b97f1 --- /dev/null +++ b/Assets/Mods/Examples/Lua/Events/BoxTest.lua.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: de746af2dcdb535418a46d9be90ea71a +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor.cs b/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor.cs index 2d5776c07..683d16541 100644 --- a/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor.cs +++ b/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor.cs @@ -8,10 +8,11 @@ namespace MoonSharp.Interpreter.Execution.VM { sealed partial class Processor { - ByteCode m_RootChunk; + public ByteCode m_RootChunk; + public Instruction m_doFileRequireHack; - FastStack m_ValueStack = new FastStack(131072); - FastStack m_ExecutionStack = new FastStack(131072); + public FastStack m_ValueStack = new FastStack(131072); + public FastStack m_ExecutionStack = new FastStack(131072); List m_CoroutinesStack; Table m_GlobalTable; diff --git a/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor_Errors.cs b/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor_Errors.cs index 65e786593..c86f5abd4 100644 --- a/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor_Errors.cs +++ b/Assets/Plugins/MoonSharp/Interpreter/Execution/VM/Processor/Processor_Errors.cs @@ -6,10 +6,10 @@ sealed partial class Processor { private SourceRef GetCurrentSourceRef(int instructionPtr) { - if (instructionPtr >= 0 && instructionPtr < m_RootChunk.Code.Count) - { + if (m_doFileRequireHack != null) + return m_doFileRequireHack.SourceCodeRef; + else if (instructionPtr >= 0 && instructionPtr < m_RootChunk.Code.Count) return m_RootChunk.Code[instructionPtr].SourceCodeRef; - } return null; } diff --git a/Assets/Plugins/MoonSharp/Interpreter/Script.cs b/Assets/Plugins/MoonSharp/Interpreter/Script.cs index 6e3bb11aa..612e347e5 100644 --- a/Assets/Plugins/MoonSharp/Interpreter/Script.cs +++ b/Assets/Plugins/MoonSharp/Interpreter/Script.cs @@ -179,9 +179,7 @@ public DynValue LoadString(string code, Table globalTable = null, string codeFri m_Sources.Add(source); - int address = Loader_Fast.LoadChunk(this, - source, - m_ByteCode); + int address = Loader_Fast.LoadChunk(this, source, m_ByteCode, m_MainProcessor); SignalSourceCodeChange(source); SignalByteCodeChange(); diff --git a/Assets/Plugins/MoonSharp/Interpreter/Tree/Fast_Interface/Loader_Fast.cs b/Assets/Plugins/MoonSharp/Interpreter/Tree/Fast_Interface/Loader_Fast.cs index e3775921a..3fa23731a 100644 --- a/Assets/Plugins/MoonSharp/Interpreter/Tree/Fast_Interface/Loader_Fast.cs +++ b/Assets/Plugins/MoonSharp/Interpreter/Tree/Fast_Interface/Loader_Fast.cs @@ -41,9 +41,10 @@ private static ScriptLoadingContext CreateLoadingContext(Script script, SourceCo }; } - internal static int LoadChunk(Script script, SourceCode source, ByteCode bytecode) + internal static int LoadChunk(Script script, SourceCode source, ByteCode bytecode, Processor processor) { ScriptLoadingContext lcontext = CreateLoadingContext(script, source); + try { Statement stat; @@ -55,6 +56,7 @@ internal static int LoadChunk(Script script, SourceCode source, ByteCode bytecod //var srcref = new SourceRef(source.SourceID); + using (script.PerformanceStats.StartStopwatch(Diagnostics.PerformanceCounter.Compilation)) using (bytecode.EnterSource(null)) { @@ -70,7 +72,9 @@ internal static int LoadChunk(Script script, SourceCode source, ByteCode bytecod } catch (SyntaxErrorException ex) { - ex.DecorateMessage(script); + Instruction i = new Instruction(lcontext.Lexer.Current.GetSourceRef()) { OpCode = OpCode.Nop, Name = "none" }; + processor.m_doFileRequireHack = i; + ex.DecorateMessage(script, lcontext.Lexer.Current.GetSourceRef()); ex.Rethrow(); throw; } diff --git a/Assets/Scenes/TransitionOverworld.unity b/Assets/Scenes/TransitionOverworld.unity index a51d09bad..418f5fc9b 100644 --- a/Assets/Scenes/TransitionOverworld.unity +++ b/Assets/Scenes/TransitionOverworld.unity @@ -5393,7 +5393,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 1731033919} - m_RootOrder: 4 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -6277,6 +6277,7 @@ RectTransform: - {fileID: 743800824} - {fileID: 670959144} - {fileID: 952942992} + - {fileID: 1957097253} - {fileID: 1117834469} m_Father: {fileID: 1779322336} m_RootOrder: 8 @@ -7246,6 +7247,79 @@ CanvasRenderer: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1942351437} m_CullTransparentMesh: 0 +--- !u!1 &1957097252 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 183300, guid: 65ee94c713ee95942a47240fb8f2ae5c, + type: 2} + m_PrefabInternal: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1957097253} + - component: {fileID: 1957097255} + - component: {fileID: 1957097254} + m_Layer: 5 + m_Name: itembox + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1957097253 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 22418524, guid: 65ee94c713ee95942a47240fb8f2ae5c, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1957097252} + 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_Children: [] + m_Father: {fileID: 1731033919} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -320, y: -240} + m_SizeDelta: {x: 640, y: 480} + m_Pivot: {x: 0, y: 0} +--- !u!114 &1957097254 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 11481144, guid: 65ee94c713ee95942a47240fb8f2ae5c, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1957097252} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 21300000, guid: 1940471d360cdfc4390f579caff5a009, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 +--- !u!222 &1957097255 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 22269356, guid: 65ee94c713ee95942a47240fb8f2ae5c, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1957097252} + m_CullTransparentMesh: 0 --- !u!1 &1977298764 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/test2.unity b/Assets/Scenes/test2.unity index 5695dd6db..8efc54ebf 100644 --- a/Assets/Scenes/test2.unity +++ b/Assets/Scenes/test2.unity @@ -198,49 +198,6 @@ EdgeCollider2D: m_Points: - {x: -0.5, y: 0} - {x: 0.5, y: 0} ---- !u!1 &50872521 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 1849668906715600, guid: a0add8308da8d24468328221253c3ec7, - type: 2} - m_PrefabInternal: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 50872523} - - component: {fileID: 50872522} - m_Layer: 0 - m_Name: SpritePivot - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!210 &50872522 -SortingGroup: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 210702407409670196, guid: a0add8308da8d24468328221253c3ec7, - type: 2} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 50872521} - m_Enabled: 1 - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!4 &50872523 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 4671881132980978, guid: a0add8308da8d24468328221253c3ec7, - type: 2} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 50872521} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 280, y: 186, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 157357802} - m_Father: {fileID: 0} - m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &131311699 GameObject: m_ObjectHideFlags: 0 @@ -282,171 +239,8 @@ Transform: m_Children: - {fileID: 2106957597} m_Father: {fileID: 0} - m_RootOrder: 6 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &157357796 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 157357802} - - component: {fileID: 157357801} - - component: {fileID: 157357800} - - component: {fileID: 157357799} - - component: {fileID: 157357798} - - component: {fileID: 157357797} - m_Layer: 21 - m_Name: Bpie3 - m_TagString: Event - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!114 &157357797 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 157357796} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5b6761159c8f6224a8a895abea10dd25, type: 3} - m_Name: - m_EditorClassIdentifier: - SetNativeSize: 1 - SpritePath: Overworld/Bpie - Loop: 0 - SoundPath: - done: 0 ---- !u!114 &157357798 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 157357796} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 846d0d1a9b9e1c14884c79473a1f1d14, type: 3} - m_Name: - m_EditorClassIdentifier: - scriptToLoad: Bpie - actualPage: 3 - eventTriggers: - - {x: 1, y: 0} - - {x: 2, y: 2} - - {x: 3, y: 2} - moveSpeed: 1 ---- !u!61 &157357799 -BoxCollider2D: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 157357796} - m_Enabled: 1 - m_Density: 1 - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_UsedByEffector: 0 - m_UsedByComposite: 0 - m_Offset: {x: 0, y: 0.15} - m_SpriteTilingProperty: - border: {x: 0, y: 0, z: 0, w: 0} - pivot: {x: 0.5, y: 0.5} - oldSize: {x: 0.4, y: 0.28} - newSize: {x: 0.4, y: 0.28} - adaptiveTilingThreshold: 0.5 - drawMode: 0 - adaptiveTiling: 0 - m_AutoTiling: 0 - serializedVersion: 2 - m_Size: {x: 0.4, y: 0.3} - m_EdgeRadius: 0 ---- !u!50 &157357800 -Rigidbody2D: - serializedVersion: 4 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 157357796} - m_BodyType: 1 - m_Simulated: 1 - m_UseFullKinematicContacts: 0 - m_UseAutoMass: 0 - m_Mass: 1 - m_LinearDrag: 0 - m_AngularDrag: 0.05 - m_GravityScale: 1 - m_Material: {fileID: 0} - m_Interpolate: 0 - m_SleepingMode: 1 - m_CollisionDetection: 0 - m_Constraints: 0 ---- !u!212 &157357801 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 157357796} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 0 - m_ReflectionProbeUsage: 0 - m_RenderingLayerMask: 4294967295 - m_Materials: - - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 0 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: ef6b4cbe2b261634d9c5bd2811405b0d, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 0.4, y: 0.28} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 ---- !u!224 &157357802 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 157357796} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 100, y: 100, z: 1} - m_Children: [] - m_Father: {fileID: 50872523} - m_RootOrder: 0 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - 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: 0.4, y: 0.28} - m_Pivot: {x: 0.5, y: 0} --- !u!1 &178145621 GameObject: m_ObjectHideFlags: 0 @@ -554,7 +348,7 @@ Transform: m_Children: - {fileID: 1441977566} m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &413061391 GameObject: @@ -924,49 +718,6 @@ PolygonCollider2D: - {x: -0.6122708, y: -1.6012062} - {x: -0.606358, y: -2.399723} - {x: -3.1997173, y: -2.4001143} ---- !u!1 &1033740881 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 1849668906715600, guid: a0add8308da8d24468328221253c3ec7, - type: 2} - m_PrefabInternal: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1033740883} - - component: {fileID: 1033740882} - m_Layer: 0 - m_Name: SpritePivot - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!210 &1033740882 -SortingGroup: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 210702407409670196, guid: a0add8308da8d24468328221253c3ec7, - type: 2} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1033740881} - m_Enabled: 1 - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!4 &1033740883 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 4671881132980978, guid: a0add8308da8d24468328221253c3ec7, - type: 2} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1033740881} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 167, y: 286, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 1844181798} - m_Father: {fileID: 0} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1137831012 GameObject: m_ObjectHideFlags: 0 @@ -1531,6 +1282,12 @@ Prefab: propertyPath: m_Name value: SpritePivot objectReference: {fileID: 0} + - target: {fileID: 212134501322781040, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_Sprite + value: + objectReference: {fileID: 21300000, guid: 49257d0756bb14041b22743111edac9c, + type: 3} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: a0add8308da8d24468328221253c3ec7, type: 2} m_IsPrefabAsset: 0 @@ -1919,7 +1676,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 4671881132980978, guid: a0add8308da8d24468328221253c3ec7, type: 2} propertyPath: m_RootOrder - value: 7 + value: 5 objectReference: {fileID: 0} - target: {fileID: 1849668906715600, guid: a0add8308da8d24468328221253c3ec7, type: 2} propertyPath: m_Name @@ -2221,169 +1978,432 @@ EdgeCollider2D: m_Points: - {x: -0.5, y: 0} - {x: 0.5, y: 0} ---- !u!1 &1844181792 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1844181798} - - component: {fileID: 1844181797} - - component: {fileID: 1844181796} - - component: {fileID: 1844181795} - - component: {fileID: 1844181794} - - component: {fileID: 1844181793} - m_Layer: 21 - m_Name: Bpie2 - m_TagString: Event - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1844181793 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1844181792} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5b6761159c8f6224a8a895abea10dd25, type: 3} - m_Name: - m_EditorClassIdentifier: - SetNativeSize: 1 - SpritePath: Overworld/Bpie - Loop: 0 - SoundPath: - done: 0 ---- !u!114 &1844181794 -MonoBehaviour: +--- !u!1001 &1973657632 +Prefab: m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1844181792} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 846d0d1a9b9e1c14884c79473a1f1d14, type: 3} - m_Name: - m_EditorClassIdentifier: - scriptToLoad: Bpie - actualPage: 1 - eventTriggers: - - {x: 0, y: 0} - - {x: 1, y: 0} - - {x: 2, y: 2} - moveSpeed: 1 ---- !u!61 &1844181795 -BoxCollider2D: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1844181792} - m_Enabled: 1 - m_Density: 1 - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_UsedByEffector: 0 - m_UsedByComposite: 0 - m_Offset: {x: 0, y: 0.15} - m_SpriteTilingProperty: - border: {x: 0, y: 0, z: 0, w: 0} - pivot: {x: 0.5, y: 0.5} - oldSize: {x: 0.4, y: 0.28} - newSize: {x: 0.4, y: 0.28} - adaptiveTilingThreshold: 0.5 - drawMode: 0 - adaptiveTiling: 0 - m_AutoTiling: 0 serializedVersion: 2 - m_Size: {x: 0.4, y: 0.3} - m_EdgeRadius: 0 ---- !u!50 &1844181796 -Rigidbody2D: - serializedVersion: 4 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1844181792} - m_BodyType: 1 - m_Simulated: 1 - m_UseFullKinematicContacts: 0 - m_UseAutoMass: 0 - m_Mass: 1 - m_LinearDrag: 0 - m_AngularDrag: 0.05 - m_GravityScale: 1 - m_Material: {fileID: 0} - m_Interpolate: 0 - m_SleepingMode: 1 - m_CollisionDetection: 0 - m_Constraints: 0 ---- !u!212 &1844181797 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1844181792} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 0 - m_ReflectionProbeUsage: 0 - m_RenderingLayerMask: 4294967295 - m_Materials: - - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 0 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: ef6b4cbe2b261634d9c5bd2811405b0d, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 0.4, y: 0.28} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 ---- !u!224 &1844181798 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1844181792} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 100, y: 100, z: 1} - m_Children: [] - m_Father: {fileID: 1033740883} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - 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: 0.4, y: 0.28} - m_Pivot: {x: 0.5, y: 0} + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 11460532, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: eventTriggers.Array.size + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.size + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_RootOrder + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_AnchoredPosition.x + value: 1040 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_AnchoredPosition.y + value: 740 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_SizeDelta.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_SizeDelta.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_AnchorMin.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_AnchorMax.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_Pivot.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 114980733475525374, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: SpritePath + value: + objectReference: {fileID: 0} + - target: {fileID: 11460532, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: eventTriggers.Array.data[1].x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11460532, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: eventTriggers.Array.data[2].x + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 11460532, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: eventTriggers.Array.data[3].x + value: 4 + objectReference: {fileID: 0} + - target: {fileID: 11460532, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: eventTriggers.Array.data[4].x + value: 666 + objectReference: {fileID: 0} + - target: {fileID: 11460532, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: moveSpeed + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 21250564, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_Sprite + value: + objectReference: {fileID: 21300000, guid: 29b8b27a4045bde4c8ba97c1a30b2095, + type: 3} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_LocalScale.x + value: 200 + objectReference: {fileID: 0} + - target: {fileID: 22437642, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_LocalScale.y + value: 200 + objectReference: {fileID: 0} + - target: {fileID: 6188160, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_Size.x + value: 0.34 + objectReference: {fileID: 0} + - target: {fileID: 6188160, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_Size.y + value: 0.3 + objectReference: {fileID: 0} + - target: {fileID: 11460532, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: scriptToLoad + value: Secret/68302eae + objectReference: {fileID: 0} + - target: {fileID: 124458, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_Name + value: 68302eae + objectReference: {fileID: 0} + - target: {fileID: 114980733475525374, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: SetNativeSize + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6188160, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_Offset.y + value: 0.148 + objectReference: {fileID: 0} + - target: {fileID: 21250564, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_Size.x + value: 0.28 + objectReference: {fileID: 0} + - target: {fileID: 21250564, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_Size.y + value: 0.38 + objectReference: {fileID: 0} + - target: {fileID: 6188160, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_SpriteTilingProperty.pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6188160, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_SpriteTilingProperty.pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 6188160, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_SpriteTilingProperty.oldSize.x + value: 0.38 + objectReference: {fileID: 0} + - target: {fileID: 6188160, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_SpriteTilingProperty.oldSize.y + value: 0.58 + objectReference: {fileID: 0} + - target: {fileID: 6188160, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_SpriteTilingProperty.newSize.x + value: 0.28 + objectReference: {fileID: 0} + - target: {fileID: 6188160, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_SpriteTilingProperty.newSize.y + value: 0.38 + objectReference: {fileID: 0} + - target: {fileID: 6188160, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_SpriteTilingProperty.adaptiveTilingThreshold + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 224194490068971162, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_AnchoredPosition.x + value: 400 + objectReference: {fileID: 0} + - target: {fileID: 224194490068971162, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_AnchoredPosition.y + value: 200 + objectReference: {fileID: 0} + - target: {fileID: 224194490068971162, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_LocalScale.x + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 224194490068971162, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_LocalScale.y + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 224194490068971162, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_RootOrder + value: 4 + objectReference: {fileID: 0} + - target: {fileID: 21250564, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_Color.a + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4671881132980978, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_RootOrder + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 1849668906715600, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_Name + value: SpritePivot + objectReference: {fileID: 0} + - target: {fileID: 1649222073514108, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_Name + value: Boxybox + objectReference: {fileID: 0} + - target: {fileID: 114226206946908324, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: SpritePath + value: spr_chestbox_0 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[3].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[4].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[0].x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[1].x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[2].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: moveSpeed + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: scriptToLoad + value: BoxTest + objectReference: {fileID: 0} + - target: {fileID: 212134501322781040, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_Sprite + value: + objectReference: {fileID: 21300000, guid: 0acd4547315eb914f93ba1859fa4f79b, + type: 3} + - target: {fileID: 224528923083268334, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_LocalScale.x + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 224528923083268334, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_LocalScale.y + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 4671881132980978, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_LocalPosition.x + value: 240 + objectReference: {fileID: 0} + - target: {fileID: 4671881132980978, guid: a0add8308da8d24468328221253c3ec7, type: 2} + propertyPath: m_LocalPosition.y + value: 140 + objectReference: {fileID: 0} + - target: {fileID: 61614148327684554, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_SpriteTilingProperty.oldSize.x + value: 0.4 + objectReference: {fileID: 0} + - target: {fileID: 61614148327684554, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_SpriteTilingProperty.oldSize.y + value: 0.4 + objectReference: {fileID: 0} + - target: {fileID: 61614148327684554, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_Size.x + value: 0.4 + objectReference: {fileID: 0} + - target: {fileID: 61614148327684554, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_Size.y + value: 0.4 + objectReference: {fileID: 0} + - target: {fileID: 61614148327684554, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_Offset.y + value: 0.2 + objectReference: {fileID: 0} + - target: {fileID: 114226206946908324, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: SetNativeSize + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[5].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[6].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[7].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[8].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[9].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[10].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[11].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[12].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[13].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[14].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[15].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[16].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[17].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[18].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[19].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[20].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[21].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[22].x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 114879940000294058, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: eventTriggers.Array.data[2].y + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 224528923083268334, guid: a0add8308da8d24468328221253c3ec7, + type: 2} + propertyPath: m_SizeDelta.x + value: 1 + objectReference: {fileID: 0} + m_RemovedComponents: + - {fileID: 114980733475525374, guid: a0add8308da8d24468328221253c3ec7, type: 2} + m_SourcePrefab: {fileID: 100100000, guid: a0add8308da8d24468328221253c3ec7, type: 2} + m_IsPrefabAsset: 0 --- !u!1 &2088941609 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Battle/EnemyEncounter.cs b/Assets/Scripts/Battle/EnemyEncounter.cs index 955ad92b3..826a54951 100644 --- a/Assets/Scripts/Battle/EnemyEncounter.cs +++ b/Assets/Scripts/Battle/EnemyEncounter.cs @@ -27,15 +27,18 @@ protected string RandomEncounterText() { if (EnabledEnemies.Length <= 0) return ""; int randomEnemy = UnityEngine.Random.Range(0, EnabledEnemies.Length); - if (EnabledEnemies[randomEnemy].Comments.Length <= 0) + string[] comments; + try { comments = EnabledEnemies[randomEnemy].Comments; } + catch { throw new CYFException("RandomEncounterText: Can not read the \"comments\" table of enemy #" + (randomEnemy + 1).ToString() + ".\nAre you sure it's set?"); } + if (comments.Length <= 0) return ""; - int randomComment = UnityEngine.Random.Range(0, EnabledEnemies[randomEnemy].Comments.Length); - return EnabledEnemies[randomEnemy].Comments[randomComment]; + int randomComment = UnityEngine.Random.Range(0, comments.Length); + return comments[randomComment]; } public virtual void HandleItem(UnderItem item) { //if (!CustomItemHandler(item)) - item.inCombatUse(); + //item.inCombatUse(); } public virtual void HandleSpare() { diff --git a/Assets/Scripts/Battle/LuaEnemyController.cs b/Assets/Scripts/Battle/LuaEnemyController.cs index 52aa99bfd..86d1df099 100644 --- a/Assets/Scripts/Battle/LuaEnemyController.cs +++ b/Assets/Scripts/Battle/LuaEnemyController.cs @@ -214,11 +214,11 @@ private void Start() { script.scriptname = scriptName; script.Bind("SetSprite", (Action)SetSprite); script.Bind("SetActive", (Action)SetActive); - script.Bind("isActive", (Func)InFight); + script.Bind("isactive", DynValue.NewBoolean(true)); script.Bind("Kill", (Action)DoKill); script.Bind("Spare", (Action)DoSpare); - script.Bind("Move", (Action)Move); - script.Bind("MoveTo", (Action)MoveTo); + script.Bind("Move", (Action)Move); + script.Bind("MoveTo", (Action)MoveTo); script.Bind("BindToArena", (Action)BindToArena); script.Bind("SetDamage", (Action)SetDamage); script.Bind("SetBubbleOffset", (Action)SetBubbleOffset); @@ -246,7 +246,7 @@ private void Start() { /*if (script.GetVar("canspare") == null) CanSpare = false; if (script.GetVar("cancheck") == null) CanCheck = true;*/ } - catch (InterpreterException ex) { UnitaleUtil.DisplayLuaError(scriptName, ex.DecoratedMessage); } + catch (InterpreterException ex) { UnitaleUtil.DisplayLuaError(scriptName, ex.DecoratedMessage != null ? ex.DecoratedMessage : ex.Message); } catch (Exception ex) { UnitaleUtil.DisplayLuaError(scriptName, "Unknown error. Usually means you're missing a sprite.\nSee documentation for details.\nStacktrace below in case you wanna notify a dev.\n\nError: " + ex.Message + "\n\n" + ex.StackTrace); } } @@ -353,23 +353,24 @@ public void DoKill() { /// Set if we should consider this monster for menus e.g. /// /// - public void SetActive(bool active) { inFight = active; } + public void SetActive(bool active) { + inFight = active; + script.SetVar("isactive", DynValue.NewBoolean(active)); + } - public void Move(float x, float y, bool bindToArena = false) { + public void Move(float x, float y) { if (!canMove) return; GetComponent().position = new Vector2(GetComponent().position.x + x, GetComponent().position.y + y); } - public void MoveTo(float x, float y, bool bindToArena = false) { + public void MoveTo(float x, float y) { if (!canMove) return; GetComponent().position = new Vector2(x, y); } public void BindToArena(bool bind, bool isUnderArena = false) { - if (!canMove) - return; int count = 0; if (bind) { //If bind :ahde: foreach (LuaEnemyController luaec in GameObject.FindObjectsOfType()) //for each enemies... diff --git a/Assets/Scripts/Battle/LuaEnemyEncounter.cs b/Assets/Scripts/Battle/LuaEnemyEncounter.cs index f0faf14be..9b65436f3 100644 --- a/Assets/Scripts/Battle/LuaEnemyEncounter.cs +++ b/Assets/Scripts/Battle/LuaEnemyEncounter.cs @@ -95,6 +95,13 @@ private DynValue CreateProjectile(Script s, string sprite, float xpos, float ypo private void PrepareWave() { DynValue nextWaves = script.GetVar("nextwaves"); + if (nextWaves.Type != DataType.Table) { + if (nextWaves.Type == DataType.Nil) + UnitaleUtil.DisplayLuaError(StaticInits.ENCOUNTER, "nextwaves is not defined in your script."); + else + UnitaleUtil.DisplayLuaError(StaticInits.ENCOUNTER, "nextwaves is a " + nextWaves.Type.ToString() + ", but should be a table."); + return; + } waves = new ScriptWrapper[nextWaves.Table.Length]; waveNames = new string[waves.Length]; int currentWaveScript = 0; @@ -103,7 +110,7 @@ private void PrepareWave() { for (int i = 0; i < waves.Length; i++) { currentWaveScript = i; DynValue ArenaStatus = UserData.Create(ArenaManager.luaStatus); - waves[i] = new ScriptWrapper() { script = LuaScriptBinder.BoundScript() }; + waves[i] = new ScriptWrapper(); waves[i].script.Globals.Set("Arena", ArenaStatus); waves[i].script.Globals["EndWave"] = (Action)EndWaveTimer; waves[i].script.Globals["State"] = (Action)UIController.SwitchStateOnString; @@ -318,8 +325,11 @@ public override void EndWave(bool death = false) { Table t = script["Wave"].Table; if (!death) foreach (object obj in t.Keys) { - try { ((ScriptWrapper)t[obj]).Call("EndingWave"); } - catch { UnitaleUtil.DisplayLuaError(StaticInits.ENCOUNTER, "You shouldn't override Wave, now you get an error :P"); } + try { + ((ScriptWrapper)t[obj]).Call("EndingWave"); + ScriptWrapper.instances.Remove(((ScriptWrapper)t[obj])); + LuaScriptBinder.scriptlist.Remove(((ScriptWrapper)t[obj]).script); + } catch { UnitaleUtil.DisplayLuaError(StaticInits.ENCOUNTER, "You shouldn't override Wave, now you get an error :P"); } } if (!GlobalControls.retroMode) foreach (LuaProjectile p in FindObjectsOfType()) diff --git a/Assets/Scripts/Battle/UIController.cs b/Assets/Scripts/Battle/UIController.cs index f88dc5716..ac9592c3b 100644 --- a/Assets/Scripts/Battle/UIController.cs +++ b/Assets/Scripts/Battle/UIController.cs @@ -9,13 +9,13 @@ using UnityEngine.SceneManagement; /// -/// The class responsible for making some people lose faith in the project. In very dire need of refactoring, +/// The class responsible for making some people lose faith in the project. In very dire need of refactoring, /// but hard to do until functionality can be split into battle and overworld functions. -/// +/// /// As it stands this class is a messy finite state machine that takes care of controlling not only the battle, /// but also a lot of things it shouldn't (text manager, enemy dialogue, keyboard controls etc.) /// If you're familiar with the term cyclomatic complexity, you probably wouldn't want to hire me at this point. -/// +/// /// The eventual redesign of the UI controller will try to change over as much of the functionality to Lua. /// As we're missing some key functionality to accomplish this, refactoring has been put off for now. /// @@ -91,13 +91,13 @@ public enum UIState { UNUSED, //Used for OnDeath. Keep this state secret, please. PAUSE // Used exclusively for State("PAUSE"). Not a real state, but it needs to be listed to allow users to call State("PAUSE"). } - + // Variables for PAUSE's "encounter freezing" behavior public UIState frozenState = UIState.PAUSE; // used to keep track of what state was frozen public float frozenTimestamp = 0.0f; // used for DEFENDING's wavetimer private bool frozenControlOverride = true; // used for the player's control override private bool frozenPlayerVisibility= true; // used for the player's invincibility timer when hurt - + public delegate void Message(); public static event Message SendToStaticInits; @@ -120,25 +120,29 @@ public static void EndBattle(bool fromGameOver = false) { if (GameObject.Find("TopLayer")) spr.layer = "Top"; spr.Scale(640, 480); + if (GlobalControls.modDev) // empty the inventory if not in the overworld + Inventory.inventory.Clear(); Inventory.RemoveAddedItems(); GlobalControls.lastTitle = false; PlayerCharacter.instance.MaxHPShift = 0; + PlayerCharacter.instance.SetLevel(PlayerCharacter.instance.LV); #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN if (GlobalControls.crate) Misc.WindowName = ControlPanel.instance.WinodwBsaisNmae; else Misc.WindowName = ControlPanel.instance.WindowBasisName; #endif - + // reset the battle camera's position Misc.ResetCamera(); - + // stop encounter storage for good! ScriptWrapper.instances.Clear(); - + // properly set "isInFight" to false, as it shouldn't be true anymore GlobalControls.isInFight = false; - + for (int i = 0; i < LuaScriptBinder.scriptlist.Count; i++) LuaScriptBinder.scriptlist[i] = null; + LuaScriptBinder.scriptlist.Clear(); LuaScriptBinder.ClearBattleVar(); GlobalControls.stopScreenShake = true; MusicManager.hiddenDictionary.Clear(); @@ -198,13 +202,13 @@ public void SwitchState(UIState state, bool first = false) { } // END DEBUG // below: actions based on ending a previous state, or actions that affect multiple states - + // PAUSE can freeze states if (state == UIState.PAUSE && frozenState != UIState.PAUSE) return; else if (state == UIState.PAUSE && frozenState == UIState.PAUSE) { frozenState = this.state; - + // execute extra code based on the state that is being frozen switch(frozenState) { case UIState.ACTIONSELECT: @@ -214,7 +218,7 @@ public void SwitchState(UIState state, bool first = false) { case UIState.DEFENDING: frozenControlOverride = PlayerController.instance.overrideControl; PlayerController.instance.setControlOverride(true); - + frozenTimestamp = Time.time; break; case UIState.ENEMYDIALOGUE: @@ -227,17 +231,17 @@ public void SwitchState(UIState state, bool first = false) { FightUI fui = fightUI.boundFightUiInstances[0]; if (fui.slice != null && fui.slice.keyframes != null) fui.slice.keyframes.paused = true; - + if (fightUI.line != null && fightUI.line.keyframes != null) fightUI.line.keyframes.paused = true; break; } - + frozenPlayerVisibility = PlayerController.instance.selfImg.enabled; PlayerController.instance.selfImg.enabled = true; - + // Debug.Log("Freezing state " + frozenState.ToString() + ""); - + return; //else if (state != UIState.NONE && this.state == UIState.NONE && frozenState != UIState.NONE) { } else if (state == frozenState && frozenState != UIState.PAUSE) { @@ -249,7 +253,7 @@ public void SwitchState(UIState state, bool first = false) { break; case UIState.DEFENDING: PlayerController.instance.setControlOverride(frozenControlOverride); - + frozenTimestamp = Time.time - frozenTimestamp; encounter.waveTimer += frozenTimestamp; break; @@ -263,28 +267,28 @@ public void SwitchState(UIState state, bool first = false) { FightUI fui = fightUI.boundFightUiInstances[0]; if (fui.slice != null && fui.slice.keyframes != null) fui.slice.keyframes.paused = false; - + if (fightUI.line != null && fightUI.line.keyframes != null) fightUI.line.keyframes.paused = false; break; } - + // Debug.Log("Unfreezing state " + frozenState.ToString() + ""); - + PlayerController.instance.selfImg.enabled = frozenPlayerVisibility; - + frozenState = UIState.PAUSE; - + return; } else if (frozenState != UIState.PAUSE) frozenState = UIState.PAUSE; - + frozenTimestamp = 0.0f; - + if (state == UIState.DEFENDING || state == UIState.ENEMYDIALOGUE) { PlayerController.instance.setControlOverride(state != UIState.DEFENDING); textmgr.DestroyText(); - PlayerController.instance.SetPositionQueue(320, 160, true); + PlayerController.instance.SetPosition(320, 160, true); PlayerController.instance.GetComponent().enabled = true; fightBtn.overrideSprite = null; actBtn.overrideSprite = null; @@ -316,6 +320,10 @@ public void SwitchState(UIState state, bool first = false) { encounter.EndWave(); switch (this.state) { case UIState.ATTACKING: + // Error for no active enemies + if (encounter.EnabledEnemies.Length == 0) + throw new CYFException("Cannot enter state ATTACKING with no active enemies."); + textmgr.DestroyText(); PlayerController.instance.GetComponent().enabled = false; if (!fightUI.multiHit) { @@ -355,9 +363,10 @@ public void SwitchState(UIState state, bool first = false) { case UIState.ITEMMENU: battleDialogued = false; - if (Inventory.inventory.Count == 0) { + // Error for empty inventory + if (Inventory.inventory.Count == 0) throw new CYFException("Cannot enter state ITEMMENU with empty inventory."); - } else { + else { string[] items = GetInventoryPage(0); selectedItem = 0; textmgr.SetText(new SelectMessage(items, false)); @@ -392,6 +401,10 @@ public void SwitchState(UIState state, bool first = false) { break; case UIState.ENEMYSELECT: + // Error for no active enemies + if (encounter.EnabledEnemies.Length == 0) + throw new CYFException("Cannot enter state ENEMYSELECT with no active enemies."); + string[] names = new string[encounter.EnabledEnemies.Length]; string[] colorPrefixes = new string[names.Length]; for (int i = 0; i < encounter.EnabledEnemies.Length; i++) { @@ -409,13 +422,13 @@ public void SwitchState(UIState state, bool first = false) { names = newnames; } for (int i = 0; i < names.Length; i++) - names[i] += "[color:ffffff]"; + names[i] += "[color:ffffff]"; textmgr.SetText(new SelectMessage(names, true, colorPrefixes)); if (forcedaction != Actions.FIGHT && forcedaction != Actions.ACT) forcedaction = action; if (forcedaction == Actions.FIGHT) { int maxWidth = (int)initialHealthPos.x, count = 0; - + for (int i = 0; i < encounter.EnabledEnemies.Length; i++) { if (encounter.EnabledEnemies.Length > 3) if (i > 1) @@ -495,7 +508,18 @@ public void SwitchState(UIState state, bool first = false) { Image speechBubImg = speechBub.GetComponent(); if (sbTextMan.CharacterCount(msgs[0]) == 0) speechBubImg.color = new Color(speechBubImg.color.r, speechBubImg.color.g, speechBubImg.color.b, 0); else speechBubImg.color = new Color(speechBubImg.color.r, speechBubImg.color.g, speechBubImg.color.b, 1); - SpriteUtil.SwapSpriteFromFile(speechBubImg, encounter.EnabledEnemies[i].DialogBubble, i); + + // error catcher + try { SpriteUtil.SwapSpriteFromFile(speechBubImg, encounter.EnabledEnemies[i].DialogBubble, i); } + catch { + if (encounter.EnabledEnemies[i].DialogBubble != "UI/SpeechBubbles/") + UnitaleUtil.DisplayLuaError(encounter.EnabledEnemies[i].scriptName + ": Creating a dialogue bubble", + "The dialogue bubble " + encounter.EnabledEnemies[i].script.GetVar("dialogbubble").ToString() + " doesn't exist."); + else + UnitaleUtil.DisplayLuaError(encounter.EnabledEnemies[i].scriptName + ": Creating a dialogue bubble", + "This monster has no set dialogue bubble."); + } + Sprite speechBubSpr = speechBubImg.sprite; // TODO improve position setting/remove hardcoding of position setting speechBub.transform.SetParent(encounter.EnabledEnemies[i].transform); @@ -527,6 +551,8 @@ public void SwitchState(UIState state, bool first = false) { } public static void SwitchStateOnString(Script scr, string state) { + if (state == null) + throw new CYFException("State: Argument cannot be nil."); if (!instance.encounter.gameOverStance) { try { UIState newState = (UIState)Enum.Parse(typeof(UIState), state, true); @@ -537,7 +563,7 @@ public static void SwitchStateOnString(Script scr, string state) { throw new CYFException("The state \"" + state + "\" is not a valid state. Are you sure it exists?\n\nPlease double-check in the Misc. Functions section of the docs for a list of every valid state."); // a different error has occured else - throw new CYFException("An error occured while trying to enter the state \"" + state + "\":\n" + ex.Message + "\n\nTraceback (for devs):\n" + ex.ToString()); + throw new CYFException("An error occured while trying to enter the state \"" + state + "\":\n\n" + ex.Message + "\n\nTraceback (for devs):\n" + ex.ToString()); } } } @@ -562,7 +588,7 @@ private void Awake() { instance = this; } - + public void UpdateBubble() { for (int i = 0; i < encounter.EnabledEnemies.Length; i++) { try { @@ -792,7 +818,7 @@ private void RenewLifebars(int page) { public UIState GetState() { return state; } private void HandleAction() { - if (!stated || state == UIState.ATTACKING) + if (!stated || state == UIState.ATTACKING) switch (state) { case UIState.ATTACKING: fightUI.StopAction(); @@ -814,14 +840,20 @@ private void HandleAction() { case UIState.ACTIONSELECT: switch (action) { case Actions.FIGHT: - SwitchState(UIState.ENEMYSELECT); + if (encounter.EnabledEnemies.Length > 0) + SwitchState(UIState.ENEMYSELECT); + else + textmgr.DoSkipFromPlayer(); break; case Actions.ACT: if (GlobalControls.crate) if (ControlPanel.instance.Safe) UnitaleUtil.PlaySound("MEOW", "sounds/meow" + Math.RandomRange(1, 8)); else UnitaleUtil.PlaySound("MEOW", "sounds/meow" + Math.RandomRange(1, 9)); - else SwitchState(UIState.ENEMYSELECT); + else if (encounter.EnabledEnemies.Length > 0) + SwitchState(UIState.ENEMYSELECT); + else + textmgr.DoSkipFromPlayer(); break; case Actions.ITEM: @@ -1079,7 +1111,7 @@ private void HandleArrows() { } else if (left) { if (selectedEnemy % 2 == 1) unpair = true; - selectedEnemy = (selectedEnemy - 2 + encounter.EnabledEnemies.Length) % encounter.EnabledEnemies.Length; + selectedEnemy = (selectedEnemy - 2 + encounter.EnabledEnemies.Length) % encounter.EnabledEnemies.Length; if (encounter.EnabledEnemies.Length % 2 == 1 && selectedEnemy > encounter.EnabledEnemies.Length - 3) if (unpair && encounter.EnabledEnemies.Length % 2 == 0) selectedEnemy = encounter.EnabledEnemies.Length - 1; else if (unpair && encounter.EnabledEnemies.Length % 2 == 1) selectedEnemy = encounter.EnabledEnemies.Length - 2; @@ -1277,12 +1309,12 @@ private void SetPlayerOnSelection(int selection) { private void Start() { // reset GlobalControls' frame timer GlobalControls.frame = 0; - + textmgr = GameObject.Find("TextManager").GetComponent(); textmgr.SetEffect(new TwitchEffect(textmgr)); textmgr.SetCaller(LuaEnemyEncounter.script); encounter = FindObjectOfType(); - + fightBtn = GameObject.Find("FightBt").GetComponent(); actBtn = GameObject.Find("ActBt").GetComponent(); itemBtn = GameObject.Find("ItemBt").GetComponent(); @@ -1297,12 +1329,12 @@ private void Start() { mercyBtn.sprite = SpriteRegistry.Get("UI/Buttons/mecrybt_0"); mercyBtn.GetComponent().SpritePath = "UI/Buttons/mecrybt_0"; } - + ArenaManager.instance.ResizeImmediate(ArenaManager.UIWidth, ArenaManager.UIHeight); //ArenaManager.instance.MoveToImmediate(0, -160, false); - - /*GameObject.Find("HideEncounter").GetComponent().sprite = Sprite.Create(GlobalControls.texBeforeEncounter, - new Rect(0, 0, GlobalControls.texBeforeEncounter.width, GlobalControls.texBeforeEncounter.height), + + /*GameObject.Find("HideEncounter").GetComponent().sprite = Sprite.Create(GlobalControls.texBeforeEncounter, + new Rect(0, 0, GlobalControls.texBeforeEncounter.width, GlobalControls.texBeforeEncounter.height), new Vector2(0.5f, 0.5f));*/ //if (GameOverBehavior.gameOverContainer) // GameObject.Destroy(GameOverBehavior.gameOverContainer); @@ -1356,22 +1388,22 @@ private void Start() { if (toAdd) rts[indexText].SetParent(rts[indexDeb]);*/ //} - + // If retromode is enabled, set the inventory to the one with TESTDOGs (can be overridden) if (GlobalControls.retroMode && GlobalControls.modDev) { // Set the in-game names of these items to TestDogN instead of DOGTESTN for (int i = 1; i <= 7; i++) Inventory.NametoShortName.Add("DOGTEST" + i, "TestDog" + i); - + Inventory.luaInventory.AddCustomItems(new string[] {"DOGTEST1", "DOGTEST2", "DOGTEST3", "DOGTEST4", "DOGTEST5", "DOGTEST6", "DOGTEST7"}, new int[] {3, 3, 3, 3, 3, 3, 3}); Inventory.luaInventory.SetInventory(new string[] {"DOGTEST1", "DOGTEST2", "DOGTEST3", "DOGTEST4", "DOGTEST5", "DOGTEST6", "DOGTEST7"}); - + // Undo our changes to this table! for (int i = 1; i <= 7; i++) Inventory.NametoShortName.Remove("DOGTEST" + i); } - + StaticInits.SendLoaded(); // GameObject.Destroy(GameObject.Find("HideEncounter")); psContainer = new GameObject("psContainer"); @@ -1383,13 +1415,13 @@ private void Start() { if (SendToStaticInits != null) SendToStaticInits(); - + if (GlobalControls.crate) { UserDebugger.instance.gameObject.transform.GetChild(0).gameObject.GetComponent().text = "DEGUBBER (F9 OT TOGLGE, DEBUG(STIRNG) TO PRNIT)"; GameObject.Find("HPLabelCrate").GetComponent().enabled = true; GameObject.Find("HPLabel").GetComponent().enabled = false; } - + // PlayerController.instance.Awake(); PlayerController.instance.playerAbs = new Rect(0, 0, PlayerController.instance.selfImg.sprite.texture.width - 8, @@ -1398,7 +1430,7 @@ private void Start() { PlayerController.instance.SetPosition(48, 25, true); fightUI = GameObject.Find("FightUI").GetComponent(); fightUI.gameObject.SetActive(false); - + encounter.CallOnSelfOrChildren("EncounterStarting"); if (GameObject.Find("Text")) { GameObject.Find("Text").transform.SetParent(UserDebugger.instance.transform); @@ -1436,7 +1468,7 @@ IEnumerator ISuperFlee() { PlayerController.instance.GetComponent().enabled = false; AudioClip yay = AudioClipRegistry.GetSound("runaway"); UnitaleUtil.PlaySound("Mercy", yay, 0.65f); - + string[] fleeTexts; DynValue tempFleeTexts = LuaEnemyEncounter.script.GetVar("fleetexts"); if (tempFleeTexts.Type == DataType.Table) { @@ -1482,7 +1514,7 @@ private void Update() { return; if (encounterHasUpdate) encounter.TryCall("Update"); - + ParticleSystem[] pss = GameObject.FindObjectsOfType(); //while (pss.Length > psList.Count) // psList.Add(true); @@ -1497,10 +1529,10 @@ private void Update() { i--; a--; } } - + if (frozenState != UIState.PAUSE) return; - + if (textmgr.IsPaused() &&!ArenaManager.instance.isResizeInProgress()) textmgr.SetPause(false); @@ -1565,7 +1597,7 @@ private void Update() { SwitchState(UIState.ENEMYDIALOGUE); //else // checkAndTriggerVictory(); - } + } } tempIndex++; } diff --git a/Assets/Scripts/Debug/ProjectileHitboxRenderer.cs b/Assets/Scripts/Debug/ProjectileHitboxRenderer.cs index b9dd21201..fce7b85c0 100644 --- a/Assets/Scripts/Debug/ProjectileHitboxRenderer.cs +++ b/Assets/Scripts/Debug/ProjectileHitboxRenderer.cs @@ -33,7 +33,7 @@ private IEnumerator OnPostRender() { for (int i = 0; i < projectiles.Length; i ++) { GameObject go = projectiles[i].gameObject; - bottomRight = go.GetComponent().selfAbs.center; + bottomRight = go.GetComponent().selfAbs.center - new Vector2(Misc.cameraX, Misc.cameraY); topLeft.Set (bottomRight.x - go.GetComponent().selfAbs.width / 2, bottomRight.y + go.GetComponent().selfAbs.height / 2, zIndex); topRight.Set (bottomRight.x + go.GetComponent().selfAbs.width / 2, bottomRight.y + go.GetComponent().selfAbs.height / 2, zIndex); bottomLeft.Set (bottomRight.x - go.GetComponent().selfAbs.width / 2, bottomRight.y - go.GetComponent().selfAbs.height / 2, zIndex); diff --git a/Assets/Scripts/Device/GlobalControls.cs b/Assets/Scripts/Device/GlobalControls.cs index f5984b78b..e10fc93ce 100644 --- a/Assets/Scripts/Device/GlobalControls.cs +++ b/Assets/Scripts/Device/GlobalControls.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine.SceneManagement; +using MoonSharp.Interpreter; /// /// Controls that should be active on all screens. Pretty much a hack to allow people to reset. Now it's more useful. @@ -55,22 +56,22 @@ void Awake() { // check if safe mode has a stored preference that is a boolean if (LuaScriptBinder.GetAlMighty(null, "CYFSafeMode") != null - && LuaScriptBinder.GetAlMighty(null, "CYFSafeMode").Type.ToString() == "Boolean") + && LuaScriptBinder.GetAlMighty(null, "CYFSafeMode").Type == DataType.Boolean) ControlPanel.instance.Safe = LuaScriptBinder.GetAlMighty(null, "CYFSafeMode").Boolean; // check if retro mode has a stored preference that is a boolean if (LuaScriptBinder.GetAlMighty(null, "CYFRetroMode") != null - && LuaScriptBinder.GetAlMighty(null, "CYFRetroMode").Type.ToString() == "Boolean") + && LuaScriptBinder.GetAlMighty(null, "CYFRetroMode").Type == DataType.Boolean) retroMode = LuaScriptBinder.GetAlMighty(null, "CYFRetroMode").Boolean; // check if fullscreen mode has a stored preference that is a boolean if (LuaScriptBinder.GetAlMighty(null, "CYFPerfectFullscreen") != null - && LuaScriptBinder.GetAlMighty(null, "CYFPerfectFullscreen").Type.ToString() == "Boolean") + && LuaScriptBinder.GetAlMighty(null, "CYFPerfectFullscreen").Type == DataType.Boolean) perfectFullscreen = LuaScriptBinder.GetAlMighty(null, "CYFPerfectFullscreen").Boolean; // check if window scale has a stored preference that is a number if (LuaScriptBinder.GetAlMighty(null, "CYFWindowScale") != null - && LuaScriptBinder.GetAlMighty(null, "CYFWindowScale").Type.ToString() == "Number") + && LuaScriptBinder.GetAlMighty(null, "CYFWindowScale").Type == DataType.Number) windowScale = (int)LuaScriptBinder.GetAlMighty(null, "CYFWindowScale").Number; awakened = true; @@ -143,10 +144,10 @@ void Update () { GameObject.Find("Text").transform.SetParent(UserDebugger.instance.gameObject.transform); UserDebugger.instance.gameObject.SetActive(!UserDebugger.instance.gameObject.activeSelf); Camera.main.GetComponent().enabled = !Camera.main.GetComponent().enabled; - } else if (isInFight && Input.GetKeyDown(KeyCode.H)) + } else if (isInFight && Input.GetKeyDown(KeyCode.H) && SceneManager.GetActiveScene().name != "Error" && UserDebugger.instance.gameObject.activeSelf) GameObject.Find("Main Camera").GetComponent().enabled = !GameObject.Find("Main Camera").GetComponent().enabled; else if (Input.GetKeyDown(KeyCode.Escape) && (canTransOW.Contains(SceneManager.GetActiveScene().name) || isInFight)) { - if (isInFight && LuaEnemyEncounter.script.GetVar("unescape").Boolean && SceneManager.GetActiveScene().name == "Battle") + if (isInFight && LuaEnemyEncounter.script.GetVar("unescape").Boolean && SceneManager.GetActiveScene().name != "Error") return; if (SceneManager.GetActiveScene().name == "Error" && !modDev) return; @@ -213,6 +214,9 @@ private IEnumerator IShakeScreen(object[] args) { while (frameCount < frames) { if (stopScreenShake) { tf.position = new Vector3(tf.position.x - totalShift.x, tf.position.y - totalShift.y, tf.position.z); + UserDebugger.instance.transform.position = new Vector3(UserDebugger.instance.transform.position.x - totalShift.x, + UserDebugger.instance.transform.position.y - totalShift.y, + UserDebugger.instance.transform.position.z); screenShaking = false; yield break; } @@ -222,8 +226,12 @@ private IEnumerator IShakeScreen(object[] args) { if (UnitaleUtil.IsOverworld) PlayerOverworld.instance.cameraShift = new Vector2(PlayerOverworld.instance.cameraShift.x + shift.x - totalShift.x, PlayerOverworld.instance.cameraShift.y + shift.y - totalShift.y); - else + else { tf.position = new Vector3(tf.position.x + shift.x - totalShift.x, tf.position.y + shift.y - totalShift.y, tf.position.z); + UserDebugger.instance.transform.position = new Vector3(UserDebugger.instance.transform.position.x + shift.x - totalShift.x, + UserDebugger.instance.transform.position.y + shift.y - totalShift.y, + UserDebugger.instance.transform.position.z); + } //print(totalShift + " + " + shift + " = " + (totalShift + shift)); totalShift = shift; frameCount++; @@ -231,6 +239,10 @@ private IEnumerator IShakeScreen(object[] args) { } screenShaking = false; tf.position = new Vector3(tf.position.x - totalShift.x, tf.position.y - totalShift.y, tf.position.z); + if (!UnitaleUtil.IsOverworld) + UserDebugger.instance.transform.position = new Vector3(UserDebugger.instance.transform.position.x - totalShift.x, + UserDebugger.instance.transform.position.y - totalShift.y, + UserDebugger.instance.transform.position.z); } public void ShakeScreen(float duration, float intensity, bool isIntensityDecreasing) { diff --git a/Assets/Scripts/Device/Misc.cs b/Assets/Scripts/Device/Misc.cs index 649bfce6e..635cfe4b4 100644 --- a/Assets/Scripts/Device/Misc.cs +++ b/Assets/Scripts/Device/Misc.cs @@ -1,6 +1,7 @@ using UnityEngine; using System.Runtime.InteropServices; using System.Text; +using System.IO; public class Misc { public string MachineName { @@ -19,7 +20,7 @@ public bool FullScreen { get { return Screen.fullScreen; } set { Screen.fullScreen = value; - + GlobalControls.SetFullScreen(value, 2); } } @@ -31,40 +32,87 @@ public static int ScreenHeight { public static int ScreenWidth { get { return Screen.currentResolution.width; } } - + public static float cameraX { get { return Camera.main.transform.position.x - 320; } - set { Camera.main.transform.position = new Vector3(value + 320, Camera.main.transform.position.y, Camera.main.transform.position.z); } + set { + Camera.main.transform.position = new Vector3(value + 320, Camera.main.transform.position.y, Camera.main.transform.position.z); + if (!UnitaleUtil.IsOverworld && UserDebugger.instance) + UserDebugger.instance.transform.position = new Vector3(value + 620, UserDebugger.instance.transform.position.y, UserDebugger.instance.transform.position.z); + } } - + public static float cameraY { get { return Camera.main.transform.position.y - 240; } - set { Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, value + 240, Camera.main.transform.position.z); } + set { + Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, value + 240, Camera.main.transform.position.z); + if (!UnitaleUtil.IsOverworld && UserDebugger.instance) + UserDebugger.instance.transform.position = new Vector3(UserDebugger.instance.transform.position.x, value + 480, UserDebugger.instance.transform.position.z); + } } - + public static void MoveCamera(float x, float y) { cameraX += x; cameraY += y; } - + public static void MoveCameraTo(float x, float y) { cameraX = x; cameraY = y; } - + public static void ResetCamera() { MoveCameraTo(0f, 0f); } public static void DestroyWindow() { Application.Quit(); } + public static LuaFile OpenFile(string path, string mode = "rw") { + return new LuaFile(path, mode); + } + + public bool FileExists(string path) { + if (path.Contains("..")) + throw new CYFException("You cannot check for a file outside of a mod folder. The use of \"..\" is forbidden."); + return File.Exists((FileLoader.ModDataPath + "/" + path).Replace('\\', '/')); + } + + public string[] ListDir(string path, bool getFolders = false) { + if (path == null) + throw new CYFException("Cannot list a directory with a nil path."); + if (path.Contains("..")) + throw new CYFException("You cannot list directories outside of a mod folder. The use of \"..\" is forbidden."); + + path = (FileLoader.ModDataPath + "/" + path).Replace('\\', '/'); + if (!Directory.Exists(path)) + throw new CYFException("Invalid path:\n\n\"" + path + "\""); + + DirectoryInfo d = new DirectoryInfo(path); + System.Collections.Generic.List retval = new System.Collections.Generic.List(); + if (!getFolders) + foreach (FileInfo fi in d.GetFiles()) + retval.Add(Path.GetFileName(fi.ToString())); + else + foreach (DirectoryInfo di in d.GetDirectories()) + retval.Add(di.Name); + return retval.ToArray(); + } + + public static string OSType { + get { + if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer) return "Windows"; + else if (Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer) return "Linux"; + else return "Mac"; + } + } + #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN [DllImport("user32.dll")] - private static extern int GetActiveWindow(); + private static extern int GetActiveWindow(); public static int window = GetActiveWindow(); - + public static void RetargetWindow() { window = GetActiveWindow(); } - + [DllImport("user32.dll")] public static extern int FindWindow(string className, string windowName); [DllImport("user32.dll")] @@ -131,7 +179,7 @@ private static Rect GetWindowRect() { GetWindowRect(window, out r); return new Rect(r.Left, r.Top, Mathf.Abs(r.Right - r.Left), Mathf.Abs(r.Top - r.Bottom)); } - + public static int WindowWidth { get { Rect size = GetWindowRect(); @@ -147,54 +195,54 @@ public static int WindowHeight { } #else public static string WindowName { - get { - UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); + get { + UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); return ""; } set { UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); } } - public static int WindowX { - get { - UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); + public static int WindowX { + get { + UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); return 0; } set { UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); } } public static int WindowY { - get { - UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); + get { + UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); return 0; } set { UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); } } public static void MoveWindowTo(int X, int Y) { - UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); + UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); return; } public static void MoveWindow(int X, int Y) { - UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); + UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); return; } public static Rect GetWindowRect() { - UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); + UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); return new Rect(); } - + public static int WindowWidth { - get { - UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); + get { + UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); return 0; } } public static int WindowHeight { - get { - UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); + get { + UnitaleUtil.DisplayLuaError("Windows-only function", "This feature is Windows-only! Sorry, but you can't use it here."); return 0; } } diff --git a/Assets/Scripts/Inventory/Inventory.cs b/Assets/Scripts/Inventory/Inventory.cs index c2bf081f7..395fe8432 100644 --- a/Assets/Scripts/Inventory/Inventory.cs +++ b/Assets/Scripts/Inventory/Inventory.cs @@ -11,6 +11,7 @@ public static class Inventory { public static List addedItems = new List(); public static List addedItemsTypes = new List(); public static LuaInventory luaInventory; + public static int inventorySize = 8; public static int tempAmount = 0; public static Dictionary NametoDesc = new Dictionary(), NametoShortName = new Dictionary(); public static Dictionary NametoType = new Dictionary(), NametoPrice = new Dictionary(); @@ -20,6 +21,7 @@ public static class Inventory { public static void SetItemList(string[] items = null) { foreach (string item in items) { + // Make sure that the item exists before trying to create it string outString = ""; int outInt = 0; if (!addedItems.Contains(item) && !NametoDesc.TryGetValue(item, out outString) && !NametoShortName.TryGetValue(item, out outString) && !NametoType.TryGetValue(item, out outInt) && !NametoPrice.TryGetValue(item, out outInt)) @@ -29,8 +31,8 @@ public static void SetItemList(string[] items = null) { inventory = new List(new UnderItem[] { }); if (items != null) for (int i = 0; i < items.Length; i++) { - if (i == 8) - UnitaleUtil.WriteInLogAndDebugger("[WARN]The inventory can only contain 8 items, yet you tried to add the item \"" + items[i] + "\" as item number " + (i + 1) + "."); + if (i == inventorySize) + UnitaleUtil.WriteInLogAndDebugger("[WARN]The inventory can only contain " + inventorySize + " items, yet you tried to add the item \"" + items[i] + "\" as item number " + (i + 1) + "."); else { // Search through addedItemsTypes to find the type of the new item int type = 0; @@ -40,24 +42,40 @@ public static void SetItemList(string[] items = null) { if (addedItems[j] == items[i]) type = addedItemsTypes[j]; } - inventory.Add(new UnderItem(items[i], type)); + inventory.Add(new UnderItem(items[i])); } } } public static void SetItem(int index, string Name) { - if (index > 7) throw new CYFException("The inventory can only contain 8 items."); + if (index >= inventorySize) throw new CYFException("The inventory can only contain " + inventorySize + " items."); else if (index >= inventory.Count) AddItem(Name); else inventory[index] = new UnderItem(Name); } public static bool AddItem(string Name) { - if (inventory.Count == 8) + if (inventory.Count == inventorySize) return false; + // Make sure that the item exists before trying to create it + string outString = ""; + int outInt = 0; + if (!addedItems.Contains(Name) && !NametoDesc.TryGetValue(Name, out outString) && !NametoShortName.TryGetValue(Name, out outString) && + !NametoType.TryGetValue(Name, out outInt) && !NametoPrice.TryGetValue(Name, out outInt)) + throw new CYFException("Inventory.AddItem: The item \"" + Name + "\" was not found.\n\nAre you sure you called Inventory.AddCustomItems first?"); inventory.Add(new UnderItem(Name)); return true; } + public static int GetItemType(string Name) { + int type = 0; + if (addedItems.Contains(Name)) + for (int i = addedItems.Count - 1; i >= 0; i--) + if (addedItems[i] == Name) + return addedItemsTypes[i]; + NametoType.TryGetValue(Name, out type); + return type; + } + private static bool CallOnSelf(string func, DynValue[] param = null) { bool result; if (param != null) @@ -99,7 +117,6 @@ public static void UseItem(int ID) { if (addedItems.Count != 0) { for (int i = 0; i < addedItems.Count; i++) if (addedItems[i].ToLower() == Name.ToLower()) { - type = addedItemsTypes[i]; if (type == 1 || type == 2) mess = ChangeEquipment(ID, mess); if (!usedItemNoDelete && type == 0) diff --git a/Assets/Scripts/Inventory/ItemBox.cs b/Assets/Scripts/Inventory/ItemBox.cs new file mode 100644 index 000000000..fd9a96d26 --- /dev/null +++ b/Assets/Scripts/Inventory/ItemBox.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; + +public static class ItemBox { + public static int capacity = 10; + public static List items = new List(); + + public static void AddToBox(string name) { + if (!Inventory.ItemExists(name)) { + UnitaleUtil.WriteInLogAndDebugger("The item " + name + "doesn't exist in CYF's item database."); + return; + } + if (items.Count == capacity) { + UnitaleUtil.WriteInLogAndDebugger("The box is already full! You can't add another item to it!"); + return; + } + items.Add(new UnderItem(name)); + } + + public static void RemoveFromBox(int index) { + if (index < 0 || index >= items.Count) { + UnitaleUtil.WriteInLogAndDebugger("Tried to remove the item #" + index + " of the box, however it only has " + items.Count + " items in it, starting from the index 0."); + return; + } + items.RemoveAt(index); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Inventory/ItemBox.cs.meta b/Assets/Scripts/Inventory/ItemBox.cs.meta new file mode 100644 index 000000000..0f2804d1d --- /dev/null +++ b/Assets/Scripts/Inventory/ItemBox.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5102e971101de484ca0145388635d9cd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Inventory/UnderItem.cs b/Assets/Scripts/Inventory/UnderItem.cs index e550d9627..adc956b5f 100644 --- a/Assets/Scripts/Inventory/UnderItem.cs +++ b/Assets/Scripts/Inventory/UnderItem.cs @@ -4,7 +4,7 @@ public class UnderItem { //private static int dogNumber = 1; - public UnderItem(string Name, int type = 0) { + public UnderItem(string Name) { //Let's end this dog tyranny! //ID = "DOGTEST" + dogNumber; //ShortName = "TestDog" + dogNumber; @@ -17,7 +17,7 @@ public UnderItem(string Name, int type = 0) { ShortName = Name; else ShortName = Short; - this.Type = type; + Type = Inventory.GetItemType(Name); return; } } @@ -27,10 +27,10 @@ public UnderItem(string Name, int type = 0) { Inventory.AddItemsToDictionaries(); } - this.Name = Name; string Sn = "", Desc = ""; int Ty = type; + this.Name = Name; string Sn = "", Desc = ""; int Ty = Type; if (!Inventory.NametoDesc.TryGetValue(Name, out Desc)) UnitaleUtil.DisplayLuaError("Creating an item", "Tried to create the item \"" + Name + "\", but a set description for it was not found."); if (!Inventory.NametoShortName.TryGetValue(Name, out Sn)) Sn = Name; - if (type == 0) Inventory.NametoType.TryGetValue(Name, out Ty); + if (Type == 0) Inventory.NametoType.TryGetValue(Name, out Ty); ShortName = Sn; Description = Desc; Type = Ty; } @@ -39,8 +39,4 @@ public UnderItem(string Name, int type = 0) { public string ShortName { get; private set; } public string Description { get; private set; } public int Type { get; private set; } //0 = normal, 1 = equipATK, 2 = equipDEF, 3 = special - - public void inOverworldUse() {} - - public void inCombatUse() {} } \ No newline at end of file diff --git a/Assets/Scripts/Lua/CLRBindings/LuaFile.cs b/Assets/Scripts/Lua/CLRBindings/LuaFile.cs new file mode 100644 index 000000000..4f55ccc8a --- /dev/null +++ b/Assets/Scripts/Lua/CLRBindings/LuaFile.cs @@ -0,0 +1,114 @@ +using System; +using System.IO; +using UnityEngine; + +public class LuaFile { + private string path; + private string mode; + private string[] content; + + public int lineCount { + get { return content.Length; } + } + + public string openMode { + get { return mode; } + } + + public LuaFile(string path, string mode = "rw") { + if (path == null) + throw new CYFException("Cannot open a file with a nil path."); + if (path.Contains("..")) + throw new CYFException("You cannot open a file outside of a mod folder. The use of \"..\" is forbidden."); + path = (FileLoader.ModDataPath + "/" + path).Replace('\\', '/'); + + if (mode != "r" && mode != "w" && mode != "rw" && mode != "wr") + throw new CYFException("A file's open mode can only be r (read), w (write) or rw (read + write)."); + if (mode == "r" && !File.Exists(path)) + throw new CYFException("You can't open a file that doesn't exist in read-only mode."); + if (!Directory.Exists(path.Substring(0, path.Length - Path.GetFileName(path).Length))) + throw new CYFException("Invalid path:\n\n\"" + path + "\""); + + this.path = path; + this.mode = mode; + + content = File.Exists(path) ? File.ReadAllText(path).Split('\n') : null; + } + + public string ReadLine(int line) { + if (!mode.Contains("r")) + throw new CYFException("This file has been opened in write-only mode, you can't read anything from it."); + if (!File.Exists(path)) + throw new CYFException("The file at the path \"" + path + "\" doesn't exist, so you can't read from it."); + if (line > content.Length || line < 1 || line % 1 != 0) + throw new CYFException("Cannot read line #" + line + " of a file with " + content.Length + " lines."); + return content[line - 1]; + } + + public string[] ReadLines() { + if (!mode.Contains("r")) + throw new CYFException("This file has been opened in write-only mode, you can't read anything from it."); + if (!File.Exists(path)) + throw new CYFException("The file at the path \"" + path + "\" doesn't exist, so you can't read from it."); + return content; + } + + public void Write(string data, bool append = true) { + if (!mode.Contains("w")) + throw new CYFException("This file has been opened in read-only mode, you can't write anything to it."); + if (data == null) + throw new CYFException("You can't write nil to a file! If you want to empty the file, use an empty string with the append parameter set to false instead."); + + if (!File.Exists(path)) + File.Create(path).Close(); + + if (append) File.WriteAllText(path, File.ReadAllText(path) + data); + else File.WriteAllText(path, data); + + content = File.ReadAllText(path).Split('\n'); + } + + public void ReplaceLine(int line, string data) { + if (!mode.Contains("w")) + throw new CYFException("This file has been opened in read-only mode, you can't write anything to it."); + if (line > content.Length || line < 1 || line % 1 != 0) + throw new CYFException("Cannot replace line #" + line + " of a file with " + content.Length + " lines."); + if (data == null) + throw new CYFException("You can't set a line to nil! If you want to remove the line, use the function DeleteLine()."); + + if (data.Contains("\n")) { + string[] content1 = new string[line - 1], + content2 = data.Split('\n'), + content3 = new string[lineCount - line]; + Array.Copy(content, 0, content1, 0, line - 1); + Array.Copy(content, line, content3, 0, lineCount - line); + string[] newContent = new string[lineCount - 1 + content2.Length]; + content1.CopyTo(newContent, 0); + content2.CopyTo(newContent, line - 1); + content3.CopyTo(newContent, line - 1 + content2.Length); + content = newContent; + } else + content[line - 1] = data; + + File.WriteAllText(path, string.Join("\n", content)); + } + + public void DeleteLine(int line) { + if (!mode.Contains("w")) + throw new CYFException("This file has been opened in read-only mode, you can't write anything to it."); + if (line > content.Length || line < 1 || line % 1 != 0) + throw new CYFException("The file only has " + content.Length + " lines yet you're trying to delete this file's line #" + line); + + string[] newContent = new string[lineCount - 1]; + Array.Copy(content, 0, newContent, 0, line - 1); + Array.Copy(content, line, newContent, line - 1, lineCount - line); + content = newContent; + } + + public void Delete() { + if (!mode.Contains("w")) + throw new CYFException("This file has been opened in read-only mode, you can't write anything to it."); + if (File.Exists(path)) + File.Delete(path); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Lua/CLRBindings/LuaFile.cs.meta b/Assets/Scripts/Lua/CLRBindings/LuaFile.cs.meta new file mode 100644 index 000000000..a5de97223 --- /dev/null +++ b/Assets/Scripts/Lua/CLRBindings/LuaFile.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bd23885bb0d1dd140a21c6e636d2ac00 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Lua/CLRBindings/LuaInventory.cs b/Assets/Scripts/Lua/CLRBindings/LuaInventory.cs index 51249d860..b2274f5bd 100644 --- a/Assets/Scripts/Lua/CLRBindings/LuaInventory.cs +++ b/Assets/Scripts/Lua/CLRBindings/LuaInventory.cs @@ -19,10 +19,12 @@ public int GetType(int index) { public void SetItem(int index, string Name) { Inventory.SetItem(index-1, Name); } - public bool AddItem(string Name, int index = 8) { - if (index == 8) + public bool AddItem(string Name, int index = -1) { + if (Name == null) + throw new CYFException("Inventory.AddItem: The first argument (item name) is nil.\n\nSee the documentation for proper usage."); + if (index == -1) return Inventory.AddItem(Name); - else if (index > 0 && Inventory.inventory.Count < 8) { + else if (index > 0 && Inventory.inventory.Count < Inventory.inventorySize) { if (index > Inventory.inventory.Count + 1) index = Inventory.inventory.Count + 1; @@ -30,6 +32,13 @@ public bool AddItem(string Name, int index = 8) { bool result = false; for (var i = 0; i <= Inventory.inventory.Count; i++) { if (i == index - 1) { + // Make sure that the item exists before trying to create it + string outString = ""; + int outInt = 0; + if (!Inventory.addedItems.Contains(Name) && !Inventory.NametoDesc.TryGetValue(Name, out outString) && + !Inventory.NametoShortName.TryGetValue(Name, out outString) && !Inventory.NametoType.TryGetValue(Name, out outInt) && + !Inventory.NametoPrice.TryGetValue(Name, out outInt)) + throw new CYFException("Inventory.AddItem: The item \"" + Name + "\" was not found.\n\nAre you sure you called Inventory.AddCustomItems first?"); inv.Add(new UnderItem(Name)); result = true; } @@ -54,11 +63,19 @@ public void RemoveItem(int index) { } public void AddCustomItems(string[] names, int[] types) { + if (names == null) + throw new CYFException("Inventory.AddCustomItems: The first argument (list of item names) is nil.\n\nSee the documentation for proper usage."); + else if (types == null) + throw new CYFException("Inventory.AddCustomItems: The second argument (list of item types) is nil.\n\nSee the documentation for proper usage."); Inventory.addedItems.AddRange(names); Inventory.addedItemsTypes.AddRange(types); } - public void SetInventory(string[] names) { Inventory.SetItemList(names); } + public void SetInventory(string[] names) { + if (names == null) + throw new CYFException("Inventory.SetInventory: Attempt to set the player's inventory to nil.\n\nSee the documentation for proper usage."); + Inventory.SetItemList(names); + } public int ItemCount { get { return Inventory.inventory.Count; } diff --git a/Assets/Scripts/Lua/CLRBindings/LuaPlayerStatus.cs b/Assets/Scripts/Lua/CLRBindings/LuaPlayerStatus.cs index 4c4ad87ef..29626117d 100644 --- a/Assets/Scripts/Lua/CLRBindings/LuaPlayerStatus.cs +++ b/Assets/Scripts/Lua/CLRBindings/LuaPlayerStatus.cs @@ -86,6 +86,7 @@ public int maxhpshift { /// Get player's current ATK. /// public int atk { + set { PlayerCharacter.instance.ATK = value; } get { return PlayerCharacter.instance.ATK; } } @@ -107,6 +108,7 @@ public int weaponatk { /// Get player's current DEF. /// public int def { + set { PlayerCharacter.instance.DEF = value; } get { return PlayerCharacter.instance.DEF; } } @@ -130,6 +132,9 @@ public int armordef { public string name { get { return PlayerCharacter.instance.Name; } set { + if (value == null) + throw new CYFException("Player.name: Attempt to set the player's name to a nil value.\n\nPlease double-check your code."); + string shortName = value; if (shortName.Length > 9) shortName = value.Substring(0, 9); @@ -239,8 +244,25 @@ public void SetControlOverride(bool overrideControl) { /// /// /// - public void SetMaxHPShift(int shift, float invulSec = 1.7f, bool set = false, bool canHeal = false) { player.setMaxHPShift(shift, invulSec, set, canHeal); } - public void setMaxHPShift(int shift, float invulSec = 1.7f, bool set = false, bool canHeal = false) { SetMaxHPShift(shift, invulSec, set, canHeal); } + public void SetMaxHPShift(int shift, float invulSec = 1.7f, bool set = false, bool canHeal = false, bool sound = true) { player.setMaxHPShift(shift, invulSec, set, canHeal, sound); } + public void setMaxHPShift(int shift, float invulSec = 1.7f, bool set = false, bool canHeal = false, bool sound = true) { SetMaxHPShift(shift, invulSec, set, canHeal, sound); } + + /// + /// Resets any of the player's Max HP, ATK and DEF to their default values, based on LV. + /// + /// If true, will reset Max HP. + /// If true, will reset ATK. + /// If true, will reset DEF. + public void ResetStats(bool resetMHP = true, bool resetATK = true, bool resetDEF = true) { + if (resetMHP) { + PlayerCharacter.instance.MaxHPShift = 0; + UIStats.instance.setMaxHP(); + } + if (resetATK) + atk = 8 + (2 * lv); + if (resetDEF) + def = 10 + (int)UnityEngine.Mathf.Floor((lv - 1) / 4); + } public void SetAttackAnim(string[] anim, float frequency = 1 / 6f) { if (anim.Length == 0) { diff --git a/Assets/Scripts/Lua/CLRBindings/LuaSpriteController.cs b/Assets/Scripts/Lua/CLRBindings/LuaSpriteController.cs index 6e3302009..7f3715c83 100644 --- a/Assets/Scripts/Lua/CLRBindings/LuaSpriteController.cs +++ b/Assets/Scripts/Lua/CLRBindings/LuaSpriteController.cs @@ -147,6 +147,18 @@ public float height { } } + // The x pivot of the sprite. + public float xpivot { + get { return img.GetComponent().pivot.x; } + set { SetPivot(value, img.GetComponent().pivot.y); } + } + + // The y pivot of the sprite. + public float ypivot { + get { return img.GetComponent().pivot.y; } + set { SetPivot(img.GetComponent().pivot.x, value); } + } + // Is the current animation finished? True if there is a finished animation, false otherwise public bool animcomplete { get { @@ -377,7 +389,7 @@ public void SetParent(LuaSpriteController parent) { } try { GetTarget().SetParent(parent.img.transform); - } catch { throw new CYFException("You tried to set a removed sprite/unexisting sprite as this sprite's parent."); } + } catch { throw new CYFException("You tried to set a removed sprite/nil sprite as this sprite's parent."); } } // Sets the pivot of a sprite (its rotation point) @@ -429,6 +441,8 @@ public void Scale(float xs, float ys) { // Sets an animation for this instance with a frame timer public void SetAnimation(string[] spriteNames, float frametime, string prefix = "") { + if (spriteNames == null) + throw new CYFException("sprite.SetAnimation: The first argument (list of images) is nil.\n\nSee the documentation for proper usage."); if (frametime < 0) throw new CYFException("sprite.SetAnimation: An animation can not have negative speed!"); else if (frametime == 0) @@ -494,7 +508,7 @@ public DynValue animationpaused { } set { if (img.GetComponent()) { - if (value.Type.ToString() != "Boolean") + if (value.Type != DataType.Boolean) throw new CYFException("sprite.paused can only be set to a boolean value."); if (keyframes != null) @@ -602,20 +616,24 @@ public void SendToBottom() { } public void MoveBelow(LuaSpriteController sprite) { - if (sprite == null) throw new CYFException("The sprite passed as an argument is null."); - else if (sprite.GetTarget().parent != GetTarget().parent) UnitaleUtil.WriteInLogAndDebugger("[WARN]You can't relatively move two sprites without the same parent."); + if (sprite == null) throw new CYFException("sprite.MoveBelow: The sprite passed as an argument is nil."); + else if (sprite.GetTarget().parent != GetTarget().parent) UnitaleUtil.WriteInLogAndDebugger("[WARN]You can't change the order of two sprites without the same parent."); else GetTarget().SetSiblingIndex(sprite.GetTarget().GetSiblingIndex()); } public void MoveAbove(LuaSpriteController sprite) { - if (sprite == null) throw new CYFException("The sprite passed as an argument is null."); - else if (sprite.GetTarget().parent != GetTarget().parent) UnitaleUtil.WriteInLogAndDebugger("[WARN]You can't relatively move two sprites without the same parent."); + if (sprite == null) throw new CYFException("sprite.MoveAbove: The sprite passed as an argument is nil."); + else if (sprite.GetTarget().parent != GetTarget().parent) UnitaleUtil.WriteInLogAndDebugger("[WARN]You can't change the order of two sprites without the same parent."); else GetTarget().SetSiblingIndex(sprite.GetTarget().GetSiblingIndex() + 1); } public void Remove() { if (_img == null) return; + else if (!GlobalControls.retroMode && tag == "projectile") { + img.GetComponent().ctrl.Remove(); + return; + } bool throwError = false; if ((!GlobalControls.retroMode && img.gameObject.name == "player") || (!GlobalControls.retroMode && tag == "projectile") || tag == "enemy" || tag == "bubble") { @@ -716,9 +734,15 @@ void Update() { firstFrame = false; } - public void SetVar(string name, DynValue value) { vars[name] = value; } + public void SetVar(string name, DynValue value) { + if (name == null) + throw new CYFException("sprite.SetVar: The first argument (the index) is null.\n\nSee the documentation for proper usage."); + vars[name] = value; + } public DynValue GetVar(string name) { + if (name == null) + throw new CYFException("sprite.GetVar: The first argument (the index) is null.\n\nSee the documentation for proper usage."); DynValue retval; if (vars.TryGetValue(name, out retval)) return retval; else return DynValue.NewNil(); diff --git a/Assets/Scripts/Lua/CLRBindings/LuaTextManager.cs b/Assets/Scripts/Lua/CLRBindings/LuaTextManager.cs index 30293e546..e161e3437 100644 --- a/Assets/Scripts/Lua/CLRBindings/LuaTextManager.cs +++ b/Assets/Scripts/Lua/CLRBindings/LuaTextManager.cs @@ -18,6 +18,8 @@ public class LuaTextManager : TextManager { private BubbleSide bubbleSide = BubbleSide.NONE; private ProgressMode progress = ProgressMode.AUTO; private Color textColor; + private float xScale = 1; + private float yScale = 1; public bool isactive { get { @@ -30,7 +32,8 @@ enum ProgressMode { AUTO, MANUAL, NONE } protected override void Awake() { base.Awake(); - transform.parent.SetParent(GameObject.Find("TopLayer").transform); + if (!UnitaleUtil.IsOverworld) + transform.parent.SetParent(GameObject.Find("TopLayer").transform); container = transform.parent.gameObject; containerBubble = UnitaleUtil.GetChildPerName(container.transform, "BubbleContainer").gameObject; speechThing = UnitaleUtil.GetChildPerName(containerBubble.transform, "SpeechThing", false, true).GetComponent(); @@ -56,7 +59,7 @@ protected override void Update() { if (base.CanAutoSkipAll() || base.CanAutoSkipThis()) NextLine(); if (CanSkip() && !LineComplete() && GlobalControls.input.Cancel == UndertaleInput.ButtonState.PRESSED) - SkipLine(); + DoSkipFromPlayer(); } } @@ -66,6 +69,9 @@ private void CheckExists() { throw new CYFException("Attempt to perform action on removed text object."); } + // Shortcut to `DestroyText()` + public void Remove() { DestroyText(true); } + private void ResizeBubble() { float effectiveBubbleHeight = bubbleHeight != -1 ? bubbleHeight < 16 ? 40 : bubbleHeight + 24 : UnitaleUtil.CalcTextHeight(this) < 16 ? 40 : UnitaleUtil.CalcTextHeight(this) + 24; containerBubble.transform.GetComponent().sizeDelta = new Vector2(textMaxWidth + 20, effectiveBubbleHeight); //To set the borders @@ -144,6 +150,30 @@ public int bubbleHeight { _bubbleHeight = value == -1 ? -1 : value < 40 ? 40 : value; } } + + public float xscale { + get { return xScale; } + set { + xScale = value; + Scale(xScale, yScale); + } + } + + public float yscale { + get { return yScale; } + set { + yScale = value; + Scale(xScale, yScale); + } + } + + public void Scale(float xs, float ys) { + CheckExists(); + xScale = xs; + yScale = ys; + + container.gameObject.GetComponent().localScale = new Vector3(xs, ys, 1.0f); + } public string layer { get { @@ -163,9 +193,9 @@ public string layer { public void MoveBelow(LuaTextManager otherText) { CheckExists(); if (otherText == null || !otherText.isactive) - throw new CYFException("The text object passed as an argument is null or inactive."); + throw new CYFException("The text object passed as an argument is nil or inactive."); else if (this.transform.parent.parent != otherText.transform.parent.parent) - UnitaleUtil.WriteInLogAndDebugger("[WARN]You can't change the order of two text objects on different layers."); + UnitaleUtil.WriteInLogAndDebugger("[WARN]You can't change the order of two text objects without the same parent."); else { try { this.transform.parent.SetSiblingIndex(otherText.transform.parent.GetSiblingIndex()); } catch { throw new CYFException("Error while calling text.MoveBelow."); } @@ -175,9 +205,9 @@ public void MoveBelow(LuaTextManager otherText) { public void MoveAbove(LuaTextManager otherText) { CheckExists(); if (otherText == null || !otherText.isactive) - throw new CYFException("The text object passed as an argument is null or inactive."); + throw new CYFException("The text object passed as an argument is nil or inactive."); else if (this.transform.parent.parent != otherText.transform.parent.parent) - UnitaleUtil.WriteInLogAndDebugger("[WARN]You can't change the order of two text objects on different layers."); + UnitaleUtil.WriteInLogAndDebugger("[WARN]You can't change the order of two text objects without the same parent."); else { try { this.transform.parent.SetSiblingIndex(otherText.transform.parent.GetSiblingIndex() + 1); } catch { throw new CYFException("Error while calling text.MoveAbove."); } @@ -261,7 +291,7 @@ public bool allLinesComplete { public void SetParent(LuaSpriteController parent) { CheckExists(); try { container.transform.SetParent(parent.img.transform); } - catch { throw new CYFException("You tried to set a removed sprite/unexisting sprite as this text's parent."); } + catch { throw new CYFException("You tried to set a removed sprite/nil sprite as this text object's parent."); } } public void SetText(DynValue text) { @@ -339,6 +369,8 @@ public void AddText(DynValue text) { } public void SetVoice(string voiceName) { + if (voiceName == null) + throw new CYFException("Text.SetVoice: The first argument (the voice name) is nil.\n\nSee the documentation for proper usage."); CheckExists(); if (voiceName == "none") default_voice = null; @@ -347,6 +379,8 @@ public void SetVoice(string voiceName) { } public void SetFont(string fontName, bool firstTime = false) { + if (fontName == null) + throw new CYFException("Text.SetFont: The first argument (the font name) is nil.\n\nSee the documentation for proper usage."); CheckExists(); UnderFont uf = SpriteFontRegistry.Get(fontName); if (uf == null) @@ -359,7 +393,9 @@ public void SetFont(string fontName, bool firstTime = false) { GetComponent().localPosition = new Vector2(0, 0); } - public void SetEffect(string effect, float intensity) { + public void SetEffect(string effect, float intensity = -1) { + if (effect == null) + throw new CYFException("Text.SetEffect: The first argument (the effect name) is nil.\n\nSee the documentation for proper usage."); CheckExists(); switch (effect.ToLower()) { case "none": @@ -395,6 +431,9 @@ public void ShowBubble(string side = null, DynValue position = null) { SetSpeechThingPositionAndSide(side, position); } + // Shortcut to `SetSpeechThingPositionAndSide` + public void SetTail(string side, DynValue position) { SetSpeechThingPositionAndSide(side, position); } + public void SetSpeechThingPositionAndSide(string side, DynValue position) { CheckExists(); bubbleLastVar = position; @@ -456,6 +495,9 @@ public void NextLine() { } } + // Shortcut to `SetAutoWaitTimeBetweenTexts` + public void SetWaitTime(int time) { SetAutoWaitTimeBetweenTexts(time); } + public void SetAutoWaitTimeBetweenTexts(int time) { CheckExists(); framesWait = time; diff --git a/Assets/Scripts/Lua/CLRBindings/MusicManager.cs b/Assets/Scripts/Lua/CLRBindings/MusicManager.cs index faa66f6eb..164ab945f 100644 --- a/Assets/Scripts/Lua/CLRBindings/MusicManager.cs +++ b/Assets/Scripts/Lua/CLRBindings/MusicManager.cs @@ -91,11 +91,15 @@ public static void UnpauseAll() { } public static string GetSoundDictionary(string key) { + if (key == null) + throw new CYFException("Audio.GetSoundDictionary: The first argument (the index) is nil.\n\nSee the documentation for proper usage."); if (hiddenDictionary.ContainsKey(key.ToLower())) return (string)hiddenDictionary[key.ToLower()]; else return key; } public static void SetSoundDictionary(string key, string value) { + if (key == null) + throw new CYFException("Audio.SetSoundDictionary: The first argument (the index) is nil.\n\nSee the documentation for proper usage."); if (key == "RESETDICTIONARY") hiddenDictionary.Clear(); else { diff --git a/Assets/Scripts/Lua/CLRBindings/NewMusicManager.cs b/Assets/Scripts/Lua/CLRBindings/NewMusicManager.cs index 75a83160f..8e7c2f23a 100644 --- a/Assets/Scripts/Lua/CLRBindings/NewMusicManager.cs +++ b/Assets/Scripts/Lua/CLRBindings/NewMusicManager.cs @@ -7,6 +7,8 @@ public class NewMusicManager { public static Dictionary audioname = new Dictionary(); public static void CreateChannel(string name) { + if (name == null) + throw new CYFException("NewAudio.CreateChannel: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); if (audiolist.ContainsKey(name)) { Debug.LogWarning("The audio channel " + name + " already exists."); return; @@ -31,6 +33,8 @@ public static AudioSource CreateChannelAndGetAudioSource(string name) { } public static void DestroyChannel(string name) { + if (name == null) + throw new CYFException("NewAudio.DestroyChannel: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); if (name == "src") throw new CYFException("You can't delete the audio channel \"src\"."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); try { @@ -40,20 +44,32 @@ public static void DestroyChannel(string name) { audioname.Remove(name); } - public static bool Exists(string name) { return audiolist.ContainsKey(name); } + public static bool Exists(string name) { + if (name == null) + throw new CYFException("NewAudio.Exists: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); + return audiolist.ContainsKey(name); + } public static string GetAudioName(string name) { + if (name == null) + throw new CYFException("NewAudio.GetAudioName: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); return audioname[name]; } public static float GetTotalTime(string name) { + if (name == null) + throw new CYFException("NewAudio.GetTotalTime: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); if (((AudioSource)audiolist[name]).clip != null) return ((AudioSource)audiolist[name]).clip.length; return 0; } public static void PlayMusic(string name, string music, bool loop = false, float volume = 1) { + if (name == null) + throw new CYFException("NewAudio.PlayMusic: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); + else if (music == null) + throw new CYFException("NewAudio.PlayMusic: The second argument (the music name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); ((AudioSource)audiolist[name]).Stop(); ((AudioSource)audiolist[name]).loop = loop; @@ -67,6 +83,10 @@ public static void PlayMusic(string name, string music, bool loop = false, float } public static void PlaySound(string name, string sound, bool loop = false, float volume = 0.65f) { + if (name == null) + throw new CYFException("NewAudio.PlaySound: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); + else if (sound == null) + throw new CYFException("NewAudio.PlaySound: The second argument (the sound name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); ((AudioSource)audiolist[name]).Stop(); ((AudioSource)audiolist[name]).loop = loop; @@ -80,6 +100,10 @@ public static void PlaySound(string name, string sound, bool loop = false, float } public static void PlayVoice(string name, string voice, bool loop = false, float volume = 0.65f) { + if (name == null) + throw new CYFException("NewAudio.PlayVoice: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); + else if (voice == null) + throw new CYFException("NewAudio.PlayVoice: The second argument (the voice name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); ((AudioSource)audiolist[name]).Stop(); ((AudioSource)audiolist[name]).loop = loop; @@ -100,6 +124,8 @@ public static void SetPitch(string name, float value) { } public static float GetPitch(string name) { + if (name == null) + throw new CYFException("NewAudio.GetPitch: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); return ((AudioSource)audiolist[name]).pitch; } @@ -112,23 +138,33 @@ public static void SetVolume(string name, float value) { } public static float GetVolume(string name) { + if (name == null) + throw new CYFException("NewAudio.GetVolume: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); return ((AudioSource)audiolist[name]).volume; } public static void Play(string name) { + if (name == null) + throw new CYFException("NewAudio.Play: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); ((AudioSource)audiolist[name]).Play(); } public static void Stop(string name) { + if (name == null) + throw new CYFException("NewAudio.Stop: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); ((AudioSource)audiolist[name]).Stop(); } public static void Pause(string name) { + if (name == null) + throw new CYFException("NewAudio.Pause: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); ((AudioSource)audiolist[name]).Pause(); } public static void Unpause(string name) { + if (name == null) + throw new CYFException("NewAudio.Unpause: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); ((AudioSource)audiolist[name]).UnPause(); } @@ -139,11 +175,15 @@ public static void SetPlayTime(string name, float value) { } public static float GetPlayTime(string name) { + if (name == null) + throw new CYFException("NewAudio.GetPlayTime: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); return ((AudioSource)audiolist[name]).time; } public static float GetCurrentTime(string name) { + if (name == null) + throw new CYFException("NewAudio.GetCurrentTime: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); return ((AudioSource)audiolist[name]).time; } @@ -164,6 +204,8 @@ public static void UnpauseAll() { } public static bool isStopped(string name) { + if (name == null) + throw new CYFException("NewAudio.isStopped: The first argument (the channel name) is nil.\n\nSee the documentation for proper usage."); if (!audiolist.ContainsKey(name)) throw new CYFException("The audio channel " + name + " doesn't exist."); return !((AudioSource)audiolist[name]).isPlaying; } diff --git a/Assets/Scripts/Lua/CLRBindings/Overworld/LuaGeneralOW.cs b/Assets/Scripts/Lua/CLRBindings/Overworld/LuaGeneralOW.cs index 8b7e51219..b87f6c04f 100644 --- a/Assets/Scripts/Lua/CLRBindings/Overworld/LuaGeneralOW.cs +++ b/Assets/Scripts/Lua/CLRBindings/Overworld/LuaGeneralOW.cs @@ -56,56 +56,46 @@ [CYFEventFunction] public void SetChoice(DynValue choices, string question = "", else PlayerOverworld.instance.UIPos = 0; - bool threeLines = false; TextMessage textMsgChoice = new TextMessage("", false, false, true); textMsgChoice.AddToText("[mugshot:null]"); - string[] finalText = new string[3]; + List finalText = new List(); + bool[] oneLiners = new bool[2]; //Do not put more than 3 lines and 2 choices //If the 3rd parameter is a string, it has to be a question if (question != "") { - textMsgChoice.AddToText(question + "\n"); - - //int lengthAfter = question.Split('\n').Length; - //if (question.Split('\n').Length > lengthAfter) lengthAfter = question.Split('\n').Length; - - /*if (lengthAfter > 2)*/ //textMsgChoice.addToText("\n"); - //else textMsgChoice.addToText("\n\n"); + textMsgChoice.AddToText("* " + question + "\n"); } - for (int i = 0; i < choices.Table.Length; i++) { + for (int i = 0; i < 2; i++) { //If there's no text, just don't print it - if (i == 2 && question != "") - break; if (choices.Table.Get(i + 1).String == null) continue; - string[] preText = choices.Table.Get(i + 1).String.Split('\n'), text = new string[3]; - if (preText.Length == 3) - threeLines = true; - for (int j = 0; j < 3; j++) { - if (j < preText.Length) text[j] = preText[j]; - else text[j] = ""; + string[] preText = choices.Table.Get(i + 1).String.Split('\n'); + oneLiners[i] = preText.Length == 1 && question != ""; + if (oneLiners[i]) { + string line = preText[0]; + preText = new string[] { "", line }; } - for (int k = 0; k < 3; k++) { - if (text[k] != "") - if (k == 0) text[k] = "* " + text[k]; - else text[k] = " " + text[k]; - - finalText[k] += text[k] + '\t'; - if (k == text.Length - 1) + for (int j = 0; j < 3; j++) { + if (j == finalText.Count) + finalText.Add(""); + finalText[j] += "[charspacing:8] [charspacing:2]" + (i == 0 ? " " : "") + (j >= preText.Length ? "" : preText[j]) + (i == 0 ? "\t" : ""); + if (j == 2) break; } } //Add the text to the text to print then the SetChoice function with its parameters - if (!threeLines && question != "") - textMsgChoice.AddToText("\n"); - textMsgChoice.AddToText(finalText[0] + "\n" + finalText[1] + "\n" + finalText[2]); + for (int i = 0; i < finalText.Count; i++) { + if (finalText[i] != "\t") + textMsgChoice.AddToText(finalText[i] + ((i == finalText.Count - 1) ? "" : "\n")); + } textmgr.SetText(textMsgChoice); textmgr.transform.parent.parent.SetAsLastSibling(); - StCoroutine("ISetChoice", new object[] { question != "", threeLines }); + StCoroutine("ISetChoice", new object[] { question != "", oneLiners }); } [CYFEventFunction] public void Wait(int frames) { StCoroutine("IWait", frames); } diff --git a/Assets/Scripts/Lua/CLRBindings/Overworld/LuaInventoryOW.cs b/Assets/Scripts/Lua/CLRBindings/Overworld/LuaInventoryOW.cs index 2c54e7e03..66d12f483 100644 --- a/Assets/Scripts/Lua/CLRBindings/Overworld/LuaInventoryOW.cs +++ b/Assets/Scripts/Lua/CLRBindings/Overworld/LuaInventoryOW.cs @@ -38,4 +38,6 @@ [CYFEventFunction] public bool AddItem(string Name) { [CYFEventFunction] public int GetItemID(string name) { try { return Inventory.InventoryNumber(name); } finally { appliedScript.Call("CYFEventNextCommand"); } } [CYFEventFunction] public int GetItemCount() { try { return Inventory.inventory.Count; } finally { appliedScript.Call("CYFEventNextCommand"); } } + + [CYFEventFunction] public void SpawnBoxMenu() { StCoroutine("ISpawnBoxMenu", new object[] { }); } } \ No newline at end of file diff --git a/Assets/Scripts/Lua/CLRBindings/ProjectileController.cs b/Assets/Scripts/Lua/CLRBindings/ProjectileController.cs index d467c5120..20c4d558f 100644 --- a/Assets/Scripts/Lua/CLRBindings/ProjectileController.cs +++ b/Assets/Scripts/Lua/CLRBindings/ProjectileController.cs @@ -196,6 +196,8 @@ public void Remove() { lastY = y; lastAbsX = absx; lastAbsY = absy; + if (p.gameObject.GetComponent() != null) + GameObject.Destroy(p.gameObject.GetComponent()); spr.StopAnimation(); BulletPool.instance.Requeue(p); p = null; @@ -224,9 +226,15 @@ public void MoveToAbs(float x, float y) { public void SendToBottom() { p.self.SetAsFirstSibling(); } - public void SetVar(string name, DynValue value) { vars[name] = value; } + public void SetVar(string name, DynValue value) { + if (name == null) + throw new CYFException("bullet.SetVar: The first argument (the index) is nil.\n\nSee the documentation for proper usage."); + vars[name] = value; + } public DynValue GetVar(string name) { + if (name == null) + throw new CYFException("bullet.GetVar: The first argument (the index) is nil.\n\nSee the documentation for proper usage."); DynValue retval; if (vars.TryGetValue(name, out retval)) return retval; else return null; diff --git a/Assets/Scripts/Lua/LuaScriptBinder.cs b/Assets/Scripts/Lua/LuaScriptBinder.cs index bbae94a82..bb913dfb4 100644 --- a/Assets/Scripts/Lua/LuaScriptBinder.cs +++ b/Assets/Scripts/Lua/LuaScriptBinder.cs @@ -13,7 +13,7 @@ public static class LuaScriptBinder { private static Dictionary dict = new Dictionary(), battleDict = new Dictionary(), alMightyDict = new Dictionary(); private static MusicManager mgr = new MusicManager(); private static NewMusicManager newmgr = new NewMusicManager(); - public static List