C .
ODE
G
AMELET
# 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
# 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) ## 動作 - 角色 - 新增角色 - 角色說話 - 清除角色對話 - 角色持有金幣 - 取得角色屬性 - 角色發動攻擊 - 角色跳至定點 - 取得角色身體動畫 - 設定角色身體動畫 - 移動角色位置 - 角色重生位置 - 人物走至定點 - 人物面向 - 設定AI參數 - 範圍傷害/治療 - 角色設置彈匣 - 替換角色部件 - 跟隨人物 - 尋找前往目標 - 角色加減血 - 人物裝備武器 - 施展技能 - 取得擊殺數 - 角色切換主副手 - 集氣並施展技能 - 角色丟棄當前武器道具 - 角色賺取分數 - 替換角色身體動畫物件 - 組合角色 - 移除角色組合器 - 設置蛇組合器 - 行為 - 搖頭 - 閃現 - 控制器 - 大腦 - 設置 AI 腦中移動狀態 - AI 大腦觸發事件 - 任務流程 - 任務完成 - 任務失敗 - 遊戲繼續 - 遊戲暫停 - 略過事件按鈕 - 設定遊戲規則 - 特效 - 新增標題文字 - 移除特效 - @自訂動態特效 - 自訂動態特效說話 - 進度條特效 - 操控進度條 - 角色 - 角色濾鏡 - 眼冒金星特效 - @集氣特效 - 初始人物色調 - 外流生命值特效 - 影分身特效 - 角色頭特效 - 角色漂浮特效 - 靈魂震盪特效 - 技能 - 光彈特效 - 震地特效 - 衝擊波特效 - 設置角色燃燒 - 噴射火焰 - 黑龍 - 黑龍波 - 血爆特效 - 炸彈爆炸特效 - 地圖 - 視野縮放 - 爆炸特效 - 塵土飛楊特效 - 治療特效 - 散發光環特效 - 飛濺特效 - 爆炸痕跡特效 - @自訂地圖特效/貼圖 - 移除地圖特效/貼圖 - @自訂特效/貼圖濾鏡 - 新增地圖動畫 - 操控地圖動畫 - 隨機取得可行走座標 - 火焰燃燒特效 - 煙霧上升特效 - 煙火特效 - 地圖冰凍特效 - 基礎飛鳥特效 - 快跳文字特效 - 替身木樁特效 - 龍捲風特效 - 畫面 - 畫面遮色 - 畫面濾鏡 - 下雨特效 - 打雷特效 - 目標提示特效 - 魄力標題動畫特效 - 武器道具 - 新增武器道具 - 新增可拾取道具 - 取得骰子點數 - 發射火箭 - 設定道具屬性 - 移除地板武器道具 - 修復盾牌 - 建立遠程武器資料 - 地圖 - 取得滑鼠相對位置 - 增加可走區域 - 新增地圖標示文字 - 移除地圖標示文字 - 新增地圖物件 - 移除地圖物件 - 新增地圖標示箭頭 - 取得地勢高度 - 取得隨機座標 - 路徑搜尋 - 地圖物件說話 - 設定地圖格子 - 設定臨時地圖格子 - 移除可走區域 - 地圖機關 - 新增燭火 - 新增拉桿開關 - 新增告示牌 - 新增可推石塊 - 新增淹水機關 - 操作拉桿開關 - 系統 - 離開遊戲 - 下一場遊戲 - 執行光暈事件表 - 音訊 - 播放光暈戰記音效 - 設置光暈戰記音樂 - 特殊工具 - 數據化地圖 - 新增數據化地圖核心 - 新增數據化地圖資料 - 移除數據化地圖資料 - 取得數據化地圖物件 - 更新數據化地圖區域大小 - 生成數據化地圖 - 儲存數據化地圖至 Cookies - 從 Cookies 讀取數據化地圖 - 角色錄製 - 開始錄製 - 停止錄製 - 開始播放 - 計算 - 計算角色位置 - 視窗 - 任務提示視窗 - 初始化任務提示視窗 - 設置任務提示格內容 ## 檢查 - 角色 - 角色位置 - 角色數值比較 - 人物面向 - 角色所在區域 - 說話內容 - 角色狀態 - 角色離開玩家視線 - 地圖 - 可行走座標 - 滑鼠位置 - 檢查地勢高度 - 可通過路徑 - 可通過路徑(路徑搜尋) - 找出所有座標 - 武器道具 - 骰子點數 - 特效 - 自訂動態特效位置 - 自訂動態特效所在區域 ## 觸發 - 角色 - 角色進入戰場 - 角色死亡 - 角色發動攻擊 - 角色受傷 - 角色座標改變 - 地圖機關 - 拉桿開關 - 告示牌按鈕 - 特效 - 自訂動態特效撞到障礙物 - 自訂動態特效碰到角色 - 自訂動態特效抵達目的地 - 自訂動態特效時間到 - 技能 - 黑龍消失 - 武器道具 - 拾取武器道具 - 掉落武器道具 - 骰子點數 ## 作者 **[cook1470](/profile/cook1470)** ### **[More modes](/profile/64897095@github)**
# 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*
# 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> 找到最左側<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>
# 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
# 瓦片地圖引擎(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) { ... } } ```
# 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)**
# TwilightWarsEventsNarrativeExp 光暈同人陣的事件擴充模組,本包目的旨在加強玩家敘事能力<br> 裡面也有塞一些我自製的 UI<br> <br> 要寫模組當天才開始自己摸C.G,在此之前從沒研究過原始碼,<br> 如果模組出什麼bug 不見得能馬上修好 (゚⊿゚ III) # 目前內容 ## 畫面演出擴充 ### 動作 - 彈出式書信:在畫面上跳出一張自訂內容的紙,可以選擇紙張種類(正常/破舊/染血),按鈕關閉,支援 HTML - 彈出式便條紙:在畫面上跳出一張自訂內容的便條,可以選擇紙張種類(正常/破舊/染血),按鈕關閉,支援 HTML - 腦內風暴:畫面將隨機出現大小不一的自訂詞彙,可以設定時間,時間到後清除 **【[→ 效果範例](https://i.imgur.com/JilxaaN.mp4)】** - 漫畫格突入:畫面右上角突入一個漫畫格,自訂跟蹤對象和持續時間,該人物即使不在玩家視野範圍內也能正常被觀測 **【[→ 效果範例](https://i.imgur.com/BfdFn6J.png)】** <br> ## 幽冥特製 UI! ### 動作 - 建立自訂進度環:快速建立一個自訂的進度環,包含自訂色系、自訂大小、自訂位置,可選擇是否顯示數值 **【[→ 效果範例](https://i.imgur.com/0hgJKy8.mp4)】** - 改變自訂進度環數值:可更新自訂進度環的進度(當前進度 +100 ~ -100) - 改變自訂進度環的位置:可調整自訂進度環在畫面上的位置 - 任務提示框美化&自訂顏色:修改光暈原生的任務提示 UI ,使提示框與輸入框平齊、按鈕填滿框框,可自訂色系 ### 檢查 - 比較自訂進度環的進度值(進度 vs 自訂值) **【[→ 效果範例](https://i.imgur.com/xlPYqOH.mp4)】** <br> <hr> <br> ### ※隨時失去價值的破玩意兒 - 衝擊波(可選迴避):單純是一個可以迴避友軍攻擊的衝擊波, 2023.7.19 的時候還沒辦法,等等小哈應該就修好了 2ㄏ2ㄏ ### ※研擬中 ... - 參戰演出:畫面出現以人物為焦點的動畫,可以自訂標題文字,該人物即使不在玩家攝影機範圍內也能正常被觀測 <br> ## 其他自製工具 - **[Pixi.JS Quick Graphics 圖形快速設計工具](https://determinationlove.github.io/PixiJS-Quick-Graphics/)  【[→ 操作範例](https://i.imgur.com/11049gN.mp4)】** ## 作者 **[DeLove(燐火幽冥)](/profile/103439374071744052100@google)**
# CgEventsLib The engine of CgEvents. CgEvents is a great way to build your own games with with a CG.built-in editor. ## Live Demo <a href="cg://source/test/physics.events" class="mat-raised-button mat-primary">Open Demo Events Sheet</a> ## Concept The engine takes a *.events file to run. The .events file is an encoded json which contains a config field and a events field. ```json { config: { stage: { width: "number", height: "number", resolutionPolicy: "showAll" | "exactFit" | "fixedWidth" | "fixedHeight" | "origin", alignHorizontal: "left" | "center" | "right", alignVertical: "top" | "middle" | "bottom" } }, events: [ { id: "string", triggers: [], checks: [], actions: [] }, ... ] } ``` Yon can edit the json with CG.built-in editor to control all your game events. ## How Events Work Each event contains a TRIGGER, some CHECKS, and some ACTION. The event flow works like this: 1. The TRIGGER of the event is triggered by the engine (keyboard pressed, event over, or maybe the hero collides with an enemy) 1. Once the trigger is triggered, the engine then goes check the CHECKS. 1. If all CHECKS pass, the engine executes all the ACTIONS in the event. ## Getting Started ```typescript let manager = new CgEventManager(); manager.importFromSource('CG.YourProject/yourGame.events') .then(() => manager.preload()) .then(() => manager.start()) ; ``` ## Versioning We use [SemVer](http://semver.org/) for versioning. ## Authors * **[Haskasu](/profile/Haskasu)**
ⒸCode.Gamelet.com | Privacy Policy | Terms of Service