commit
06ad2d4f4b
@ -44,8 +44,13 @@
|
||||
mergeNavbar: true,
|
||||
formatUpdated: '{YYYY}-{MM}-{DD} {HH}:{mm}:{ss}',
|
||||
}
|
||||
if (typeof navigator.serviceWorker !== 'undefined') {
|
||||
navigator.serviceWorker.register('serviceWorker.js')
|
||||
if (navigator.serviceWorker) {
|
||||
navigator.serviceWorker.getRegistrations()
|
||||
.then(function(registrations) {
|
||||
for(let registration of registrations) {
|
||||
registration.unregister();
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script src="https://cdn.bootcss.com/docsify/4.5.5/docsify.min.js"></script>
|
||||
|
||||
@ -1,75 +0,0 @@
|
||||
const RUNTIME = 'docsify'
|
||||
const HOSTNAME_WHITELIST = [
|
||||
self.location.hostname,
|
||||
'fonts.gstatic.com',
|
||||
'fonts.googleapis.com',
|
||||
'cdn.bootcss.com'
|
||||
]
|
||||
|
||||
// The Util Function to hack URLs of intercepted requests
|
||||
const getFixedUrl = (req) => {
|
||||
var now = Date.now()
|
||||
var url = new URL(req.url)
|
||||
|
||||
// 1. fixed http URL
|
||||
// Just keep syncing with location.protocol
|
||||
// fetch(httpURL) belongs to active mixed content.
|
||||
// And fetch(httpRequest) is not supported yet.
|
||||
url.protocol = self.location.protocol
|
||||
|
||||
// 2. add query for caching-busting.
|
||||
// Github Pages served with Cache-Control: max-age=600
|
||||
// max-age on mutable content is error-prone, with SW life of bugs can even extend.
|
||||
// Until cache mode of Fetch API landed, we have to workaround cache-busting with query string.
|
||||
// Cache-Control-Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=453190
|
||||
if (url.hostname === self.location.hostname) {
|
||||
url.search += (url.search ? '&' : '?') + 'cache-bust=' + now
|
||||
}
|
||||
return url.href
|
||||
}
|
||||
|
||||
/**
|
||||
* @Lifecycle Activate
|
||||
* New one activated when old isnt being used.
|
||||
*
|
||||
* waitUntil(): activating ====> activated
|
||||
*/
|
||||
self.addEventListener('activate', event => {
|
||||
event.waitUntil(self.clients.claim())
|
||||
})
|
||||
|
||||
/**
|
||||
* @Functional Fetch
|
||||
* All network requests are being intercepted here.
|
||||
*
|
||||
* void respondWith(Promise<Response> r)
|
||||
*/
|
||||
self.addEventListener('fetch', event => {
|
||||
// Skip some of cross-origin requests, like those for Google Analytics.
|
||||
if (HOSTNAME_WHITELIST.indexOf(new URL(event.request.url).hostname) > -1) {
|
||||
// Stale-while-revalidate
|
||||
// similar to HTTP's stale-while-revalidate: https://www.mnot.net/blog/2007/12/12/stale
|
||||
// Upgrade from Jake's to Surma's: https://gist.github.com/surma/eb441223daaedf880801ad80006389f1
|
||||
const cached = caches.match(event.request)
|
||||
const fixedUrl = getFixedUrl(event.request)
|
||||
const fetched = fetch(fixedUrl, { cache: 'no-store' })
|
||||
const fetchedCopy = fetched.then(resp => resp.clone())
|
||||
|
||||
// Call respondWith() with whatever we get first.
|
||||
// If the fetch fails (e.g disconnected), wait for the cache.
|
||||
// If there’s nothing in cache, wait for the fetch.
|
||||
// If neither yields a response, return offline pages.
|
||||
event.respondWith(
|
||||
Promise.race([fetched.catch(_ => cached), cached])
|
||||
.then(resp => resp || fetched)
|
||||
.catch(_ => { /* eat any errors */ })
|
||||
)
|
||||
|
||||
// Update the cache with the version we fetched (only for ok status)
|
||||
event.waitUntil(
|
||||
Promise.all([fetchedCopy, caches.open(RUNTIME)])
|
||||
.then(([response, cache]) => response.ok && cache.put(event.request, response))
|
||||
.catch(_ => { /* eat any errors */ })
|
||||
)
|
||||
}
|
||||
})
|
||||
@ -44,6 +44,8 @@
|
||||
|
||||
如果提示“该素材未被定义”或有红色问号框,请参见[素材注册](#素材注册)。
|
||||
|
||||
绘制地图时可以右键弹出菜单,移动图块和事件。
|
||||
|
||||
### 从RMXP导入已有的地图
|
||||
|
||||
如果我们想复刻一个现有的,已经被RMXP所制作的塔,也有很便捷的方式,那就是用到我们的“地图生成器”。
|
||||
@ -178,19 +180,28 @@ HTML5的塔都是可以进行控制台调试的。
|
||||
|
||||
在控制台中,我们可以输入一些命令对游戏进行调试,常见的命令有:
|
||||
|
||||
- `core.status.floorId` 获得当前层的floorId。
|
||||
- `core.status.thisMap` 获得当前地图信息。
|
||||
- `core.status.hero` 获得当前勇士状态信息。例如core.status.hero.atk就是当前勇士的攻击力数值。
|
||||
- `core.material.enemys` 获得所有怪物信息。例如core.material.enemys.greenSlime就是获得绿色史莱姆的属性数据。
|
||||
- `core.material.items` 获得所有道具的信息。
|
||||
- `core.debug()` 无敌模式;使用此命令将会把攻防都置为10000,方便进行乱撞。
|
||||
- `core.setStatus('atk', 100)` 直接设置勇士的属性;这里可以把`atk`换成`hp`, `def`, `mdef`, `money`, `experience`等之一。
|
||||
- `core.getStatus('atk')` 获得勇士的属性数据。
|
||||
- `core.updateStatusBar()` 立刻更新状态栏和地图显伤。
|
||||
- `core.setStatus('atk', 100)` 直接设置勇士的属性。本句等价于 `core.status.hero.atk = 1000`
|
||||
- `core.getStatus('atk')` 返回当前属性数值。本句等价于 `core.status.hero.atk`
|
||||
- `core.setItem('pickaxe', 10)` 直接设置勇士某个道具的个数。这里可以需要写道具的ID。
|
||||
- `core.hasItem('pickaxe')` 返回勇士是否拥有某个道具。
|
||||
- `core.itemCount('pickaxe')` 获得勇士某个道具的个数。请注意不是getItem,那个函数是用来游戏中获取道具的。
|
||||
- `core.setFlag('xxx', 1)` 设置某个flag/自定义变量的值
|
||||
- `core.getFlag('xxx', 10)` 获得某个flag/自定义变量的值;如果该项不存在(未被定义),则返回第二个参数的值。
|
||||
- `core.hasFlag('xxx')` 返回是否存在某个变量且不为0。
|
||||
- `core.insertAction(list)` 执行一段自定义事件。比如 `core.insertAction(["你好"])` 将执行一个剧情文本显示事件。
|
||||
- `core.status.floorId` 获得当前层的floorId
|
||||
- `core.changeFloor('MT2')` 立刻执行楼层切换到MT2层。
|
||||
- `core.changeFloor('MT2', 'downFloor')` 立刻执行楼层切换到MT2层的下楼点位置。
|
||||
- `core.getBlock(3, 5, 'MT1')` 获得当前地图上某一个块的信息。第三个参数为floorId,可省略表示当前楼层。
|
||||
- `core.resetMap()` 重置当前层地图。当修改地图后,再读档时修改的地图不会立刻生效,此时可以使用resetMap来重置当前楼层的地图。
|
||||
……
|
||||
- `localStorage` 获得所有的存档数据。可以用 `core.getLocalStorage('save1')` 来具体获得某个存档。
|
||||
- ……
|
||||
|
||||
更多API和详细参数介绍可参见[API列表](api)。
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user