播片系统,仅负责对话的显示。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.5 KiB

3 years ago
#include "line.j"
struct Broadcast
timer recorder
real progress
real tick
integer progressLine
Line array lines[100]
integer lineLength = 0
string name
static method create takes string name returns thistype
local thistype b = thistype.allocate()
set b.name = name
set b.lineLength = 0
set b.recorder = null
set b.progress = 0
set b.progressLine = 0
return b
endmethod
method getLength takes nothing returns integer
return this.lineLength
endmethod
method add takes Line line returns thistype
set this.lines[this.lineLength] = line
set this.lineLength = this.lineLength + 1
return this
endmethod
method ready takes real tick returns thistype
set this.recorder = CreateTimer()
set this.tick = tick
return this
endmethod
method nextTick takes nothing returns real
if this.getLength() == 0 then
return - 4000 // 当前播片没有台词,立即结束
endif
if this.progress >= this.lines[this.progressLine].begin then
call this.lines[this.progressLine].say()
set this.progressLine = this.progressLine + 1
if this.progressLine >= this.getLength() then
return - 2000 // 播片台词播放完毕
endif
endif
set this.progress = this.progress + this.tick
return this.progress // 正常运行返回当前播片进度
endmethod
endstruct