commit
						4d6735b2a9
					
				
				 3 changed files with 137 additions and 0 deletions
			
			
		| @ -0,0 +1,24 @@ | ||||
| library broadcast2 initializer InitBroadcast2 | ||||
| 
 | ||||
|     /** | ||||
|     * 播片系统 | ||||
|     * 为剧情设计 | ||||
|     * 当前版本仅涉及文本显示对话功能 | ||||
|     *  | ||||
|     * 版本: 2.01 | ||||
|     * By Soul2 | ||||
|     */ | ||||
| 
 | ||||
|     #define SayPointX 0.62 | ||||
|     #define SayPointY - 0.5 | ||||
| 
 | ||||
|     #include "struct/broadcast.j" | ||||
| 
 | ||||
|     #undef SayPointX | ||||
|     #undef SayPointY | ||||
| 
 | ||||
|     function InitBroadcast2 takes nothing returns nothing | ||||
|         // init something | ||||
|     endfunction | ||||
| 
 | ||||
| endlibrary | ||||
| @ -0,0 +1,53 @@ | ||||
| #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 | ||||
| @ -0,0 +1,60 @@ | ||||
| struct Line | ||||
|     unit speaker | ||||
|     string speakerName | ||||
|     string content | ||||
|     integer begin | ||||
|     integer end | ||||
|     integer enemy | ||||
| 
 | ||||
|     static method create takes integer begin, integer end returns thistype | ||||
|         local thistype l = thistype.allocate() | ||||
|         set l.begin = begin | ||||
|         set l.end = end | ||||
|         return l | ||||
|     endmethod | ||||
| 
 | ||||
|     method foe takes nothing returns thistype | ||||
|         set this.enemy = 1 | ||||
|         return this | ||||
|     endmethod | ||||
| 
 | ||||
|     method setSpeak takes string speakerName, string content returns thistype | ||||
|         set this.speakerName = speakerName | ||||
|         set this.content = content | ||||
|         return this | ||||
|     endmethod | ||||
| 
 | ||||
|     method setSpeak2 takes unit speaker, string content returns thistype | ||||
|         set this.speaker = speaker | ||||
|         set this.content = content | ||||
|         return this | ||||
|     endmethod | ||||
|      | ||||
|     method getSpeaker takes integer enemy returns string | ||||
|         local string color = "|cff00ff00" | ||||
|         if enemy == 1 then | ||||
|             set color = "|cffff4000" | ||||
|         endif | ||||
|         if this.speaker != null then | ||||
|             if IsUnitType(this.speaker, UNIT_TYPE_HERO) then | ||||
|                 return color + GetHeroProperName(this.speaker) + "|r" | ||||
|             else | ||||
|                 return color + GetUnitName(this.speaker) + "|r" | ||||
|             endif | ||||
|         else | ||||
|             return color + this.speakerName + "|r" | ||||
|         endif | ||||
|     endmethod | ||||
| 
 | ||||
| 
 | ||||
|     method say takes nothing returns thistype | ||||
|         local string speaker = this.getSpeaker(this.enemy) | ||||
|         call DisplayTimedTextToPlayer(Player(0), SayPointX, SayPointY, this.getDuration(), speaker + ": " + this.content) | ||||
|         return this | ||||
|     endmethod | ||||
| 
 | ||||
|     method getDuration takes nothing returns real | ||||
|         return I2R(this.end - this.begin) | ||||
|     endmethod | ||||
| 
 | ||||
| endstruct | ||||
					Loading…
					
					
				
		Reference in new issue