mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-04-19 17:16:08 +08:00
feat: API文档
This commit is contained in:
parent
85031d3c39
commit
121fbe369d
@ -45,7 +45,296 @@ export default defineConfig({
|
||||
]
|
||||
}
|
||||
],
|
||||
'/api/': [{ text: 'API列表', items: [] }]
|
||||
'/api/': [
|
||||
{
|
||||
text: 'API列表',
|
||||
items: [
|
||||
{ text: '概览', link: '/api/' },
|
||||
{
|
||||
text: '系统 API',
|
||||
collapsed: true,
|
||||
items: [
|
||||
{
|
||||
text: 'Mota.require',
|
||||
link: '/api/system#require'
|
||||
},
|
||||
{
|
||||
text: 'Mota.requireAll',
|
||||
link: '/api/system#requireall'
|
||||
},
|
||||
{
|
||||
text: 'Mota.rewrite',
|
||||
link: '/api/system#rewrite'
|
||||
},
|
||||
{
|
||||
text: 'Mota.r',
|
||||
link: '/api/system#r'
|
||||
},
|
||||
{
|
||||
text: 'Mota.rf',
|
||||
link: '/api/system#rf'
|
||||
},
|
||||
{
|
||||
text: 'Mota.Plugin',
|
||||
link: '/api/system#plugin'
|
||||
},
|
||||
{
|
||||
text: 'Mota.Package',
|
||||
link: '/api/system#package'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
text: '类',
|
||||
collapsed: true,
|
||||
items: [
|
||||
{
|
||||
text: 'EventEmitter',
|
||||
link: '/api/class/event-emitter'
|
||||
},
|
||||
{
|
||||
text: 'IndexedEventEmitter',
|
||||
link: '/api/class/indexed-event-emitter'
|
||||
},
|
||||
{
|
||||
text: 'Disposable',
|
||||
link: '/api/class/disposable'
|
||||
},
|
||||
{
|
||||
text: 'GameStorage',
|
||||
link: '/api/class/game-storage'
|
||||
},
|
||||
{
|
||||
text: 'MotaSetting',
|
||||
link: '/api/class/mota-setting'
|
||||
},
|
||||
{
|
||||
text: 'SettingDisplayer',
|
||||
link: '/api/class/setting-displayer'
|
||||
},
|
||||
{
|
||||
text: 'Focus',
|
||||
link: '/api/class/focus'
|
||||
},
|
||||
{
|
||||
text: 'GameUi',
|
||||
link: '/api/class/game-ui'
|
||||
},
|
||||
{
|
||||
text: 'UiController',
|
||||
link: '/api/class/ui-controller'
|
||||
},
|
||||
{
|
||||
text: 'Hotkey',
|
||||
link: '/api/class/hotkey'
|
||||
},
|
||||
{
|
||||
text: 'Keyboard',
|
||||
link: '/api/class/keyboard'
|
||||
},
|
||||
{
|
||||
text: 'CustomToolbar',
|
||||
link: '/api/class/custom-toolbar'
|
||||
},
|
||||
{
|
||||
text: 'AudioPlayer',
|
||||
link: '/api/class/audio-player'
|
||||
},
|
||||
{
|
||||
text: 'SoundEffect',
|
||||
link: '/api/class/sound-effect'
|
||||
},
|
||||
{
|
||||
text: 'SoundController',
|
||||
link: '/api/class/sound-controller'
|
||||
},
|
||||
{
|
||||
text: 'BgmController',
|
||||
link: '/api/class/bgm-controller'
|
||||
},
|
||||
{
|
||||
text: 'ResourceController',
|
||||
link: '/api/class/resource-controller'
|
||||
},
|
||||
{
|
||||
text: 'MComponent',
|
||||
link: '/api/class/m-component'
|
||||
},
|
||||
{
|
||||
text: 'Range',
|
||||
link: '/api/class/range'
|
||||
},
|
||||
{
|
||||
text: 'EnemyCollection',
|
||||
link: '/api/class/enemy-collection'
|
||||
},
|
||||
{
|
||||
text: 'DamageEnemy',
|
||||
link: '/api/class/damage-enemy'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
text: '函数',
|
||||
collapsed: true,
|
||||
items: [
|
||||
{
|
||||
text: 'getHeroStatusOn',
|
||||
link: '/api/function#getherostatuson'
|
||||
},
|
||||
{
|
||||
text: 'getHeroStatusOf',
|
||||
link: '/api/function#getherostatusof'
|
||||
},
|
||||
{
|
||||
text: 'getEnemy',
|
||||
link: '/api/function#getenemy'
|
||||
},
|
||||
{
|
||||
text: 'm',
|
||||
link: '/api/function#m'
|
||||
},
|
||||
{
|
||||
text: 'unwrapBinary',
|
||||
link: '/api/function#unwrapbinary'
|
||||
},
|
||||
{
|
||||
text: 'checkAssist',
|
||||
link: '/api/function#checkassist'
|
||||
},
|
||||
{
|
||||
text: 'isAssist',
|
||||
link: '/api/function#isassist'
|
||||
},
|
||||
{
|
||||
text: 'generateKeyboardEvent',
|
||||
link: '/api/function#generatekeyboardevent'
|
||||
},
|
||||
{
|
||||
text: 'addAnimate',
|
||||
link: '/api/function#addanimate'
|
||||
},
|
||||
{
|
||||
text: 'removeAnimate',
|
||||
link: '/api/function#removeanimate'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
text: '变量',
|
||||
collapsed: true,
|
||||
items: [
|
||||
{
|
||||
text: 'loading',
|
||||
link: '/api/var#loading'
|
||||
},
|
||||
{
|
||||
text: 'hook',
|
||||
link: '/api/var#hook'
|
||||
},
|
||||
{
|
||||
text: 'gameListener',
|
||||
link: '/api/var#gamelistener'
|
||||
},
|
||||
{
|
||||
text: 'mainSetting',
|
||||
link: '/api/var#mainsetting'
|
||||
},
|
||||
{
|
||||
text: 'gameKey',
|
||||
link: '/api/var#gamekey'
|
||||
},
|
||||
{
|
||||
text: 'mainUi',
|
||||
link: '/api/var#mainui'
|
||||
},
|
||||
{
|
||||
text: 'fixedUi',
|
||||
link: '/api/var#fixedui'
|
||||
},
|
||||
{
|
||||
text: 'KeyCode',
|
||||
link: '/api/var#keycode'
|
||||
},
|
||||
{
|
||||
text: 'ScanCode',
|
||||
link: '/api/var#scancode'
|
||||
},
|
||||
{
|
||||
text: 'bgm',
|
||||
link: '/api/var#bgm'
|
||||
},
|
||||
{
|
||||
text: 'sound',
|
||||
link: '/api/var#sound'
|
||||
},
|
||||
{
|
||||
text: 'settingStorage',
|
||||
link: '/api/var#settingstorage'
|
||||
},
|
||||
{
|
||||
text: 'status',
|
||||
link: '/api/var#status'
|
||||
},
|
||||
{
|
||||
text: 'enemySpecials',
|
||||
link: '/api/var#enemyspecials'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
text: '模块',
|
||||
collapsed: true,
|
||||
items: [
|
||||
{
|
||||
text: 'CustomComponents',
|
||||
link: '/api/module/custom-components'
|
||||
},
|
||||
{
|
||||
text: 'Use',
|
||||
link: '/api/module/use'
|
||||
},
|
||||
{
|
||||
text: 'Mark',
|
||||
link: '/api/module/mark'
|
||||
},
|
||||
{
|
||||
text: 'KeyCodes',
|
||||
link: '/api/module/key-codes'
|
||||
},
|
||||
{
|
||||
text: 'UITools',
|
||||
link: '/api/module/ui-tools'
|
||||
},
|
||||
{
|
||||
text: 'Damage',
|
||||
link: '/api/module/damage'
|
||||
},
|
||||
{
|
||||
text: 'UI',
|
||||
link: '/api/module/ui'
|
||||
},
|
||||
{
|
||||
text: 'UIComponents',
|
||||
link: '/api/module/ui-components'
|
||||
},
|
||||
{
|
||||
text: 'MCGenerator',
|
||||
link: '/api/module/mc-generator'
|
||||
},
|
||||
{
|
||||
text: 'RenderUtils',
|
||||
link: '/api/module/render-utils'
|
||||
},
|
||||
{
|
||||
text: 'MiscComponents',
|
||||
link: '/api/module/misc-components'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
socialLinks: [
|
||||
|
170
docs/api/class/audio-player.md
Normal file
170
docs/api/class/audio-player.md
Normal file
@ -0,0 +1,170 @@
|
||||
# 类 AudioPlayer
|
||||
|
||||
渲染进程类,游戏进程不能直接使用,继承自 [`EventEmitter`](./event-emitter.md)
|
||||
|
||||
- 实例成员
|
||||
- [`index`](#index)
|
||||
- [`data`](#data)
|
||||
- [`buffer`](#buffer)
|
||||
- [`source`](#source)
|
||||
- [`baseNode`](#basenode)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`update`](#update)
|
||||
- [`getSource`](#getSource)
|
||||
- [`play`](#play)
|
||||
- [`ready`](#ready)
|
||||
- [`getDestination`](#getdestination)
|
||||
- 静态成员
|
||||
- [`ac`](#ac)
|
||||
- [`index`](#static-index)
|
||||
|
||||
## index
|
||||
|
||||
```ts
|
||||
declare var index: number
|
||||
```
|
||||
|
||||
## data
|
||||
|
||||
```ts
|
||||
declare var data: ArrayBuffer
|
||||
```
|
||||
|
||||
## buffer
|
||||
|
||||
```ts
|
||||
declare var buffer: AudioBuffer | null
|
||||
```
|
||||
|
||||
## source
|
||||
|
||||
```ts
|
||||
declare var source: AudioBufferSourceNode | undefined
|
||||
```
|
||||
|
||||
## baseNode
|
||||
|
||||
```ts
|
||||
declare var baseNode: BaseNode[]
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
包含了音频在播放时经过的每个音频处理路由的根节点,参考[自定义音频路由](../../guide/audio.md#自定义音频路由)
|
||||
|
||||
- 接口 `BaseNode`
|
||||
|
||||
```ts
|
||||
interface BaseNode {
|
||||
node: AudioNode;
|
||||
channel?: number;
|
||||
}
|
||||
```
|
||||
|
||||
- `node`: 路由节点
|
||||
- `channel`: 连接至的音频入口(input channel)
|
||||
|
||||
## constructor()
|
||||
|
||||
```ts
|
||||
interface AudioPlayer {
|
||||
new(data: ArrayBuffer): AudioPlayer
|
||||
}
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `data`: 音频的 `ArrayBuffer` 数据,一般是 xhr 请求的 response
|
||||
|
||||
## update()
|
||||
|
||||
```ts
|
||||
declare function update(data: ArrayBuffer): Promise<void>
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
更新音频的 `ArrayBuffer` 数据,并解析为 `AudioBuffer`,赋值给 [`buffer`](#buffer) 属性
|
||||
|
||||
## getSource()
|
||||
|
||||
```ts
|
||||
declare function getSource(): AudioBufferSourceNode
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
获取音频的源节点
|
||||
|
||||
## play()
|
||||
|
||||
```ts
|
||||
declare function play(when?: number, offset?: number, duration?: number): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `when`: 声音开始播放的时间,注意不是声音从哪开始播放。时间与 [`ac`](#ac) 共用一个时间轴,即在 `ac` 的何时播放这个音频,如果小于 `ac` 的 `currentTime`,那么会立刻开始播放,单位是秒
|
||||
- `offset`: 从声音的何时开始播放,例如填 5 就是从声音的第 5 秒开始播放
|
||||
- `duration`: 指定声音播放多长时间,单位为秒
|
||||
|
||||
## ready()
|
||||
|
||||
```ts
|
||||
declare function ready(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
准备音频路由,将源节点连接至各个音频路由根节点
|
||||
|
||||
## getDestination()
|
||||
|
||||
```ts
|
||||
declare function getDestination(): AudioDestinationNode
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
获取音频目的地节点
|
||||
|
||||
## ac
|
||||
|
||||
```ts
|
||||
declare var ac: AudioContext
|
||||
```
|
||||
|
||||
- 静态成员说明
|
||||
|
||||
音频处理上下文实例,所有的音频处理(bgm 除外)都是用它来实现的
|
||||
|
||||
## static index
|
||||
|
||||
```ts
|
||||
declare var index: number
|
||||
```
|
||||
|
||||
## play 事件
|
||||
|
||||
```ts
|
||||
interface AudioPlayerEvent {
|
||||
play: (node: AudioBufferSourceNode) => void
|
||||
}
|
||||
```
|
||||
|
||||
## update 事件
|
||||
|
||||
```ts
|
||||
interface AudioPlayerEvent {
|
||||
update: (audio: AudioBuffer) => void
|
||||
}
|
||||
```
|
||||
|
||||
## end 事件
|
||||
|
||||
```ts
|
||||
interface AudioPlayerEvent {
|
||||
end: (node: AudioBufferSourceNode) => void
|
||||
}
|
||||
```
|
259
docs/api/class/bgm-controller.md
Normal file
259
docs/api/class/bgm-controller.md
Normal file
@ -0,0 +1,259 @@
|
||||
# 类 BgmController
|
||||
|
||||
渲染进程类,游戏进程不能直接使用,继承自 [`ResourceController`](./resource-controller.md)
|
||||
|
||||
- 实例成员
|
||||
- [`stack`](#stack)
|
||||
- [`redoStack`](#redostack)
|
||||
- [`now`](#now)
|
||||
- [`transitionTime`](#transitiontime)
|
||||
- [`transitionCurve`](#transitioncurve)
|
||||
- [`volume`](#volume)
|
||||
- [`disable`](#disable)
|
||||
- [`playing`](#playing)
|
||||
- 实例方法
|
||||
- [`add`](#add)
|
||||
- [`load`](#load)
|
||||
- [`changeTo`](#changeto)
|
||||
- [`pause`](#pause)
|
||||
- [`resume`](#resume)
|
||||
- [`play`](#play)
|
||||
- [`undo`](#undo)
|
||||
- [`redo`](#redo)
|
||||
- [`setTransition`](#settransition)
|
||||
- [`get`](#get)
|
||||
- 实例事件
|
||||
- [`changeBgm`](#changebgm-事件)
|
||||
- [`pause`](#pause-事件)
|
||||
- [`resume`](#resume-事件)
|
||||
|
||||
## 部分接口说明
|
||||
|
||||
```ts
|
||||
interface BgmEmits {
|
||||
preventDefault: () => void
|
||||
}
|
||||
```
|
||||
|
||||
事件监听参数,用于阻止默认行为,例如切歌、暂停、继续
|
||||
|
||||
## stack
|
||||
|
||||
```ts
|
||||
declare var stack: string[]
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
播放栈,存储了之前播放的最多 10 个 bgm
|
||||
|
||||
## redoStack
|
||||
|
||||
```ts
|
||||
declare var redoStack: string[]
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
恢复栈,undo 操作之后会存入这里,从而可以被 redo
|
||||
|
||||
## now
|
||||
|
||||
```ts
|
||||
declare var now: string | undefined
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
当前正在播放的 bgm
|
||||
|
||||
## transitionTime
|
||||
|
||||
```ts
|
||||
declare var transitionTime: number
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
切歌或者暂停等操作的音乐渐变时长
|
||||
|
||||
## transitionCurve
|
||||
|
||||
```ts
|
||||
declare var transitionCurve: TimingFn
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
切歌或者暂停等操作的音乐音量渐变曲线
|
||||
|
||||
## volume
|
||||
|
||||
```ts
|
||||
declare var volume: number
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
当前的音乐音量
|
||||
|
||||
## disable
|
||||
|
||||
```ts
|
||||
declare var disable: boolean
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
是否关闭了音乐
|
||||
|
||||
## playing
|
||||
|
||||
```ts
|
||||
declare var playing: boolean
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
是否正在播放音乐
|
||||
|
||||
## add()
|
||||
|
||||
```ts
|
||||
declare function add(uri: string, data: HTMLAudioElement): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `id`: bgm 的`uri`,由于 bgm 是一类资源,因此`uri`为`bgms.xxx`的形式
|
||||
- `data`: bgm 音频元素
|
||||
|
||||
- 方法说明
|
||||
|
||||
添加一个音乐
|
||||
|
||||
## load()
|
||||
|
||||
```ts
|
||||
declare function load(id: string): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
预先加载一个音乐,从而在播放音乐的时候不会产生卡顿
|
||||
|
||||
## changeTo()
|
||||
|
||||
```ts
|
||||
declare function changeTo(id: string, when: number = -1, noStack: boolean = false): void
|
||||
```
|
||||
|
||||
- 参考[切换音乐](../../guide/audio.md#切换-bgm)
|
||||
|
||||
## pause()
|
||||
|
||||
```ts
|
||||
declare function pause(transition: boolean = true): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
暂停音乐播放,继续播放时将会延续暂停的时刻
|
||||
|
||||
## resume()
|
||||
|
||||
```ts
|
||||
declare function resume(transition: boolean = true): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
继续当前 bgm 的播放,从上一次暂停的时刻开始播放
|
||||
|
||||
## play()
|
||||
|
||||
```ts
|
||||
declare function play(id: string, when: number = 0, noStack: boolean = false): void
|
||||
```
|
||||
|
||||
- 参考[切换音乐](../../guide/audio.md#切换-bgm)
|
||||
|
||||
## undo()
|
||||
|
||||
```ts
|
||||
declare function undo(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
撤销当前播放,改为播放前一个 bgm
|
||||
|
||||
## redo()
|
||||
|
||||
```ts
|
||||
declare function redo(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
取消上一次的撤销,改为播放上一次撤销的 bgm
|
||||
|
||||
## setTransition()
|
||||
|
||||
```ts
|
||||
declare function setTransition(time?: number, curve?: TimingFn): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
修改切歌的渐变信息,参考[设置渐变参数](../../guide/audio.md#设置渐变参数)
|
||||
|
||||
## get()
|
||||
|
||||
```ts
|
||||
declare function get(id: string): HTMLAudioElement
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `id`: 音乐的名称,不是 uri
|
||||
|
||||
- 方法说明
|
||||
|
||||
根据音乐的名称获取到对应的音频元素
|
||||
|
||||
## changeBgm 事件
|
||||
|
||||
```ts
|
||||
interface BgmControllerEvent {
|
||||
changeBgm: (ev: BgmEmits, id: string, before: string) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当歌曲发生切换时触发,包括但不限于直接切歌、撤销、恢复。默认行为为切歌
|
||||
|
||||
## pause 事件
|
||||
|
||||
```ts
|
||||
interface BgmControllerEvent {
|
||||
pause: (ev: BgmEmits, id: string) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当音乐暂停时触发,默认行为为暂停
|
||||
|
||||
## resume 事件
|
||||
|
||||
```ts
|
||||
interface BgmControllerEvent {
|
||||
resume: (ev: BgmEmits, id: string) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当音乐继续播放时触发,默认行为为继续播放
|
492
docs/api/class/custom-toolbar.md
Normal file
492
docs/api/class/custom-toolbar.md
Normal file
@ -0,0 +1,492 @@
|
||||
# 类 CustomToolbar
|
||||
|
||||
渲染进程类,游戏进程不可直接使用,继承自 [`EventEmitter`](./event-emitter.md)
|
||||
|
||||
- 实例成员
|
||||
- [`items`](#items)
|
||||
- [`num`](#num)
|
||||
- [`id`](#id)
|
||||
- [`x`](#x)
|
||||
- [`y`](#y)
|
||||
- [`width`](#width)
|
||||
- [`height`](#height)
|
||||
- [`assistKey`](#assistkey)
|
||||
- [`showIds`](#showids)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`add`](#add)
|
||||
- [`delete`](#delete)
|
||||
- [`set`](#set)
|
||||
- [`emitTool`](#emittool)
|
||||
- [`refresh`](#refresh)
|
||||
- [`setPos`](#setpos)
|
||||
- [`setSize`](#setsize)
|
||||
- [`show`](#show)
|
||||
- [`close`](#close)
|
||||
- [`closeAll`](#closeall)
|
||||
- 静态成员
|
||||
- [`num`](#static-num)
|
||||
- [`list`](#list)
|
||||
- [`info`](#info)
|
||||
- 静态方法
|
||||
- [`get`](#get)
|
||||
- [`register`](#register)
|
||||
- [`save`](#save)
|
||||
- [`load`](#load)
|
||||
- [`showAll`](#showall)
|
||||
- [`closeAll`](#static-closeall)
|
||||
- 实例事件
|
||||
- [`add`](#add-事件)
|
||||
- [`delete`](#delete-事件)
|
||||
- [`set`](#set-事件)
|
||||
- [`emit`](#emit-事件)
|
||||
- [`posChange`](#poschange-事件)
|
||||
|
||||
## 使用案例
|
||||
|
||||
- 新增一个默认的自定义工具栏
|
||||
|
||||
```ts
|
||||
const { CustomToolbar } = Mota.requireAll('class');
|
||||
const { KeyCode } = Mota.requireAll('var');
|
||||
|
||||
const myBar = new CustomToolbar('myBar');
|
||||
mybar.x = 100;
|
||||
mybar.y = 100;
|
||||
mybar.width = 300;
|
||||
mybar.height = 70; // 高度,对于默认设置,自定义工具栏一行的高度为60,行高为10,因此设为70正好为一行
|
||||
// 添加你自己的自定义工具项,这里添加了一个M的快捷键
|
||||
mybar.add({ id: 'myTool', type: 'hotkey', key: KeyCode.KeyM, assist: 0 })
|
||||
```
|
||||
|
||||
## 部分接口与类型说明
|
||||
|
||||
```ts
|
||||
interface ToolbarItemBase {
|
||||
type: string
|
||||
id: string
|
||||
}
|
||||
```
|
||||
|
||||
自定义工具项的基础信息,每个自定义工具项必定包含,在此之外还可以自定义其他属性
|
||||
|
||||
- `type`: 自定义工具的类型
|
||||
- `id`: 自定义工具的 id
|
||||
|
||||
```ts
|
||||
interface CustomToolbarProps {
|
||||
item: ToolbarItemBase
|
||||
toolbar: CustomToolbar
|
||||
}
|
||||
```
|
||||
|
||||
自定义工具项的组件参数(props),对于编辑组件也是如此
|
||||
|
||||
- `item`: 当前的自定义工具项
|
||||
- `toolbar`: 自定义工具项所处的自定义工具栏实例
|
||||
|
||||
:::info 消歧义
|
||||
一般情况下,自定义工具栏指的是一整个自定义工具栏界面,自定义工具或者自定义工具项表示单个的自定义工具,例如是一个按键工具等,自定义工具栏里面包含若干个自定义工具项
|
||||
:::
|
||||
|
||||
```ts
|
||||
type ToolItemEmitFn = (
|
||||
this: CustomToolbar,
|
||||
id: string,
|
||||
item: ToolbarItemBase
|
||||
) => boolean;
|
||||
```
|
||||
|
||||
工具被触发时执行的触发函数
|
||||
|
||||
- `id`: 触发的工具的 id
|
||||
- `item`: 触发的自定义工具信息
|
||||
|
||||
## items
|
||||
|
||||
```ts
|
||||
declare var items: ToolbarItemBase[]
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
保存了这个自定义工具栏的所有自定义工具项
|
||||
|
||||
## num
|
||||
|
||||
```ts
|
||||
declare var num: number
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
这个自定义工具栏的唯一标识符
|
||||
|
||||
## id
|
||||
|
||||
```ts
|
||||
declare var id: string
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
表示这个自定义工具栏的 id
|
||||
|
||||
## x
|
||||
|
||||
```ts
|
||||
declare var x: number
|
||||
```
|
||||
|
||||
## y
|
||||
|
||||
```ts
|
||||
declare var y: number
|
||||
```
|
||||
|
||||
## width
|
||||
|
||||
```ts
|
||||
declare var width: number
|
||||
```
|
||||
|
||||
## height
|
||||
|
||||
```ts
|
||||
declare var height: number
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
以上四个成员描述了这个自定义工具栏所处的位置(相对页面左上角),以及长和宽
|
||||
|
||||
## assistKey
|
||||
|
||||
```ts
|
||||
declare var assistKey: number
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
表示了当前自定义工具栏的辅助按键信息
|
||||
|
||||
## showIds
|
||||
|
||||
```ts
|
||||
declare var showIds: number[]
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
描述了所有打开的基于本自定义工具栏的界面。由于一个自定义工具栏可以打开多个界面,因此使用一个数组进行存储所有打开的界面
|
||||
|
||||
## constructor()
|
||||
|
||||
```ts
|
||||
interface CustomToolbar {
|
||||
new(id: string): CustomToolbar
|
||||
}
|
||||
```
|
||||
|
||||
## add()
|
||||
|
||||
```ts
|
||||
declare function add(item: ToolbarItemBase): this
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
添加一个自定义工具项
|
||||
|
||||
## delete()
|
||||
|
||||
```ts
|
||||
declare function delete(id: string): this
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
删除一个自定义工具项
|
||||
|
||||
## set()
|
||||
|
||||
```ts
|
||||
declare function set(id: string, item: Partial<SettableItemData>): this
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `id`: 要设置的自定义工具项的 id
|
||||
- `item`: 设置信息,除了 `type` 和 `id` 设置不了外,其余均可设置
|
||||
|
||||
- 方法说明
|
||||
|
||||
设置一个自定义工具项的信息
|
||||
|
||||
## emitTool()
|
||||
|
||||
```ts
|
||||
declare function emitTool(id: string): this
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
触发一个自定义工具项
|
||||
|
||||
## refresh()
|
||||
|
||||
```ts
|
||||
declare function refresh(): this
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
强制刷新所有的自定义工具项的显示
|
||||
|
||||
## setPos()
|
||||
|
||||
```ts
|
||||
declare function setPos(x?: number, y?: number): void
|
||||
```
|
||||
|
||||
## setSize()
|
||||
|
||||
```ts
|
||||
declare function setSize(width?: number, height?: number): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
这两个方法用于设置这个自定义工具栏的位置和长宽
|
||||
|
||||
## show()
|
||||
|
||||
```ts
|
||||
declare function show(): number
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
基于这个自定义工具栏,显示出来其对应的界面,可以显示多个,内容互通
|
||||
|
||||
- 返回值
|
||||
|
||||
显示的界面的唯一标识符
|
||||
|
||||
## close()
|
||||
|
||||
```ts
|
||||
declare function close(id: number): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `id`: 要关闭的自定义工具栏界面的标识符
|
||||
|
||||
- 方法说明
|
||||
|
||||
关闭一个自定义工具栏界面
|
||||
|
||||
## closeAll()
|
||||
|
||||
```ts
|
||||
declare function closeAll(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
关闭这个自定义工具栏的所有显示
|
||||
|
||||
## static num
|
||||
|
||||
```ts
|
||||
declare var num: number
|
||||
```
|
||||
|
||||
- 静态成员说明
|
||||
|
||||
当前唯一标识符增长到了多少
|
||||
|
||||
## list
|
||||
|
||||
```ts
|
||||
declare var list: CustomToolbar[]
|
||||
```
|
||||
|
||||
- 静态成员说明
|
||||
|
||||
存储了当前所有的自定义工具栏实例
|
||||
|
||||
## info
|
||||
|
||||
```ts
|
||||
declare var info: Record<string, RegisteredCustomToolInfo>
|
||||
```
|
||||
|
||||
- 静态成员说明
|
||||
|
||||
存储了所有类型的自定义工具类型
|
||||
|
||||
- 接口 `RegisteredCustomToolInfo`
|
||||
|
||||
```ts
|
||||
interface RegisteredCustomToolInfo {
|
||||
name: string;
|
||||
onEmit: ToolItemEmitFn;
|
||||
show: CustomToolbarComponent;
|
||||
editor: CustomToolbarComponent;
|
||||
onCreate: (item: any) => ToolbarItemBase;
|
||||
}
|
||||
```
|
||||
|
||||
- `name`: 这个自定义工具类型的名称,例如快捷键、使用道具等
|
||||
- `onEmit`: 当这个自定义工具类型被触发时,执行的函数
|
||||
- `show`: 这个自定义工具类型显示在界面上的时候的显示组件
|
||||
- `editor`: 这个自定义工具类型在玩家编辑时,显示的组件,例如使用道具类型就是选择要使用的道具,也就是在系统设置里面的自定义工具栏中显示的编辑界面
|
||||
- `onCreate`: 当添加一个新的这个类型的自定义工具项时,执行的初始化函数,一般是把一些变量设为默认值,例如使用道具就是设置为使用怪物手册
|
||||
|
||||
- 系统自带自定义工具类型
|
||||
|
||||
- `hotkey`: 快捷键工具,默认按键为 `Unknown`,无辅助按键
|
||||
- `item`: 使用道具,默认使用的道具为怪物手册
|
||||
- `assistKey`: 开关辅助按键,可以开关 Ctrl 等辅助按键,然后触发快捷键工具时会附带辅助按键触发
|
||||
|
||||
## get()
|
||||
|
||||
```ts
|
||||
declare function get(id: string): CustomToolbar
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
根据自定义工具栏的 id 获取自定义工具栏实例
|
||||
|
||||
## register()
|
||||
|
||||
```ts
|
||||
declare function register(
|
||||
type: string,
|
||||
name: string,
|
||||
onEmit: ToolItemEmitFn,
|
||||
show: CustomToolbarComponent,
|
||||
editor: CustomToolbarComponent,
|
||||
onCreate: (item: any) => ToolbarItemBase
|
||||
)
|
||||
```
|
||||
|
||||
- 参数说明(参考[`info`](#info))
|
||||
|
||||
- `type`: 要注册的自定义工具类型
|
||||
- `name`: 该类型的中文名
|
||||
- `onEmit`: 当触发这个自定义工具的时候执行的函数
|
||||
- `show`: 这个自定义工具在自定义工具栏的显示组件
|
||||
- `editor`: 这个自定义工具在编辑时编辑组件
|
||||
- `onCreate`: 当这个自定义工具在编辑器中被添加时,执行的初始化脚本
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
注册一个自定义工具类型
|
||||
|
||||
- 示例
|
||||
|
||||
以下是样板中注册使用道具的工具类型的代码
|
||||
|
||||
```ts
|
||||
CustomToolbar.register(
|
||||
'item',
|
||||
'使用道具',
|
||||
function (id, item) {
|
||||
// 道具
|
||||
core.tryUseItem(item.item);
|
||||
return true;
|
||||
},
|
||||
COM.ItemTool,
|
||||
EDITOR.ItemTool,
|
||||
item => {
|
||||
return {
|
||||
item: 'book',
|
||||
...item
|
||||
};
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
## save()
|
||||
|
||||
```ts
|
||||
declare function save(): void
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
将目前的自定义工具栏状态存入本地存储
|
||||
|
||||
## load()
|
||||
|
||||
```ts
|
||||
declare function load(): void
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
从本地存储读取自定义工具栏状态
|
||||
|
||||
## showAll()
|
||||
|
||||
```ts
|
||||
declare function showAll(): void
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
把所有自定义工具栏都打开一个新的界面(如果是一打开的,会再打开一个)
|
||||
|
||||
## static closeAll()
|
||||
|
||||
```ts
|
||||
declare function closeAll(): void
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
关闭所有自定义工具栏的所有显示
|
||||
|
||||
## add 事件
|
||||
|
||||
```ts
|
||||
interface CustomToolbarEvent {
|
||||
add: (item: ToolbarItemBase) => void
|
||||
}
|
||||
```
|
||||
|
||||
## delete 事件
|
||||
|
||||
```ts
|
||||
interface CustomToolbarEvent {
|
||||
delete: (item: ToolbarItemBase) => void
|
||||
}
|
||||
```
|
||||
|
||||
## set 事件
|
||||
|
||||
```ts
|
||||
interface CustomToolbarEvent {
|
||||
set: (id: string, data: Partial<SettableItemData>) => void
|
||||
}
|
||||
```
|
||||
|
||||
## emit 事件
|
||||
|
||||
```ts
|
||||
interface CustomToolbarEvent {
|
||||
emit: (id: string, item: ValueOf<ToolbarItemMap>) => void
|
||||
}
|
||||
```
|
||||
|
||||
## posChange 事件
|
||||
|
||||
```ts
|
||||
interface CustomToolbarEvent {
|
||||
posChange: (bar: CustomToolbar) => void
|
||||
}
|
||||
```
|
286
docs/api/class/damage-enemy.md
Normal file
286
docs/api/class/damage-enemy.md
Normal file
@ -0,0 +1,286 @@
|
||||
# 类 DamageEnemy
|
||||
|
||||
游戏进程类,渲染进程也可以使用
|
||||
|
||||
- 实例成员
|
||||
- [`id`](#id)
|
||||
- [`x`](#x)
|
||||
- [`y`](#y)
|
||||
- [`floorId`](#floorid)
|
||||
- [`enemy`](#enemy)
|
||||
- [`col`](#col)
|
||||
- [`info`](#info)
|
||||
- [`providedHalo`](#providedhalo)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`reset`](#reset)
|
||||
- [`calAttribute`](#calattribute)
|
||||
- [`getRealInfo`](#getrealinfo)
|
||||
- [`getHaloSpecials`](#gethalospecials)
|
||||
- [`preProvideHalo`](#preprovidehalo)
|
||||
- [`provideHalo`](#providehalo)
|
||||
- [`injectHalo`](#injecthalo)
|
||||
- [`calDamage`](#caldamage)
|
||||
- [`calMapDamage`](#calmapdamage)
|
||||
- [`setMapDamage`](#setmapdamage)
|
||||
- [`calCritical`](#calcritical)
|
||||
- [`calDefDamage`](#caldefdamage)
|
||||
- [`getSeckillAtk`](#getseckillatk)
|
||||
|
||||
## id
|
||||
|
||||
```ts
|
||||
declare var id: string
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
怪物的 id
|
||||
|
||||
## x
|
||||
|
||||
```ts
|
||||
declare var x: number | undefined
|
||||
```
|
||||
|
||||
## y
|
||||
|
||||
```ts
|
||||
declare var y: number | undefined
|
||||
```
|
||||
|
||||
## floorId
|
||||
|
||||
```ts
|
||||
declare var floorId: string
|
||||
```
|
||||
|
||||
## enemy
|
||||
|
||||
```ts
|
||||
declare var enemy: Enemy
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
怪物的原始信息,即在造塔界面中填写的信息,不可修改
|
||||
|
||||
## col
|
||||
|
||||
```ts
|
||||
declare var col: EnemyCollection | undefined
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
该怪物所属的怪物集合,也可以是 `undefined`,表示不属于任何集合
|
||||
|
||||
## info
|
||||
|
||||
```ts
|
||||
declare var info: EnemyInfo
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
描述了这个怪物在计算真实属性后的属性,经过光环等加成
|
||||
|
||||
## providedHalo
|
||||
|
||||
```ts
|
||||
declare var providedHalo: Set<number>
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
存储了这个怪物所有已经施加过的光环
|
||||
|
||||
## constructor()
|
||||
|
||||
```ts
|
||||
interface DamageEnemy {
|
||||
new(
|
||||
enemy: Enemy,
|
||||
x?: number,
|
||||
y?: number,
|
||||
floorId?: string,
|
||||
col?: EnemyCollection
|
||||
): DamageEnemy
|
||||
}
|
||||
```
|
||||
|
||||
## reset()
|
||||
|
||||
```ts
|
||||
declare function reset(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
重设怪物信息,恢复至原始信息,计算怪物真实属性第零步
|
||||
|
||||
## calAttribute()
|
||||
|
||||
```ts
|
||||
declare function calAttribute(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
计算怪物在不计光环下的属性,在 inject 光环之前,预平衡光环之后执行,计算怪物属性第二步
|
||||
|
||||
## getRealInfo()
|
||||
|
||||
```ts
|
||||
declare function getRealInfo(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
计算怪物的真实属性,在 inject 光环后执行,计算怪物属性的第四步,也是最后一步
|
||||
|
||||
## getHaloSpecials()
|
||||
|
||||
```ts
|
||||
declare function getHaloSpecials(): number[]
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
获取到所有还未施加过的光环属性
|
||||
|
||||
## preProvideHalo()
|
||||
|
||||
```ts
|
||||
declare function preProvideHalo(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
光环预提供,用于平衡所有怪的光环属性,避免出现不同情况下光环效果不一致的现象,计算怪物属性的第一步
|
||||
|
||||
## provideHalo()
|
||||
|
||||
```ts
|
||||
declare function provideHalo(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
向其他怪物提供光环,计算怪物属性的第三步
|
||||
|
||||
## injectHalo()
|
||||
|
||||
```ts
|
||||
declare function injectHalo(halo: HaloFn, enemy: EnemyInfo): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
接受来自其他怪物的光环,参考[光环处理](../../guide/battle.md#光环处理)
|
||||
|
||||
## calDamage()
|
||||
|
||||
```ts
|
||||
declare function calDamage(hero: Partial<HeroStatus> = core.status.hero): { damage: number }
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `hero`: 允许部分指定勇士信息,从而达到不修改勇士属性的情况下传入不同勇士信息的效果
|
||||
|
||||
- 方法说明
|
||||
|
||||
计算怪物伤害
|
||||
|
||||
## calMapDamage()
|
||||
|
||||
```ts
|
||||
declare function calMapDamage(
|
||||
damage: Record<string, MapDamage> = {},
|
||||
hero: Partial<HeroStatus> = getHeroStatusOn(Damage.realStatus)
|
||||
): Record<string, MapDamage>
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `damage`: 地图伤害存入的对象
|
||||
- `hero`: 部分指定勇士的真实属性,即经过 buff 等加成的属性
|
||||
|
||||
- 方法说明
|
||||
|
||||
计算地图伤害
|
||||
|
||||
## setMapDamage()
|
||||
|
||||
```ts
|
||||
declare function setMapDamage(
|
||||
damage: Record<string, MapDamage>,
|
||||
loc: string,
|
||||
dam: number,
|
||||
type?: string
|
||||
): void
|
||||
```
|
||||
|
||||
## calCritical()
|
||||
|
||||
```ts
|
||||
declare function calCritical(
|
||||
num: number = 1,
|
||||
hero: Partial<HeroStatus> = core.status.hero
|
||||
): CriticalDamageDelta[]
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `num`: 计算前多少个临界
|
||||
|
||||
- 方法说明
|
||||
|
||||
计算怪物的临界,使用二分法
|
||||
|
||||
- 接口 `CriticalDamageDelta`
|
||||
|
||||
```ts
|
||||
interface CriticalDamageDelta {
|
||||
/** 跟最小伤害值的减伤 */
|
||||
delta: number;
|
||||
damage: number;
|
||||
info: { damage: number };
|
||||
/** 勇士的攻击增量 */
|
||||
atkDelta: number;
|
||||
}
|
||||
```
|
||||
|
||||
- `damage`: 伤害大小
|
||||
|
||||
## calDefDamage()
|
||||
|
||||
```ts
|
||||
declare function calDefDamage(
|
||||
num: number = 1,
|
||||
hero: Partial<HeroStatus> = core.status.hero
|
||||
): DamageDelta
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `num`: 要加多少防御
|
||||
|
||||
- 方法说明
|
||||
|
||||
计算 n 防减伤
|
||||
|
||||
- 接口 `DamageDelta`
|
||||
|
||||
为接口 [`CriticalDamageDelta`](#calcritical) 去掉 `atkDelta` 属性
|
||||
|
||||
## getSeckillAtk()
|
||||
|
||||
```ts
|
||||
declare function getSeckillAtk(): number
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
计算在一回合内击杀怪物所需要的攻击力,用于临界计算
|
135
docs/api/class/disposable.md
Normal file
135
docs/api/class/disposable.md
Normal file
@ -0,0 +1,135 @@
|
||||
# 类 Disposable
|
||||
|
||||
渲染进程、游戏进程通用类,继承自 [`EventEmitter`](./event-emitter.md)
|
||||
|
||||
- 实例成员
|
||||
- [`protected _data`](#protected-_data)
|
||||
- [`protected activated`](#protected-activated)
|
||||
- [`protected destroyed`](#protected-destroyed)
|
||||
- [`set get data`](#set-get-data)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`active`](#active)
|
||||
- [`dispose`](#dispose)
|
||||
- [`destroy`](#destroy)
|
||||
- 实例事件
|
||||
- [`active`](#active-事件)
|
||||
- [`dispose`](#dispose-事件)
|
||||
- [`destroy`](#destroy-事件)
|
||||
|
||||
## protected \_data
|
||||
|
||||
```ts
|
||||
declare var _data: any | undefined
|
||||
```
|
||||
|
||||
## protected activated
|
||||
|
||||
```ts
|
||||
declare var activated: boolean
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
表示该变量是否被激活
|
||||
|
||||
## protected destroyed
|
||||
|
||||
```ts
|
||||
declare var destroyed: boolean
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
表示该变量是否已经被摧毁,摧毁后不可再调用
|
||||
|
||||
## set get data
|
||||
|
||||
```ts
|
||||
interface Disposable {
|
||||
set data(value: any | null): void
|
||||
get data(): any | null
|
||||
}
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
用于设置和获取变量的值,被摧毁后不可设置或者获取,被失效后可以设置,但获取会返回 `null`
|
||||
|
||||
## constructor()
|
||||
|
||||
```ts
|
||||
interface Disposable {
|
||||
new(data: any): Disposable
|
||||
}
|
||||
```
|
||||
|
||||
- 构造器说明
|
||||
|
||||
传入数据,返回 `Disposable` 实例,构造后变量处于失效状态
|
||||
|
||||
## active()
|
||||
|
||||
```ts
|
||||
declare function active(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
激活变量
|
||||
|
||||
## dispose()
|
||||
|
||||
```ts
|
||||
declare function dispose(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
使变量失效,失效后获取变量会返回 `null`
|
||||
|
||||
## destroy()
|
||||
|
||||
```ts
|
||||
declare function destroy(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
摧毁变量,摧毁后不可设置或获取变量
|
||||
|
||||
## active 事件
|
||||
|
||||
```ts
|
||||
interface DisposableEvent {
|
||||
active: (value: any) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当变量被激活时触发,参数表示变量的值
|
||||
|
||||
## dispose 事件
|
||||
|
||||
```ts
|
||||
interface DisposableEvent {
|
||||
dispose: (value: any) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当变量失效时触发,参数表示变量的值
|
||||
|
||||
## destroy 事件
|
||||
|
||||
```ts
|
||||
interface DisposableEvent {
|
||||
destroy: () => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当变量被摧毁时触发
|
163
docs/api/class/enemy-collection.md
Normal file
163
docs/api/class/enemy-collection.md
Normal file
@ -0,0 +1,163 @@
|
||||
# 类 EnemyCollection
|
||||
|
||||
游戏进程类,渲染进程也可以使用
|
||||
|
||||
- 实例成员
|
||||
- [`floorId`](#floorid)
|
||||
- [`list`](#list)
|
||||
- [`range`](#range)
|
||||
- [`mapDamage`](#mapdamage)
|
||||
- [`haloList`](#halolist)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`get`](#get)
|
||||
- [`extract`](#extract)
|
||||
- [`calRealAttribute`](#calrealattribute)
|
||||
- [`calMapDamage`](#calmapdamage)
|
||||
- [`applyHalo`](#applyhalo)
|
||||
- [`preBalanceHalo`](#prebalancehalo)
|
||||
- [`render`](#render)
|
||||
|
||||
## floorId
|
||||
|
||||
```ts
|
||||
declare var floorId: string
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
怪物集合所属楼层
|
||||
|
||||
## list
|
||||
|
||||
```ts
|
||||
declare var list: DamageEnemy[]
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
这个怪物集合中所有的怪物
|
||||
|
||||
## mapDamage
|
||||
|
||||
```ts
|
||||
declare var mapDamage: Record<LocString, MapDamage>
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
存储了当前楼层的所有地图伤害,键为位置,格式为 `x,y`,值为这一点的伤害信息
|
||||
|
||||
- 接口 `MapDamage`
|
||||
|
||||
```ts
|
||||
interface MapDamage {
|
||||
damage: number;
|
||||
type: Set<string>;
|
||||
repulse?: LocArr[];
|
||||
ambush?: DamageEnemy[];
|
||||
}
|
||||
```
|
||||
|
||||
- `damage`: 这一点的伤害值
|
||||
- `type`: 这一点的伤害类型集合,例如阻击夹击伤害等
|
||||
- `repulse`: 阻击信息
|
||||
- `ambush`: 捕捉信息
|
||||
|
||||
## haloList
|
||||
|
||||
```ts
|
||||
declare var haloList: HaloData[]
|
||||
```
|
||||
|
||||
## constructor()
|
||||
|
||||
```ts
|
||||
interface EnemyCollection {
|
||||
new(floorId: string): EnemyCollection
|
||||
}
|
||||
```
|
||||
|
||||
## get()
|
||||
|
||||
```ts
|
||||
declare function get(x: number, y: number): DamageEnemy | undefined
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
获取指定位置的怪物实例,不存在则返回 `undefined`
|
||||
|
||||
## extract()
|
||||
|
||||
```ts
|
||||
declare function extract(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
解析当前地图的怪物信息,将每个怪物都生成一个 [`DamageEnemy`](./damage-enemy.md) 实例,并添加到 [`list`](#list) 中
|
||||
|
||||
## calRealAttribute()
|
||||
|
||||
```ts
|
||||
declare function calRealAttribute(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
计算怪物的真实属性,即经过各种属性光环等加成后的属性
|
||||
|
||||
## calMapDamage()
|
||||
|
||||
```ts
|
||||
declare function calMapDamage(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
计算当前地图的地图伤害信息
|
||||
|
||||
## applyHalo()
|
||||
|
||||
```ts
|
||||
declare function applyHalo(
|
||||
type: string,
|
||||
data: any,
|
||||
enemy: DamageEnemy,
|
||||
halo: HaloFn | HaloFn[],
|
||||
recursion: boolean = false
|
||||
): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `type`: 光环范围类型,例如方形范围等
|
||||
- `data`: 范围参数,例如方形范围就要传入位置即边长
|
||||
- `enemy`: 施加光环的怪物
|
||||
- `halo`: 光环执行函数,用于给怪物增加属性,如果传入数组,那么每个都会执行
|
||||
- `recursion`: 对于一般光环,填 `false` 即可,对于可以加光环或者特殊属性的光环,需要填 `true`
|
||||
|
||||
- 方法说明
|
||||
|
||||
给同楼层的怪物施加光环
|
||||
|
||||
## preBalanceHalo()
|
||||
|
||||
```ts
|
||||
declare function preBalanceHalo(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
预平衡光环,用于处理可以加光环或者特殊属性的光环
|
||||
|
||||
## render()
|
||||
|
||||
```ts
|
||||
declare function render(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
渲染所有的伤害信息,包括地图伤害与临界
|
190
docs/api/class/event-emitter.md
Normal file
190
docs/api/class/event-emitter.md
Normal file
@ -0,0 +1,190 @@
|
||||
# 类 EventEmitter
|
||||
|
||||
渲染进程、游戏进程通用类
|
||||
|
||||
- 实例成员
|
||||
- [`protected events`](#protected-events)
|
||||
- [`protected emitter`](#protected-emitter)
|
||||
- 实例方法
|
||||
- [`on`](#on)
|
||||
- [`off`](#off)
|
||||
- [`once`](#once)
|
||||
- [`emit`](#emit)
|
||||
- [`setEmitter`](#setemitter)
|
||||
- [`removeAllListeners`](#removealllisteners)
|
||||
|
||||
## protected events
|
||||
|
||||
```ts
|
||||
declare var events: Record<string, Listener>
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
该成员描述了所有注册的被注册的监听事件,键表示事件名称,值表示监听信息
|
||||
|
||||
- `Lienster` 类型
|
||||
|
||||
该类型描述了一个监听事件,包含下列属性:
|
||||
|
||||
- `fn`: 监听函数
|
||||
- `once`: 是否配置为 `once` 模式,即触发一次后自动删除
|
||||
- `immediate`: 是否配置为 `immediate` 模式,即注册时立刻触发一次
|
||||
|
||||
## protected emitter
|
||||
|
||||
```ts
|
||||
declare var emitter: Record<string, EmitFn>
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
该成员描述了所有的自定义触发器,键表示事件名称,值表示触发器函数
|
||||
|
||||
- `EmitFn` 类型
|
||||
|
||||
该类型是一个函数
|
||||
|
||||
```ts
|
||||
type EmitFn = (event: string, ...params: any[]) => any
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `event`: 触发的事件类型
|
||||
- `params`: 传递给监听函数的参数
|
||||
|
||||
- 返回值:`emit` 方法的返回值是该函数的返回值组成的数组
|
||||
|
||||
## on()
|
||||
|
||||
```ts
|
||||
function on(
|
||||
event: string,
|
||||
fn: (...params: any) => any,
|
||||
options?: Partial<ListenerOptions>
|
||||
): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `event`: 要监听的事件
|
||||
- `fn`: 事件触发时执行的函数
|
||||
- `options`: 事件监听配置,配置内容包含:
|
||||
- `once`: 是否在触发一次后自动删除
|
||||
- `immediate`: 是否在监听时立刻触发一次,不传入任何参数
|
||||
|
||||
- 方法说明
|
||||
|
||||
该方法用于监听事件,当事件被触发时,所有的监听函数都会被执行一次,同时传入相应的参数。
|
||||
|
||||
- 示例
|
||||
|
||||
```js
|
||||
const { EventEmitter } = Mota.requireAll('class');
|
||||
|
||||
const myEmitter = new EventEmitter();
|
||||
myEmitter.on('event', () => console.log('event emitted!'));
|
||||
```
|
||||
|
||||
## off()
|
||||
|
||||
```ts
|
||||
function off(event: string, fn: (...params: any) => any): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `event`: 要取消监听的事件
|
||||
- `fn`: 要取消监听的函数,要求传入函数的引用
|
||||
|
||||
- 方法说明
|
||||
|
||||
该方法用于取消监听一个事件,传入想要取消监听的函数的引用即可
|
||||
|
||||
- 示例
|
||||
|
||||
```js
|
||||
const fn = () => console.log('event emitted!');
|
||||
|
||||
myEmitter.on('event', fn);
|
||||
myEmitter.off('event', fn); // 取消监听
|
||||
```
|
||||
|
||||
## once()
|
||||
|
||||
```ts
|
||||
function once(event: string, fn: (...params: any) => any): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
等价于 `on(event, fn, { once: true })`,传入的函数在触发一次后立刻删除
|
||||
|
||||
- 示例
|
||||
|
||||
```js
|
||||
myEmitter.once('event', () => console.log('only emit once!'));
|
||||
```
|
||||
|
||||
## emit()
|
||||
|
||||
```ts
|
||||
function emit(event: string, ...params: any[]): any[]
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `event`: 要触发的事件名称
|
||||
- `params`: 传递给事件的参数
|
||||
|
||||
- 返回值
|
||||
|
||||
所有触发的监听函数的返回值组成的数组
|
||||
|
||||
- 方法说明
|
||||
|
||||
用于触发一个类型的事件,执行某个事件所有监听器函数,并传入对应的参数
|
||||
|
||||
## setEmitter()
|
||||
|
||||
```ts
|
||||
function setEmitter(
|
||||
event: string,
|
||||
fn: (event: Listener[], ...params: any) => any
|
||||
): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `event`: 要设置触发器函数的事件
|
||||
- `fn`: 触发器函数,接受事件内容,以及 `emit` 函数传入的参数作为参数,返回任意类型的值,作为 `emit` 函数的返回值
|
||||
|
||||
- 方法说明
|
||||
|
||||
用于设置一个事件在触发时执行的函数,将返回值组成数组作为 `emit` 函数的返回值
|
||||
|
||||
- 示例
|
||||
|
||||
以下是一个监听函数的返回值是 `Promise`,同时对其解包的示例
|
||||
|
||||
```js
|
||||
myEmitter.setEmitter('event', async (event, ...params) => {
|
||||
const res = await Promise.all(event.map(v => v.fn()));
|
||||
return res;
|
||||
});
|
||||
```
|
||||
|
||||
## removeAllListeners()
|
||||
|
||||
```ts
|
||||
function removeAllListeners(event?: string): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `event`: 填写时,表示移除指定事件的所有监听器,不填时,表示移除所有事件的所有监听器
|
||||
|
||||
- 方法说明
|
||||
|
||||
该方法用于移除一个事件或者所有事件的所有监听器
|
189
docs/api/class/focus.md
Normal file
189
docs/api/class/focus.md
Normal file
@ -0,0 +1,189 @@
|
||||
# 类 Focus
|
||||
|
||||
渲染进程类,在游戏进程中不可直接使用,继承自 [`EventEmitter`](./event-emitter.md)
|
||||
|
||||
- 实例属性
|
||||
- [`stack`](#stack)
|
||||
- [`focused`](#focused)
|
||||
- [`readonly equal`](#readonly-equal)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`focus`](#focus)
|
||||
- [`unfocus`](#unfocus)
|
||||
- [`add`](#add)
|
||||
- [`pop`](#pop)
|
||||
- [`splice`](#splice)
|
||||
- [`spliceIndex`](#spliceindex)
|
||||
- 实例事件
|
||||
- [`focus`](#focus-事件)
|
||||
- [`unfocus`](#unfocus-事件)
|
||||
- [`add`](#add-事件)
|
||||
- [`pop`](#pop-事件)
|
||||
- [`splice`](#splice-事件)
|
||||
|
||||
## stack
|
||||
|
||||
```ts
|
||||
declare var stack: any[]
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
该成员描述了当前列表的显示栈
|
||||
|
||||
## focused
|
||||
|
||||
```ts
|
||||
declare var focused: any | null
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
该成员描述了当聚焦于的元素
|
||||
|
||||
## readonly equal
|
||||
|
||||
```ts
|
||||
declare const equal: boolean
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
该成员描述了不同元素间的关系,当该项为 `true` 时,表示成员间为平等关系,删除任意一项不会影响其他项,而为 `false` 时,删除一项后会将其之后的所有项一并删除
|
||||
|
||||
## consturctor()
|
||||
|
||||
```ts
|
||||
interface Focus {
|
||||
new(react: boolean = false, equal: boolean = false): Focus
|
||||
}
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
- `react`: 显示栈是否设置为浅层响应式(`shallowReactive`)变量
|
||||
- `equal`: 成员关系是否为平等关系
|
||||
|
||||
## focus()
|
||||
|
||||
```ts
|
||||
declare function focus(target: any, add: boolean = false): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `target`: 聚焦目标,是聚焦目标的引用,而非索引
|
||||
- `add`: 当聚焦目标不存在时,是否自动追加到显示栈末尾
|
||||
|
||||
- 方法说明
|
||||
|
||||
该方法用于聚焦于一个显示元素
|
||||
|
||||
## unfocus()
|
||||
|
||||
```ts
|
||||
declare function unfocus(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
该方法用于取消聚焦显示元素
|
||||
|
||||
## add()
|
||||
|
||||
```ts
|
||||
declare function add(item: any): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
该方法用于在显示栈末尾追加一个元素
|
||||
|
||||
## pop()
|
||||
|
||||
```ts
|
||||
declare function pop(): any | null
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
弹出显示栈末尾的元素
|
||||
|
||||
## splice()
|
||||
|
||||
```ts
|
||||
declare function splice(item: any): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
方法用于裁切显示栈,对于平等模式,只会删除对应元素,而对于非平等模式,其之后的所有元素都会被删除
|
||||
|
||||
## spliceIndex()
|
||||
|
||||
```ts
|
||||
declare function spliceIndex(index: number): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
根据索引裁切显示栈,与 [`splice`](#splice) 方法类似
|
||||
|
||||
## focus 事件
|
||||
|
||||
```ts
|
||||
interface FocusEvent {
|
||||
focus: (before: any | null, after: any) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当聚焦于一个元素时,该事件会被触发,传入之前聚焦的元素以及当前聚焦的元素作为参数
|
||||
|
||||
## unfocus 事件
|
||||
|
||||
```ts
|
||||
interface FocusEvent {
|
||||
unfocus: (before: any | null) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当取消聚焦元素时,该事件被触发,传入之前聚焦于的元素作为参数
|
||||
|
||||
## add 事件
|
||||
|
||||
```ts
|
||||
interface FocusEvent {
|
||||
add: (item: any) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当向显示栈内添加内容时,该事件被触发,传入添加的元素作为参数
|
||||
|
||||
## pop 事件
|
||||
|
||||
```ts
|
||||
interface FocusEvent {
|
||||
pop: (item: any | null) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当弹出显示栈的末尾元素时,该事件被触发,传入弹出的元素作为参数
|
||||
|
||||
## splice 事件
|
||||
|
||||
```ts
|
||||
interface FocusEvent {
|
||||
splice: (spliced: any[]) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当显示栈被裁切时,该事件被触发,传入所有被裁切的元素组成的数组作为参数
|
216
docs/api/class/game-storage.md
Normal file
216
docs/api/class/game-storage.md
Normal file
@ -0,0 +1,216 @@
|
||||
# 类 GameStroage
|
||||
|
||||
该类是渲染进程类,游戏进程不能直接使用
|
||||
|
||||
- 实例成员
|
||||
- [`key`](#key)
|
||||
- [`data`](#data)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`read`](#read)
|
||||
- [`write`](#write)
|
||||
- [`setValue`](#setvalue)
|
||||
- [`getValue`](#getvalue)
|
||||
- [`toJSON`](#tojson)
|
||||
- [`clear`](#clear)
|
||||
- [`keys`](#keys)
|
||||
- [`values`](#values)
|
||||
- [`entries`](#entries)
|
||||
- 静态成员
|
||||
- [`list`](#list)
|
||||
- 静态方法
|
||||
- [`fromGame`](#fromgame)
|
||||
- [`fromAuthor`](#fromauthor)
|
||||
- [`get`](#get)
|
||||
|
||||
## key
|
||||
|
||||
```ts
|
||||
declare var key: string
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
该成员表示了这个存储实例的名称
|
||||
|
||||
## data
|
||||
|
||||
```ts
|
||||
declare var data: Record<string, any>
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
该成员存储了这个存储实例的所有内容,在写入时会将这个成员写入,读取时会覆盖这个成员
|
||||
|
||||
## constructor()
|
||||
|
||||
```ts
|
||||
interface GameStorage {
|
||||
new(key: string): GameStorage
|
||||
}
|
||||
```
|
||||
|
||||
- 构造器说明
|
||||
|
||||
传入存储名称,构造一个存储实例。存储名称不建议直接填入,建议使用 [`fromGame`](#fromgame) 或者 [`fromAuthor`](#fromauthor) 方法生成
|
||||
|
||||
## read()
|
||||
|
||||
```ts
|
||||
declare function read(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
从本地存储读取,并写入到 `data` 成员中
|
||||
|
||||
## write()
|
||||
|
||||
```ts
|
||||
declare function write(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
将 `data` 成员中的数据写入到本地存储中
|
||||
|
||||
## setValue()
|
||||
|
||||
```ts
|
||||
declare function setValue(key: string, value: any): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
该方法用于更改一个该存储实例上的存储的值
|
||||
|
||||
- 示例
|
||||
|
||||
```js
|
||||
myStorage.setValue('key', 123); // 将存储 'key' 设为 123
|
||||
```
|
||||
|
||||
## getValue()
|
||||
|
||||
```ts
|
||||
declare function getValue(key: string, defaultValue?: any): any
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `key`: 存储键名
|
||||
- `defaultValue`: 当存储不存在时,获取的默认值
|
||||
|
||||
- 方法说明
|
||||
|
||||
获取一个存储的值,当值不存在时返回默认值
|
||||
|
||||
## toJSON()
|
||||
|
||||
```ts
|
||||
declare function toJSON(): string
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
将这个存储实例转化为序列化的 `JSON` 字符串
|
||||
|
||||
## clear()
|
||||
|
||||
```ts
|
||||
declare function clear(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
将这个存储的所有内容清空
|
||||
|
||||
## keys()
|
||||
|
||||
```ts
|
||||
declare function keys(): string[]
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
获取到这个存储的所有键,组成一个字符串数组返回
|
||||
|
||||
## values()
|
||||
|
||||
```ts
|
||||
declare function values(): any[]
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
获取这个存储的所有值,组成一个数组返回
|
||||
|
||||
## entries()
|
||||
|
||||
```ts
|
||||
declare function entries(): [string, any][]
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
获取这个存储的所有键和值,组成以数组 `[键, 值]` 构成的数组返回
|
||||
|
||||
## list
|
||||
|
||||
```ts
|
||||
declare var list: GameStorage[]
|
||||
```
|
||||
|
||||
- 静态成员说明
|
||||
|
||||
该静态成员描述了所有构造的存储实例
|
||||
|
||||
- 示例
|
||||
|
||||
```js
|
||||
GameStroage.list.forEach(v => v.clear()); // 清空所有存储实例的存储
|
||||
```
|
||||
|
||||
## fromGame()
|
||||
|
||||
```ts
|
||||
declare function fromGame(key: string): string
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
该静态方法用于生成一个与游戏关联的键,用于生成存储实例,由此生成的存储实例只在本游戏内有效,与其他游戏没有关联。
|
||||
|
||||
- 示例
|
||||
|
||||
```js
|
||||
const myStorage = new GameStorage(GameStorage.fromGame('key'));
|
||||
```
|
||||
|
||||
## fromAuthor()
|
||||
|
||||
```ts
|
||||
declare function fromAuthor(_: any, key: string): string
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
该静态方法用于生成一个与作者关联的键,同作者的塔中该存储会共通。第一个参数无用,随便填即可,第二个参数说明的是存储的名称。
|
||||
|
||||
- 示例
|
||||
|
||||
```js
|
||||
const myStorage = new GameStorage(GameStorage.fromAuthor(void 0, 'key'));
|
||||
const value = myStorage.getValue('key'); // 共通存储,可以从其他塔获取
|
||||
```
|
||||
|
||||
## get()
|
||||
|
||||
```ts
|
||||
declare function get(key: string): GameStorage
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
该静态方法用于获取对应名称的存储实例,等价于 `GameStorage.list.find(v => v.key === key)`
|
90
docs/api/class/game-ui.md
Normal file
90
docs/api/class/game-ui.md
Normal file
@ -0,0 +1,90 @@
|
||||
# 类 GameUi
|
||||
|
||||
渲染进程类,游戏进程不能直接使用,继承自 [`EventEmitter`](./event-emitter.md)
|
||||
|
||||
- 实例成员
|
||||
- [`component`](#component)
|
||||
- [`id`](#id)
|
||||
- [`symbol`](#symbol)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`with`](#with)
|
||||
- 静态成员
|
||||
- [`uiList`](#uilist)
|
||||
- 实例事件
|
||||
- [`close`](#close-事件)
|
||||
- [`open`](#open-事件)
|
||||
|
||||
## component
|
||||
|
||||
```ts
|
||||
declare var component: Component
|
||||
```
|
||||
|
||||
## id
|
||||
|
||||
```ts
|
||||
declare var id: string
|
||||
```
|
||||
|
||||
## symbol
|
||||
|
||||
```ts
|
||||
declare var symbol: symbol
|
||||
```
|
||||
|
||||
## constructor()
|
||||
|
||||
```ts
|
||||
interface GameUi {
|
||||
new(id: string, component: Component): GameUi
|
||||
}
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
- `id`: UI 的名称,也就是 id
|
||||
- `component`: UI 组件,一般是函数式组件或者导出组件
|
||||
|
||||
## with()
|
||||
|
||||
```ts
|
||||
declare function with(vBind?: any, vOn?: any): ShowableGameUi
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
传入参数与监听事件,返回一个可显示 UI 对象
|
||||
|
||||
## uiList
|
||||
|
||||
```ts
|
||||
declare var uiList: GameUi[]
|
||||
```
|
||||
|
||||
- 静态成员说明
|
||||
|
||||
包含了所有注册的 `GameUi` 实例
|
||||
|
||||
## close 事件
|
||||
|
||||
```ts
|
||||
interface GameUiEvent {
|
||||
close: () => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当这个 UI 被打开时触发该事件
|
||||
|
||||
## open 事件
|
||||
|
||||
```ts
|
||||
interface GameUiEvent {
|
||||
open: () => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当这个 UI 被关闭时触发该事件
|
366
docs/api/class/hotkey.md
Normal file
366
docs/api/class/hotkey.md
Normal file
@ -0,0 +1,366 @@
|
||||
# 类 Hotkey
|
||||
|
||||
渲染进程类,在游戏进程不能直接使用,继承自 [`EventEmitter`](./event-emitter.md)
|
||||
|
||||
- 实例属性
|
||||
- [`id`](#id)
|
||||
- [`name`](#name)
|
||||
- [`data`](#data)
|
||||
- [`keyMap`](#keymap)
|
||||
- [`groupName`](#groupname)
|
||||
- [`groups`](#groups)
|
||||
- [`enabled`](#enabled)
|
||||
- [`conditionMap`](#conditionmap)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`register`](#register)
|
||||
- [`realize`](#realize)
|
||||
- [`use`](#use)
|
||||
- [`dispose`](#dispose)
|
||||
- [`set`](#set)
|
||||
- [`emitKey`](#emitkey)
|
||||
- [`group`](#group)
|
||||
- [`enable`](#enable)
|
||||
- [`disable`](#disable)
|
||||
- [`when`](#when)
|
||||
- [`toJSON`](#tojson)
|
||||
- [`fromJSON`](#fromjson)
|
||||
- 静态属性
|
||||
- [`list`](#list)
|
||||
- 静态方法
|
||||
- [`get`](#get)
|
||||
- 实例事件
|
||||
- [`set`](#set-事件)
|
||||
- [`emit`](#emit-事件)
|
||||
|
||||
## 部分接口与类型说明
|
||||
|
||||
```ts
|
||||
interface AssistHotkey {
|
||||
ctrl: boolean
|
||||
shift: boolean
|
||||
alt: boolean
|
||||
}
|
||||
```
|
||||
|
||||
三个属性分别表示对应的按键是否按下,或者是否需要被按下
|
||||
|
||||
```ts
|
||||
interface RegisteredHotkeyData extends Partial<AssistHotkey> {
|
||||
id: string
|
||||
name: string
|
||||
defaults: KeyCode
|
||||
type?: KeyEmitType
|
||||
}
|
||||
```
|
||||
|
||||
- `id`: 注册的这个按键的 id,可以加后缀,参考[同 id 按键](../../guide/hotkey.md#同-id-按键)
|
||||
- `name`: 这个按键的名称,会显示在自定义快捷键界面中
|
||||
- `defaults`: 玩家不进行设置时,这个功能的默认按键
|
||||
- `type`: 占位属性,暂时无用
|
||||
- `ctrl` `shift` `alt`: 玩家不进行设置时,这个功能默认的辅助按键,按下辅助按键后按下默认按键才可触发功能
|
||||
|
||||
```ts
|
||||
interface HotkeyData extends Required<RegisteredHotkeyData> {
|
||||
key: KeyCode
|
||||
func: Map<symbol, HotkeyFunc>
|
||||
group?: string
|
||||
}
|
||||
```
|
||||
|
||||
- `key`: 当前这个功能的按键
|
||||
- `func`: 所有当前存在的作用域下,每个作用域触发时的执行函数
|
||||
- `group`: 这个按键所处的分组,参考 [按键分组](../../guide/hotkey.md#按键分组)
|
||||
|
||||
```ts
|
||||
type HotkeyFunc = (id: string, code: KeyCode, ev: KeyboardEvent) => void;
|
||||
```
|
||||
|
||||
表示按键的触发函数
|
||||
|
||||
- `id`: 触发的按键的 id,包含数字后缀
|
||||
- `code`: 触发时按下的按键
|
||||
- `ev`: 触发时的 `KeyboardEvent`,对于虚拟键盘,会进行不完全拟真
|
||||
|
||||
## id
|
||||
|
||||
```ts
|
||||
declare var id: string
|
||||
```
|
||||
|
||||
## name
|
||||
|
||||
```ts
|
||||
declare var name: string
|
||||
```
|
||||
|
||||
## data
|
||||
|
||||
```ts
|
||||
declare var data: Record<string, HotkeyData>
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
该成员存储了所有注册的按键信息,其中键表示按键的 id,值表示这个 id 对应的按键
|
||||
|
||||
## keyMap
|
||||
|
||||
```ts
|
||||
declare var keyMap: Map<KeyCode, HotkeyData[]>
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
存储了每个按键可以触发的功能列表,例如 X 键打开怪物手册等
|
||||
|
||||
## groupName
|
||||
|
||||
```ts
|
||||
declare var groupName: Record<string, string>
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
存储了每个分组对应的显示名称,键表示分组 id,值表示分组名称
|
||||
|
||||
## groups
|
||||
|
||||
```ts
|
||||
declare var groups: Record<string, string[]>
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
存储了每个分组所包含的按键 id,键表示分组 id,值是一个数组,包含了所有的按键 id
|
||||
|
||||
## enabled
|
||||
|
||||
```ts
|
||||
declare var enabled: boolean
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
表示当前按键实例是否被启用
|
||||
|
||||
## conditionMap
|
||||
|
||||
```ts
|
||||
declare var conditionMap: Map<symbol, () => boolean>
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
描述了每个作用域下的按键启用条件,也就是 [`when`](#when) 函数的功能
|
||||
|
||||
## constructor()
|
||||
|
||||
```ts
|
||||
interface Hotkey {
|
||||
new(id: string, name: string): Hotkey
|
||||
}
|
||||
```
|
||||
|
||||
## register()
|
||||
|
||||
```ts
|
||||
declare function register(data: RegisterHotkeyData): this
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
注册一个按键,id 可以包含数字后缀,可以显示为同一个按键操作拥有多个按键可以触发
|
||||
|
||||
## realize()
|
||||
|
||||
```ts
|
||||
declare function realize(id: string, func: HotkeyFunc): this
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `id`: 要实现的按键 id,可以不包含数字后缀
|
||||
- `func`: 按键被触发时执行的函数
|
||||
|
||||
- 方法说明
|
||||
|
||||
实现一个按键按下时的操作
|
||||
|
||||
## use()
|
||||
|
||||
```ts
|
||||
declare function use(symbol: symbol): this
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
使用一个 symbol 作为当前作用域,之后调用 [`realize`](#realize) 所实现的按键功能将会添加至此作用域
|
||||
|
||||
## dispose()
|
||||
|
||||
```ts
|
||||
declare function dispose(symbol?: symbol): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `symbol`: 要释放的作用域
|
||||
|
||||
- 方法说明
|
||||
|
||||
释放一个作用域,释放后作用域将退回至删除的作用域的上一级
|
||||
|
||||
## set()
|
||||
|
||||
```ts
|
||||
declare function set(id: string, key: KeyCode, assist: number): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `id`: 要修改的按键的 id
|
||||
- `key`: 要修改为的触发按键
|
||||
- `assist`: 要修改为的辅助按键
|
||||
|
||||
- 方法说明
|
||||
|
||||
设置一个按键信息
|
||||
|
||||
## emitKey()
|
||||
|
||||
```ts
|
||||
declare function emitKey(
|
||||
key: KeyCode,
|
||||
assist: number,
|
||||
type: KeyEmitType,
|
||||
ev: KeyboardEvent
|
||||
): boolean
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `key`: 要触发的按键
|
||||
- `assist`: 触发时的辅助按键
|
||||
- `type`: 暂时为占位参数,填写 `up` 即可
|
||||
- `ev`: 触发按键时的按键事件信息 `KeyboardEvent`,参考 dom 中的按键事件
|
||||
|
||||
- 方法说明
|
||||
|
||||
触发一个按键
|
||||
|
||||
- 返回值
|
||||
|
||||
是否成功触发至少一个按键
|
||||
|
||||
## group()
|
||||
|
||||
```ts
|
||||
declare function group(id: string, name: string): this
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `id`: 分组的 id
|
||||
- `name`: 分组的显示名称
|
||||
|
||||
- 方法说明
|
||||
|
||||
按键分组,分组后调用 [`register`](#register) 注册的按键会进入这个分组,参考[按键分组](../../guide/hotkey.md#按键分组)
|
||||
|
||||
## enable()
|
||||
|
||||
```ts
|
||||
declare function enabled(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
启用这个按键实例
|
||||
|
||||
## disable()
|
||||
|
||||
```ts
|
||||
declare function disabled(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
禁用这个按键实例
|
||||
|
||||
## when()
|
||||
|
||||
```ts
|
||||
declare function when(fn: () => boolean): this
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
在当前作用域下,满足一定条件后启用按键功能
|
||||
|
||||
## toJSON()
|
||||
|
||||
```ts
|
||||
declare function toJSON(): string
|
||||
```
|
||||
|
||||
## fromJSON()
|
||||
|
||||
```ts
|
||||
declare function fromJSON(data: string): void
|
||||
```
|
||||
|
||||
## list
|
||||
|
||||
```ts
|
||||
declare var list: Hotkey[]
|
||||
```
|
||||
|
||||
- 静态成员说明
|
||||
|
||||
存储了所有的按键实例
|
||||
|
||||
## get()
|
||||
|
||||
```ts
|
||||
declare function get(id: string): Hotkey
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
根据 id 获取到对应的按键实例
|
||||
|
||||
## set 事件
|
||||
|
||||
```ts
|
||||
interface HotkeyEvent {
|
||||
set: (id: string, key: KeyCode, assist: number) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `id`: 设置的按键的 id
|
||||
- `key`: 设置为的触发按键
|
||||
- `assist`: 设置为的辅助按键
|
||||
|
||||
- 事件说明
|
||||
|
||||
当设置按键信息(执行`set`函数)时触发该事件
|
||||
|
||||
## emit 事件
|
||||
|
||||
```ts
|
||||
interface HotkeyEvent {
|
||||
emit: (key: KeyCode, assist: number) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `key`: 触发的按键
|
||||
- `assist`: 触发的辅助按键
|
||||
|
||||
- 事件说明
|
||||
|
||||
当触发一个按键时触发该事件
|
59
docs/api/class/indexed-event-emitter.md
Normal file
59
docs/api/class/indexed-event-emitter.md
Normal file
@ -0,0 +1,59 @@
|
||||
# 类 IndexedEventEmitter
|
||||
|
||||
渲染进程、游戏进程通用类,继承自 [`EventEmitter`](./event-emitter.md)
|
||||
|
||||
- 示例方法
|
||||
- [`onIndex`](#onindex)
|
||||
- [`onceIndex`](#onceindex)
|
||||
- [`offIndex`](#offindex)
|
||||
|
||||
## onIndex()
|
||||
|
||||
```ts
|
||||
function onIndex(
|
||||
event: string,
|
||||
symbol: string | number | symbol,
|
||||
fn: (...params: any) => any,
|
||||
options?: Partial<ListenerOptions>
|
||||
): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `event`: 要监听的事件名称
|
||||
- `symbol`: 监听函数的标识符
|
||||
- `fn`: 监听函数,在事件被触发时执行
|
||||
- `options`: 监听配置,见[`EventEmitter`](./event-emitter.md#on)
|
||||
|
||||
- 方法说明
|
||||
|
||||
监听一个事件,同时为监听函数分配标识符,用于取消监听
|
||||
|
||||
## onceIndex()
|
||||
|
||||
```ts
|
||||
function onceIndex(
|
||||
event: string,
|
||||
symbol: string | number | symbol,
|
||||
fn: (...params: any) => any
|
||||
): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
等价于`on(event, symbol, fn, { once: true })`
|
||||
|
||||
## offIndex()
|
||||
|
||||
```ts
|
||||
function offIndex(event: string, symbol: string | number | symbol): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `event`: 要取消监听的事件
|
||||
- `symbol`: 监听函数的标识符
|
||||
|
||||
- 方法说明
|
||||
|
||||
根据监听函数的标识符取消监听
|
363
docs/api/class/keyboard.md
Normal file
363
docs/api/class/keyboard.md
Normal file
@ -0,0 +1,363 @@
|
||||
# 类 Keyboard
|
||||
|
||||
渲染进程类,不能直接在游戏进程使用,继承自[EventEmitter](./event-emitter.md)
|
||||
|
||||
- 实例成员
|
||||
- [`id`](#id)
|
||||
- [`keys`](#keys)
|
||||
- [`assist`](#assist)
|
||||
- [`fontSize`](#fontsize)
|
||||
- [`scope`](#scope)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`add`](#add)
|
||||
- [`remove`](#remove)
|
||||
- [`withAssist`](#withassist)
|
||||
- [`createScope`](#createscope)
|
||||
- [`disposeScope`](#disposescope)
|
||||
- [`extend`](#extend)
|
||||
- [`emitKey`](#emitKey)
|
||||
- 静态成员
|
||||
- [`list`](#list)
|
||||
- 静态方法
|
||||
- [`get`](#get)
|
||||
- 实例事件
|
||||
- [`add`](#add-事件)
|
||||
- [`remove`](#remove-事件)
|
||||
- [`extend`](#extend-事件)
|
||||
- [`emit`](#emit-事件)
|
||||
- [`scopeCreate`](#scopecreate-事件)
|
||||
- [`scopeDispose`](#scopedispose-事件)
|
||||
|
||||
## id
|
||||
|
||||
```ts
|
||||
declare var id: string
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
这个虚拟键盘的 id
|
||||
|
||||
## keys
|
||||
|
||||
```ts
|
||||
declare var keys: KeyboardItem[]
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
包含了所有被添加的按键
|
||||
|
||||
- 接口 `KeyboardItem`
|
||||
|
||||
- `key`: 枚举 `KeyCode` 成员,表示按下这个键后触发哪个按键
|
||||
- `text`: 可选,表示按键的显示文字,兼容 html 标签
|
||||
- `x`: 这个按键的横坐标
|
||||
- `y`: 这个按键的纵坐标
|
||||
- `width`: 这个按键的宽度
|
||||
- `height`: 这个按键的高度
|
||||
|
||||
## assist
|
||||
|
||||
```ts
|
||||
declare var assist: number
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
表示当前虚拟键盘按下的辅助按键(`ctrl` `shift` `alt`)
|
||||
|
||||
## fontSize
|
||||
|
||||
```ts
|
||||
declare var fontSize: number
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
当前虚拟键盘的字体大小
|
||||
|
||||
## scope
|
||||
|
||||
```ts
|
||||
declare var scope: symbol
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
当前虚拟键盘处在的作用域
|
||||
|
||||
## constructor()
|
||||
|
||||
```ts
|
||||
interface Keyboard {
|
||||
new(id: string): Keyboard
|
||||
}
|
||||
```
|
||||
|
||||
## add()
|
||||
|
||||
```ts
|
||||
declare function add(item: KeyboardItem): this
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
向这个虚拟键盘添加一个按键
|
||||
|
||||
## remove()
|
||||
|
||||
```ts
|
||||
declare function remove(item: KeyboardItem): this
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
删除一个按键,参数表示要删除的按键的引用
|
||||
|
||||
## withAssist()
|
||||
|
||||
```ts
|
||||
declare function withAssist(assist: number): symbol
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `assist`: 初始状态下被触发的辅助按键,可以通过[`wrapAssist`](../function.md#wrapassist)函数来创建
|
||||
|
||||
- 方法说明
|
||||
|
||||
创造一个在某些辅助按键已经按下的情况下的作用域,这些被按下的辅助按键还可以被玩家手动取消
|
||||
|
||||
- 返回值
|
||||
|
||||
创建的作用域的`symbol`
|
||||
|
||||
## createScope()
|
||||
|
||||
```ts
|
||||
declare function createScope(): symbol
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
创建一个全新的作用域,在这个作用域下不会影响到任何其他作用域,例如开关辅助按键等,监听事件也不会相冲突
|
||||
|
||||
- 返回值
|
||||
|
||||
这个作用域对应的`symbol`
|
||||
|
||||
## disposeScope()
|
||||
|
||||
```ts
|
||||
declare function disposeScope(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
销毁上一次创建的作用域
|
||||
|
||||
## extend()
|
||||
|
||||
```ts
|
||||
declare function extend(
|
||||
keyboard: Keyboard,
|
||||
offsetX: number = 0,
|
||||
offsetY: number = 0
|
||||
): this
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `keyboard`: 要继承的按键实例
|
||||
- `offsetX`: 继承时所有按键的偏移横坐标
|
||||
- `offsetY`: 继承时所有按键的偏移纵坐标
|
||||
|
||||
- 方法说明
|
||||
|
||||
继承自一个其他的虚拟按键实例,例如主键盘可以由字母按键、数字按键等继承而来,同时指定偏移坐标
|
||||
|
||||
## emitKey()
|
||||
|
||||
```ts
|
||||
declare function emitKey(key: KeyboardItem, index: number): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `key`: 触发的按键信息,是按键的引用
|
||||
- `index`: 这个按键在 [`keys`](#keys) 中的索引
|
||||
|
||||
- 方法说明
|
||||
|
||||
触发一个虚拟按键
|
||||
|
||||
## list
|
||||
|
||||
```ts
|
||||
declare var list: Keyboard[]
|
||||
```
|
||||
|
||||
- 静态成员说明
|
||||
|
||||
包含了所有的 `Keyboard` 实例
|
||||
|
||||
## get()
|
||||
|
||||
```ts
|
||||
declare function get(id: string): Keyboard
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
根据虚拟按键实例的 id 获取到虚拟按键实例
|
||||
|
||||
- 系统自带虚拟按键
|
||||
|
||||
- `qwe`: 字母键盘,包含 A-Z
|
||||
- `num`: 字母键盘上方的数字键盘,非小键盘,包含 0-9 及反引号键、减号键、等号键和退格键
|
||||
- `char`: 符号键盘,包含 \[\]\\;',./
|
||||
- `fn`: Fn 键盘,包含 F1-F12 及 Escape
|
||||
- `assist`: 辅助按键键盘,包含 Tab、大写锁定、左右 Shift、左右 Ctrl、左右 Alt、左右 Meta(Windows 电脑的 Win 键,或是 Mac 电脑的 Command 键)、空格键、回车键
|
||||
- `arrow`: 方向键,包含上下左右四个方向键
|
||||
- `numpad`: 小键盘,包含小键盘的 0-9(与数字键盘的 0-9 不同)、小键盘锁(NumLock)、小键盘的+-\*/、小键盘的点、回车(与主键盘的回车相同)
|
||||
- `media`: 媒体按键,包含播放/暂停、停止播放、上一首、下一首
|
||||
- `tool`: 功能按键,包含 PageUp、PageDn、Insert、Delete、Home、End
|
||||
- `main`: 主键盘,继承 `qwe` `num` `char` `fn` `assist`,无新增按键
|
||||
- `toolArrow`: 方向键与功能键,继承 `arrow` `tool`,无新增按键
|
||||
- `mini`: 小键盘,继承 `numpad`,无新增按键
|
||||
- `full`: 全按键,继承 `main` `toolArrow` `mini` `media`,无新增按键
|
||||
|
||||
## add 事件
|
||||
|
||||
```ts
|
||||
interface VirtualKeyboardEvent {
|
||||
add: (item: KeyboardItem) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当添加虚拟按键时触发事件
|
||||
|
||||
## remove 事件
|
||||
|
||||
```ts
|
||||
interface VirtualKeyboardEvent {
|
||||
remove: (item: KeyboardItem) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当移除一个虚拟按键时触发
|
||||
|
||||
## extend 事件
|
||||
|
||||
```ts
|
||||
interface VirtualKeyboardEvent {
|
||||
extend: (extended: Keyboard) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当继承其他虚拟键盘实例时触发
|
||||
|
||||
## emit 事件
|
||||
|
||||
```ts
|
||||
interface VirtualKeyboardEvent {
|
||||
emit: (
|
||||
item: KeyboardItem,
|
||||
assist: number,
|
||||
index: number,
|
||||
ev: VirtualKeyEmit
|
||||
) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `item`: 触发的按键信息
|
||||
- `assist`: 触发时的辅助按键按下情况
|
||||
- `index`: 按键信息处在的按键列表中的索引
|
||||
- `ev`: 剩余内容,包含一些函数以供调用
|
||||
|
||||
- 接口 `VirtualKeyEmit`
|
||||
|
||||
```ts
|
||||
interface VirtualKeyEmit {
|
||||
preventDefault(): void
|
||||
preventAssist(): void
|
||||
}
|
||||
```
|
||||
|
||||
- `preventDefault`: 阻止非辅助虚拟按键的默认行为。虚拟按键的默认行为为触发 `Hotkey` 在当前作用域下对应的按键,调用后即可阻止这一默认行为的发生
|
||||
- `preventAssist`: 阻止辅助按键的默认行为。辅助按键的默认行为是开关对应的辅助按键开关状态,调用后可以阻止这一默认行为的发生
|
||||
|
||||
- 事件说明
|
||||
|
||||
当触发一个虚拟按键时触发这个事件
|
||||
|
||||
- 示例
|
||||
|
||||
以下是样板自带函数 `getVirtualKeyOnce` 的源代码实现,这个函数便依赖于这个事件。
|
||||
|
||||
```ts {10}
|
||||
export function getVitualKeyOnce(
|
||||
emitAssist: boolean = false,
|
||||
assist: number = 0,
|
||||
emittable: KeyCode[] = []
|
||||
): Promise<KeyboardEmits> {
|
||||
return new Promise(res => {
|
||||
const key = Keyboard.get('full')!;
|
||||
key.withAssist(assist);
|
||||
const id = mainUi.open('virtualKey', { keyboard: key });
|
||||
key.on('emit', (item, assist, index, ev) => {
|
||||
ev.preventDefault();
|
||||
if (emitAssist) {
|
||||
if (emittable.length === 0 || emittable.includes(item.key)) {
|
||||
res({ key: item.key, assist: 0 });
|
||||
key.disposeScope();
|
||||
mainUi.close(id);
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
!isAssist(item.key) &&
|
||||
(emittable.length === 0 || emittable.includes(item.key))
|
||||
) {
|
||||
res({ key: item.key, assist });
|
||||
key.disposeScope();
|
||||
mainUi.close(id);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
## scopeCreate 事件
|
||||
|
||||
```ts
|
||||
interface VirtualKeyboardEvent {
|
||||
scopeCreate: (scope: symbol) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当创建一个作用域时触发这个事件
|
||||
|
||||
## scopeDispose 事件
|
||||
|
||||
```ts
|
||||
interface VirtualKeyboardEvent {
|
||||
scopeDispose: (scope: symbol) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当释放一个作用域时触发这个事件
|
179
docs/api/class/m-component.md
Normal file
179
docs/api/class/m-component.md
Normal file
@ -0,0 +1,179 @@
|
||||
# 类 MComponent
|
||||
|
||||
渲染进程类,游戏进程不能直接使用。对于部分方法,请参考 [UI 编写](../../guide/ui.md)
|
||||
|
||||
- 实例成员
|
||||
- [`content`](#content)
|
||||
- 实例方法
|
||||
- [`defineProps`](#defineprops)
|
||||
- [`defineEmits`](#defineemits)
|
||||
- [`div`](#div)
|
||||
- [`span`](#span)
|
||||
- [`canvas`](#canvas)
|
||||
- [`text`](#text)
|
||||
- [`com`](#com)
|
||||
- [`vfor`](#vfor)
|
||||
- [`h`](#h)
|
||||
- [`onSetup`](#onsetup)
|
||||
- [`onMounted`](#onmounted)
|
||||
- [`setup`](#setup)
|
||||
- [`ret`](#ret)
|
||||
- [`export`](#export)
|
||||
- 静态成员
|
||||
- [`mountNum`](#mountnum)
|
||||
- 静态方法
|
||||
- [`vNodeS`](#vnodes)
|
||||
- [`vNodeM`](#vnodem)
|
||||
- [`vNode`](#vNode)
|
||||
- [`unwrapProps`](#unwrapprops)
|
||||
- [`prop`](#prop)
|
||||
|
||||
## content
|
||||
|
||||
```ts
|
||||
declare var content: any[]
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
存储了当前组件的所有内容
|
||||
|
||||
## defineProps()
|
||||
|
||||
```ts
|
||||
declare function defineProps(props: Record<string, any>): this
|
||||
```
|
||||
|
||||
## defineEmits()
|
||||
|
||||
```ts
|
||||
declare function defineEmits(emits: string[]): this
|
||||
```
|
||||
|
||||
## div()
|
||||
|
||||
```ts
|
||||
declare function div(children?: any, config?: any): this
|
||||
```
|
||||
|
||||
## span()
|
||||
|
||||
```ts
|
||||
declare function span(children?: any, config?: any): this
|
||||
```
|
||||
|
||||
## canvas()
|
||||
|
||||
```ts
|
||||
declare function canvas(config?: any): this
|
||||
```
|
||||
|
||||
## text()
|
||||
|
||||
```ts
|
||||
declare function text(text: string | (() => string), config?: any): this
|
||||
```
|
||||
|
||||
## com()
|
||||
|
||||
```ts
|
||||
declare function com(component: any, config?: any): this
|
||||
```
|
||||
|
||||
## vfor()
|
||||
|
||||
```ts
|
||||
declare function vfor(items: any, map: (value: any, index: number) => VNode): this
|
||||
```
|
||||
|
||||
## h()
|
||||
|
||||
```ts
|
||||
declare function h(type: any, children?: any, config?: any): this
|
||||
```
|
||||
|
||||
## onSetup()
|
||||
|
||||
```ts
|
||||
declare function onSetup(fn: OnSetupFunction): this
|
||||
```
|
||||
|
||||
## onMounted()
|
||||
|
||||
```ts
|
||||
declare function onMounted(fn: OnMountedFunction): this
|
||||
```
|
||||
|
||||
## setup()
|
||||
|
||||
```ts
|
||||
declare function setup(fn: SetupFunction): this
|
||||
```
|
||||
|
||||
## ret()
|
||||
|
||||
```ts
|
||||
declare function ret(fn: RetFunction): this
|
||||
```
|
||||
|
||||
## export()
|
||||
|
||||
```ts
|
||||
declare function export(): Component
|
||||
```
|
||||
|
||||
## mountNum
|
||||
|
||||
```ts
|
||||
declare var mountNum: number
|
||||
```
|
||||
|
||||
## vNodeS()
|
||||
|
||||
```ts
|
||||
declare function vNodeS(child: any, mount?: number): VNode
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
将单个渲染内容输出为单个 `VNode`
|
||||
|
||||
## vNodeM()
|
||||
|
||||
```ts
|
||||
declare function vNodeM(mc: MComponent, mount?: number): VNode[]
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
将一个 `MComponent` 组件渲染为一个 `VNode` 数组
|
||||
|
||||
## vNode()
|
||||
|
||||
```ts
|
||||
declare function vNode(children: any, mount?: number): VNode[]
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
将一系列渲染内容输出为一个 `VNode` 数组
|
||||
|
||||
## unwrapProps()
|
||||
|
||||
```ts
|
||||
declare function unwrapProps(props?: Record<string, () => any>): Record<string, any>
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
获取 props 的真实值。因为传入渲染内容的 props 是一个函数,因此需要一层调用
|
||||
|
||||
## prop()
|
||||
|
||||
```ts
|
||||
declare function prop(component: Component, props: Record<string, any>): VNode
|
||||
```
|
||||
|
||||
- 静态方法说明
|
||||
|
||||
在渲染时给一个组件传递 props。实际效果为在调用后并不会传递,当被传递的组件被渲染时,将会传递 props。
|
259
docs/api/class/mota-setting.md
Normal file
259
docs/api/class/mota-setting.md
Normal file
@ -0,0 +1,259 @@
|
||||
# 类 MotaSetting
|
||||
|
||||
渲染进程类,在游戏进程不可直接使用,继承自 [`EventEmitter`](./event-emitter.md)
|
||||
|
||||
- 实例成员
|
||||
- [`readonly list`](#readonly-list)
|
||||
- 实例方法
|
||||
- [`reset`](#reset)
|
||||
- [`register`](#register)
|
||||
- [`getSetting`](#getsetting)
|
||||
- [`setValue`](#setvalue)
|
||||
- [`addValue`](#addvalue)
|
||||
- [`getValue`](#getvalue)
|
||||
- [`setDisplayFunc`](#setdisplayfunc)
|
||||
- [`setValueController`](#setvaluecontroller)
|
||||
- [`setDescription`](#setdescription)
|
||||
- 静态成员
|
||||
- [`noStorage`](#nostorage)
|
||||
- 实例事件
|
||||
- [`valueChange`](#valuechange-事件)
|
||||
|
||||
## readonly list
|
||||
|
||||
```ts
|
||||
declare const list: Record<string, MotaSettingItem>
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
该成员描述了这个设置实例在这一级设置中的所有设置。理论上其所有成员都是只读的。
|
||||
|
||||
- 接口 `MotaSettingItem`
|
||||
|
||||
```ts
|
||||
interface MotaSettingItem<T extends MotaSettingType = MotaSettingType> {
|
||||
name: string; // 设置的显示名称
|
||||
key: string; // 设置的名称(id)
|
||||
value: T; // 设置当前的值
|
||||
controller: SettingComponent; // 设置的编辑组件
|
||||
description?: string; // 设置的说明文字
|
||||
defaults?: boolean | number; // 设置的默认值
|
||||
step?: [number, number, number]; // 数字型设置的步长信息
|
||||
display?: (value: T) => string; // 设置显示函数
|
||||
}
|
||||
```
|
||||
|
||||
- 详细说明
|
||||
|
||||
- `name`: 设置的显示名称,例如 `宝石血瓶显伤`
|
||||
- `key`: 设置的名称,也就是设置的 id,不能包含 `.`
|
||||
- `value`: 设置当前的值,可以是数字、布尔值和设置实例,该项是设置实例时表示级联设置。通过方法 [`setValue`](#setvalue) 设置,在设置时**不可**更改数据类型
|
||||
- `controller`: 设置的编辑组件,可以通过 [`setValueController`](#setvaluecontroller) 方法设置,一般在注册设置的时候指定
|
||||
- `description`: 设置的说明文字,如果使用默认的设置 UI 的话,会显示在右方
|
||||
- `defaults`: 设置的默认值,在注册后,如果没有设置,那么设置就会是这个值。当设置是一个级联设置的时候,该项为 `undefined`
|
||||
- `step`: 当此项设置为数字型设置时,该成员表示步长信息,第一项表示最小值,第二项表示最大值,第三项表示单步步长
|
||||
- `display`: 设置的显示函数,如果设置了,那么显示的值会是它的返回值,参考[指南](../../guide/setting.md#设置显示函数)
|
||||
|
||||
## reset()
|
||||
|
||||
```ts
|
||||
declare function reset(setting: Record<string, number | boolean>): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `setting`: 重设的设置信息,是一系列键值对,键表示设置的 id,值表示设置的值,例如`{ 'mySetting1.mySetting2': 123 }`
|
||||
|
||||
- 方法说明
|
||||
|
||||
该方法用于重设设置,一般用于初始化设置信息
|
||||
|
||||
## register()
|
||||
|
||||
```ts
|
||||
// overload 1
|
||||
declare function register(
|
||||
key: string,
|
||||
name: string,
|
||||
value: number,
|
||||
com?: SettingComponent,
|
||||
step?: [number, number, number]
|
||||
): this
|
||||
// overload 2
|
||||
declare function register(
|
||||
key: string,
|
||||
name: string,
|
||||
value: boolean | MotaSetting,
|
||||
com?: SettingComponent
|
||||
): this
|
||||
```
|
||||
|
||||
- 用法一
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `key`: 要注册的设置名称,也就是 id,不能包含 `.`
|
||||
- `name`: 设置的显示名称
|
||||
- `value`: 设置的初始值(默认值)
|
||||
- `com`: 设置的编辑组件,也就是右侧设置说明下方的内容
|
||||
- `step`: 步长信息,是一个数组,第一项表示最小值,第二项表示最大值,第三项表示单步步长
|
||||
|
||||
- 方法说明
|
||||
|
||||
该用法用于注册一个数字型设置
|
||||
|
||||
- 用法二
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `key`: 要注册的设置名称,也就是 id,不能包含 `.`
|
||||
- `name`: 设置的显示名称
|
||||
- `value`: 设置的初始值(默认值),或者是级联设置
|
||||
- `com`: 设置的编辑组件,也就是右侧设置说明下方的内容
|
||||
|
||||
- 方法说明
|
||||
|
||||
该用法用于注册一个布尔型变量,或者是级联设置。当 `value` 传递一个设置实例的时候,会认为是级联设置
|
||||
|
||||
## getSetting()
|
||||
|
||||
```ts
|
||||
declare function getSetting(key: string): Readonly<MotaSettingItem | null>
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `key`: 设置的键名,对于级联设置,使用 `.` 进行连接,例如 `mySetting1.mySetting2`
|
||||
|
||||
- 返回值
|
||||
|
||||
该函数返回获取到的设置,如果没有获取到设置,会抛出错误。获取的返回值理论上(在 ts 下)是只读的,不允许修改。
|
||||
|
||||
- 方法说明
|
||||
|
||||
该方法用于获取到一个设置
|
||||
|
||||
## setValue()
|
||||
|
||||
```ts
|
||||
declare function setValue(key: string, value: boolean | number): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
该方法用于设置一个设置的值,接受设置键名,以及要设置为的值为参数。
|
||||
|
||||
- 示例
|
||||
|
||||
```js
|
||||
mySetting.setValue('mySetting1.mySetting2', 200);
|
||||
```
|
||||
|
||||
## addValue()
|
||||
|
||||
```ts
|
||||
declare function addValue(key: string, value: number): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
该方法用于增减一个数字型设置的值,其中 `value` 表示增减的多少
|
||||
|
||||
- 示例
|
||||
|
||||
```js
|
||||
mySetting.addValue('mySetting1.mySetting2', 100); // 增加100,减少100可以填-100
|
||||
```
|
||||
|
||||
## getValue()
|
||||
|
||||
```ts
|
||||
declare function getValue(
|
||||
key: string,
|
||||
defaultValue?: boolean | number
|
||||
): boolean | number
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `key`: 设置的键名
|
||||
- `defaultValue`: 当设置或设置的值不存在,或者设置是一个级联设置时,返回的默认值
|
||||
|
||||
- 方法说明
|
||||
|
||||
用于获取一个设置的值,当设置或设置的值不存在,或者设置是一个级联设置时,会返回默认值
|
||||
|
||||
## setDisplayFunc()
|
||||
|
||||
```ts
|
||||
declare function setDisplayFunc(
|
||||
key: string,
|
||||
func: (value: boolean | number) => string
|
||||
): this
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `key`: 设置的键名
|
||||
- `func`: 显示函数,接受当前设置的值作为参数,返回一个字符串作为显示值
|
||||
|
||||
- 示例
|
||||
|
||||
```js
|
||||
mySetting.setDisplayFunc('mySetting1.mySetting2', value => value ? '宝石' : '血瓶');
|
||||
```
|
||||
|
||||
## setValueController()
|
||||
|
||||
```ts
|
||||
declare function setValueController(key: string, com: SettingComponent): this
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `key`: 设置的键名
|
||||
- `com`: 要设置成的编辑组件,以函数式组件为宜
|
||||
|
||||
## setDescription()
|
||||
|
||||
```ts
|
||||
declare function setDescription(key: string, desc: string): this
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `key`: 设置的键名
|
||||
- `desc`: 要设置成的描述信息,允许 html 元素的出现
|
||||
|
||||
## noStorage
|
||||
|
||||
```ts
|
||||
declare var noStorage: string[]
|
||||
```
|
||||
|
||||
- 静态成员说明
|
||||
|
||||
该成员描述了所有不计入本地存储的样板自带设置的键名
|
||||
|
||||
- 示例
|
||||
|
||||
```js
|
||||
MotaSetting.noStorage.push('mySetting');
|
||||
```
|
||||
|
||||
## valueChange 事件
|
||||
|
||||
```ts
|
||||
interface MotaSettingEvent {
|
||||
valueChange: <T extends boolean | number>(
|
||||
key: string,
|
||||
newValue: T,
|
||||
oldValue: T
|
||||
) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当设置的值被设置时触发该事件,传入设置的键名、新值、旧值作为参数
|
122
docs/api/class/range.md
Normal file
122
docs/api/class/range.md
Normal file
@ -0,0 +1,122 @@
|
||||
# 类 Range
|
||||
|
||||
游戏进程类,渲染进程也可以使用
|
||||
|
||||
- 实例成员
|
||||
- [`collection`](#collection)
|
||||
- [`cache`](#cache)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`scan`](#scan)
|
||||
- [`inRange`](#inrange)
|
||||
- [`clearCache`](#clearcache)
|
||||
- 静态成员
|
||||
- [`rangeType`](#rangetype)
|
||||
- 静态方法
|
||||
- [`registerRangeType`](#registerrangetype)
|
||||
|
||||
## 部分接口说明
|
||||
|
||||
```ts
|
||||
interface RangeCollection {
|
||||
list: Partial<Loc>[]
|
||||
range: Range
|
||||
}
|
||||
```
|
||||
|
||||
- `list`: 所有可能被这个范围实例扫描到的内容,是一个对象,可选包含 `x` `y` 两个属性
|
||||
- `range`: 这个内容集所属的范围实例
|
||||
|
||||
## collection
|
||||
|
||||
```ts
|
||||
declare var range: RangeCollection
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
存储所有可能被这个范围实例扫描到的内容
|
||||
|
||||
## cache
|
||||
|
||||
```ts
|
||||
declare var cache: Record<string, any>
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
缓存,一般需要你手动操作,内容随意
|
||||
|
||||
## constructor()
|
||||
|
||||
```ts
|
||||
interface Range {
|
||||
new(collection: RangeCollection): Range
|
||||
}
|
||||
```
|
||||
|
||||
## scan()
|
||||
|
||||
```ts
|
||||
declare function scan(type: string, data: any): any[]
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `type`: 范围类型,系统自带 `square` 和 `manhattan`,表示方形与曼哈顿范围
|
||||
- `data`: 传入给扫描函数的数据,例如可以是范围的坐标与大小等
|
||||
|
||||
- 方法说明
|
||||
|
||||
扫描 collection 中在范围内的物品
|
||||
|
||||
- 返回值
|
||||
|
||||
所有在范围内的物品构成的数组
|
||||
|
||||
## inRange()
|
||||
|
||||
```ts
|
||||
declare function inRange(type: string, data: any, item: Partial<Loc>): boolean
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
判断一个物品是否在指定范围中,用法与 [`scan`](#scan) 类似
|
||||
|
||||
## clearCache()
|
||||
|
||||
```ts
|
||||
declare function clearCache(): void
|
||||
```
|
||||
|
||||
## rangeType
|
||||
|
||||
```ts
|
||||
declare var rangeType: Record<string, RangeType>
|
||||
```
|
||||
|
||||
- 静态成员说明
|
||||
|
||||
存储了所有注册的范围类型
|
||||
|
||||
- 接口 `RangeType`
|
||||
|
||||
```ts
|
||||
interface RangeType {
|
||||
scan: RangeScanFn;
|
||||
inRange: InRangeFn;
|
||||
}
|
||||
```
|
||||
|
||||
## registerRangeType()
|
||||
|
||||
```ts
|
||||
declare function registerRangeType(
|
||||
type: string,
|
||||
scan: RangeScanFn<Partial<Loc>>,
|
||||
inRange: InRangeFn<Partial<Loc>>
|
||||
)
|
||||
```
|
||||
|
||||
- 参考[范围处理](../../guide/battle.md#范围处理)
|
63
docs/api/class/resource-controller.md
Normal file
63
docs/api/class/resource-controller.md
Normal file
@ -0,0 +1,63 @@
|
||||
# 抽象类 ReousrceController
|
||||
|
||||
渲染进程类,游戏进程不能直接使用,继承自 [`EventEmitter`](./event-emitter.md)
|
||||
|
||||
- 实例成员
|
||||
- [`list`](#list)
|
||||
- 实例方法
|
||||
- [`abstract add`](#abstract-add)
|
||||
- [`remove`](#remove)
|
||||
- 实例事件
|
||||
- [`add`](#add-事件)
|
||||
- [`remove`](#remove-事件)
|
||||
|
||||
## list
|
||||
|
||||
```ts
|
||||
declare var list: Record<string, any>
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
存储了每个资源的信息,键为资源的 uri,值为资源的数据
|
||||
|
||||
## abstract add()
|
||||
|
||||
```ts
|
||||
declare function add(uri: string, data: any): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `uri`: 资源的唯一标识符(Unique Resource Identifier)
|
||||
- `data`: 资源数据
|
||||
|
||||
- 方法说明
|
||||
|
||||
添加一个资源
|
||||
|
||||
## remove()
|
||||
|
||||
```ts
|
||||
declare function remove(uri: string): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
根据 uri 删除一个资源
|
||||
|
||||
## add 事件
|
||||
|
||||
```ts
|
||||
interface ResourceControllerEvent {
|
||||
add: (uri: string, data: D) => void
|
||||
}
|
||||
```
|
||||
|
||||
## remove 事件
|
||||
|
||||
```ts
|
||||
interface ResourceControllerEvent {
|
||||
delete: (uri: string, content: T) => void
|
||||
}
|
||||
```
|
119
docs/api/class/setting-displayer.md
Normal file
119
docs/api/class/setting-displayer.md
Normal file
@ -0,0 +1,119 @@
|
||||
# 类 SettingDisplayer
|
||||
|
||||
渲染进程类,游戏进程不可直接使用,继承自 [`EventEmitter`](./event-emitter.md)
|
||||
|
||||
- 实例属性
|
||||
- [`setting`](#setting)
|
||||
- [`selectStack`](#selectstack)
|
||||
- [`displayInfo`](#displayinfo)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`add`](#add)
|
||||
- [`cut`](#cut)
|
||||
- [`updata`](#update)
|
||||
- 实例事件
|
||||
- [`update`](#update-事件)
|
||||
|
||||
## setting
|
||||
|
||||
```ts
|
||||
declare var setting: MotaSetting
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
该成员描述了当前显示实例的设置
|
||||
|
||||
## selectStack
|
||||
|
||||
```ts
|
||||
declare var selectStack: string[]
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
该成员描述了当前的设置选择栈,例如当选中了级联设置 `setting1.setting2` 时,选择栈就是 `['setting1', 'setting2']`
|
||||
|
||||
## displayInfo
|
||||
|
||||
```ts
|
||||
declare var displayInfo: SettingDisplayInfo[]
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
该成员是响应式对象(`reactive`),描述了当前设置的所有显示信息,包含父设置(级联设置)的信息,一般情况下信息与选择栈同步。
|
||||
|
||||
- 接口 `SettingDisplayInfo`
|
||||
|
||||
```ts
|
||||
interface SettingDisplayInfo {
|
||||
item: MotaSettingItem | null;
|
||||
list: Record<string, MotaSettingItem>;
|
||||
text: string[];
|
||||
}
|
||||
```
|
||||
|
||||
- 详细说明
|
||||
- `item`: 描述了当前设置的信息,当没有选择设置或选择的是级联设置的时候为 `null`
|
||||
- `list`: 这个设置的选择栈
|
||||
- `text`: 显示的文字信息,经由 `split` 处理,分割字符为 `\n`,可以经过 [`splitText`](../module/render-utils.md#splittext) 函数处理后直接显示
|
||||
|
||||
## constructor()
|
||||
|
||||
```ts
|
||||
interface SettingDisplayer {
|
||||
new(setting: MotaSetting): SettingDisplayer
|
||||
}
|
||||
```
|
||||
|
||||
- 构造器说明
|
||||
|
||||
传入要显示的设置实例,返回一个显示器实例
|
||||
|
||||
## add()
|
||||
|
||||
```ts
|
||||
declare function add(key: string): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
该方法用于向选择栈里面添加一个选择项,例如现在我选择了 `setting2`,那么就应该调用 `add('setting2')`
|
||||
|
||||
## cut()
|
||||
|
||||
```ts
|
||||
declare function cut(index: number, noUpdate: boolean = false): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `index`: 从第几个元素开始剪切,即第一个剪切项的索引
|
||||
- `noUpdate`: 是否不进行刷新
|
||||
|
||||
- 方法说明
|
||||
|
||||
该方法用于剪切选择栈,例如我从选择支 `s1.s2.s3.s4` 切换至了 `s1.s6`,那么应该先调用 `cut(1)`,再调用 `add('s6')`
|
||||
|
||||
## update()
|
||||
|
||||
```ts
|
||||
declare function update(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
用于更新选择栈显示信息
|
||||
|
||||
## update 事件
|
||||
|
||||
```ts
|
||||
interface SettingDisplayerEvent {
|
||||
update: (stack: string[], display: SettingDisplayInfo[]) => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
该事件会在选择栈更新时触发,传入的参数分别是当前的选择栈和当前选择栈显示信息
|
108
docs/api/class/sound-controller.md
Normal file
108
docs/api/class/sound-controller.md
Normal file
@ -0,0 +1,108 @@
|
||||
# 类 SoundController
|
||||
|
||||
渲染进程类,游戏进程不能直接使用,继承自 [`ResourceController`](./resource-controller.md)
|
||||
|
||||
- 实例方法
|
||||
- [`add`](#add)
|
||||
- [`play`](#play)
|
||||
- [`stop`](#stop)
|
||||
- [`stopById`](#stopbyid)
|
||||
- [`stopAll`](#stopall)
|
||||
- [`get`](#get)
|
||||
- [`getPlaying`](#getplaying)
|
||||
|
||||
## add()
|
||||
|
||||
```ts
|
||||
declare function add(uri: string, data: ArrayBuffer): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `uri`: 音频的 uri,由于音频也是一种资源,因此格式为`sounds.xxx`
|
||||
- `data`: 音频的 ArrayBuffer 信息,会被解析为 AudioBuffer
|
||||
|
||||
- 方法说明
|
||||
|
||||
添加一个新的音频
|
||||
|
||||
## play()
|
||||
|
||||
```ts
|
||||
declare function play(sound: string, end?: () => void): number
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `sound`: 音频名称,直接填写名称即可,不需填写 `sounds.xxx`
|
||||
- `end`: 当任意一个同名音效播放完毕后执行的函数
|
||||
|
||||
- 方法说明
|
||||
|
||||
播放一个音频
|
||||
|
||||
- 返回值
|
||||
|
||||
本次播放的唯一标识符
|
||||
|
||||
## stop()
|
||||
|
||||
```ts
|
||||
declare function stop(id: number): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `id`: 要停止播放的音效的唯一标识符
|
||||
|
||||
- 方法说明
|
||||
|
||||
根据音效的唯一标识符停止播放一个音效
|
||||
|
||||
## stopById()
|
||||
|
||||
```ts
|
||||
declare function stopById(id: string): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `id`: 要停止播放的音效的名称
|
||||
|
||||
- 方法说明
|
||||
|
||||
根据音效的名称停止播放所有对应的音效
|
||||
|
||||
## stopAll()
|
||||
|
||||
```ts
|
||||
declare function stopAll(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
停止播放所有音效
|
||||
|
||||
## get()
|
||||
|
||||
```ts
|
||||
declare function get(id: string): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `id`: 音效名称,注意不是 uri
|
||||
|
||||
- 方法说明
|
||||
|
||||
根据音效名称获取音效实例
|
||||
|
||||
## getPlaying()
|
||||
|
||||
```ts
|
||||
declare function getPlaying(): string[]
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
获取所有正在播放的音效名称
|
150
docs/api/class/sound-effect.md
Normal file
150
docs/api/class/sound-effect.md
Normal file
@ -0,0 +1,150 @@
|
||||
# 类 SoundEffect
|
||||
|
||||
渲染进程类,游戏进程不能直接使用,继承自 [`AudioPlayer`](./audio-player.md)
|
||||
|
||||
- 实例成员
|
||||
- [`gain`](#gain)
|
||||
- [`panner`](#panner)
|
||||
- [`volume`](#volume)
|
||||
- [`stereo`](#stereo)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`protected initAudio`](#protected-initaudio)
|
||||
- [`playSE`](#playse)
|
||||
- [`stopAll`](#stopall)
|
||||
- [`stopByIndex`](#stopbyindex)
|
||||
- [`setPanner`](#setpanner)
|
||||
- 静态成员
|
||||
- [`playIndex`](#playindex)
|
||||
- [`volume`](#static-volume)
|
||||
- [`disable`](#disable)
|
||||
|
||||
## gain
|
||||
|
||||
```ts
|
||||
declare var gain: GainNode
|
||||
```
|
||||
|
||||
## panner
|
||||
|
||||
```ts
|
||||
declare var panner: PannerNode
|
||||
```
|
||||
|
||||
## volume
|
||||
|
||||
```ts
|
||||
declare var volume: number
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
当前音效的音量
|
||||
|
||||
## stereo
|
||||
|
||||
```ts
|
||||
declare var stereo: boolean
|
||||
```
|
||||
|
||||
- 成员说明
|
||||
|
||||
是否启用立体声
|
||||
|
||||
## constructor()
|
||||
|
||||
```ts
|
||||
interface SoundEffect {
|
||||
new(data: ArrayBuffer, stereo: boolean = true): SoundEffect
|
||||
}
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `data`: 音频的 `ArrayBuffer` 数据
|
||||
- `stereo`: 是否启用立体声,默认启用
|
||||
|
||||
## protected initAudio()
|
||||
|
||||
```ts
|
||||
declare function initAudio(stereo: boolean = true): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
初始化音频,设置音频路由线路
|
||||
|
||||
- 不启用立体声:source -> gain -> destination
|
||||
- 启用立体声:source -> panner -> gain -> destination
|
||||
|
||||
## playSE()
|
||||
|
||||
```ts
|
||||
declare function playSE(): number
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
播放这个音效
|
||||
|
||||
- 返回值
|
||||
|
||||
本次播放的唯一标识符
|
||||
|
||||
## stopAll()
|
||||
|
||||
```ts
|
||||
declare function stopAll(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
停止这个音效的所有播放
|
||||
|
||||
## stopByIndex()
|
||||
|
||||
```ts
|
||||
declare function stopByIndex(index: number): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
根据播放的唯一标识符停止音效播放
|
||||
|
||||
## setPanner()
|
||||
|
||||
```ts
|
||||
declare function setPanner(source?: Partial<Panner>, listener?: Partial<Listener>): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
设置立体声信息,参考[立体声](../../guide/audio.md#播放立体声)
|
||||
|
||||
## playIndex
|
||||
|
||||
```ts
|
||||
declare var playIndex: number
|
||||
```
|
||||
|
||||
- 静态成员
|
||||
|
||||
## static volume
|
||||
|
||||
```ts
|
||||
declare var volume: number
|
||||
```
|
||||
|
||||
- 静态成员说明
|
||||
|
||||
控制所有音效的音量
|
||||
|
||||
## disable
|
||||
|
||||
```ts
|
||||
declare var disable: boolean
|
||||
```
|
||||
|
||||
- 静态成员说明
|
||||
|
||||
音效是否被关闭
|
223
docs/api/class/ui-controller.md
Normal file
223
docs/api/class/ui-controller.md
Normal file
@ -0,0 +1,223 @@
|
||||
# 类 UiController
|
||||
|
||||
渲染进程类,游戏进程无法直接使用,继承自 [`Focus`](./focus.md)
|
||||
|
||||
- 实例成员
|
||||
- [`list`](#list)
|
||||
- [`num`](#num)
|
||||
- [`show`](#show)
|
||||
- 实例方法
|
||||
- 构造器[`constructor`](#constructor)
|
||||
- [`showEnd`](#showend)
|
||||
- [`showAll`](#showall)
|
||||
- [`get`](#get)
|
||||
- [`holdOn`](#holdon)
|
||||
- [`close`](#close)
|
||||
- [`closeByName`](#closebyname)
|
||||
- [`open`](#open)
|
||||
- [`register`](#register)
|
||||
- [`unregister`](#unregister)
|
||||
- [`focusByNum`](#focusbynum)
|
||||
- [`getByNum`](#getbynum)
|
||||
- [`hasName`](#hasname)
|
||||
- 静态成员
|
||||
- [`list`](#static-list)
|
||||
- 实例事件
|
||||
- [`start`](#start-事件)
|
||||
- [`end`](#end-事件)
|
||||
|
||||
## list
|
||||
|
||||
```ts
|
||||
declare var list: Record<string, GameUi>
|
||||
```
|
||||
|
||||
## num
|
||||
|
||||
```ts
|
||||
declare var num: number
|
||||
```
|
||||
|
||||
## show
|
||||
|
||||
```ts
|
||||
declare var show: 'end' | 'all'
|
||||
```
|
||||
|
||||
## constructor()
|
||||
|
||||
```ts
|
||||
interface UiController {
|
||||
new(equal?: boolean): UiController
|
||||
}
|
||||
```
|
||||
|
||||
## showEnd()
|
||||
|
||||
```ts
|
||||
declare function showEnd(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
设置为只显示最后一个 ui
|
||||
|
||||
## showAll()
|
||||
|
||||
```ts
|
||||
declare function showAll(): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
设置为显示所有 ui
|
||||
|
||||
## get()
|
||||
|
||||
```ts
|
||||
declare function get(id: string): GameUi
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
通过 ui 的 id 获取到注册的 `GameUi` 实例
|
||||
|
||||
## holdOn()
|
||||
|
||||
```ts
|
||||
declare function holdOn(): { end(): void }
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
暂时保持下一次 ui 关闭不会引起闪烁现象,参考[防闪烁处理](../../guide/ui-control.md#防闪烁处理)
|
||||
|
||||
- 返回值
|
||||
|
||||
返回值是一个对象,包含一个 `end` 方法,用于结束此次的防闪烁处理,如果没有 ui 已经打开,那么会立刻关闭 ui 界面
|
||||
|
||||
## close()
|
||||
|
||||
```ts
|
||||
declare function close(num: number): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
根据 ui 的唯一标识符关闭一个 ui,如果这个控制器是非平等控制器,那么会同时关闭之后的所有 ui
|
||||
|
||||
## closeByName()
|
||||
|
||||
```ts
|
||||
declare function closeByName(id: string): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
根据 ui 的名称(id)关闭一个 ui,如果是非平等控制器,在第一个匹配的 ui 后的所有 ui 也会一同关闭
|
||||
|
||||
## open()
|
||||
|
||||
```ts
|
||||
declare function open(id: string, vBind?: any, vOn?: any): number
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `id`: 要打开的 ui 的名称(id)
|
||||
- `vBind`: 要传递给 ui 的参数(props)
|
||||
- `vOn`: 要监听 ui 的事件(emits)
|
||||
|
||||
- 方法说明
|
||||
|
||||
打开一个指定的 ui,同时可以为其指定参数与监听的事件,返回打开的 ui 的唯一标识符
|
||||
|
||||
- 返回值
|
||||
|
||||
打开的 ui 的唯一标识符,可以用来关闭这个 ui
|
||||
|
||||
## register()
|
||||
|
||||
```ts
|
||||
declare function register(...ui: GameUi[]): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
注册若干个 ui,每个 ui 都是一个 `GameUi` 实例,对于同名(id 相同)的 ui,会直接覆盖
|
||||
|
||||
- 示例
|
||||
|
||||
```js
|
||||
myUi.register(new GameUi('ui1', ui1), new GameUi('ui2', ui2));
|
||||
```
|
||||
|
||||
## unregister()
|
||||
|
||||
```ts
|
||||
declare function unregister(...id: string[]): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
用于取消注册若干个 ui,传入 ui 的名称(id)作为参数
|
||||
|
||||
## focusByNum()
|
||||
|
||||
```ts
|
||||
declare function focusByNum(num: number): void
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
根据 ui 的唯一标识符聚焦 ui
|
||||
|
||||
## getByNum()
|
||||
|
||||
```ts
|
||||
declare function getByNum(num: number): IndexedGameUi | undefined
|
||||
```
|
||||
|
||||
## hasName()
|
||||
|
||||
```ts
|
||||
declare function hasName(id: string): boolean
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
根据 ui 的名称(id)判断一个 ui 是否被开启
|
||||
|
||||
## static list
|
||||
|
||||
```ts
|
||||
declare var list: UiController[]
|
||||
```
|
||||
|
||||
- 静态成员说明
|
||||
|
||||
描述了所有被创建过的 ui 控制器实例
|
||||
|
||||
## start 事件
|
||||
|
||||
```ts
|
||||
interface UiControllerEvent {
|
||||
start: () => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当 ui 界面被打开,也就是当被打开的 ui 个数从 0 变为 1 时,触发该事件
|
||||
|
||||
## end 事件
|
||||
|
||||
```ts
|
||||
interface UiControllerEvent {
|
||||
end: () => void
|
||||
}
|
||||
```
|
||||
|
||||
- 事件说明
|
||||
|
||||
当 ui 界面被关闭,也就是当被打开的 ui 个数从 1 变为 0 时,触发该事件。如果当前处于防闪烁状态,那么不会触发
|
@ -0,0 +1,158 @@
|
||||
# 函数 API
|
||||
|
||||
此处列出所有的单个函数的 API,函数 API 使用 `Mota.requireAll('fn')` 获取
|
||||
|
||||
## getHeroStatusOn()
|
||||
|
||||
```ts
|
||||
declare function getHeroStatusOn(name: 'all', floorId?: string): HeroStatus
|
||||
declare function getHeroStatusOn(name: string, floorId?: string): any
|
||||
declare function getHeroStatusOn(name: string[], floorId?: string): Partial<HeroStatus>
|
||||
```
|
||||
|
||||
- 第一种用法
|
||||
|
||||
获取勇士的所有真实属性
|
||||
|
||||
- 第二种用法
|
||||
|
||||
获取勇士的单个真实属性
|
||||
|
||||
- 第三种用法
|
||||
|
||||
获取勇士的指定真实属性
|
||||
|
||||
## getHeroStatusOf()
|
||||
|
||||
```ts
|
||||
declare function getHeroStatusOf(
|
||||
status: Partial<HeroStatus>,
|
||||
name: 'all',
|
||||
floorId?: string
|
||||
): HeroStatus
|
||||
declare function getHeroStatusOf(
|
||||
status: Partial<HeroStatus>,
|
||||
name: string,
|
||||
floorId?: string
|
||||
): any
|
||||
declare function getHeroStatusOf(
|
||||
status: Partial<HeroStatus>,
|
||||
name: string[],
|
||||
floorId?: string
|
||||
): Partial<HeroStatus>
|
||||
```
|
||||
|
||||
三种用法与 [`getHeroStatusOn`](#getherostatuson) 类似,只不过多了一个部分指定勇士原始属性的参数
|
||||
|
||||
## getEnemy()
|
||||
|
||||
```ts
|
||||
declare function getEnemy(
|
||||
x: number,
|
||||
y: number,
|
||||
floorId: string = core.status.floorId
|
||||
): DamageEnemy
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
获取到指定楼层指定位置的怪物实例
|
||||
|
||||
## m()
|
||||
|
||||
```ts
|
||||
declare function m(): MComponent
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
构造一个 `MComponent` 实例,等价于 `new MComponent()`
|
||||
|
||||
## unwrapBinary()
|
||||
|
||||
```ts
|
||||
declare function unwrapBinary(bin: number): AssistHotkey
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
将一个三位二进制解析为辅助按键对象信息,表示三个辅助按键是否都被按下
|
||||
|
||||
- 接口 `AssistHotkey` 参考 [类 Hotkey](./class/hotkey.md#部分接口与类型说明)
|
||||
|
||||
- 示例
|
||||
|
||||
```ts
|
||||
unwrapBinary(0b111); // { ctrl: true, shift: true, alt: true }
|
||||
```
|
||||
|
||||
## checkAssist()
|
||||
|
||||
```ts
|
||||
declare function checkAssist(bin: number, key: KeyCode): boolean
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
判断一个三位二进制数据中指定按键是否被按下
|
||||
|
||||
- 示例
|
||||
|
||||
```ts
|
||||
checkAssist(0b000, KeyCode.Ctrl); // false
|
||||
```
|
||||
|
||||
## isAssist()
|
||||
|
||||
```ts
|
||||
declare function isAssist(key: KeyCode): boolean
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
判断一个按键是否是辅助按键
|
||||
|
||||
- 示例
|
||||
|
||||
```ts
|
||||
isAssist(KeyCode.KeyX); // false
|
||||
```
|
||||
|
||||
## generateKeyboardEvent()
|
||||
|
||||
```ts
|
||||
declare function generateKeyboardEvent(key: KeyCode, assist: number): KeyboardEvent
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `key`: 占位参数,目前无用
|
||||
- `assist`: 按下了哪些辅助按键
|
||||
|
||||
- 函数说明
|
||||
|
||||
生成拟真的 `KeyboardEvent` 事件
|
||||
|
||||
## addAnimate()
|
||||
|
||||
```ts
|
||||
declare function addAnimate(fn: (time: number) => void): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `fn`: 每个动画帧(即怪物或者动画图块动一次)执行的函数
|
||||
|
||||
- 函数说明
|
||||
|
||||
添加一个在每个动画帧,也就是每个怪物或者动画图块动一次的时候,执行的函数
|
||||
|
||||
## removeAnimate()
|
||||
|
||||
```ts
|
||||
declare function removeAnimate(fn: (time: number) => void): void
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
删除一个由 [`addAnimate`](#addanimate) 添加的动画帧函数,注意要传入函数的引用
|
@ -0,0 +1,81 @@
|
||||
# API 列表
|
||||
|
||||
新样板的所有 API 列表(不包括插件和第三方库)
|
||||
|
||||
## 系统 API
|
||||
|
||||
- [`Mota.require`](./system.md#require)
|
||||
- [`Mota.requireAll`](./system.md#requireall)
|
||||
- [`Mota.rewrite`](./system.md#rewrite)
|
||||
- [`Mota.r`](./system.md#r)
|
||||
- [`Mota.rf`](./system.md#rf)
|
||||
- [`Mota.Plugin`](./system.md#plugin)
|
||||
- [`Mota.Package`](./system.md#package)
|
||||
|
||||
## 类
|
||||
|
||||
- [`EventEmitter`](./class/event-emitter.md)
|
||||
- [`IndexedEventEmitter`](./class/indexed-event-emitter.md)
|
||||
- [`Disposable`](./class/disposable.md)
|
||||
- [`GameStorage`](./class/game-storage.md)
|
||||
- [`MotaSetting`](./class/mota-setting.md)
|
||||
- [`SettingDisplayer`](./class/setting-displayer.md)
|
||||
- [`Focus`](./class/focus.md)
|
||||
- [`GameUi`](./class/game-ui.md)
|
||||
- [`UiController`](./class/ui-controller.md)
|
||||
- [`Hotkey`](./class/hotkey.md)
|
||||
- [`Keyboard`](./class/keyboard.md)
|
||||
- [`CustomToolbar`](./class/custom-toolbar.md)
|
||||
- [`AudioPlayer`](./class/audio-player.md)
|
||||
- [`SoundEffect`](./class/sound-effect.md)
|
||||
- [`SoundController`](./class/sound-controller.md)
|
||||
- [`BgmController`](./class/bgm-controller.md)
|
||||
- [`ResourceController`](./class/resource-controller.md)
|
||||
- [`MComponent`](./class/m-component.md)
|
||||
- [`Range`](./class/range.md)
|
||||
- [`EnemyCollection`](./class/enemy-collection.md)
|
||||
- [`DamageEnemy`](./class/damage-enemy.md)
|
||||
|
||||
## 函数
|
||||
|
||||
- [`getHeroStatusOn`](./function#getherostatuson)
|
||||
- [`getHeroStatusOf`](./function#getherostatusof)
|
||||
- [`getEnemy`](./function#getenemy)
|
||||
- [`m`](./function#m)
|
||||
- [`unwrapBinary`](./function#unwrapbinary)
|
||||
- [`checkAssist`](./function#checkassist)
|
||||
- [`isAssist`](./function#isassist)
|
||||
- [`generateKeyboardEvent`](./function#generatekeyboardevent)
|
||||
- [`addAnimate`](./function#addanimate)
|
||||
- [`removeAnimate`](./function#removeanimate)
|
||||
|
||||
## 变量
|
||||
|
||||
- [`loading`](./var#loading)
|
||||
- [`hook`](./var#hook)
|
||||
- [`gameListener`](./var#gamelistener)
|
||||
- [`mainSetting`](./var#mainsetting)
|
||||
- [`gameKey`](./var#gamekey)
|
||||
- [`mainUi`](./var#mainui)
|
||||
- [`fixedUi`](./var#fixedui)
|
||||
- [`KeyCode`](./var#keycode)
|
||||
- [`ScanCode`](./var#scancode)
|
||||
- [`bgm`](./var#bgm)
|
||||
- [`sound`](./var#sound)
|
||||
- [`settingStorage`](./var#settingstorage)
|
||||
- [`status`](./var#status)
|
||||
- [`enemySpecials`](./var#enemyspecials)
|
||||
|
||||
## 模块
|
||||
|
||||
- [`CustomComponents`](./module/custom-components.md)
|
||||
- [`Use`](./module/use.md)
|
||||
- [`Mark`](./module/mark.md)
|
||||
- [`KeyCodes`](./module/key-codes.md)
|
||||
- [`UITools`](./module/ui-tools.md)
|
||||
- [`Damage`](./module/damage.md)
|
||||
- [`UI`](./module/ui.md)
|
||||
- [`UIComponents`](./module/ui-components.md)
|
||||
- [`MCGenerator`](./module/mc-generator.md)
|
||||
- [`RenderUtils](./module/render-utils.md)
|
||||
- [`MiscComponents`](./module/misc-components.md)
|
57
docs/api/module/custom-components.md
Normal file
57
docs/api/module/custom-components.md
Normal file
@ -0,0 +1,57 @@
|
||||
# 模块 CustomComponents
|
||||
|
||||
渲染进程模块,游戏进程不能直接使用。
|
||||
|
||||
这个模块包含了一些系统使用的函数式组件。
|
||||
|
||||
- 函数
|
||||
- [`createSettingComponents`](#createsettingcomponents)
|
||||
- [`createToolbarComponents`](#createtoolbarcomponents)
|
||||
- [`createToolbarEditorComponents`](#createtoolbareditorcomponents)
|
||||
|
||||
## createSettingComponents()
|
||||
|
||||
```ts
|
||||
declare function createSettingComponents(): {
|
||||
Default: SettingComponent
|
||||
Boolean: SettingComponent
|
||||
Number: SettingComponent
|
||||
HotkeySetting: SettingComponent
|
||||
ToolbarEditor: SettingComponent
|
||||
Radio: (items: string[]) => SettingComponent
|
||||
}
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
获取所有的设置的编辑组件,参考 [指南](../../guide/setting.md#注册设置)
|
||||
|
||||
## createToolbarComponents()
|
||||
|
||||
```ts
|
||||
declare function createToolbarComponents(): {
|
||||
DefaultTool: CustomToolbarComponent;
|
||||
KeyTool: CustomToolbarComponent;
|
||||
ItemTool: CustomToolbarComponent;
|
||||
AssistKeyTool: CustomToolbarComponent;
|
||||
}
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
获取所有的自定义工具项显示组件
|
||||
|
||||
## createToolbarEditorComponents()
|
||||
|
||||
```ts
|
||||
declare function createToolbarEditorComponents(): {
|
||||
DefaultTool: CustomToolbarComponent;
|
||||
KeyTool: CustomToolbarComponent;
|
||||
ItemTool: CustomToolbarComponent;
|
||||
AssistKeyTool: CustomToolbarComponent;
|
||||
}
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
获取所有自定义工具项的编辑组件,即在系统设置的自定义工具栏项内的编辑组件
|
70
docs/api/module/damage.md
Normal file
70
docs/api/module/damage.md
Normal file
@ -0,0 +1,70 @@
|
||||
# 模块 Damage
|
||||
|
||||
游戏进程类,渲染进程也可以使用
|
||||
|
||||
包含了部分伤害计算相关的函数与变量
|
||||
|
||||
- 变量
|
||||
- [`haloSpecials`](#halospecials)
|
||||
- [`changeableHaloValue`](#changeablehalovalue)
|
||||
- [`realStatus`](#realstatus)
|
||||
- 函数
|
||||
- [`calDamageWith`](#caldamagewith)
|
||||
- [`ensureFloorDamage`](#ensurefloordamage)
|
||||
- [`getSingleEnemy`](#getsingleenemy)
|
||||
|
||||
## haloSpecials
|
||||
|
||||
```ts
|
||||
declare var haloSpecials: Set<number>
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
保存了所有的光环类属性
|
||||
|
||||
## changeableHaloValue
|
||||
|
||||
```ts
|
||||
declare var changeableHaloValue: Map<number, string[]>
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
包含了所有会被第一类光环影响的特殊属性数值
|
||||
|
||||
## realStatus
|
||||
|
||||
```ts
|
||||
declare var realStatus: string[]
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
计算伤害时会用到的勇士属性,攻击防御,其余的不会有 buff 加成,直接从 core.status.hero 取
|
||||
|
||||
## calDamageWith()
|
||||
|
||||
```ts
|
||||
declare function calDamageWith(info: EnemyInfo, hero: Partial<HeroStatus>): number | null
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
计算怪物伤害的函数,示例参考插件
|
||||
|
||||
## ensureFloorDamage()
|
||||
|
||||
```ts
|
||||
declare function ensureFloorDamage(floor: string): void
|
||||
```
|
||||
|
||||
## getSingleEnemy()
|
||||
|
||||
```ts
|
||||
declare function getSingleEnemy(id: string): DamageEnemy
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
用于获取一个不在地图上的单个怪物,不会受到任何光环的影响
|
5
docs/api/module/keyCodes.md
Normal file
5
docs/api/module/keyCodes.md
Normal file
@ -0,0 +1,5 @@
|
||||
# 模块 KeyCodes
|
||||
|
||||
渲染进程类,游戏进程不可直接使用
|
||||
|
||||
摘自 vscode 的 keyCodes.ts,这里不再赘述,直接参考 vscode 源码即可,里面常用的两个枚举 `KeyCode` 及 `ScanCode` 已经在变量 API 中列举。
|
51
docs/api/module/mark.md
Normal file
51
docs/api/module/mark.md
Normal file
@ -0,0 +1,51 @@
|
||||
# 模块 Mark
|
||||
|
||||
渲染进程模块,游戏进程不能直接使用
|
||||
|
||||
该模块包含了标记怪物相关的功能
|
||||
|
||||
- 函数
|
||||
- [`markEnemy`](#markenemy)
|
||||
- [`unmarkEnemy`](#unmarkenemy)
|
||||
- [`checkMarkedEnemy`](#checkmarkedenemy)
|
||||
- [`hasMarkedEnemy`](#hasmarkedenemy)
|
||||
|
||||
## markEnemy()
|
||||
|
||||
```ts
|
||||
declare function markEnemy(id: string): void
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
标记一个指定 id 的怪物
|
||||
|
||||
## unmarkEnemy()
|
||||
|
||||
```ts
|
||||
declare function unmarkEnemy(id: string): void
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
取消标记指定 id 的怪物
|
||||
|
||||
## checkMarkedEnemy()
|
||||
|
||||
```ts
|
||||
declare function checkMarkedEnemy(): void
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
检查所有标记的怪物状态
|
||||
|
||||
## hasMarkedEnemy()
|
||||
|
||||
```ts
|
||||
declare function hasMarkedEnemy(id: string): boolean
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
判断一个怪物是否被标记
|
5
docs/api/module/mc-generator.md
Normal file
5
docs/api/module/mc-generator.md
Normal file
@ -0,0 +1,5 @@
|
||||
# 模块 MCGenerator
|
||||
|
||||
渲染进程模块,游戏进程不能直接使用。
|
||||
|
||||
参考 [UI 编写](../../guide/ui.md)
|
11
docs/api/module/misc-components.md
Normal file
11
docs/api/module/misc-components.md
Normal file
@ -0,0 +1,11 @@
|
||||
# 模块 MiscComponents
|
||||
|
||||
渲染进程模块,游戏进程不能直接使用
|
||||
|
||||
包含了一些零散的 UI
|
||||
|
||||
- [`VirtualKey`](#virtualkey)
|
||||
|
||||
## VirtualKey
|
||||
|
||||
与 [`Keyboard`](./ui-components.md#keyboard) 一样
|
5
docs/api/module/render-utils.md
Normal file
5
docs/api/module/render-utils.md
Normal file
@ -0,0 +1,5 @@
|
||||
# 模块 RenderUtils
|
||||
|
||||
渲染进程类,游戏进程不能直接使用
|
||||
|
||||
包含了渲染进程中会用到的一些功能函数,可以查看类型标注来看有哪些,一般都有注释,这里不再赘述
|
86
docs/api/module/ui-components.md
Normal file
86
docs/api/module/ui-components.md
Normal file
@ -0,0 +1,86 @@
|
||||
# 模块 UIComponents
|
||||
|
||||
渲染进程模块,游戏进程不能直接使用
|
||||
|
||||
包含了可以用在 UI 里面的可复用组件
|
||||
|
||||
- [`Box`](#box)
|
||||
- [`BoxAnimate`](#boxanimate)
|
||||
- [`Column`](#column)
|
||||
- [`EnemyOne`](#enemyone)
|
||||
- [`Scroll`](#scroll)
|
||||
- `EnemyCritical`
|
||||
- `EnemySpecial`
|
||||
- `EnemyTarget`
|
||||
- [`Keyboard`](#keyboard)
|
||||
|
||||
## Box
|
||||
|
||||
一个可以拖动的盒子,例如状态栏
|
||||
|
||||
- 参数(均为可选)
|
||||
- `dragable`: 盒子是否可以拖动
|
||||
- `resizeable`: 盒子是否可以自定义大小
|
||||
- `v-model:left`: 盒子的左上角横坐标
|
||||
- `v-model:top`: 盒子的左上角纵坐标
|
||||
- `v-model:width`: 盒子的宽度
|
||||
- `v-model:height`: 盒子的高度
|
||||
- 插槽
|
||||
- `default`: 盒子中显示的内容
|
||||
|
||||
## BoxAnimate
|
||||
|
||||
一个显示图块动画的组件,例如怪物手册中的怪物图标
|
||||
|
||||
- 参数
|
||||
- `id`: 显示的图标 id
|
||||
- `noboarder`: 可选,是否没有边框与背景
|
||||
- `width`: 可选,图标的宽度,默认为 32
|
||||
- `height`: 可选,图标的高度,默认为 32
|
||||
|
||||
## Column
|
||||
|
||||
一个分为两栏进行显示的组件,例如设置快捷键中左右两侧中左侧显示按键分组,右侧显示组别信息
|
||||
|
||||
- 参数(均为可选)
|
||||
- `width`: 组件整体的宽度,占画面的百分比,一般不建议超过 90
|
||||
- `height`: 组件整体的高度,占画面的百分比,一般不建议超过 90
|
||||
- `left`: 左侧栏占比,范围 0-100
|
||||
- `right`: 右侧栏占比,范围 0-100
|
||||
- 事件
|
||||
- `close`: 当点击左上角的返回后触发这个事件
|
||||
- 插槽
|
||||
- `left`: 左侧栏显示的内容
|
||||
- `right`: 右侧栏显示的内容
|
||||
|
||||
## EnemyOne
|
||||
|
||||
显示单个怪物信息,就是怪物手册中的单个怪物信息
|
||||
|
||||
- 参数
|
||||
- `enemy`: 怪物信息,类型为 `ToShowEnemy`
|
||||
- `selected`: 这个怪物是否被选中
|
||||
- 事件
|
||||
- `hover`: 当鼠标放到这个怪物身上或在怪物身上移动时触发
|
||||
- `select`: 当选中这个怪物时触发
|
||||
|
||||
## Scroll
|
||||
|
||||
滚动条组件,例如状态栏等
|
||||
|
||||
- 参数(均为可选)
|
||||
- `v-model:now`: 当前滚动条位置
|
||||
- `type`: 滚动条模式,`horizontal` 还是 `vertical`,默认为竖直,即 `vertical`
|
||||
- `v-model:drag`: 是否正在拖动
|
||||
- `width`: 滚动条的宽度
|
||||
- `v-model:update`: 取反以更新滚动条信息
|
||||
- `noScroll`: 不显示滚动条,例如状态栏
|
||||
- 插槽
|
||||
- `default`: 滚动条内的显示内容
|
||||
|
||||
## Keyboard
|
||||
|
||||
虚拟键盘组件
|
||||
|
||||
- 参数
|
||||
- `keyboard`: 要显示哪个虚拟键盘
|
5
docs/api/module/ui-tools.md
Normal file
5
docs/api/module/ui-tools.md
Normal file
@ -0,0 +1,5 @@
|
||||
# 模块 UITools
|
||||
|
||||
渲染进程类,游戏进程不能直接使用
|
||||
|
||||
包含了样板自带 UI 所使用到的部分功能性函数,内容过多,这里不再赘述,一般也用不到,如果想了解的话直接在群里面问就行,或者去查看源码。拥有完整的类型标注
|
24
docs/api/module/ui.md
Normal file
24
docs/api/module/ui.md
Normal file
@ -0,0 +1,24 @@
|
||||
# 模块 UI
|
||||
|
||||
渲染进程模块,游戏进程不能直接使用
|
||||
|
||||
包含游戏中的所有 UI
|
||||
|
||||
- `Book`
|
||||
- `BookDetail`
|
||||
- `Chapter`
|
||||
- `Equipbox`
|
||||
- `Fixed`
|
||||
- `FixedDetail`
|
||||
- `Fly`
|
||||
- `Marked`
|
||||
- `Settings`
|
||||
- `Shop`
|
||||
- `Start`
|
||||
- `StatusBar`
|
||||
- `Toolbox`
|
||||
- `Hotkey`
|
||||
- `Toolbar`
|
||||
- `ToolEditor`
|
||||
|
||||
以上 UI 中均包含 `ui` 和 `num` 两个参数
|
106
docs/api/module/use.md
Normal file
106
docs/api/module/use.md
Normal file
@ -0,0 +1,106 @@
|
||||
# 模块 Use
|
||||
|
||||
渲染进程模块,游戏进程不能直接使用
|
||||
|
||||
此模块包含了若干与 DOM 相关的功能函数与变量
|
||||
|
||||
- 变量
|
||||
- [`isMobile`](#ismobile)
|
||||
- 函数
|
||||
- [`useDrag`](#usedrag)
|
||||
- [`cancelGlobalDrag`](#cancelglobaldrag)
|
||||
- [`useWheel`](#usewheel)
|
||||
- [`useUp`](#useup)
|
||||
- [`useDown`](#usedown)
|
||||
|
||||
## isMobile
|
||||
|
||||
```ts
|
||||
declare var isMobile: boolean
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
表明是否是移动端,不过应该是没用的。。
|
||||
|
||||
## useDrag()
|
||||
|
||||
```ts
|
||||
declare function useDrag(
|
||||
ele: HTMLElement | HTMLElement[],
|
||||
fn: DragFn,
|
||||
ondown?: DragFn,
|
||||
onup?: (e: MouseEvent | TouchEvent) => void,
|
||||
global: boolean = false
|
||||
): void
|
||||
```
|
||||
|
||||
- 类型说明
|
||||
|
||||
```ts
|
||||
type DragFn = (x: number, y: number, e: MouseEvent | TouchEvent) => void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `ele`: 目标元素,当为全局拖拽时,传入数组表示所有元素共用一个全局拖拽函数
|
||||
- `fn`: 拖拽时触发的函数,传入 x y 和鼠标事件或点击事件
|
||||
- `ondown`: 鼠标按下时执行的函数
|
||||
- `global`: 是否全局拖拽,即拖拽后鼠标或手指离开元素后是否依然视为正在拖拽
|
||||
|
||||
- 函数说明
|
||||
|
||||
向一个或若干个元素添加拖拽事件,如果是全局拖拽,当目标元素被销毁后,必须调用 `cancelGlobalDrag` 函数
|
||||
|
||||
## cancelGlobalDrag()
|
||||
|
||||
```ts
|
||||
declare function cancelGlobalDrag(fn: DragFn): void
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
取消一个全局拖拽函数,传入拖拽函数引用
|
||||
|
||||
## useWheel()
|
||||
|
||||
```ts
|
||||
declare function useWheel(
|
||||
ele: HTMLElement,
|
||||
fn: (x: number, y: number, z: number, e: WheelEvent) => void
|
||||
): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `ele`: 要添加滚轮监听函数的元素
|
||||
- `fn`: 当滚轮滚动时,执行的函数
|
||||
|
||||
- 函数说明
|
||||
|
||||
当触发滚轮时执行函数
|
||||
|
||||
## useUp()
|
||||
|
||||
```ts
|
||||
declare function useUp(ele: HTMLElement, fn: DragFn): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `ele`: 要监听的元素
|
||||
- `fn`: 当鼠标抬起或手指抬起时,触发的函数
|
||||
|
||||
- 函数说明
|
||||
|
||||
当手指或鼠标抬起时触发函数
|
||||
|
||||
## useDown()
|
||||
|
||||
```ts
|
||||
declare function useDown(ele: HTMLElement, fn: DragFn): void
|
||||
```
|
||||
|
||||
- 函数说明
|
||||
|
||||
与 [`useUp`](#useup) 类似,不过触发时机变为了手指或鼠标按下时触发
|
130
docs/api/system.md
Normal file
130
docs/api/system.md
Normal file
@ -0,0 +1,130 @@
|
||||
# 系统 API
|
||||
|
||||
系统 API 处于对象 `Mota` 上,是使用新样板 API 的根对象
|
||||
|
||||
## require()
|
||||
|
||||
```ts
|
||||
declare function require(type: InterfaceType, key: string): any
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `type`: 要获取的 API 类型,目前包含 `class` `fn` `var` `module` 四种类型,分别表示类、函数、变量、模块
|
||||
- `key`: 要获取的 API 的名称
|
||||
|
||||
- 方法说明
|
||||
|
||||
获取一个样板接口
|
||||
|
||||
## requireAll()
|
||||
|
||||
```ts
|
||||
declare function requireAll(type: InterfaceType): any
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
获取一种 API 类型的所有接口,并以对象的形式返回
|
||||
|
||||
## rewrite()
|
||||
|
||||
```ts
|
||||
declare function rewrite(
|
||||
base: any,
|
||||
key: string,
|
||||
type: 'full' | 'add' | 'front',
|
||||
re: Function,
|
||||
bind?: any,
|
||||
rebind?: any
|
||||
): Function
|
||||
```
|
||||
|
||||
- 方法说明
|
||||
|
||||
复写函数,参考[函数复写](../guide/system.md#函数复写)
|
||||
|
||||
## r()
|
||||
|
||||
```ts
|
||||
declare function r(fn: (packages: PackageInterface) => void, thisArg?: any): void
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `fn`: 要执行的函数,包含一个参数,表示系统使用的第三方库
|
||||
- `thisArg`: 函数执行时绑定的上下文(this 指向)
|
||||
|
||||
- 方法说明
|
||||
|
||||
在渲染进程包裹下执行一个函数
|
||||
|
||||
## rf()
|
||||
|
||||
```ts
|
||||
declare function rf(fn: Function, thisArg: any): Function
|
||||
```
|
||||
|
||||
- 参数说明
|
||||
|
||||
- `fn`: 要绑定的函数
|
||||
- `thisArg`: 函数调用时传入的上下文(this 指向)
|
||||
|
||||
- 方法说明
|
||||
|
||||
将一个函数包裹为渲染进程函数
|
||||
|
||||
## Plugin
|
||||
|
||||
```ts
|
||||
interface Plugin {
|
||||
require(key: string): any
|
||||
requireAll(): any
|
||||
register(key: string, data: any, init?: any): void
|
||||
}
|
||||
```
|
||||
|
||||
参考[指南](../guide/system.md#motaplugin)
|
||||
|
||||
系统自带插件包括
|
||||
|
||||
- 渲染进程插件
|
||||
- `shadow_r`
|
||||
- `gameShadow_r`
|
||||
- `fly_r`
|
||||
- `pop_r`
|
||||
- `frag_r`
|
||||
- `use_r`
|
||||
- `gameCanvas_r`
|
||||
- `smooth_r`
|
||||
- `shader_r`
|
||||
- 游戏进程插件
|
||||
- `utils_g`
|
||||
- `shop_g`
|
||||
- `replay_g`
|
||||
- `removeMap_g`
|
||||
- `heroFourFrames_g`
|
||||
- `rewrite_g`
|
||||
- `itemDetail_g`
|
||||
- `remainEnemy_g`
|
||||
|
||||
## Package
|
||||
|
||||
```ts
|
||||
interface Package {
|
||||
require(key: string): any
|
||||
requireAll(): any
|
||||
}
|
||||
```
|
||||
|
||||
参考[指南](../guide/system.md#motapackage)
|
||||
|
||||
系统暴露出的第三方库:
|
||||
|
||||
- `axios`
|
||||
- `chart.js`
|
||||
- `jszip`
|
||||
- `lodash`
|
||||
- `lz-string`
|
||||
- `mutate-animate`
|
||||
- `vue`
|
632
docs/api/var.md
632
docs/api/var.md
@ -0,0 +1,632 @@
|
||||
# 变量 API
|
||||
|
||||
此处列出所有的单个变量的 API,需要通过 `Mota.requireAll('var')` 获取
|
||||
|
||||
## loading
|
||||
|
||||
```ts
|
||||
declare var loading: GameLoading
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
渲染进程变量,用于控制或监听游戏的加载进程
|
||||
|
||||
- 接口 `GameLoading`,继承自 [`EventEmitter`](./class/event-emitter.md)
|
||||
|
||||
```ts
|
||||
interface GameLoading extends EventEmitter {
|
||||
addMaterialLoaded(): void
|
||||
addAutotileLoaded(): void
|
||||
onAutotileLoaded(autotiles: Record<string, HTMLImageElement>)
|
||||
}
|
||||
```
|
||||
|
||||
- 接口说明
|
||||
|
||||
以上三个方法一般都是没有调用的必要的,具体干什么的也不需要太在意,这个变量的主要功能是监听加载进程
|
||||
|
||||
- 事件说明
|
||||
|
||||
以下事件中的监听函数均没有参数或返回值
|
||||
|
||||
- `coreLoaded`: 当 `core.js` 加载完毕后触发
|
||||
- `coreInit`: 当 `core` 初始化完毕后触发,大部分情况下,需要在游戏开始时执行的脚本都应当在这个时候执行
|
||||
|
||||
## hook
|
||||
|
||||
```ts
|
||||
declare var hook: EventEmitter
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
渲染进程变量,一个用于监听事件的变量,目前包含的事件较少,包含以下事件,事件均没有参数和返回值
|
||||
|
||||
- `reset`: 当游戏初始化(每次读档和开始新游戏)时触发
|
||||
- `mounted`: 当渲染进程的根组件挂载完毕后触发
|
||||
- `statusBarUpdate`: 当状态栏更新时触发
|
||||
- `renderLoaded`: 当渲染进程加载完毕后触发
|
||||
|
||||
## gameListener
|
||||
|
||||
```ts
|
||||
declare var gameListener: GameListener
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
渲染进程变量,一个用于监听部分游戏操作的变量
|
||||
|
||||
- 接口 `GameListener`,继承自 [`EventEmitter`](./class/event-emitter.md)
|
||||
|
||||
包含以下事件:
|
||||
|
||||
- `hoverBlock`
|
||||
|
||||
```ts
|
||||
interface ListenerEvent {
|
||||
hoverBlock: (block: Block, ev: MouseEvent) => void
|
||||
}
|
||||
```
|
||||
|
||||
当鼠标移动到一个图块上时触发,参数分别是移动到的图块,以及 dom 事件参数,手机端无效
|
||||
|
||||
- `leaveBlock`
|
||||
|
||||
```ts
|
||||
interface ListenerEvent {
|
||||
leaveBlock: (block: Block, ev: MouseEvent, leaveGame: boolean) => void
|
||||
}
|
||||
```
|
||||
|
||||
当鼠标离开一个图块上时触发,前两个参数与 `hoverBlock` 事件一致,第三个参数表明鼠标是否是由于离开游戏画面而离开的图块
|
||||
|
||||
- `clickBlock`
|
||||
|
||||
```ts
|
||||
interface ListenerEvent {
|
||||
clickBlock: (block: Block, ev: MouseEvent) => void
|
||||
}
|
||||
```
|
||||
|
||||
当鼠标点击一个图块时触发,参数与 `hoverBlock` 事件一致
|
||||
|
||||
- `mouseMove`
|
||||
|
||||
```ts
|
||||
interface ListenerEvent {
|
||||
mouseMove: (ev: MouseEvent) => void
|
||||
}
|
||||
```
|
||||
|
||||
当鼠标移动时触发
|
||||
|
||||
## mainSetting
|
||||
|
||||
```ts
|
||||
declare var mainSetting: MotaSetting
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
渲染进程变量,系统设置变量,可以在道具 系统设置 中打开
|
||||
|
||||
## gameKey
|
||||
|
||||
```ts
|
||||
declare var gameKey: Hotkey
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
渲染进程变量,系统按键控制系统,不建议创建新的 `Hotkey` 实例实现自己的按键,推荐直接在这个变量上新增自己的按键
|
||||
|
||||
## mainUi
|
||||
|
||||
```ts
|
||||
declare var mainUi: UiController
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
渲染进程变量,主要 UI 控制器,UI 之间有嵌套关系
|
||||
|
||||
## fixedUi
|
||||
|
||||
```ts
|
||||
declare var fixedUi: UiController
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
渲染进程变量,平等 UI 控制器,UI 之间无嵌套关系,且互不影响,参考[UI 控制](../guide/ui-control.md#mainui-与-fixedui)
|
||||
|
||||
## KeyCode
|
||||
|
||||
```ts
|
||||
declare const enum KeyCode {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
渲染进程变量,摘自微软的 vscode 的 keyCodes.ts,描述了键盘上的所有按键,几乎不存在遗漏按键,注意对于一个键有两个功能的,例如 `1/!`,依然只会视为一个按键,以下是这个枚举从小到大的所有内容:
|
||||
|
||||
```ts
|
||||
declare const enum KeyCode {
|
||||
DependsOnKbLayout = -1,
|
||||
|
||||
/**
|
||||
* Placed first to cover the 0 value of the enum.
|
||||
*/
|
||||
Unknown = 0,
|
||||
|
||||
Backspace,
|
||||
Tab,
|
||||
Enter,
|
||||
Shift,
|
||||
Ctrl,
|
||||
Alt,
|
||||
PauseBreak,
|
||||
CapsLock,
|
||||
Escape,
|
||||
Space,
|
||||
PageUp,
|
||||
PageDown,
|
||||
End,
|
||||
Home,
|
||||
LeftArrow,
|
||||
UpArrow,
|
||||
RightArrow,
|
||||
DownArrow,
|
||||
Insert,
|
||||
Delete,
|
||||
|
||||
Digit0,
|
||||
Digit1,
|
||||
Digit2,
|
||||
Digit3,
|
||||
Digit4,
|
||||
Digit5,
|
||||
Digit6,
|
||||
Digit7,
|
||||
Digit8,
|
||||
Digit9,
|
||||
|
||||
KeyA,
|
||||
KeyB,
|
||||
KeyC,
|
||||
KeyD,
|
||||
KeyE,
|
||||
KeyF,
|
||||
KeyG,
|
||||
KeyH,
|
||||
KeyI,
|
||||
KeyJ,
|
||||
KeyK,
|
||||
KeyL,
|
||||
KeyM,
|
||||
KeyN,
|
||||
KeyO,
|
||||
KeyP,
|
||||
KeyQ,
|
||||
KeyR,
|
||||
KeyS,
|
||||
KeyT,
|
||||
KeyU,
|
||||
KeyV,
|
||||
KeyW,
|
||||
KeyX,
|
||||
KeyY,
|
||||
KeyZ,
|
||||
|
||||
Meta,
|
||||
ContextMenu,
|
||||
|
||||
F1,
|
||||
F2,
|
||||
F3,
|
||||
F4,
|
||||
F5,
|
||||
F6,
|
||||
F7,
|
||||
F8,
|
||||
F9,
|
||||
F10,
|
||||
F11,
|
||||
F12,
|
||||
F13,
|
||||
F14,
|
||||
F15,
|
||||
F16,
|
||||
F17,
|
||||
F18,
|
||||
F19,
|
||||
|
||||
NumLock,
|
||||
ScrollLock,
|
||||
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the ';:' key
|
||||
*/
|
||||
Semicolon,
|
||||
/**
|
||||
* For any country/region, the '+' key
|
||||
* For the US standard keyboard, the '=+' key
|
||||
*/
|
||||
Equal,
|
||||
/**
|
||||
* For any country/region, the ',' key
|
||||
* For the US standard keyboard, the ',<' key
|
||||
*/
|
||||
Comma,
|
||||
/**
|
||||
* For any country/region, the '-' key
|
||||
* For the US standard keyboard, the '-_' key
|
||||
*/
|
||||
Minus,
|
||||
/**
|
||||
* For any country/region, the '.' key
|
||||
* For the US standard keyboard, the '.>' key
|
||||
*/
|
||||
Period,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the '/?' key
|
||||
*/
|
||||
Slash,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the '`~' key
|
||||
*/
|
||||
Backquote,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the '[{' key
|
||||
*/
|
||||
BracketLeft,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the '\|' key
|
||||
*/
|
||||
Backslash,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the ']}' key
|
||||
*/
|
||||
BracketRight,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the ''"' key
|
||||
*/
|
||||
Quote,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
*/
|
||||
OEM_8,
|
||||
/**
|
||||
* Either the angle bracket key or the backslash key on the RT 102-key keyboard.
|
||||
*/
|
||||
IntlBackslash,
|
||||
|
||||
Numpad0, // VK_NUMPAD0, 0x60, Numeric keypad 0 key
|
||||
Numpad1, // VK_NUMPAD1, 0x61, Numeric keypad 1 key
|
||||
Numpad2, // VK_NUMPAD2, 0x62, Numeric keypad 2 key
|
||||
Numpad3, // VK_NUMPAD3, 0x63, Numeric keypad 3 key
|
||||
Numpad4, // VK_NUMPAD4, 0x64, Numeric keypad 4 key
|
||||
Numpad5, // VK_NUMPAD5, 0x65, Numeric keypad 5 key
|
||||
Numpad6, // VK_NUMPAD6, 0x66, Numeric keypad 6 key
|
||||
Numpad7, // VK_NUMPAD7, 0x67, Numeric keypad 7 key
|
||||
Numpad8, // VK_NUMPAD8, 0x68, Numeric keypad 8 key
|
||||
Numpad9, // VK_NUMPAD9, 0x69, Numeric keypad 9 key
|
||||
|
||||
NumpadMultiply, // VK_MULTIPLY, 0x6A, Multiply key
|
||||
NumpadAdd, // VK_ADD, 0x6B, Add key
|
||||
NUMPAD_SEPARATOR, // VK_SEPARATOR, 0x6C, Separator key
|
||||
NumpadSubtract, // VK_SUBTRACT, 0x6D, Subtract key
|
||||
NumpadDecimal, // VK_DECIMAL, 0x6E, Decimal key
|
||||
NumpadDivide, // VK_DIVIDE, 0x6F,
|
||||
|
||||
/**
|
||||
* Cover all key codes when IME is processing input.
|
||||
*/
|
||||
KEY_IN_COMPOSITION,
|
||||
|
||||
ABNT_C1, // Brazilian (ABNT) Keyboard
|
||||
ABNT_C2, // Brazilian (ABNT) Keyboard
|
||||
|
||||
AudioVolumeMute,
|
||||
AudioVolumeUp,
|
||||
AudioVolumeDown,
|
||||
|
||||
BrowserSearch,
|
||||
BrowserHome,
|
||||
BrowserBack,
|
||||
BrowserForward,
|
||||
|
||||
MediaTrackNext,
|
||||
MediaTrackPrevious,
|
||||
MediaStop,
|
||||
MediaPlayPause,
|
||||
LaunchMediaPlayer,
|
||||
LaunchMail,
|
||||
LaunchApp2,
|
||||
|
||||
/**
|
||||
* VK_CLEAR, 0x0C, CLEAR key
|
||||
*/
|
||||
Clear,
|
||||
|
||||
/**
|
||||
* Placed last to cover the length of the enum.
|
||||
* Please do not depend on this value!
|
||||
*/
|
||||
MAX_VALUE
|
||||
}
|
||||
```
|
||||
|
||||
## ScanCode
|
||||
|
||||
```ts
|
||||
declare const enum ScanCode {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
渲染进程变量,与 [`KeyCode`](#keycode) 类似,每个按键几乎都有一个对于的值,不过这里与 `KeyboardEvent.code` 相对应:
|
||||
|
||||
```ts
|
||||
declare const enum ScanCode {
|
||||
DependsOnKbLayout = -1,
|
||||
None,
|
||||
Hyper,
|
||||
Super,
|
||||
Fn,
|
||||
FnLock,
|
||||
Suspend,
|
||||
Resume,
|
||||
Turbo,
|
||||
Sleep,
|
||||
WakeUp,
|
||||
KeyA,
|
||||
KeyB,
|
||||
KeyC,
|
||||
KeyD,
|
||||
KeyE,
|
||||
KeyF,
|
||||
KeyG,
|
||||
KeyH,
|
||||
KeyI,
|
||||
KeyJ,
|
||||
KeyK,
|
||||
KeyL,
|
||||
KeyM,
|
||||
KeyN,
|
||||
KeyO,
|
||||
KeyP,
|
||||
KeyQ,
|
||||
KeyR,
|
||||
KeyS,
|
||||
KeyT,
|
||||
KeyU,
|
||||
KeyV,
|
||||
KeyW,
|
||||
KeyX,
|
||||
KeyY,
|
||||
KeyZ,
|
||||
Digit1,
|
||||
Digit2,
|
||||
Digit3,
|
||||
Digit4,
|
||||
Digit5,
|
||||
Digit6,
|
||||
Digit7,
|
||||
Digit8,
|
||||
Digit9,
|
||||
Digit0,
|
||||
Enter,
|
||||
Escape,
|
||||
Backspace,
|
||||
Tab,
|
||||
Space,
|
||||
Minus,
|
||||
Equal,
|
||||
BracketLeft,
|
||||
BracketRight,
|
||||
Backslash,
|
||||
IntlHash,
|
||||
Semicolon,
|
||||
Quote,
|
||||
Backquote,
|
||||
Comma,
|
||||
Period,
|
||||
Slash,
|
||||
CapsLock,
|
||||
F1,
|
||||
F2,
|
||||
F3,
|
||||
F4,
|
||||
F5,
|
||||
F6,
|
||||
F7,
|
||||
F8,
|
||||
F9,
|
||||
F10,
|
||||
F11,
|
||||
F12,
|
||||
PrintScreen,
|
||||
ScrollLock,
|
||||
Pause,
|
||||
Insert,
|
||||
Home,
|
||||
PageUp,
|
||||
Delete,
|
||||
End,
|
||||
PageDown,
|
||||
ArrowRight,
|
||||
ArrowLeft,
|
||||
ArrowDown,
|
||||
ArrowUp,
|
||||
NumLock,
|
||||
NumpadDivide,
|
||||
NumpadMultiply,
|
||||
NumpadSubtract,
|
||||
NumpadAdd,
|
||||
NumpadEnter,
|
||||
Numpad1,
|
||||
Numpad2,
|
||||
Numpad3,
|
||||
Numpad4,
|
||||
Numpad5,
|
||||
Numpad6,
|
||||
Numpad7,
|
||||
Numpad8,
|
||||
Numpad9,
|
||||
Numpad0,
|
||||
NumpadDecimal,
|
||||
IntlBackslash,
|
||||
ContextMenu,
|
||||
Power,
|
||||
NumpadEqual,
|
||||
F13,
|
||||
F14,
|
||||
F15,
|
||||
F16,
|
||||
F17,
|
||||
F18,
|
||||
F19,
|
||||
F20,
|
||||
F21,
|
||||
F22,
|
||||
F23,
|
||||
F24,
|
||||
Open,
|
||||
Help,
|
||||
Select,
|
||||
Again,
|
||||
Undo,
|
||||
Cut,
|
||||
Copy,
|
||||
Paste,
|
||||
Find,
|
||||
AudioVolumeMute,
|
||||
AudioVolumeUp,
|
||||
AudioVolumeDown,
|
||||
NumpadComma,
|
||||
IntlRo,
|
||||
KanaMode,
|
||||
IntlYen,
|
||||
Convert,
|
||||
NonConvert,
|
||||
Lang1,
|
||||
Lang2,
|
||||
Lang3,
|
||||
Lang4,
|
||||
Lang5,
|
||||
Abort,
|
||||
Props,
|
||||
NumpadParenLeft,
|
||||
NumpadParenRight,
|
||||
NumpadBackspace,
|
||||
NumpadMemoryStore,
|
||||
NumpadMemoryRecall,
|
||||
NumpadMemoryClear,
|
||||
NumpadMemoryAdd,
|
||||
NumpadMemorySubtract,
|
||||
NumpadClear,
|
||||
NumpadClearEntry,
|
||||
ControlLeft,
|
||||
ShiftLeft,
|
||||
AltLeft,
|
||||
MetaLeft,
|
||||
ControlRight,
|
||||
ShiftRight,
|
||||
AltRight,
|
||||
MetaRight,
|
||||
BrightnessUp,
|
||||
BrightnessDown,
|
||||
MediaPlay,
|
||||
MediaRecord,
|
||||
MediaFastForward,
|
||||
MediaRewind,
|
||||
MediaTrackNext,
|
||||
MediaTrackPrevious,
|
||||
MediaStop,
|
||||
Eject,
|
||||
MediaPlayPause,
|
||||
MediaSelect,
|
||||
LaunchMail,
|
||||
LaunchApp2,
|
||||
LaunchApp1,
|
||||
SelectTask,
|
||||
LaunchScreenSaver,
|
||||
BrowserSearch,
|
||||
BrowserHome,
|
||||
BrowserBack,
|
||||
BrowserForward,
|
||||
BrowserStop,
|
||||
BrowserRefresh,
|
||||
BrowserFavorites,
|
||||
ZoomToggle,
|
||||
MailReply,
|
||||
MailForward,
|
||||
MailSend,
|
||||
|
||||
MAX_VALUE
|
||||
}
|
||||
```
|
||||
|
||||
## bgm
|
||||
|
||||
```ts
|
||||
declare var bgm: BgmController
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
渲染进程变量,用于控制当前的 bgm 状态,参考 [类 BgmController](./class/bgm-controller.md)
|
||||
|
||||
## sound
|
||||
|
||||
```ts
|
||||
declare var sound: SoundController
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
渲染进程变量,用于控制音效的播放,参考 [类 SoundController](./class/sound-controller.md)
|
||||
|
||||
## settingStorage
|
||||
|
||||
```ts
|
||||
declare var settingStorage: GameStorage
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
渲染进程变量,用于保存所有的系统设置信息
|
||||
|
||||
## status
|
||||
|
||||
```ts
|
||||
declare var status: { value: boolean }
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
渲染进程变量,用于控制状态栏刷新,取反后立刻刷新状态栏的显示
|
||||
|
||||
## enemySpecials
|
||||
|
||||
```ts
|
||||
declare var enemySpecials: SpecialDeclaration[]
|
||||
```
|
||||
|
||||
- 变量说明
|
||||
|
||||
游戏进程变量,描述了所有特殊属性定义,示例参考插件
|
@ -34,7 +34,7 @@ bgm.play('myBgm.mp3'); // 无渐变的切歌
|
||||
|
||||
### 暂停与继续、撤销与恢复
|
||||
|
||||
可以使用 `pause` 和 `resume` 函数暂停或者继续播放,它们都可以传入一个函数,表示暂停或者继续过程是否渐变
|
||||
可以使用 `pause` 和 `resume` 函数暂停或者继续播放,它们都可以传入一个参数,表示暂停或者继续过程是否渐变
|
||||
|
||||
```js
|
||||
const { bgm } = Mota.requireAll('var');
|
||||
@ -188,7 +188,7 @@ convolver.buffer = await ac.decodeAudioData(sound.get('mySound2.mp3').data);
|
||||
convolver.connect(ac.destination);
|
||||
const se = sound.get('mySound.mp3');
|
||||
// 添加至路由根节点,播放时就会经过这个路由节点的处理
|
||||
se.baseNode.push(convolver);
|
||||
se.baseNode.push({ node: convolver });
|
||||
// 或者覆盖系统自带的根节点
|
||||
se.baseNode = [convolver];
|
||||
se.baseNode = [{ node: convolver }];
|
||||
```
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
新样板创建了一种新的设置系统,它允许你自定义设置列表,以及设置的编辑组件,它是 `MotaSetting` 类。
|
||||
|
||||
:::warning
|
||||
系统自带的设置在系统设置物品内
|
||||
:::
|
||||
|
||||
## 注册设置
|
||||
|
||||
想要添加你自己的设置,就需要注册一个设置。对于新样板的设置,全部在 `mainSetting` 变量里面,然后调用 `register` 函数即可注册:
|
||||
|
@ -191,7 +191,5 @@ const myUI = mainUi.get('myUI');
|
||||
- `add(item)`: 打开新 UI 时触发,参数是打开的 UI,是 `GameUi` 实例。该事件继承自类 [`Focus`](../api/class.md#Focus) 的事件。
|
||||
- `pop(item)`: 弹出最后一个 UI 时触发,参数是被弹出的 `GameUi` 实例。注意关闭 UI 不会触发此事件,因为关闭 UI 会使用 `splice` 而不是 `pop`。该事件继承自类 [`Focus`](../api/class.md#Focus) 的事件。
|
||||
- `splice(spliced)`: 当 UI 被截断(关闭)时触发,参数是被关闭的 UI 数组。该事件继承自类 [`Focus`](../api/class.md#Focus) 的事件。
|
||||
- `register(item)`: 当 UI 被注册时触发,参数是注册列表,是由 `GameUi` 组成的数组。
|
||||
- `unregister(item)`: 当 UI 被取消注册时触发,参数是取消注册的列表。该事件与 `register` 事件类似。
|
||||
- `start()`: 当 UI 根组件被打开时触发。当 UI 控制器从没有任何 UI 变成有至少一个 UI 被显示时,也即当没有 UI 打开的情况下任何 UI 被打开时,会触发此事件。无参数。
|
||||
- `end()`: 当 UI 根组件被关闭时触发,即当所有 UI 都被关闭时触发。无参数。
|
||||
|
@ -12,7 +12,7 @@ hero:
|
||||
link: /guide/diff
|
||||
- theme: alt
|
||||
text: API列表
|
||||
link: /api-examples
|
||||
link: /api/index
|
||||
- theme: alt
|
||||
text: 旧样板文档
|
||||
link: https://h5mota.com/games/template/_docs/#/
|
||||
|
@ -3101,7 +3101,7 @@ ui.prototype._drawNotes = function () {
|
||||
|
||||
////// 绘制快捷商店选择栏 //////
|
||||
ui.prototype._drawQuickShop = function () {
|
||||
const shop = Mota.Plugin.require('shop');
|
||||
const shop = Mota.Plugin.require('shop_g');
|
||||
core.status.event.id = 'selectShop';
|
||||
var shopList = core.status.shops,
|
||||
keys = shop.listShopIds();
|
||||
|
@ -1116,7 +1116,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = {
|
||||
);
|
||||
|
||||
// ----- 计算第一类光环
|
||||
// 特殊属性对于的特殊属性数值
|
||||
// 特殊属性对应的特殊属性数值
|
||||
const changeable = Mota.require('module', 'Damage').changeableHaloValue;
|
||||
changeable
|
||||
.set(21, ['atkValue', 'defValue'])
|
||||
|
@ -80,8 +80,8 @@ export class BgmController
|
||||
|
||||
this.playing = true;
|
||||
if (!this.disable) {
|
||||
this.setTransitionAnimate(id, 1);
|
||||
if (this.now) this.setTransitionAnimate(this.now, 0, when);
|
||||
this.setTransitionAnimate(id, 1, when);
|
||||
if (this.now) this.setTransitionAnimate(this.now, 0);
|
||||
}
|
||||
|
||||
if (!noStack) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { has } from '@/plugin/utils';
|
||||
import { AudioParamOf, AudioPlayer } from './audio';
|
||||
import resource from '@/data/resource.json';
|
||||
import { ResourceController } from '../loader/controller';
|
||||
|
||||
// todo: 立体声,可设置音源位置
|
||||
@ -24,7 +23,6 @@ export class SoundEffect extends AudioPlayer {
|
||||
|
||||
gain: GainNode = AudioPlayer.ac.createGain();
|
||||
panner: PannerNode | null = null;
|
||||
merger: ChannelMergerNode | null = null;
|
||||
|
||||
set volumn(value: number) {
|
||||
this.gain.gain.value = value * SoundEffect.volume;
|
||||
@ -63,9 +61,7 @@ export class SoundEffect extends AudioPlayer {
|
||||
* 设置音频路由线路
|
||||
* ```txt
|
||||
* 不启用立体声:source -> gain -> destination
|
||||
* 启用立体声:source -> panner -> gain --> destination
|
||||
* 单声道立体声:source -> merger -> panner -> gain -> destination
|
||||
* 单声道立体声指音源为单声道,合成为双声道后模拟为立体声
|
||||
* 启用立体声:source -> panner -> gain -> destination
|
||||
* ```
|
||||
* @param stereo 是否启用立体声
|
||||
*/
|
||||
@ -74,7 +70,6 @@ export class SoundEffect extends AudioPlayer {
|
||||
const ac = AudioPlayer.ac;
|
||||
if (!channel) return;
|
||||
this.panner = null;
|
||||
this.merger = null;
|
||||
if (stereo) {
|
||||
this.panner = ac.createPanner();
|
||||
this.panner.connect(this.gain);
|
||||
@ -155,7 +150,6 @@ export class SoundController extends ResourceController<
|
||||
* @param data 音频的ArrayBuffer信息,会被解析为AudioBuffer
|
||||
*/
|
||||
add(uri: string, data: ArrayBuffer) {
|
||||
const stereo = resource.stereoSE.includes(uri);
|
||||
const se = new SoundEffect(data, true);
|
||||
if (this.list[uri]) {
|
||||
console.warn(`Repeated sound effect: '${uri}'.`);
|
||||
|
@ -56,6 +56,7 @@ import EnemySpecial from '@/panel/enemySpecial.vue';
|
||||
import EnemyTarget from '@/panel/enemyTarget.vue';
|
||||
import KeyboardPanel from '@/panel/keyboard.vue';
|
||||
import { MCGenerator } from './main/layout';
|
||||
import { ResourceController } from './loader/controller';
|
||||
|
||||
// ----- 类注册
|
||||
Mota.register('class', 'AudioPlayer', AudioPlayer);
|
||||
@ -72,6 +73,7 @@ Mota.register('class', 'SoundController', SoundController);
|
||||
Mota.register('class', 'SoundEffect', SoundEffect);
|
||||
Mota.register('class', 'UiController', UiController);
|
||||
Mota.register('class', 'MComponent', MComponent);
|
||||
Mota.register('class', 'ResourceController', ResourceController);
|
||||
// ----- 函数注册
|
||||
Mota.register('fn', 'm', m);
|
||||
Mota.register('fn', 'unwrapBinary', unwarpBinary);
|
||||
|
@ -25,6 +25,6 @@ export abstract class ResourceController<
|
||||
remove(uri: string) {
|
||||
const content = this.list[uri];
|
||||
delete this.list[uri];
|
||||
this.emit(uri, content);
|
||||
this.emit('delete', uri, content);
|
||||
}
|
||||
}
|
||||
|
@ -199,11 +199,13 @@ export class CustomToolbar extends EventEmitter<CustomToolbarEvent> {
|
||||
setPos(x?: number, y?: number) {
|
||||
has(x) && (this.x = x);
|
||||
has(y) && (this.y = y);
|
||||
this.emit('posChange', this);
|
||||
}
|
||||
|
||||
setSize(width?: number, height?: number) {
|
||||
has(width) && (this.width = width);
|
||||
has(height) && (this.height = height);
|
||||
this.emit('posChange', this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -288,7 +290,7 @@ export class CustomToolbar extends EventEmitter<CustomToolbarEvent> {
|
||||
static load() {
|
||||
toolbarStorage.read();
|
||||
for (const [key, value] of Object.entries(toolbarStorage.data)) {
|
||||
const bar = new CustomToolbar(key);
|
||||
const bar = this.get(key) ?? new CustomToolbar(key);
|
||||
bar.x = value.x;
|
||||
bar.y = value.y;
|
||||
bar.width = value.w;
|
||||
|
@ -9,8 +9,6 @@ interface FocusEvent<T> extends EmitableEvent {
|
||||
unfocus: (before: T | null) => void;
|
||||
add: (item: T) => void;
|
||||
pop: (item: T | null) => void;
|
||||
register: (item: T[]) => void;
|
||||
unregister: (item: T[]) => void;
|
||||
splice: (spliced: T[]) => void;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ import { Keyboard } from '../custom/keyboard';
|
||||
|
||||
const qweKey = new Keyboard('qwe'); // 字母键盘,A-Z
|
||||
const numKey = new Keyboard('num'); // 数字键盘,1-0
|
||||
const charKey = new Keyboard('charKey'); // 符号键盘,!@<>等
|
||||
const charKey = new Keyboard('char'); // 符号键盘,:;<>等
|
||||
const fnKey = new Keyboard('fn'); // Fn键盘,F1-F12
|
||||
const assistKey = new Keyboard('assist'); // 辅助键盘,tab,capslk,shift,ctrl等
|
||||
const arrowKey = new Keyboard('arrow'); // 方向键
|
||||
|
@ -133,7 +133,7 @@ export class MComponent {
|
||||
*/
|
||||
com(
|
||||
component: Component | MComponent,
|
||||
config: Omit<MotaComponentConfig, 'innerText' | 'component'>
|
||||
config?: Omit<MotaComponentConfig, 'innerText' | 'component'>
|
||||
) {
|
||||
return this.h(component, [], config);
|
||||
}
|
||||
|
@ -205,7 +205,10 @@ export class MotaSetting extends EventEmitter<SettingEvent> {
|
||||
*/
|
||||
setDescription(key: string, desc: string) {
|
||||
const setting = this.getSettingBy(key.split('.'));
|
||||
setting.description = desc;
|
||||
setting.description = desc.replace(
|
||||
/\<\s*script.*\/?\>(.*\<\/\s*script\s*\>)?/g,
|
||||
''
|
||||
);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,6 @@ interface EnemyInfo extends Partial<Enemy> {
|
||||
|
||||
interface DamageInfo {
|
||||
damage: number;
|
||||
/** 自动切换技能时使用的技能 */
|
||||
skill?: number;
|
||||
}
|
||||
|
||||
interface MapDamage {
|
||||
@ -105,7 +103,6 @@ export class EnemyCollection implements RangeCollection<DamageEnemy> {
|
||||
|
||||
/**
|
||||
* 计算怪物真实属性
|
||||
* @param noCache 是否不使用缓存
|
||||
*/
|
||||
calRealAttribute() {
|
||||
this.haloList = [];
|
||||
@ -125,6 +122,7 @@ export class EnemyCollection implements RangeCollection<DamageEnemy> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* 计算怪物伤害
|
||||
* @param noCache 是否不使用缓存
|
||||
*/
|
||||
@ -488,9 +486,8 @@ export class DamageEnemy<T extends EnemyIds = EnemyIds> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算怪物临界,计算临界时,根据当前方向计算临界,但也会输出与当前最少伤害的伤害差值
|
||||
* 计算怪物临界
|
||||
* @param num 要计算多少个临界
|
||||
* @param dir 从怪物位置指向勇士的方向
|
||||
* @param hero 勇士属性,最终结果将会与由此属性计算出的伤害相减计算减伤
|
||||
*/
|
||||
calCritical(
|
||||
@ -591,7 +588,6 @@ export class DamageEnemy<T extends EnemyIds = EnemyIds> {
|
||||
/**
|
||||
* 计算n防减伤
|
||||
* @param num 要加多少防御
|
||||
* @param dir 从怪物位置指向勇士的方向
|
||||
* @param hero 勇士属性,最终结果将会与由此属性计算出的伤害相减计算减伤
|
||||
*/
|
||||
calDefDamage(
|
||||
|
@ -84,14 +84,16 @@ export interface GameEvent extends EmitableEvent {
|
||||
mounted: () => void;
|
||||
/** Emitted in plugin/ui.js */
|
||||
statusBarUpdate: () => void;
|
||||
/** Emitted in libs/events.js */
|
||||
afterGetItem: (
|
||||
itemId: AllIdsOf<'items'>,
|
||||
x: number,
|
||||
y: number,
|
||||
isGentleClick: boolean
|
||||
) => void;
|
||||
afterOpenDoor: (doorId: AllIdsOf<'animates'>, x: number, y: number) => void;
|
||||
/** Emitted in core/index.ts */
|
||||
renderLoaded: () => void;
|
||||
// /** Emitted in libs/events.js */
|
||||
// afterGetItem: (
|
||||
// itemId: AllIdsOf<'items'>,
|
||||
// x: number,
|
||||
// y: number,
|
||||
// isGentleClick: boolean
|
||||
// ) => void;
|
||||
// afterOpenDoor: (doorId: AllIdsOf<'animates'>, x: number, y: number) => void;
|
||||
}
|
||||
|
||||
export const hook = new EventEmitter<GameEvent>();
|
||||
|
@ -1,6 +1,7 @@
|
||||
import type { AudioPlayer } from '@/core/audio/audio';
|
||||
import type { BgmController } from '@/core/audio/bgm';
|
||||
import type { SoundController, SoundEffect } from '@/core/audio/sound';
|
||||
import type { ResourceController } from '@/core/loader/controller';
|
||||
import type { Disposable } from '@/core/common/disposable';
|
||||
import type {
|
||||
EventEmitter,
|
||||
@ -47,6 +48,7 @@ import type * as toolboxTools from '@/plugin/ui/toolbox';
|
||||
import type * as battle from './enemy/battle';
|
||||
import type * as hero from './hero';
|
||||
import type { Damage } from './enemy/damage';
|
||||
import type * as utils from '@/plugin/utils';
|
||||
// ---------- 插件
|
||||
import type * as pop_r from '../plugin/pop';
|
||||
import type * as use_r from '../plugin/use';
|
||||
@ -72,6 +74,7 @@ import type * as _lodash from 'lodash-es';
|
||||
import type * as _lzString from 'lz-string';
|
||||
import type * as _mutateAnimate from 'mutate-animate';
|
||||
import type * as _vue from 'vue';
|
||||
// ---------- UI
|
||||
import type * as UI from '@ui/index';
|
||||
import type Box from '@/components/box.vue';
|
||||
import type BoxAnimate from '@/components/boxAnimate.vue.vue';
|
||||
@ -82,6 +85,7 @@ import type EnemyCritical from '@/panel/enemyCritical.vue';
|
||||
import type EnemySpecial from '@/panel/enemySpecial.vue.vue';
|
||||
import type EnemyTarget from '@/panel/enemyTarget.vue.vue';
|
||||
import type KeyboardPanel from '@/panel/keyboard.vue.vue';
|
||||
import type { VirtualKey } from '@/core/main/init/misc';
|
||||
|
||||
export interface ClassInterface {
|
||||
// 渲染进程与游戏进程通用
|
||||
@ -103,6 +107,7 @@ export interface ClassInterface {
|
||||
SoundController: typeof SoundController;
|
||||
BgmController: typeof BgmController;
|
||||
MComponent: typeof MComponent;
|
||||
ResourceController: typeof ResourceController;
|
||||
// 定义于游戏进程,渲染进程依然可用
|
||||
Range: typeof Range;
|
||||
EnemyCollection: typeof EnemyCollection;
|
||||
@ -172,6 +177,10 @@ export interface ModuleInterface {
|
||||
KeyboardPanel: typeof KeyboardPanel;
|
||||
};
|
||||
MCGenerator: typeof MCGenerator;
|
||||
RenderUtils: typeof utils;
|
||||
MiscComponents: {
|
||||
VirtualKey: typeof VirtualKey;
|
||||
};
|
||||
}
|
||||
|
||||
export interface SystemInterfaceMap {
|
||||
|
@ -39,7 +39,7 @@ function checkMobile() {
|
||||
/**
|
||||
* 向一个元素添加拖拽事件
|
||||
* @param ele 目标元素,当为全局拖拽时,传入数组表示所有元素共用一个全局拖拽函数
|
||||
* @param fn 推拽时触发的函数,传入x y和鼠标事件或点击事件
|
||||
* @param fn 拖拽时触发的函数,传入x y和鼠标事件或点击事件
|
||||
* @param ondown 鼠标按下时执行的函数
|
||||
* @param global 是否全局拖拽,即拖拽后鼠标或手指离开元素后是否依然视为正在拖拽
|
||||
*/
|
||||
|
@ -25,8 +25,7 @@ export default function init() {
|
||||
getDamageColor,
|
||||
parseCss,
|
||||
tip,
|
||||
changeLocalStorage,
|
||||
swapChapter
|
||||
changeLocalStorage
|
||||
};
|
||||
}
|
||||
|
||||
@ -240,23 +239,6 @@ export function changeLocalStorage<T>(
|
||||
core.setLocalStorage(name, to);
|
||||
}
|
||||
|
||||
export async function swapChapter(chapter: number, hard: number) {
|
||||
const h = hard === 2 ? 'hard' : 'easy';
|
||||
const save = await axios.get(
|
||||
`${import.meta.env.BASE_URL}swap/${chapter}.${h}.h5save`,
|
||||
{
|
||||
responseType: 'text',
|
||||
responseEncoding: 'utf-8'
|
||||
}
|
||||
);
|
||||
const data = JSON.parse(decompressFromBase64(save.data));
|
||||
|
||||
core.loadData(data.data, () => {
|
||||
core.removeFlag('__fromLoad__');
|
||||
core.drawTip('读档成功');
|
||||
});
|
||||
}
|
||||
|
||||
export function ensureArray<T>(arr: T): T extends any[] ? T : T[] {
|
||||
// @ts-ignore
|
||||
return arr instanceof Array ? arr : [arr];
|
||||
|
Loading…
Reference in New Issue
Block a user