C .
ODE
G
AMELET
# 花靈宮模組 - 作者 **[妮娜](/profile/581109118900711@facebook)** - 使用此模組為你的專案增加新的陣營和技能 - 注意電腦AI使用技能時有機會比較蠢 - 過快使用技能將會有概率出BUG - 此為測試版本,有BUG很正常 - 查詢及回報請到<b><a href="https://gamelet.online/user/nina/board">我的留言板</a></b> # 說明 - 為了方便各位照搬/測試花靈宮的任務,此處將填上花靈宮裡所有用到的觸發/檢查/動作 - 有相當一部分代碼是來自TWEventsExp和CgEventsExp(下方不列出;部分存在變更,與原版有差異) - 若希望使用以上觸發/檢查/動作,請用原版,此處不會有更新 ## 目前提供支援的有: <table> <tr> <td> <h3><center>花靈宮<center></h3> <table width=280px> <tr> <th> <font color=#ee8800>陣營全稱</font> </th> <td> <center>花靈宮</center> </td> </tr> <tr> <th> <font color=#ee8800>陣營簡稱</font> </th> <td> <center>花靈</center> </td> </tr> <tr> <th> <font color=#ee8800>陣營圖標</font> </th> <td> <center><img src="https://a.gamelet.online/gassets/resource/63ca0ffc3bae29da538b0c2fb44d9d96/c0defb32442314c8.png" width=54px height=54px></center> </td> </tr> <tr> <th> <font color=#ee8800>陣營代碼</font> </th> <td> <center>fairy</center> </td> </tr> <tr> <th> <font color=#ee8800>陣營ID</font> </th> <td> <center>4</center> </td> </tr> </table> <br> <table width=280px> <tr> <th> <font color=#ee8800>武器</font> </th> <th> <font color=#56db9b>第一級技能</font> </th> <th> <font color=#60CFEA>第二級技能</font> </th> </tr> <tr> <th> <font color=#ee8800>小刀</font> </th> <td> <center><font color=#56db9b>自然庇祐</font></center> </td> <td> <center><font color=#60CFEA>迷情之風</font></center> </td> </tr> <tr> <th> <font color=#ee8800>雙爪</font> </th> <td> <center><font color=#56db9b>花影迷蹤</font></center> </td> <td> <center><font color=#60CFEA>霧隱遁音</font></center> </td> </tr> <tr> <th> <font color=#ee8800>大刀</font> </th> <td> <center><font color=#56db9b>霜寒之鋒</font></center> </td> <td> <center><font color=#60CFEA>永恆凍土</font></center> </td> </tr> <tr> <th> <font color=#ee8800>冰劍</font> </th> <td> <center><font color=#56db9b>雪光斬</font></center> </td> <td> <center><font color=#60CFEA></font></center> </td> </tr> <tr> <th> <font color=#ee8800>水晶弓</font> </th> <td> <center><font color=#56db9b>虹彩弦</font></center> </td> <td> <center><font color=#60CFEA></font></center> </td> </tr> </table> </td> <td> <h3><center>盜賊幫</center></h3> <table width=280px> <tr> <th> <font color=#ee8800>陣營全稱</font> </th> <td> <center>盜賊幫</center> </td> </tr> <tr> <th> <font color=#ee8800>陣營簡稱</font> </th> <td> <center>盜賊</center> </td> </tr> <tr> <th> <font color=#ee8800>陣營圖標</font> </th> <td> <center><img src="https://code.gamelet.com/gassets/resource/6738342fc7e884e51987674c69dc5bb5/iconThief.webp?ide" width=36px height=36px></center> </td> </tr> <tr> <th> <font color=#ee8800>陣營代碼</font> </th> <td> <center>thief</center> </td> </tr> <tr> <th> <font color=#ee8800>陣營ID</font> </th> <td> <center>5</center> </td> </tr> </table> <br> <table width=280px> <tr> <th> <font color=#ee8800>武器</font> </th> <th> <font color=#56db9b>第一級技能</font> </th> <th> <font color=#60CFEA>第二級技能</font> </th> </tr> <tr> <th> <font color=#ee8800>小刀</font> </th> <td> <center><font color=#56db9b>障眼法</font></center> </td> <td> <center><font color=#60CFEA>夜襲</font></center> </td> </tr> <tr> <th> <font color=#ee8800>雙爪</font> </th> <td> <center><font color=#56db9b>再生術</font></center> </td> <td> <center><font color=#60CFEA>血祭</font></center> </td> </tr> <tr> <th> <font color=#ee8800>大刀</font> </th> <td> <center><font color=#56db9b>落雷斬</font></center> </td> <td> <center><font color=#60CFEA>雷池</font></center> </td> </tr> <tr> <th> <font color=#ee8800>冰劍</font> </th> <td> <center><font color=#56db9b>鬼火</font></center> </td> <td> <center><font color=#60CFEA></font></center> </td> </tr> <tr> <th> <font color=#ee8800>水晶弓</font> </th> <td> <center><font color=#56db9b>燃苗</font></center> </td> <td> <center><font color=#60CFEA></font></center> </td> </tr> </table> </td> <td> <h3><center>無魂軍</center></h3> <table width=280px> <tr> <th> <font color=#ee8800>陣營全稱</font> </th> <td> <center>無魂軍</center> </td> </tr> <tr> <th> <font color=#ee8800>陣營簡稱</font> </th> <td> <center>無魂</center> </td> </tr> <tr> <th> <font color=#ee8800>陣營圖標</font> </th> <td> <center><img src="https://a.gamelet.online/gassets/resource/3a9b7857a3a317459819a5caaf7c6eca/Logo.png" width=36px height=36px></center> </td> </tr> <tr> <th> <font color=#ee8800>陣營代碼</font> </th> <td> <center>zombie</center> </td> </tr> <tr> <th> <font color=#ee8800>陣營ID</font> </th> <td> <center>6</center> </td> </tr> </table> <br> <table width=280px> <tr> <th> <font color=#ee8800>武器</font> </th> <th> <font color=#56db9b>第一級技能</font> </th> <th> <font color=#60CFEA>第二級技能</font> </th> </tr> <tr> <th> <font color=#ee8800>小刀</font> </th> <td> <center><font color=#56db9b>毒血爆</font></center> </td> <td> <center><font color=#60CFEA>毒反噬</font></center> </td> </tr> <tr> <th> <font color=#ee8800>雙爪</font> </th> <td> <center><font color=#56db9b>鐵骨功</font></center> </td> <td> <center><font color=#60CFEA>石化術</font></center> </td> </tr> <tr> <th> <font color=#ee8800>大刀</font> </th> <td> <center><font color=#56db9b>定身術</font></center> </td> <td> <center><font color=#60CFEA>狂暴斬</font></center> </td> </tr> <tr> <th> <font color=#ee8800>冰劍</font> </th> <td> <center><font color=#56db9b>騰凝霜</font></center> </td> <td> <center><font color=#60CFEA></font></center> </td> </tr> <tr> <th> <font color=#ee8800>水晶弓</font> </th> <td> <center><font color=#56db9b>催眠彈</font></center> </td> <td> <center><font color=#60CFEA></font></center> </td> </tr> </table> </td> </tr> </table> <!-- --> ## 觸發 #### 角色 - 角色說話 <!-- --> ## 檢查 #### 技能 - 角色技能狀態 - 手持武器技能 #### 角色 - 角色狀態附加 - 角色面向某物 - 角色燃燒狀態 #### 地圖 - 可行走座標 #### 存讀 - 儲存變數 <!-- --> ## 動作 - 筆記 #### 角色 - 設定陣營暱稱 - 新增角色 - 角色漂浮能力 - 切換預設武器 - 切換至另一手 - 裝填武器彈藥 - 設定角色演員 - 移動角色位置 - 設定角色大小 - 角色可否攻擊 - 角色死亡訊息 - 人物停止說話 - 角色特殊屬性 - 取得玩家陣營演員角色 - 角色醉酒管理 - 角色反彈子彈 - 放下旗幟 #### 技能 - 角色使用技能 - 角色結束技能 - 限制使用技能 - 設定武器技能 #### 任務流程 - 跳出系統訊息 - 更多遊戲規則 - 背包道具設定 - 角色對己說話 #### 存讀 - 工作階段儲存空間數據庫存取 - 以符號分離字串 - 定義Json變數 - 轉換Json為字串 - 轉換Json為物件 #### 特效 - 聖靈治療特效 - 白鳥拳 - 角色燃燒狀態 - 應用攻擊特效 - 震地特效 - 吸血血刃特效 - 劍氣光彈 - 新增地圖痕跡 - 散發冰氣特效 - 發射火箭 - 快跳文字 - 散發光環特效 - 衝擊波 - 新增地圖動畫 - 擊退人物 - 光印 #### 武器道具 - 新增任務道具 - 新增武器道具 - 人物裝備道具 - 人物裝備武器 - 移除武器道具 #### 地圖 - 隨機可行走座標 #### 隨機 - 隨機設定陣營 - 隨機角色演員 - 隨機使用技能 - 隨機物件代碼 #### 陣營 - 新增陣營 #### 地圖機關 - 控制燭火機關
# TwilightWarsLib A Top-down view shooting game framework. ## Getting Started These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. To start a .event ```typescript CG.TwilightWarsLib.initialize() .then(() => { CG.TwilightWarsLib.events.startEvents('test/test.events', 'arena'); }) ``` To manually setup the game: ```typescript CG.TwilightWarsLib.initialize() .then(() => let mapSource = 'test/test.twmap'; CG.Base.resourceManager.addAppSource(mapSource); CG.Base.resourceManager.load(() => { let mapResource = new CG.TWMap.resources.MapResource(); mapResource.importBase64(CG.Base.resourceManager.getText(mapSource)); mapResource.loadTextures(() => { CG.Base.pixi.initialize(600, 500); let game = new CG.TwilightWarsLib.games.Game(); CG.Base.pixi.root.addChild(game); game.initResources(mapResource); game.start(); console.log('tw game created'); let me = new CG.TwilightWarsLib.games.actors.Actor(game, 'me'); game.addActor(me, new MyActorController(me), 32, 100, 0, null); game.gameCamera.setFocus(me); game.interface.setMe(me); let ai = new CG.TwilightWarsLib.games.actors.Actor(game, 'ai'); ai.camp = CG.TwilightWarsLib.games.datas.Camp.CAMP2; ai.actorClip.headClip.clip.gotoAndStop(5); game.addActor(ai, new CG.TwilightWarsLib.games.actors.controllers.AIController(ai), 160, 300, 0, null); game.createStuff(null, 64 + 16, 128 + 16, CG.TwilightWarsLib.games.items.StuffInfo.getByCode('sword'), game.stuffManager.useNextStuffId(), true); }); }); }) ``` ## Versioning We use [SemVer](http://semver.org/) for versioning. ## Authors * **[Haskasu](/profile/Haskasu)** ## Acknowledgments * Hat tip to anyone who's code was used * Inspiration * etc
# 視覺小說引擎(VisualNovelEngine) 本專案主要是用來製作視覺小說用的。 目前主要把最基本的場景、對話框、人物立繪、選項完成了,剩下的就是各種特效了,還有最麻煩的存檔系統。 相關文章: **[【教學】在網頁上做一個視覺小說遊戲](https://home.gamer.com.tw/artwork.php?sn=5866046)**、**[什麼!在網頁上也可以寫視覺小說?](https://ithelp.ithome.com.tw/articles/10337454)** 想要更進一步討論關於此模組的人,可以加入 **[Discord - 嘎姆討論區](https://discord.gg/hZKQzRfPJM)** ,這是我個人自行創建的非官方 Discord 伺服器。 或是我的 Discord 使用者名稱(Username)為:`cook1470`,若不想加入群組的人,也可以直接加我 DC 喔! <font color=red>**本模組仍處於測試、開發階段,如有任何 BUG、功能不完善等問題,歡迎於討論區提出、回報,或是直接 Discord 找我也可以!**</font> <font color=red>**This module is still in the testing and development phase. If there are any bugs, incomplete features, or other issues, feel free to report them on the forum or contact me directly on Discord!**</font> ## 成品遊戲列表 - **[小又生日活動【異世界大冒險】](https://a2569.gamelet.online/)** - **[God](https://godblesses.gamelet.online/)** ## 作者 **[酷可](/profile/64897095@github)([youtube](https://www.youtube.com/channel/UCe4mAxtv7eWFU2FDp6bMVVg)、[twitter](https://twitter.com/dg4C2qfzv9XTyXx/media))** # 素材網站推薦 ## 背景圖 **[みんちりえ](https://min-chi.material.jp/)** ## 角色立繪 **[わたおきば](https://wataokiba.net/)** ## 背景音樂 **[フリー音楽素材 H/MIX GALLERY](http://www.hmix.net/)** **[魔王魂](https://maou.audio/)**
# TwilightWarsEventsExp 本專案為光暈戰記的擴充模組,主要是建立在 **[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)** ### **[More modes](/profile/64897095@github)**
# CgEventsExp 本模組用於 CG 編輯器的擴充。 可至專案內 **Test** 資料夾,查看各動作、檢查的範例。 ### 動作 - 更新 - 顯示 - 更新文字 - 更新顯示物件 - 更新畫面遮罩 - 攝影機 - 設置攝影機焦點 - 系統 - 控制台輸出 - 儲存Cookies - 讀取Cookies - 開啟URL - 取得日期 - 輸出檔案 - 上傳檔案 - 設置 Debug 控制台 - 呼叫函數 - 彈出視窗 - 彈出確認視窗 - 彈出選項視窗 - 彈出輸入視窗 - 彈出複製字串視窗 - 彈出載入視窗 - 關閉彈出視窗 - 彈出複數字串輸入視窗 - PIXI 視窗 - 顯示自訂義 PIXI 視窗 - 關閉自訂義 PIXI 視窗 - 背包視窗 - 顯示背包視窗 - 更新背包視窗 - 變數 - 儲存區域變數 - 儲存全域變數 - 複數儲存區域變數 - 複數儲存全域變數 - 複數儲存物件變數 - 儲存 Json 變數 - 補間動畫 - 數學 - 計算兩點距離 - 函數 - Array.splice() - Array.slice() - Array.concat() - JSON.stringify() - JSON.parse() - Object.keys() - Window.btoa() - Window.atob() - String.split() - 音效 - 加載 URL 音訊 - 播放 URL 音效 - 設置 URL 音樂 - 音效濾鏡 - 播放音效 - 特效 - 文字特效 - 逐字動畫 - 文字捲動動畫 - 滾動文字特效 - 特殊工具 - 背包 - 設置背包 - 設置物品 - 設置背包物品 - 取得背包資料 - 整理背包 - 伺服器 - 狀態 - 儲存玩家狀態 - 取得玩家狀態 - 儲存玩家狀態 - 使用者名稱 - 取得玩家狀態 - 使用者名稱 - 分數 - 取得分數 - 上傳分數 - 使用者 - 取得使用者 - 道具 - 隱藏我的背包 - 事件 - 觸發事件 - 權重觸發事件 - 移除 - 移除物件 - 移除全域變數 - Base - 資源管理器 - 取得文字 - 取得 JSON - 隨機數產生器 - 設置隨機數產生器 - 使用隨機數產生器 - 柏林噪聲 - 設置柏林噪聲 - 使用一維柏林噪聲 - 使用二維柏林噪聲 - 使用三維柏林噪聲 ### 觸發 - 彈出視窗 - 視窗確認 - 視窗關閉 - PIXI 視窗 - 按下 PIXI 自訂義視窗 - 背包視窗 - 背包視窗選擇 ### 檢查 - 虛擬工具 - 背包 - 檢查背包 - 迴圈 - For Index - For...in - 變數 - 檢查物件函數結果 - 檢查物件屬性數量 ## 作者 **[cook1470](/profile/cook1470)** ### **[More modes](/profile/64897095@github)** # CgEventsExp The engine of CgEvents. You can go to the Test folder in the project to view examples of actions and inspections. ### Actions - Update - Display - Update Text - Update Display - Update Root Mask - Camera - Camera Set Focus - System - Console - Set Cookies - Get Cookies - Open Url - Get Date - Export File - Upload File - Set Debug Console - Call Function - Dialogs - Show Confirm Dialog - Show Select Dialog - Show Input Dialog - Show Copy String Dialog - Show Loading Dialog - Close Dialog - Show Inputs Dialog - PIXI Dialog - Show Custom PIXI Dialog - Close Custom PIXI Dialog - Backpack Dialog - Show Backpack Dialog - Update Backpack Dialog - Variable - Set Local - Set Global - Set Local Array - Set Global Array - Set Object Array - Set Json - Tween - Math - Distance Formula - Functions - Array.splice() - Array.slice() - Array.concat() - JSON.stringify() - JSON.parse() - Object.Keys() - Window.btoa() - Window.atob() - String.split() - Sound - Load URL Sound - Play URL Sound - Set URL Music - Sound Filter - Play Sound - Effects - Text - Typing Animation - Text Scrolling Animation - Scrolling Text Effect - Special Tools - backpack - Set Backpack - Set Item - Bag Set Item - Get Backpack - Sort Backpack - Server - State - Set User State - Get User State - Set Username State - Get Username State - Scores - Get Score - Submit Score - User - Get User - Items - Hide Backpack - Event - Trigger Event - Weight Trigger Event - Remove - Remove Object - Remove Global Var - Base - Resource Manager - Get Text - Get JSON - Random Generator - Set Random Generator - Use Random Generator - Perlin Noise - Set Perlin Noise - Use 1D Perlin Noise - Use 2D Perlin Noise - Use 3D Perlin Noise ### Triggers - Dialogs - Dialog Confirm - Dialog Close - PIXI Dialog - PIXI Button Dialog Confirm - Backpack Dialog - Backpack Dialog Select ### Checks - Special Tools - backpack - Check Backpack - Loop - For Index - For...in - variable - Check Object Function Result - Check Object Properties Count
# 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)); // 創建好以後,可以使用 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)**
<center><strong> <font size=5> <font color=EA7869> # 光暈戰記武器素材擴充包(TwilightWarsWeaponsResource) </font> </font> </strong><br> <font color=7869EA> <strong> <font size=4> <font color=7869EA> # 本模組為光暈戰記同人陣添加多種武器外觀 </font> </font> </strong><br> <strong> <font size=4> <font color=EA7869> ## 手動新增自創武器教學 </font> </font> </strong><br> <font color=7869EA> 點開事件表(.events)的<strong>光暈戰記遊戲設定</strong> <br><br> ![](https://i.imgur.com/bnCBKkk.png) <br><br> 找到下方的<strong>自製近身武器</strong>與<strong>自製遠程武器</strong> <br><br> ![](https://i.imgur.com/Al86kNu.png) </font><br><br><br> <strong> <font size=4> <font color=EA7869> ## 預置武器修改教學 </font> </font> </strong><br> <font color=7869EA> <a href="cg://source/CG.TwilightWarsWeapons/Preset.events" class="mat-raised-button mat-primary">預置事件表</a> <br><br> 找到最左側<strong>檔案總管</strong>內,<strong>CG.TwilightWarsWeapons</strong> 之中的<strong>Preset.events</strong>,右鍵<strong>複製檔案</strong>,更新後就不會遺失改過的設定 <br><br> ![](https://i.imgur.com/svcKdMk.png) <br><br> 找到複製後的<strong>Preset_copy.events</strong>,接著就能依照自己的喜好修改預置武器 <br><br> ![](https://i.imgur.com/Cuu5mUp.png) <br><br> 改完之後,找到需要使用自創武器的事件表選擇<strong>設定</strong> <br><br> ![](https://i.imgur.com/JBQr85k.png) <br><br> 在<strong>預先載入</strong>的地方把剛剛的<strong>Preset_copy.events</strong>打勾,就可以使用裡面的武器了 <br><br> ![](https://i.imgur.com/cd1zJkg.png) <br><br> </font> <strong> <font size=5> <font color=EA7869> ## 作者 </font> </font> </strong> <strong> <font size=5> <font color=7869EA> 阝千翎 </font> </font> </strong> **[<img src="https://gamelet.online/clients/assets/v1/img/cg_logo.png" width="30px" /><a href="https://code.gamelet.com/profile/Chinatsu" target="_blank" style="color:#55BBFF;">CG](/profile/117336754650487480063@google)**</a> **[<img src="https://gamelet.online/clients/assets/v1/img/gamelet_icon.png" width="30px" /><a href="https://gamelet.online/user/117336754650487480063@google/board" target="_blank" style="color:#55BBFF;">嘎姆](https://gamelet.online/user/117336754650487480063@google/board)**</a> **[<img src="https://play-lh.googleusercontent.com/Qolm5gr9jnabjk-0z79srjYC1XPVExribNz5kbDmGJeEtmRlo0UQoQEIkKMHRyt5paw" width="30px" /><a href="https://www.youtube.com/channel/UCALDNiLyfHERP13-BG9xpFQ?sub_confirmation=1" target="_blank" style="color:#55BBFF;">YouTube](https://www.youtube.com/channel/UCALDNiLyfHERP13-BG9xpFQ?sub_confirmation=1)**</a> **[<img src="https://cdn-icons-png.flaticon.com/256/1384/1384065.png" width="30px" /><a href="https://twitter.com/V_chiurin" target="_blank" style="color:#55BBFF;">推特](https://twitter.com/V_chiurin)**</a> **[<img src="https://cdn.iconscout.com/icon/free/png-256/twitch-11-461838.png" width="30px" /><a href="https://www.twitch.tv/haokute39171765" target="_blank" style="color:#55BBFF;">Twitch](https://www.twitch.tv/haokute39171765)**</a> **[<img src="https://cdn-icons-png.flaticon.com/512/145/145802.png" width="30px" /><a href="https://www.facebook.com/profile.php?id=100041014581991" target="_blank" style="color:#55BBFF;">facebook](https://www.facebook.com/profile.php?id=100041014581991)**</a> </center> <meta http-equiv="refresh" content="0;url=https://youtu.be/I9iP_hCM7mU?si=PbEhnT0Xud1pvzRw">
# PIXI 文字輸入框(PixiTextInput) 基於 Mwni 的函式庫改編而來, 這個 PIXI.js 的模組提供了一種方便的方法來將文字輸入框添加到 PIXI.js 舞台上。輸入框本身是一個 HTML \<input\> 元素,根據 PIXI.DisplayObject 給定的變換位置放置在舞台上方。方框會在 PIXI 舞台上繪製。此外,您可以選擇在文字輸入框失去焦點時,選擇是否應該用 PIXI.Text 來替代 \<input\>。 ## 我的改動 1. 事先宣告 Class 的屬性變數,因為 TypeScript 在使用 `this` 賦值前,需要事先宣告屬性變數。 2. 將所有帶有 _ 前綴的屬性、函數,變成私有屬性(`private`)。 3. 修正了一個把 `_dom_visible` 誤寫成 `dom_visible` 的 BUG。 4. 添加了三個 `interface`,`TextInputOptions、TextInputStyle、TextBoxStyle`,並於部分輸入參數加上型別標註。 5. 刪除函數 `renderWebGL`、`renderCanvas`,這些函數用於支援 pixi v4,但此模組使用的 pixi 為 v5,因此不需要這些函數。 6. 讓 _surrogate.resolution 預設為 2。 7. 修正部分因 JavaScript 源碼,轉移到 TypeScript 後所出現的錯誤提示,如型別錯誤等。 ## 使用範例 ```typescript import pixi = CG.Base.pixi; import TextInput = CG.PixiTextInput.TextInput; function examples() { // 初始化 pixi 舞台 pixi.initialize(600, 500); // 建立文字輸入框 const input = new TextInput({ input: { fontSize: '25pt', padding: '14px', width: '500px', color: '#26272E' }, box: { fill: 0xE8E9F3, rounded: 16, stroke: { color: 0xCBCEE0, width: 4 } } }) input.position.set(pixi.stageWidth * 0.5, pixi.stageHeight * 0.5); // 調整輸入框的位置 input.pivot.set(input.width * 0.5, input.height * 0.5); // 調整輸入框的錨點 pixi.root.addChild(input); // 將文字框添加到舞台中 const input2 = new TextInput({ input: { fontSize: '20pt', padding: '14px', width: '400', color: '#26272E' }, box: { fill: 0xFFFFFF, rounded: 16, stroke: { color: 0x333333, width: 4 } } }) input2.position.set(pixi.stageWidth * 0.5, pixi.stageHeight * 0.75); input2.pivot.set(input.width * 0.5, input.height * 0.5); pixi.root.addChild(input2); } examples(); ``` ## 原始 MIT 許可證 ```txt MIT License Copyright (c) 2018 Mwni Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` ## Links and Resources - [pixi-text-input](https://github.com/Mwni/pixi-text-input) ## Authors **[cook1470](/profile/cook1470)**
# 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*
# 瓦片地圖引擎(TilemapEngine) 瓦片地圖,是由一格一格的方塊所組成,本模組提供了簡單的函示庫,可以快速的渲染出一個瓦片地圖。 ## 讓我們開始吧! 本模組結合了 CgEventsEngine(CG事件表引擎),提供一些簡單的事件表動作,若不寫程式的話,也可以進行一些基本的操作。 ### 如何開始? 一般專案在新建完成後,都一定會有一個叫做 app.ts 的檔案,寫程式的位置如下表示。 ```typescript export class App { constructor() { // 程式寫在這裡,例如: console.log("Hello CG.") } } export const APP = new App(); ``` ### 創建瓦片地圖 以下為創建瓦片地圖,並將其顯示到舞台中的程式範例。 ```typescript // 新增一個瓦片地圖的資源物件。 let mapResource = new TilemapResource(); // 新增地圖的圖片資源到資源物件中,並且等待瀏覽器加載完成。 mapResource.addTileset('TileMapEngine.image.FD_Free_Tiles') .loadTileset(() => { // 加載完後才會開始做這裡的事情。 // 初始化舞台大小。 CG.Base.pixi.initialize(600, 600); // 將地圖資源初始化一個空地圖,長寬為 10x10,瓦片大小為 48,圖層有 3 個。 mapResource.emptyMap(10, 10, 48, 3); // 把圖層 0 的所有瓦片換成瓦片集 0 中,第 3 個瓦片。 mapResource.setLayerAllTile(0, 0, 3); // 新增一個瓦片地圖,並使用剛剛的地圖資源。 let tilemap = new Tilemap(mapResource); // 將瓦片地圖放置到舞台中。 CG.Base.pixi.root.addChild(tilemap); }) ``` ### 匯出地圖資料 地圖資源的資料,可以使用函數來匯出 JSON,並且將其下載成檔案。 ```typescript // 將地圖資料匯出成 JSON,並轉換成文字字串。 let text = JSON.stringify(mapResource.exportJson()); // 使用 Base 的 HtmlUtil 來下載文字檔案, map.json 為檔案名稱。 CG.Base.utils.HtmlUtil.downloadText(text, 'map.json'); ``` ### 匯入地圖資料 除了生成空白地圖,也可使用檔案匯入地圖資料來生成以前儲存的地圖。 你需要先在專案上新增檔案(如 map.json),並將之前下載的檔案內容複製到該檔案內。 ```typescript let mapResource = new TilemapResource(); // 定義地圖資源路徑。 let mapSource = 'test/map.json'; // 使用 resourceManager 匯入專案資源,後方填入地圖資源路徑。 CG.Base.resourceManager.addAppSource(mapSource); mapResource.addTileset('TileMapEngine.image.FD_Free_Tiles') .loadTileset(() => { CG.Base.pixi.initialize(600, 600); // 使用 resourceManager 取得專案資源的 JSON,並將其匯入地圖資源中。 let json = CG.Base.resourceManager.getJSON(mapSource); mapResource.importJson(json); let tilemap = new Tilemap(mapResource); CG.Base.pixi.root.addChild(tilemap); }) ``` ### 編輯地圖屬性、材質 若要以程式對瓦片地圖進行編輯,可參考下列簡易的示範。 其餘更多函示詳細說明,皆有在函示上進行備註,可自行參閱。 ```typescript // 設定座標 (1,2) 的 height 屬性為 1 mapResource.setTileAttribute(1, 2, 'height', 1); // 讀取座標 (1,2) 的 height 屬性,儲存在 height 這個變數中。 let height = mapResource.getTileAttribute(1, 2, 'height'); // 於控制台輸出() 內的內容。 console.log("座標 (1,2) 的高度為 " + height); // 座標 (1,2) 的高度為 1 // 設定圖層 0 座標 (2,2) 的瓦片為,瓦片集 0 中的第 2 個瓦片。 mapResource.setLayerTile(0, 2, 2, 0, 2); tilemap.reRender(); // 重新渲染瓦片地圖。 ``` ## Authors **[module_cook1470](/profile/64897095@github)**
# 光暈戰記 RPG 事件表模組(TwilightWarsRPGEvents) 此專案為 **[TwilightWarsLib](/edit/TwilightWarsLib)** 的 RPG 功能擴充模組。 大量自訂義的資料型態,搭配少量光暈本身的功能,主要是為了省略在光暈製作一個 RPG 任務時,還要先用一堆事件來製作相關系統、功能的步驟,而誕生的模組。 本專案的所有功能,皆是建立在任務為開放式房間、可多人遊玩,且可跨事件表的前提下製作,也就是說整個專案共用同一個玩家資料,故如果要製作更多不同的 RPG 任務,請另建新的專案製作。 有任何問題或 BUG,歡迎於討論區提出、回報。 <font color=red>**安裝此模組後,事件表會增加一些變數保留字,請避免在宣告全域變數時,使用下列名稱:**</font> **itemInfo, questInfo, {玩家代碼}_quests, {玩家代碼}_inventories, {玩家代碼}_equipmentSlot, {玩家代碼}_datas** <font color=red>**本模組不具備任何界面顯示功能,如有需要可直接安裝 [TwilightWarsRPGGUIEvents](https://code.gamelet.com/edit/TwilightWarsRPGGUIEvents) 模組,提供些許的 GUI 樣式可供使用。**</font> # 主要功能介紹 - [存讀檔功能](#存讀檔功能) <font color=grey>*ps.自動存檔、本機存/讀檔*</font> - [任務系統](#任務系統) - [自訂道具](#自訂道具) - [背包/裝備欄](#背包/裝備欄) - [跨事件表傳送](#跨事件表傳送) ## 存讀檔功能 本專案所有會更動玩家資料的動作,在變更玩家資料後,皆會**自動將資料儲存到專案資料庫**中。 專案任務作者只需要在玩家進入戰場後,使用動作來讀取資料即可,原則上並不需要考慮存檔的問題。 若有需要,本模組也提供於本機存讀檔的功能,但不建議使用於多人遊戲中,且讓玩家可以於本機存讀檔,可能會增加玩家隨意更改資料的風險。 提供可自訂玩家資料的功能,可設定例如等級、經驗值、金錢、稱號等屬性,修改數值時會自動存檔,也可隨時使用變數讀取數值。 ```typescript // 假設儲存玩家的代碼為 instance {instance.code}_datas // 使用此變數名稱可以得到該玩家的所有自訂資料。 // 若無設定資料類別,於後方加上 .資料名稱 即可取得該自訂資料的數值,例如: {instance.code}_datas.level // 可以取得該玩家,自訂資料 level 的數值。 {instance.code}_datas.money // 可以取得該玩家,自訂資料 money 的數值。 // 若有設定資料類別,於後方加上 .資料類別.資料名稱 即可取得該自訂資料的數值,例如: {instance.code}_datas.profile.level // 可以取得該玩家,資料類別 profile,裡面 level 的數值。 {instance.code}_datas.profile.money // 可以取得該玩家,資料類別 profile,裡面 money 的數值。 ``` ## 任務系統 提供可以**儲存玩家任務狀態**的功能,每個任務皆需要有不同的任務代碼,而主要的任務狀態有「未接取」、「進行中」、「已完成」。 每個任務在玩家進行中的狀態時,皆還可以**設定任務的進度**,進度的數量沒有限制,且也可以自訂進度的名稱,以及隨時更改進度的值,例如在設定某個玩家的任務狀態為「進行中」的同時,可以設定該任務的進度有「探索:0」,每當玩家到指定的地點探索後,可以讓該任務的探索進度增加,或是為擊殺型的任務時,在玩家擊殺目標對象後,使擊殺進度增加,最後在嘗試回報任務的事件中,可以在檢查的部分加上「檢查任務進度」,來檢查該任務的進度是否達到目標,以執行回報任務後會觸發的動作。 由於任務進度的數量並沒有限制,所以專案作者也可以為某個任務同時設定多個進度,並檢查所有的進度都要完成時,任務才會完成。 如在初始化時有執行過動作**「設置系統變數」**,可使用變數讀取任務資訊,可以參考下列格式: ```json // 假設儲存任務資訊的變數名稱為 questInfo,它會儲存所有任務的預設資訊。※ 詳細請看動作「設置系統變數」 {questInfo.questCode} // 將 questCode 改為自訂的任務代碼,可以取得該任務的所有資料。 {questInfo.main_0.name} // 可以取得任務代碼為 main_0 的名稱。 {questInfo.main_0.description} // 可以取得任務代碼為 main_0 的描述。 {questInfo.main_0.category} // 可以取得任務代碼為 main_0 的類別。 {questInfo.main_0.datas} // 可以取得任務代碼為 main_0 的自訂屬性,於後方加上 .屬性名稱 即可取得該自訂屬性,例如: {questInfo.main_0.datas.returnActor} // 可以取得該任務中,自訂屬性 returnActor 的資料。 ``` 如需要在事件表中,使用變數讀取玩家任務資料,可以參考下列格式: ```json // 假設儲存玩家的代碼為 instance {instance.code}_quests // 使用此變數名稱可以得到該玩家的所有任務資料。 {instance.code}_quests.questCode // 將 questCode 改為自訂的任務代碼,可以取得玩家對於該任務的資料。 // 若是讀取該玩家未曾接取過的任務,則會得到 undefined,也無法讀取下列資料。 {instance.code}_quests.main_0.state // 取得該玩家任務代碼為 main_0 的任務狀態。(數字) // 0 - 未接取, 1 - 進行中, 2 - 已完成 {instance.code}_quests.main_0.progress // 取得該玩家任務代碼為 main_0 的當前進度資料。 // 預設為空物件 {},需使用動作「設置任務進度」設置進度後,才會有內容可以讀取。 {instance.code}_quests.main_0.progress.talk // 取得該玩家任務代碼為 main_0 的 talk 進度值。(數字) {instance.code}_quests.main_1.progress.kills // 取得該玩家任務代碼為 main_1 的 kills 進度值。(數字) ``` ## 自訂道具 提供可以**自定義道具**的動作,可設定道具的名稱、描述、最大堆疊數量、物品樣式,以及其他自訂屬性,例如傷害力、防禦力、恢復力、可否裝備等。 至於定義物品道具的部分,請專門開一個事件表,將所有定義物品道具的動作放在裡面,並在玩家進入專案時執行一次即可,不需要每個事件表都重新放置動作。 或是可以直接在專案的進入點,加上 new ItemInfo 來定義物品。 ```typescript /** * @param {string} code 物品代碼 * @param {string} maxStack 最高堆疊數量 * @param {string} name 物品名稱 * @param {string} description 物品描述 * @param {string} stuffCode 物品外觀道具代碼 * @param {object} datas 自訂物品屬性 * @param {string} alias 物品圖示的資源別名 * @param {string} linkage 資源的鏈接名稱 */ new ItemInfo(code: string, maxStack: number, name?: string, description?: string, stuffCode?: string, datas?: { [key: string]: number }, alias?: string, linkage?: string) // 例如以下,創建一個 apple,最高可堆疊 10 個,手持時的武器為拳頭,datas 包含了 health 為 10。 new ItemInfo('apple', 10, '蘋果', '香甜可口的水果,散發著一股淡淡的香味。', 'kongfu', datas: { 'health': 10 }); ``` 如在初始化時有執行過動作**「設置系統變數」**,可使用變數讀取物品資訊,可以參考下列格式: ```typescript // 假設儲存物品資訊的變數名稱為 itemInfo,它會儲存所有物品道具的預設資訊。※ 詳細請看動作「設置系統變數」 {itemInfo.itemCode} // 將 itemCode 改為自訂的物品代碼,可以取得該物品的所有資料。 {itemInfo.apple.name} // 可以取得物品代碼為 apple 的名稱。 {itemInfo.apple.description} // 可以取得物品代碼為 apple 的描述。 {itemInfo.apple.datas} // 可以取得物品代碼為 apple 的自訂屬性,於後方加上 .屬性名稱 即可取得該自訂屬性,例如: {itemInfo.apple.datas.health} // 可以取得該物品中,自訂屬性 health 的數值。 ``` ## 背包/裝備欄 提供以**陣列為架構的背包系統**,並且可以為每個玩家**設置多個不同的背包**,可用裝備不同種類的物品,或是其他用途。 每個背包都可以**設置容量**,來決定這個背包可以裝多少組物品,當給予玩家物品時,若該物品的數量超過最大堆疊數量,則無法在同一欄位填裝,會自動尋找空位放入,直到背包沒有容量,且沒有可以堆疊的物品為止,並且會回傳多餘的物品數量,讓專案作者自行決定多餘的物品要怎麼處裡,例如直接丟棄,或是詢問玩家是否要替換背包中的物品,又或者是新增一個暫存用的背包,當物品數量過多時會自動裝入等等。 除了給予物品以外,也可以移除物品,移除時可以決定要不要指定背包中的哪一格,或是不指定,直接移除背包中指定物品代碼的物品。 提供可以檢查玩家背包物品數量的功能,可用於檢查玩家是否持有指定物品,且數量是否有達到條件,除了指定物品代碼以外,也可以檢查該物品的屬性是否符合條件。 提供裝備欄系統,可以自訂玩家的裝備欄狀態,以及各部位的名稱,並且裝備上物品道具,並且提供檢查**「檢查裝備欄物品」**,可檢查玩家某個裝備欄的物品,是否符合條件,例如是否為背包上的某一物品,或是符合某些物品代碼、屬性等,也可以單純檢查該裝備欄是否存在物品道具。 裝備欄的資料是直接儲存於背包資料中,故讀取背包資料時,會自動建置裝備欄的資料。 另外也提供了簡易的整理背包功能,專案作者可以讓玩家自行使用,或是在背包物品改變時使用。 如需要在事件表中,使用變數讀取玩家背包資料,可以參考下列格式: ```typescript // 假設儲存玩家的代碼為 instance {instance.code}_inventories // 使用此變數名稱可以得到該玩家的所有背包資料。 {instance.code}_inventories.inventoryCode // 將 inventoryCode 改為自訂的背包代碼,可以取得該背包的所有資料。 {instance.code}_inventories.myBag.slots // 可以取得背包代碼為 myBag 的容量大小。 {instance.code}_inventories.myBag.items // 可以取得背包代碼為 myBag 的所有物品資料。 {instance.code}_inventories.myBag.items.index // 可以取得該背包中,第 index 格的所有資料,index 請改為數字。 // index 是從 0 開始計算,故第一格為 0,第二格為 1,依此類推。 {instance.code}_inventories.myBag.items.0.item // 可以取得該背包中,第 0 格的物品資料。 {instance.code}_inventories.myBag.items.0.quantity // 可以取得該背包中,第 0 格的物品數量。 {instance.code}_inventories.myBag.items.0.equipped // 可以取得該背包中,第 0 格物品是否被裝備。 {instance.code}_inventories.myBag.items.0.slot // 可以取得該背包中,第 0 格物品的裝備位置。 {instance.code}_inventories.myBag.items.0.item.name // 可以取得該背包中,第 0 格物品的名稱。 // 將 name 改成其他屬性可以取得其他資料,例如: // code - 物品代碼, maxStack - 最大堆疊數量, stuffCode - 物品外型代碼, description - 物品描述 {instance.code}_inventories.myBag.items.0.item.datas // 可以取得該背包中,第 0 格物品的自訂屬性資料,於後方加上 .屬性名稱 即可取得該自訂屬性,例如: {instance.code}_inventories.myBag.items.0.item.datas.damage // 可以取得該物品中,自訂屬性 damage 的數值。 ``` ```typescript // 假設儲存玩家的代碼為 instance {instance.code}_equipmentSlot // 使用此變數名稱可以得到該玩家的所有裝備欄資料。 {instance.code}_equipmentSlot.slotType // 將 slotType 改為自訂的欄位類型,可以取得該欄位的所有資料。 // 所有資料包含 item, quantity, equipped, slot {instance.code}_equipmentSlot.mainHand.item // 可以取得裝備欄中,裝備類型 mainHand 的物品資料。 // item 後面可讀取的資料,如同讀取背包內的物品資料一樣。 {instance.code}_equipmentSlot.mainHand.item.name // 可以取得裝備欄中,裝備類型 mainHand 的物品名稱,其他依此類推。 ``` ## 跨事件表傳送 提供簡單的跨事件表傳送功能,可以**將玩家傳送到指定事件表的指定座標**上,只要在需要傳送玩家時,執行動作「傳送玩家」並填入事件表路徑,以及傳送座標,並且在目標事件表初始化玩家時,執行動作「讀取玩家位置」即可。 儲存玩家位置,實際上是將該**玩家目前所在的事件表路徑以及座標儲存於資料庫**,也就是說事件表的位置、名稱,即是玩家所在的地點,請在一開始就確定好事件表的位置以及名稱,並不要於日後隨意更改,否則可能會導致玩家的位置資料損壞。 傳送玩家,實際上就是一個會先執行「儲存玩家位置」,然後讓玩家執行目標事件表的動作。 而讀取玩家位置,則是會先讀取玩家位於資料庫中的位置,並且判斷當下所在的事件表是否為資料所存的事件表,若不是的話,會自動將該玩家轉移到目標事件表,如果是的話,就會傳送玩家到資料所儲存的座標。 此功能可以用於讓每張地圖都有自己的事件表,並使玩家可以在這些地圖間進行傳送,而非如同以往需要繪製一張大地圖,並使用分割區域來達成不同區域的效果,跨事件表可以有效的降低遊戲的負擔。 ## 作者 **[module_cook1470](/profile/64897095@github)**
# MidiLib A simplified library to easily play midi music. ## Getting Started Minimum codes to get a midi to play. ```typescript async function examples() { // load the midi resource let player = await loadAndCreateMidiInstrumentPlayer("MidiLib.testmidi"); player.play(); } ``` Also support playSound() in Base library. ```typescript CG.Base.resourceManager.playSound("MidiLib.testmidi"); ``` Codes to get full control. ```typescript async function examples() { // load the midi resource await resourceManager.addAppResource("MidiLib.testmidi").load(); // create the player let player = createMidiInstrumentPlayer("MidiLib.testmidi"); // preload instruments, you can specify the default instrument // find the full list of instrument names in `instruments.ts` await player.preload({ defaultInstrument: "acoustic_grand_piano" }); // play the music player.play({ loop: true, startTick: 0, loopStartTick: 0, gain: 2, // volume tempoScale: 1.5, // tempo }); // control the music player.stop(); player.pause(); player.resume(); } ``` ## Player Events Player emits events for advanced controlling ### Track Events This event emits when a midi note is time to be played (or other meta data is dispatched.) ```typescript function catchTrackEvents(player: InstrumentPlayer) { player.on(MidiTrackEvent.TYPE, (event: MidiTrackEvent) => { let trackEvent = event.trackEvent; if(trackEvent.name == NoteOnEvent.NAME) { // check events/TrackEvent.ts for all TrackEvent names ... } }) } ``` ### EndOfFileEvent This event emits when the play head running to the end of all tracks. ```typescript function catchEndOfFileEvent(player: InstrumentPlayer) { player.on(EndOfFileEvent.TYPE, (event: EndOfFileEvent) => { ... }) } ``` ### ControlEvents This event emits when the player is being controled by calling control functions ```typescript function catchControlEvents(player: InstrumentPlayer) { // play() player.on(ControlEvent.TYPES.PLAY, (event: ControlEvent) => { // this happens when preloading completes after play() is called }) // stop() player.on(ControlEvent.TYPES.STOP, (event: ControlEvent) => { ... }) // pause() player.on(ControlEvent.TYPES.PAUSE, (event: ControlEvent) => { ... }) // resume() player.on(ControlEvent.TYPES.RESUME, (event: ControlEvent) => { ... }) } ```
# 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) { ... } } ```
ⒸCode.Gamelet.com | Privacy Policy | Terms of Service