From 425f8b29b57e80ecc9f07b1b13344e193711905e Mon Sep 17 00:00:00 2001 From: Renge Date: Sat, 2 Apr 2022 21:44:53 -0400 Subject: [PATCH] feat: partially implement storymode --- dist/shattered_sword_assets/images/Logo.png | Bin 0 -> 12711 bytes .../jsons/samplestory.json | 19 +++ .../Scenes/Layers/StoryLayer.ts | 114 ++++++++++++++++++ src/shattered_sword/Scenes/Levels.ts | 19 +-- src/shattered_sword/Scenes/StoryMode.ts | 5 - .../Scenes/StorySceneTester.ts | 101 ++++++++++++++++ .../Tools/DataTypes/MapTemplate.ts | 8 +- src/shattered_sword/Tools/DataTypes/Story.ts | 23 ++++ 8 files changed, 274 insertions(+), 15 deletions(-) create mode 100644 dist/shattered_sword_assets/images/Logo.png create mode 100644 dist/shattered_sword_assets/jsons/samplestory.json create mode 100644 src/shattered_sword/Scenes/Layers/StoryLayer.ts delete mode 100644 src/shattered_sword/Scenes/StoryMode.ts create mode 100644 src/shattered_sword/Scenes/StorySceneTester.ts create mode 100644 src/shattered_sword/Tools/DataTypes/Story.ts diff --git a/dist/shattered_sword_assets/images/Logo.png b/dist/shattered_sword_assets/images/Logo.png new file mode 100644 index 0000000000000000000000000000000000000000..82f3d4c5a0029e14878ed2e072a86cc83c6fc3bc GIT binary patch literal 12711 zcmeHtc{rO}`>wWoxBJsU6{W_#t2Nh9R1tL7&#tl~DxiA?e_Fzhtmizp?mb?&n;6pdzE0 zvwHJicY8Fclil;~TEW#-iJ`j8K@AOoI;h9s^atA3g~V$=Slwm>%We`qlaq8si3{V-m>qWAklhMPg~g2j`i_VG@Vzm zXKOOXE7HzlBx+ZGxVaP|xbrDhKNRru)O>nQ#VFo}`Ne*^E{7l35rQva6>7uU1AU--GWZkZehQt@x8V?Y)?%zSp7 ziwos-^URx_dr}8qg;SxUT6pIivD5jeV9Ys&hz-TVH#T5JqfIwj?$dG%voJG0Pkp^d ztL8Aq_sN9BwwNusvz$)1qEy#TNb{wnk3Owep}2fJfS|@4Lm>ykB%IKVgej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fi|ok^#p#b>ji%k9vQM(alRm=j<+)R#4qtTh#)Ts&)gsW0s$gWOTYpenSe#TLyxHuyNwvDL+ zvH=y215fJ^Jm+^!YysYNCI=gh(}|CdtKl3SIebuCIre={3BHx@vzSEOMHID4&re<8 z`Ak_!0wf^eXe@G*>swkCL9q~4Zd(Ov_f_#z!(cyNO8oOEwp;`*d5r#ODPH&_fKVYkn@Y z`295bi4!)T2y?KAWX% z_VOL};MDph+@>wiSifR8un|B_wD#Hagn%jsM-x#??abKtq`#2bfOaZ_0t8Ei)yda8 z`zz4jJ&6)14ekDD;J^kZ{#omTQ5Ng)IW+1DT*FNLsh8Iuhg&WOMIB2^gP&@zrw!Jf z@Sa*)-}zT?vReKCs6OsCc3@D6#k8<^mp*7g*+1!T_cAn@H~Z9ZSvitinvhrI@wu@`S>H}8I`||?sT?oa%YWVRN7L4aVZM1I`oo2_ zhNKtwJ88taV3)?5a9!~oZOc7atMjq?-+>|@P?-Og*SLKP#1CukU}X)iMH*vGOlr6&Sif;HgHc3 zP>3e{>`AHT>#t!4< zP7XW+av!0a>-s1H)0UjBD+MC@|2D#NJXaLRQav{ zoaU?ws&%Sp$fef(`edRy;M(LoRX~ET?xb@?gU#7GxY2BRGH)oQ6W7Tju?}orqmj-| z?QV6W;#+CGEmDL);K1bnfBjD*@TrU?IbL|-kAMB~ SyCdg++%q&aK;M4!*Z%^8(u>Rh literal 0 HcmV?d00001 diff --git a/dist/shattered_sword_assets/jsons/samplestory.json b/dist/shattered_sword_assets/jsons/samplestory.json new file mode 100644 index 0000000..90faec8 --- /dev/null +++ b/dist/shattered_sword_assets/jsons/samplestory.json @@ -0,0 +1,19 @@ +{ + "resources": [ + { + "type": "image", + "key": "hiro", + "path": "shattered_sword_assets/images/Logo.png" + } + ], + "texts": [ + { + "speaker": "Hiro", + "content": "Hello world!" + }, + { + "speaker": "world", + "content": "Hello Hiro!" + } + ] +} \ No newline at end of file diff --git a/src/shattered_sword/Scenes/Layers/StoryLayer.ts b/src/shattered_sword/Scenes/Layers/StoryLayer.ts new file mode 100644 index 0000000..8055f10 --- /dev/null +++ b/src/shattered_sword/Scenes/Layers/StoryLayer.ts @@ -0,0 +1,114 @@ +// import Vec2 from "../../../Wolfie2D/DataTypes/Vec2"; +// import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite"; +// import Label, { HAlign } from "../../../Wolfie2D/Nodes/UIElements/Label"; +// import { UIElementType } from "../../../Wolfie2D/Nodes/UIElements/UIElementTypes"; +// import Layer from "../../../Wolfie2D/Scene/Layer"; +// import Scene from "../../../Wolfie2D/Scene/Scene"; +// import Color from "../../../Wolfie2D/Utils/Color"; +// import Story from "../../Tools/DataTypes/Story"; +// import StorySceneTester from "../StorySceneTester"; + +// export default class StoryLayer extends Layer { +// private progress: number; +// private sprites: Array; +// private currentSpeaker: string; +// private currentContent: string; + + +// constructor(scene: Scene, name: string, story: Story) { +// super(scene, name); +// this.story = story; +// } + +// static async storyLayerFactory(scene: StorySceneTester, name: string, storyPath: string): Promise { +// const response = await (await fetch(storyPath)).json(); +// let instance = new StoryLayer(scene, name, response); +// instance.story.resources.forEach((resource) => { +// switch (resource.type) { +// case "image": +// instance.scene.load.image(resource.key, resource.path); +// break; +// case "spritesheet": +// instance.scene.load.spritesheet(resource.key, resource.path); +// break; +// case "audio": +// instance.scene.load.audio(resource.key, resource.path); +// break; +// default: +// break; +// } +// }) + +// instance.currentSpeaker = instance.story.texts[0].speaker; +// instance.currentContent = instance.story.texts[0].content; + +// instance.textLabel =