C .
ODE
G
AMELET
# WovenFatesPerformanceModule WovenFatesPerformanceModule 是一組為 **平生願** 專案整理的演出用擴充模組,主要聚焦在三個方向: - **Dialogue**:對話框、選項、對話履歷與相關互動觸發 - **Notebook**:可建立、開關、增刪條目並支援翻頁演出的筆記本系統 - **Typing Animation**:可直接顯示於畫面,或掛載到顯示屏上的逐字動畫特效 這個模組的目標不是提供底層框架,而是補足事件表中常用的 **劇情演出能力**,讓對話、筆記、提示文字與資訊呈現能更直接地接入任務流程。 具體使用效果可以參考平生願重製版:https://woven-fates.gamelet.online/ --- **非常抱歉,匯入模組時會多出現許多未加載模組的資料夾和過多未必要資源的問題,現已解決。** **還請在更新後使用,本模組僅依賴 CgEventsExp + CgEventsLib + TwillightWarsLib。** **對於對各位的專案帶來的整理麻煩,真的十分抱歉,本人也是第一次弄模組。** **如遇到刷新任務後,逐字動畫顯示屏消失的問題,請勾選「已存在時重建」。** --- # DIALOGUE ## Action: - **建立對話框** 建立對話框 UI,初始化對話介面的版面、文字區與顯示結構,作為後續顯示台詞與操作履歷的基礎。 - **顯示對話內容** 更新對話框中的角色名稱與台詞內容,用於一般劇情推進與對話演出。 - **顯示對話選項** 顯示可供玩家選擇的對話選項視窗,支援自訂選項內容、位置、字體與外框樣式,可選擇是否等待玩家作答。 - **開啟對話履歷** 開啟對話紀錄視窗,讓玩家查看先前已顯示過的對話內容。 - **關閉對話履歷** 關閉對話紀錄視窗,回到一般對話流程。 ## Trigger: - **選中對話選項** 在玩家選中對話選項後觸發,可取得選項視窗 ID 與選中的值,方便把選項結果接回事件表邏輯。 - **滑鼠滾輪觸發** 監聽滑鼠滾輪輸入,可用於開關對話履歷、切換頁面或其他 UI 滾輪互動。 --- # NOTEBOOK ## Action: - **建立筆記本** 建立筆記本 UI 與控制器,初始化封面、頁面、目錄、條目內容、圖片區與翻頁機制。 - **開關筆記本** 控制筆記本的開啟、關閉或切換狀態,可用於劇情中隨時調出或收起筆記本介面。 - **新增筆記條目** 將新條目加入筆記本,支援標題、左右頁內容與圖片資料,適合用於調查、線索收集與資訊整理。 - **刪除筆記條目** 依照條目 ID 或索引刪除指定條目,可用於更新資料、覆蓋舊資訊或同步任務進度。 - **顯示筆記條目** 顯示指定條目內容,或切回筆記本目錄頁,並配合翻頁效果切換內容。 ## Trigger: - **筆記本事件觸發** 監聽筆記本的開啟、關閉、回到目錄與選中特定條目等事件,可直接把玩家閱讀行為接入事件表。 --- # TYPING ANIMATION ## Action: - **特效逐字動畫** 在畫面上顯示逐字出現的文字,並可搭配音效、晃動與淡出等效果,用於提示、旁白、內心獨白或特殊文字演出。 - **建立逐字動畫顯示屏** 建立可重用的逐字動畫顯示區,支援背景、行距、最大行數、堆疊方向與推動動畫設定,可讓多條逐字訊息依序堆疊顯示,而不互相重疊。
# TWPerfPatch 本模組為 `TwilightWarsLib` 的效能優化補丁。只要在專案中載入模組,優化邏輯即會自動生效,無需手動初始化。 ## 優化項目 ### 1\. GAF 動畫循環控制 (GAFMovieClip) * **自動切斷循環**:執行 `stop()` 時會同步停止 `requestAnimationFrame` 遞迴,確保動畫停止時不再消耗 CPU 運算資源。 * **重啟時間校正**:在執行 `play()` 時重置時間戳記,確保動畫從停止處精準接續播放。 * **記憶體壓力優化**:透過手動管理動畫回呼函式,大幅減少重複產生暫存資料造成的記憶體堆積。 ### 2\. 深度資源清理 (Game Destroy) * **強制遞迴清理**:覆寫 `destroy` 邏輯並預設開啟 `children: true`,確保場景銷毀時會自動連同所有子物件掃描並清理乾淨。 * **紋理引用釋放**:預設開啟 `texture: true`,在場景銷毀時主動釋放該場景佔用的圖片資源(Texture),提升系統回收記憶體的效率。 * **背景循環掃描**:在執行 `dispose()` 時進行深度掃描,確保所有層級中還在執行的動畫循環皆已關閉。 ## 注意事項 (Disclaimer) * **非官方補丁**:本模組非由 `TwilightWarsLib` 官方開發,屬於第三方效能優化。 * **使用風險**:本補丁會直接修改函式庫的原型邏輯(Prototype)。 * **副作用說明**:由於強制開啟了銷毀子物件與紋理的功能,若專案中有「跨場景共用且未重新加載」的圖片資源,可能導致顯示異常。建議載入後完整測試一次場景切換流程。 * **優化程度說明**:本補丁並非 100% 解決所有洩漏問題。目前仍有部分潛在的 `requestAnimationFrame` 調用深埋於函式庫內部難以追蹤,且部分 `GAFTexture` 仍可能存在無法被完全釋放的情況,僅能就目前已知路徑進行最大化優化。 ## Authors **[cook1470](/profile/cook1470)**
# RyvexiaLib 這是一個用來製作 **[Ryvexia](https://ryvexia.gamelet.online/)** 音樂遊戲的核心模組,如果想要摳出新專案來製作遊戲,請不要摳此模組,建議摳遊戲成品。 有任何問題請於 **[專案討論](https://code.gamelet.com/discuss/p/RyvexiaLib/0)** 回報,會盡快解決。 ### 遊玩方法 遊戲開始後,會播放音樂,並從畫面上方落下音符,當音符與下方的判定框重合後按下對應的按鍵來打擊音符,打擊時機越準分數越高。 預設為四個軌道,對應按鍵分別為 D、F、J、K。 音符的種類目前分為下列幾種: - **Tap**:單壓,當音符與下方的判定框重合後,按下對應的按鍵來打擊音符。 - **Hold**:長壓,當音符與下方的判定框重合後,按住對應的按鍵直到音符結束時完成打擊。 遊戲中按下 ESC 可暫停遊戲。 ## 如何開始? ```typescript // 設置譜面檔案路徑(專案內),必須先於專案內新增譜面資料檔案。 const chartSource = `CG.${CG.Base.projectCode}/test.json`; // 加載檔案。 CG.Base.resourceManager.addAppSource(chartSource) // 初始化 RyvexiaLib。 CG.RyvexiaLib.initialize() .then(() => { // 初始化完成後 // 初始化 pixi 舞台,建議舞台寬高 1920 x 1080。 CG.Base.pixi.initialize(1920, 1080); // 新增一個譜面資料物件,並匯入譜面資料。 const chartData = new CG.RyvexiaLib.datas.ChartData(); chartData.importSource(chartSource); // 加載該譜面的音樂資料。 chartData.loadMusic(() => { // 加載完成後 // 建立 Ryvexia 遊戲物件,並加入到 root 舞台顯示於畫面上。 const game = new CG.RyvexiaLib.games.Game(); CG.Base.pixi.root.addChild(game); // 設置該遊戲的譜面資料並開始遊戲。 game.setup(chartData).start(); }) }) ``` ## 自製譜面 本模組提供了具有圖形化介面的譜面編輯器,當然你也可以自己使用程式碼添加,甚至利用譜面資料可以新增資料的功能,自製一個譜面編輯器也可以。 ### 如何從編輯器開始? #### 快捷鍵: - W、上:譜面向上移動。 - S、下:譜面向下移動。 - Shift + 移動:加速移動。 - +:增加每小節的拍數。 - -:減少每小節的拍數。 - Shift + 測試遊戲:啟用自動遊玩模式。 (也可以拖動進度條來改變音樂進度。) ```typescript // 初始化 RyvexiaLib CG.RyvexiaLib.initialize() .then(() => { // 初始化 pixi 舞台 CG.Base.pixi.initialize(1920, 1080); // 創建譜面資料物件,BPM 為 160 const chartData = new CG.RyvexiaLib.datas.ChartData(160); // 設定譜面音樂資源名稱 chartData.musicAlias = "你的音樂資源別稱"; // chartData.musicFilename = "你的音樂資源檔名"; // 如果你的音樂是壓縮檔,就會需要用到這一條。 // 建立譜面編輯器並匯入譜面資源 const editor = new CG.RyvexiaLib.editors.ChartEditor(chartData); editor.loadByStorage(); // 於譜面編輯器建立後嘗試讀檔,若無檔案則會忽略。 editor.saveWhileTest = true; // 啟用編輯器測試遊戲時自動存檔。(只有在測試遊戲時會存檔,不是有更新就會儲存) // 建立主要遊戲(讓編輯器用於測試) const game = new CG.RyvexiaLib.games.Game(); // 建立編輯器頁面(用於控制編輯器與遊戲之間的溝通) const editorPage = new CG.RyvexiaLib.utils.pages.ChartEditorPage(editor, game); // 顯示編輯器頁面 editorPage.show(); }) ``` ### 如何從程式碼編輯? ```typescript // 創建一個譜面資料,bpm 為 175。 const chartData = new CG.RyvexiaLib.datas.ChartData(175); // 設定一些譜面資料。 chartData.title = 'Sing My Pleasure'; // 譜面標題 chartData.musicAlias = 'RyvexiaLib.Sing My Pleasure'; // 音樂資源別稱 chartData.musicAuthor = 'Vivy (Vo.Kairi Yagi)'; // 音樂作者、歌手 chartData.chartAuthor = '酷可(cook1470)'; // 譜面作者 // 預設有 4 個軌道,於第 1 軌道,第 0 節拍,位置 0 添加音符。 chartData.tracks[1].addNote(0, new NoteData(0)); // 於第 0 軌道,第 0 節拍,位置 0.5 添加音符。 chartData.tracks[0].addNote(1, new NoteData(0.5)); // 於第 2 軌道,第 7 節拍,位置 0.5 添加音符,音符長度 8。 chartData.tracks[2].addNote(7, new NoteData(0.5, 8)); // BPM 變速設定,於第 20 小節開始,BPM 變為 160。 chartData.bpms[20] = 160; // 於第 50 小節開始,BPM 變為 160。 chartData.bpms[50] = 175; // 創建好以後,可以使用 exportJson 匯出 JSON 物件,並使用 JSON.stringify 轉換成字串。 const text = JSON.stringify(chartData.exportJson()); // 再使用 Base 的 HtmlUtil 來下載檔案。 CG.Base.utils.HtmlUtil.downloadText(text, '我的譜面.json'); // 也可以將譜面資料壓縮後直接下載,不需轉換 JSON,且檔案大小會更小。 // CG.Base.utils.HtmlUtil.downloadText(chartData.exportGzip(), '我的譜面.rvx'); ``` 如果你想要使用壓縮後的譜面檔案,匯入的方法稍有不同。 ```typescript const chartSource = 'CG.YourProject/我的譜面.rvx'; // 與 #如何開始? 相同,先加載要使用的譜面,可參考上方介紹,在此省略。 // 利用 Base 的資源管理器讀取成字串。 const text = CG.Base.resourceManager.getText(chartSource); // 新增一個譜面資料物件,並匯入壓縮譜面資料。 const chartData = new ChartData(); chartData.importGzip(text); // 後續與 #如何開始? 相同,建立遊戲、載入音樂並開始遊戲。 ``` ## 頁面控制器 本模組提供了一個簡單的頁面控制器,以及一些預設的頁面可供使用,以下展示以編輯器為主的控制流程。 包含了封面、校正頁面、編輯器頁面。 ```ts // 初始化 RyvexiaLib CG.RyvexiaLib.initialize() .then(() => { // 初始化 pixi 舞台 CG.Base.pixi.initialize(1920, 1080); // 建立頁面管理器。 const pageManager = new CG.RyvexiaLib.utils.PageManager(); // 建立封面頁面,並註冊到頁面管理器中。 const coverPage = new CG.RyvexiaLib.utils.pages.CoverPage(); // coverPage.titleText.text = "我的音樂遊戲"; // 可改變封面標題文字,預設為 Ryvexia pageManager.registerPage(coverPage); // 建立校正、設定頁面,並註冊到頁面管理器中。 const calibrationPage = new CG.RyvexiaLib.utils.pages.CalibrationPage(); pageManager.registerPage(calibrationPage); const chartData = new CG.RyvexiaLib.datas.ChartData(175); chartData.musicAlias = "你的音樂資源別稱"; const editor = new CG.RyvexiaLib.editors.ChartEditor(chartData); editor.loadByStorage(); editor.saveWhileTest = true; const game = new CG.RyvexiaLib.games.Game(); // 建立編輯器頁面(用於控制編輯器與遊戲之間的溝通),並註冊到頁面管理器中。 const editorPage = new CG.RyvexiaLib.utils.pages.ChartEditorPage(editor, game); pageManager.registerPage(editorPage); // ========== 操控個頁面之間的切換流程。 ========== // 當於封面頁面開始時。 coverPage.onStart = () => { // 顯示校準頁面。 pageManager.show(calibrationPage.code); } // 當於校準頁面返回時。 calibrationPage.onReturn = () => { // 顯示譜面編輯器頁面。 pageManager.show(editorPage.code); } // 當於譜面編輯器頁面返回時。 editorPage.onReturn = () => { // 顯示封面。 pageManager.show(coverPage.code); } // 一開始先顯示封面頁。 pageManager.show(coverPage.code); }) ``` ## 進階設定 本模組將一些可設置常數放在 `CG.RyvexiaLib.Constant` 內,裡面有一些特別的參數可以調整,以下為預設值。 ```typescript // 以下可設定各判定分的範圍(時間差)。 CG.RyvexiaLib.Constant.PERFECT_TIME_RANGE = 46; CG.RyvexiaLib.Constant.GREAT_TIME_RANGE = 92; CG.RyvexiaLib.Constant.GOOD_TIME_RANGE = 138; CG.RyvexiaLib.Constant.MISS_TIME_RANGE = 200; // 以下可設定作為判定分顯示的文字,遊戲中、結算等。 CG.RyvexiaLib.Constant.SCORE_TYPES.PERFECT = "Perfect"; CG.RyvexiaLib.Constant.SCORE_TYPES.GREAT = "Great"; CG.RyvexiaLib.Constant.SCORE_TYPES.GOOD = "Good"; CG.RyvexiaLib.Constant.SCORE_TYPES.MISS = "Miss"; ``` ## 作者 **[module_cook1470](/profile/64897095@github)**
# GLT One Paragraph of the game description goes here ## Getting Started ### Auth (Login) ```typescript // All action must wait until auth system is ready. CG.GLT.auth.onReady(user => { if(user.isLocalGuest()) { // not login yet } else { // logged in user } }); // auth event listener, triggered when auth user changed let authListener = CG.GLT.auth.onAuth(user => { if(user.isLocalGuest()) { // logged out } else { // logged in user } }); // auth event listener, triggered when validating a new auth action // a following onAuth event is expected. this.validatingListener = onAuthValidating(() => { // show loading animation }); ``` ### API The CG.GLT.api is responsible to communicate with glt.gamelet.online. CG.GLT.commands includes all comments to query/submit data from glt.gamelet.online. The commands has a function submit() that uses CG.GLT.api.submitCommand(), so most of the time, you don't need to call the api to submit. ```typescript CG.GLT.commands.scoreService.submitScore( 'challenge', // the name of the score to submit 10, // the score SubmitType.KEEP_HIGHEST, // submit only when the new score is greater than the one on server TimeRange.ALL // submit to all time-ranges (history and weekly) ) .submit(); // to receive the weekly high score list CG.GLT.commands.scoreService.listScores( 'challenge', // the name of the scores to get TimeRange.WEEKLY, // in which time range OrderType.HIGH_TO_LOW, // how to order the scores CG.GLT.api.lastUpdatedServerTimestamp, // tell the server which week to see 0, // start index 10, // how many to get (list: UserScoreList) => { // do something with the scorelist }, (error) => { // deal with error } ) ``` ## Authors **[Haskasu](/profile/113321052805704333314@google)**
# CG.Base Provide tool kits that helps you fast build an app on Code.Gamelet. Key features include: 1. initialize [pixi.js](#pixi.init) environment 1. load and access resources that are imported via Code.Gamelet IDE 1. manage update functions that are called every frame 1. provide debug utilities ## Getting Started Follow the steps below to fast start an app with [PixiJS](#pixi.init). We will implement a box2d environment to demo the usage of Base. <a name="pixi.init"></a> ## Start with Pixi.js<a name="pixi.init"></a> ```typescript class App { constructor() { // initialize pixi CG.Base.pixi.initialize(600, 400); CG.Base.pixi.physicsDebugDraw.setActive(true); // make a physics wall var wall = CG.Base.physics.createPhysicsObject('wall', {type: 'static'}); wall.addEdge(new CG.Base.geom.Point(10, 300), new CG.Base.geom.Point(500, 330)); // make a dynamic physics ball var ball = CG.Base.physics.createPhysicsObject('ball', {type: 'dynamic'}); ball.addCircle(0, 0, 10, {friction: 0.1, density: 0.1, restitution: 0.3}); ball.setPosition(100, 10); } } new App(); ``` @see [Demo](/edit/Base_Start_with_PIXI) ## Load and play with Resources To load resources that are imported from IDE: ```typescript // tell resources what resources to load (using the alias names) CG.Base.resourceManager.addAppResource('Game1.button'); CG.Base.resourceManager.addAppResource('Game1.music'); // start loading CG.Base.resourceManager.load(() => { // all loaded callback // create button with the image "Game1.button" alias name var button = new CG.Base.pixis.interactive.Button(CG.Base.resourceManager.createPixiSprite('Game1.button', 20, 20)); // set the position of the button button.displayObject.position.set(100, 100); // add the button to pixi.root, so pixi can render the button CG.Base.pixi.root.addChild(button.displayObject); // add a click event listener button.on(CG.Base.pixis.interactive.Button.EVENT.CLICK, () => { // when the button is clicked, play sound with "Game1.music" alias name CG.Base.resourceManager.playSound('Game1.music') }); }); ``` @see [Demo](/edit/Base_Load_Resources) ## Manage update functions Take advantage of CG.Base.addUpdateFunction to make a function called every frame ```typescript class App { constructor() { CG.Base.pixi.initialize(600, 400); CG.Base.addUpdateFunction(this, this.update); } // this function will be called every frame(called 60 times per second normally) private update(deltaTime:number):void { // do something } } new App(); ``` @see [Demo](/edit/Base_Update_and_Delay_Func) You can call a function in the future by CG.Base.addDelayFunction ```typescript class App { constructor() { CG.Base.pixi.initialize(600, 400); // call this.delayAction in 1000 milliseconds(= one second) CG.Base.addDelayFunction(this, this.delayAction, 1000); } private delayAction():void { // do something } } new App(); ``` @see [Demo](/edit/Base_Update_and_Delay_Func) ## Interact with Keyboard Use CG.Base.keyboard package to interact with keyboard events. ```typescript export class App { constructor() { // make the window focused, so we can receive keyboard events. window.focus(); // initialize pixi CG.Base.pixi.initialize(600, 400); // tell resourceManager to load the resource 'Game1.button' CG.Base.resourceManager.addAppResource('Game1.button'); // load resources, and wait callback when resources are all loaded CG.Base.resourceManager.load(() => { // add keyboard event listener, when a key is pressed CG.Base.keyboardManager.on(CG.Base.keyboard.KeyboardManagerEvent.PRESSED, key => { // if the pressed key is space, we call this.createSprite() if (key == CG.Base.keyboard.Key.SPACE) { this.createSprite(); } }); }); } private createSprite(): void { // create a sprite with the image 'Game1.button' var sprite: PIXI.Sprite = CG.Base.resourceManager.createPixiSprite('Game1.button'); // set the position of the sprite sprite.position.set(CG.Base.utils.IntUtil.randomBetween(100, 500), CG.Base.utils.IntUtil.randomBetween(100, 300)); // add the sprite to pixi.root, so it can be rendered CG.Base.pixi.root.addChild(sprite); } } new App(); ``` @see [Demo](/edit/Base_PIXI_Keyboard) ## Debugging The best debug tool on browser is the [developer tools](https://developer.chrome.com/devtools) in Chrome (F12). To find your source code in developer tools, first open developer tools(F12), click "Sources" tab, and search the Network tree as below: > top => {projectCode} => gameFrame => code.gamelet.com => gassets => file/{projectCode}/src for example, if the projectCode is 'Game1', source code is located at > top => Game1 => gameFrame => code.gamelet.com => gassets => file/Game1/src ![Source Network Tree](https://code.gamelet.com/gassets/asset/Base/Base.networktree/networktree.png "Source Network Tree") ### Add Watch In addition to browser's debugging tools, CG.Base provides other useful tools. CG.Base.addWatch() adds objects or objects' properties to Watch panel in CG IDE. ```typescript export class App { constructor() { // initialize pixi CG.Base.pixi.initialize(600, 400); // tell resourceManager to load the resource 'Game1.button' CG.Base.resourceManager.addAppResource('Game1.button'); CG.Base.resourceManager.load(() => { // add the created sprite into Watch panel, the alias name in Watch panel is 'sprite' CG.Base.addWatch('sprite', this.createSprite()); }); // add this(App)'s 'time' property into Watch panel. The alias name for this property is 'now' CG.Base.addWatch('now', this, 'time'); } private createSprite(): PIXI.Sprite { // create a sprite with the image 'Game1.button' var sprite: PIXI.Sprite = CG.Base.resourceManager.createPixiSprite('Game1.button'); // set the position of the sprite sprite.position.set(CG.Base.utils.IntUtil.randomBetween(100, 500), CG.Base.utils.IntUtil.randomBetween(100, 300)); // add the sprite to pixi.root, so it can be rendered CG.Base.pixi.root.addChild(sprite); return sprite; } // a getter function, that works like a property of App object. get time(): number { return CG.Base.time(); } } new App(); ``` @see [Demo](/edit/Base_Add_Watch) ## Versioning We use [SemVer](http://semver.org/) for versioning. ## Links and Resources This library is running with the libraries below. * [Pixi.js](http://www.pixijs.com/) - 2D rendering engine * [API reference](http://pixijs.download/release/docs/index.html) * [Examples](http://pixijs.io/examples/) * [Pixi keyboard](https://github.com/Nazariglez/pixi-keyboard) - Keyboard utility * [Pixi sound](https://github.com/pixijs/pixi-sound) - Sound utility * [Pixi filters](https://github.com/pixijs/pixi-filters) - Filters Collections * [Pixi GafPlayer](https://github.com/mathieuanthoine/PixiGAFPlayer) - [GafMedia](https://gafmedia.com/) Player * [Liquidfun](http://google.github.io/liquidfun/) - Box2D based physics engine * [MD5](http://www.myersdaily.org/joseph/javascript/md5-text.html) - MD5 implementation by Joseph Myers ## Authors **Haska Su** - *Initial work*
# Base2 重新架構的Base2,相比Base少了很多功能,包括Pixi/Sound/ResourceManager/Physics/geoms都被拿掉,只留最主要的CG功能。 ## 基本功能 1. 取得專案的資料 ```typescript // 取得專案代碼 CG.Base2.projectCode; // 取得資源 CG.Base2.getAppResource(resourceAlias: string) // 取得資源網址 CG.Base2.getAppResourceFileUrl(resourceAlias: string, filename?: string) ``` ## 更新循環 Base2內建了一個更新循環系統。 ```typescript // 先定義一個每幀都要更新的函式 function updateFunc(dt: number) { } // 將函式加入更新循環系統 CG.Base2.addUpdateFunction(updateFunc); // 將函式移出更新循環系統 CG.Base2.removeUpdateFunction(updateFunc); ``` 另外也提供子更新循環系統可使用。 ```typescript import Updater = CG.Base2.utils.Updater; // 先定義一個每幀都要更新的函式 function updateFunc(dt: number) { } // 建立子更新循環系統 let updater = new Updater(); // 將函式加入更新循環系統 updater.addDelayFunction(updateFunc); // 可暫停 updater.pause(); // 可繼續 updater.resume(); ``` ## 鍵盤管理員 Base2提供了一個基本的鍵盤管理員,可以在按鍵被按下去(DOWN)、提起來(UP)、先按再提(PRESSED)的時候觸發事件。 ```typescript // 取得鍵盤管理員 import Keyboard = CG.Base.keyboards.Keyboard; import keyboard = CG.Base2.keyboard; import Key = CG.Base2.keyboards.Key; // 鍵盤事件 keyboard.on(Keyboard.EVENT.DOWN, (event: KeyboardEvent) => { if (Key.SPACE.matchEvent(event)) { // 當空白鍵被按下去的時候... } }) // 檢查目前按鍵狀態 if (keyboard.isDown(Key.SPACE)) { // 目前空白鍵是正在按下去的狀態 } ``` ## 補間變化 Base2內建了[tweenjs](https://github.com/tweenjs/tween.js)用來將某個物件的屬性,在一段時間內作動態的變化。 ```typescript async function makeAnimation() { // 建立一隻有x,y資料的動物 let animal = { x: 100, y: 100, }; // 建立補間變化,在1秒內讓動物的x和y變化到指定的值 let tween = new TWEEN.Tween(animal); tween.to( { x: 300, y: 200, }, 1000 // 毫秒 ); tween.start(); // 等待變化完畢 await CG.Base2.waitTween(tween); console.log(animal.x); // 這時會印出 300 } ``` ## JSZip Base2內建[JSZip](https://stuk.github.io/jszip/)。 ```typescript async function loadZip() { let zip = new JSZip(); await zip.loadAsync(buffer); for(let filename in zip.files) { ... } } ```
# 更好的光暈戰記事件表擴充模組(TWEventsBetterExp) 本模組延續 [**TwilightWarsEventsExp**](https://code.gamelet.com/edit/TwilightWarsEventsExp)(以下簡稱 EXP)的概念所設計,並基於 [**TwilightWarsEvents**](https://code.gamelet.com/edit/TwilightWarsEvents) 建立,用於擴充 [**光暈戰記**](https://twilightwars.gamelet.online/) 事件表功能的模組。 由於 **EXP** 過於混雜,為優化模組架構與性能,將逐步進行程式碼重構,剔除許多不必要,或與 **TwilightWarsEvents** 重疊的功能,保留真正需要的功能。 程式碼搬遷將會是一個持續性的工程,如果你有建議可以優先搬遷的功能,歡迎直接告訴我。 本模組的所有功能都放在 **光暈戰記 (BetterExp)** 目錄底下,且所有功能皆有 (BetterExp) 後綴。 ## 注意事項 即使是作用相同的功能,由於程式碼重構的關係,使用上 **EXP** 還是會和本模組有所差異,沒辦法直接將資料無痛轉移,因此你應該將其視為兩個不同的模組。 如果你是曾使用過 **EXP** 的開發者,如今想要開發新的專案,會建議不要安裝 **EXP** 而改安裝此模組。 ## 玩家社群 ### Discord - [**嘎姆討論區**](https://discord.gg/hZKQzRfPJM):於 2021/05/08 創立的非官方社群,主要用於討論嘎姆擂台的相關資訊。 ## 作者 **酷可**:[**Code.Gamelet**](/profile/114899766849308759711@google)、[**Gamelet.Online**](https://gamelet.online/user/114899766849308759711@google/board)、[**Youtube**](https://www.youtube.com/@cook1470)
# EnhBase 此模組的目標為提供一個框架,使得各模組可以透過Socket傳訊、執行特定功能等;同時希望降低各模組的依賴項,將單一模組內容以更細的粒度拆分,需要特定功能時才載入對應之模組。 此模組之更新時間與更新之功能不定,如果有任何新想法,歡迎加入[Discord群組](https://discord.gg/seJwuzCbWq)一起討論。 此模組初期可能會經過大量修改,以確定設計方向,故本模組並不穩定,如想使用請謹慎考慮。 ***建議可以先查看模組測試的部分,其中的unit_test資料夾可以參考,內含檔案同時是範例實作。*** ## 如何使用 可以透過下列程式碼以完成註冊: ```typescript let lib_name: string // 函式庫之名稱 let user: BasicUser<any> = CG.EnhBase.core.libManager.registerLib(lib_name); ``` 欲接受傳入資料,請使用下列程式碼: ```typescript let socket_unique_name: string // 可辨識之Socket名稱 let socket: Socket = user.createSocket(); socket.addHandler("data", function(data, senderCode) { // 處理資料如何使用 }) socket.listen(socket_unique_name); ``` 而欲傳輸資料給目標Socket,請使用下列程式碼: ```typescript let target_socket_name // 目標Socket名稱 socket.send("YOUR_DATA", target_socket_name); ``` --- ## 變數表功能 接續前面,假設已經取得了BasicUser物件,預設該物件會帶有一個變數表,透過下列程式碼存取: ```typescript const varTable = lib.varTable; ``` 預設該變數表會啟用保護功能,禁止外部存取,於v0.0.2引入了保護用的Key,設定為true或false可控制外部是否可存取,未來可能會更動,請謹慎使用。 ```typescript // enable protection varTable.setValue(BaseVariableTable.ABILITYS.PROTECT, true, true); // or varTable.removeValue(BaseVariableTable.ABILITYS.PROTECT) varTable.setValue(BaseVariableTable.ABILITYS.PROTECT, true); // disable protection varTable.removeValue(BaseVariableTable.ABILITYS.PROTECT) // or varTable.setValue(BaseVariableTable.ABILITYS.PROTECT, false, true); ``` 同時,就算沒有LibUser物件,也可以直接利用 ```typescript let varTable = new SimpleVariableTable(); // or (syncable) let varTable = new GenericVariableTable(); ``` 以取得變數表,並透過下列方法將變數表註冊於manager上: ```typescript core.getInstance<VariableTableManager>("VariableTableManager").addVariableTable(varTable); // or core.variableTableManager.addVariableTable(varTable); ``` ## Authors **[EnhProject](/profile/EnhProject)** - [不會取名字](/profile/buhuechuminzu) - [雪姬](/profile/setsuki)
# TwilightWarsEventsEnhFF 本專案為 **TwilightWarsEventsEnh** 模組的 **beta版本** ,「FF」是「Fast Forward」的縮寫,代表快速開發。 因為原模組的開發緩慢,所以會逐漸把原模組的功能移植至本專案完善。 ## 前言 本專案主要由 **[雪姬](/profile/setsuki)** 維護。 歡迎加入 **[Discord群組](https://discord.gg/seJwuzCbWq)** 。 ## 使用須知 ***本專案開源,若有不明之處可查看 [test](cg://source/test/README.md)*** 本專案的主要目的是要讓事件表編輯如同寫程式一般。 不只專注於 **效能** ,會更著重在提供更大的 **彈性** 。 另外,本專案不會立即修復不嚴重的錯誤。 當測試穩定後,未來會將事件表功能從本專案移植回原模組,屆時該功能可能會在一段時間後,於本模組移除。 Enh的測試、回報需要你的參與,歡迎加入 **[Discord群組](https://discord.gg/seJwuzCbWq)** 。 ## 作者 **[EnhProject](/profile/EnhProject)** - **[不會取名字](/profile/buhuechuminzu)** - **[雪姬](/profile/setsuki)** --- # TwilightWarsEventsEnhFF "FF" stands for "Fast Forward", and can be considered as **beta version** of original **TWEventsEnh**. Due to slow updates of the original Enh, the functionality from mainline Enh would be porting and refined here. ## Additional This project is mainly maintained by [雪姬](/profile/setsuki). The **[Enh Discord server](https://discord.gg/seJwuzCbWq)** is also welcoming participants! ## Important ***It is recommanded to read source code and [test](cg://source/test/README.md) of this project!*** The main concept is to make events work as code. Not just focused on **performance**, but also provide more **flexibility**. This project will not repair bugs instantly unless they are critical. If there are any bugs, they will be fixed before integrated into the main Enh. Enh needs your participate for testing, asking questions or reporting bugs! Features merged into the mainline Enh will be removed here. ## Authors **[EnhProject](/profile/EnhProject)** - **[不會取名字](/profile/buhuechuminzu)** - **[雪姬](/profile/setsuki)**
# 花靈宮模組 - 作者 **[妮娜](/profile/LoliPrincessNina)** - 使用此模組為你的專案增加新的陣營和技能 - 注意電腦AI使用技能時有機會比較蠢 - 過快使用技能將會有概率出BUG - 此為測試版本,有BUG很正常 - 查詢及回報請到<b><a href="https://gamelet.online/user/nina/board">我的留言板</a></b> # 說明 - 為了方便各位照搬/測試花靈宮的任務,此處將填上花靈宮裡所有用到的觸發/檢查/動作 - 有相當一部分代碼是來自TwilightWarsEventsExp和CgEventsExp(下方不列出;部分存在變更,與原版有差異) - 若希望使用以上觸發/檢查/動作,請用原版,此處不會有更新 ## 目前提供支援的有: ## 陣營 - 花靈宮 - 盜賊幫 - 無魂軍 - 智械兵團 - 蒼鎧營 <!-- --> ## 觸發 #### 角色 - 角色說話 - 人物受傷(內建排除傷害類型/傷害數值比對) #### 武器道具 - 使用消耗型道具(可儲存道具變數) <!-- --> ## 檢查 #### 技能 - 角色技能狀態 - 手持武器技能 #### 角色 - 角色狀態附加 - 角色面向某物 - 角色燃燒狀態 - 角色B是否角色A的敵人 - 角色是否可直視某點/物 #### 地圖 - 可行走座標 - 兩點之間的距離 #### 存讀 - 儲存變數 - 在陣列中找到字串 - 以符號分離字串 - 是否存在專案資源 #### 地圖機關 - 燭火機關狀態 - 找出所有地圖機關(迴圈) <!-- --> ## 動作 - 筆記 #### 角色 - 新增角色 - 角色漂浮能力 - 設定角色演員 - 移動角色位置 - 設定角色大小 - 角色可否攻擊 - 角色死亡訊息 - 人物停止說話 - 角色特殊屬性 - 取得玩家陣營演員角色 - 角色醉酒管理 - 角色反彈子彈 - 放下旗幟 - 鎖定面向方向 - 傳送角色加血訊息 - 傳送角色傷害訊息 - 傳送角色閃現至定點訊息 - 設定最大血量 #### 技能 - 角色結束技能 - 限制使用技能 - 設定武器技能 - 傳送技能訊息(欲自定義參數可在此處查看:<a href="https://docs.google.com/spreadsheets/d/1GAJctoQ3f1A_DutUhTHeSFdPY4ex0_U-cUnnuCS5-_g/edit?usp=sharing">技能參數</a>) - 白鳥拳 - 正/反旋風劈掌 - 千手如來 - 百裂拳 - 元氣玉 - 釋放拳法 #### 任務流程 - 跳出系統訊息 - 更多遊戲規則 - 角色對己說話 - 改變任務代碼 #### 存讀 - 工作階段儲存空間數據庫存取 - 以符號分離字串 - 定義Json變數 - 轉換Json為字串 - 轉換Json為物件 - 預載單一資源 #### 特效 - 聖光術 - 角色燃燒狀態 - 應用攻擊屬性 - 震地 - 吸血/血刃 - 劍氣光彈 - 地圖痕跡 - 冰氣 - 火箭 - 快跳文字 - 光環 - 衝擊波 - 地圖動畫 - 擊退人物 - 光印 - 冷卻 - 防護罩 - 防護罩泡泡 - 冰魂護盾 - 血滴 - 自動移除動畫 - 反衝箭 - 定時炸彈 - 空心虛線圓 #### 武器道具 - 背包道具設定 - 攜帶式道具設定 - 切換預設武器 - 切換至另一手 - 裝填武器彈藥 - 新增任務道具 - 新增武器道具 - 人物裝備道具 - 人物裝備武器 - 移除武器道具 - 玩家背包道具擁有的數量 - 設定花靈宮道具 - 遊戲道具配置 #### 地圖 - 隨機可行走座標 #### 隨機 - 隨機設定陣營 - 隨機角色演員 - 隨機使用技能 - 隨機物件代碼 - 隨機字串 - 隨機角色 #### 陣營 - 設定陣營/暱稱/技能圖示 - 新增陣營 - 改變陣營色彩風格(4個子項被拆分成2個新動作) - 回朔至初始陣營 #### 地圖機關 - 控制燭火機關 - 新增可推石塊 - 新增告示牌(NPC角色包括同人陣營選項)
# TwilightWarsEventsExp <h2><font color=red> 本模組由於過於雜亂,為了提高可維護性,以及進行效能優化,將開始進行程式碼的重構計畫。 如有需要請改用 [TWEventsBetterExp](https://code.gamelet.com/edit/TWEventsBetterExp) 模組,近期會開始慢慢將本模組的部分功能搬遷過去。 未來本模組將不再添加新功能,僅進行維護,如非必要請勿加載此模組。 </font></h2> 本專案為光暈戰記的擴充模組,主要是建立在 **[TwilightWarsLib](/edit/TwilightWarsLib)** 的基礎之上,添加一些小東西。本專案並不包含 **[TwilightWarsEvents](/edit/TwilightWarsEvents)** 模組。 本模組並不會覆蓋原有的動作、檢查,所有本模組新增的檢查、動作等,都會被整合在**光暈戰記 / 擴充包**內,且不會新增任何跟光暈無關的檢查或動作,希望是一個純淨的光暈模組,跟光暈無關的相關事件,有需要的話會在 **[CgEventsExp](/edit/CgEventsExp)** 做更新。 本專案開放查詢原始碼,所有的檢查、動作,皆有在本專案的 **Test** 資料夾內做實際範例,歡迎自行查看使用方法,也歡迎自行進入程式區內,看各個檢查、動作是如何完成。 本人希望弄一個可以讓大家互相交流、維護,甚至更新的這麼一個光暈同人模組,我覺得這樣共同成長,才會讓嘎母變得更成熟,所以如果你有什麼好想法,也都歡迎提供給我。 另外個人創了一個第三方的 **[嘎母討論區(Discord)](https://discord.gg/hZKQzRfPJM)** ,主要是希望大家有一個好的交流平台,可以一起討論一些設計,除了光暈,還有其他非光暈的專案等等,甚至是能夠一起合作,讓作者們有機會推出更多優質的作品。 有任何 BUG 的話都歡迎回報,會盡量在最短的時間內處裡掉。 **[Google 試算表 - 光暈戰記](https://docs.google.com/spreadsheets/d/1kRPdI6caisjZuHJGmCjB3kHBveR2RVAeTJoyCmqOZVs/edit?usp=sharing)** 本專案有些需要查詢的地方,例如武器道具的索引值等等,可以由此試算表查詢。 ## 其他工具 - [ImageIndex 查詢器](https://paint.gamelet.online/?version=0.0.27) ## 作者 **[cook1470](/profile/cook1470)**
ⒸCode.Gamelet.com | Privacy Policy | Terms of Service