Class: Miyako::SimpleStory
Overview
シーン実行クラス
用意したシーンインスタンスを実行
Defined Under Namespace
Modules: Scene
Constant Summary collapse
- @@sub_scenes =
[:sub_scene, :sub_routine]
Instance Attribute Summary collapse
-
#hand_over ⇒ Object
Returns the value of attribute hand_over.
Instance Method Summary collapse
-
#dispose ⇒ Object
内部の情報を解放する.
-
#initialize ⇒ SimpleStory
constructor
インスタンスの作成 ストーリー情報の初期か 返却値:: 生成したインスタンス.
-
#initialize_copy(obj) ⇒ Object
:nodoc:.
-
#next_label ⇒ Object
:nodoc:.
-
#prev_label ⇒ Object
:nodoc:.
-
#run(n, init_ho = nil) ⇒ Object
Storyの実行を始める “obj.run(MainScene)”と記述すると、SceneモジュールをmixinしたMainSceneクラスのインスタンスを作成し、評価を始める n:: 最初に実行するシーン名(クラス名を定数で).
-
#upper_label ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ SimpleStory
インスタンスの作成
ストーリー情報の初期か
- 返却値
-
生成したインスタンス
47 48 49 50 51 52 53 54 |
# File 'lib/Miyako/API/simple_story.rb', line 47 def initialize @prev_label = nil @next_label = nil @stack = [] @hand_over = nil end |
Instance Attribute Details
#hand_over ⇒ Object
Returns the value of attribute hand_over.
28 29 30 |
# File 'lib/Miyako/API/simple_story.rb', line 28 def hand_over @hand_over end |
Instance Method Details
#dispose ⇒ Object
内部の情報を解放する
103 104 105 |
# File 'lib/Miyako/API/simple_story.rb', line 103 def dispose @stack.each{|scene| scene.dispose } end |
#initialize_copy(obj) ⇒ Object
:nodoc:
56 57 58 |
# File 'lib/Miyako/API/simple_story.rb', line 56 def initialize_copy(obj) #:nodoc: @stack = @stack.dup end |
#next_label ⇒ Object
:nodoc:
36 37 38 |
# File 'lib/Miyako/API/simple_story.rb', line 36 def next_label #:nodoc: return @next_label end |
#prev_label ⇒ Object
:nodoc:
32 33 34 |
# File 'lib/Miyako/API/simple_story.rb', line 32 def prev_label #:nodoc: return @prev_label end |
#run(n, init_ho = nil) ⇒ Object
Storyの実行を始める
“obj.run(MainScene)”と記述すると、SceneモジュールをmixinしたMainSceneクラスのインスタンスを作成し、評価を始める
- n
-
最初に実行するシーン名(クラス名を定数で)
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/Miyako/API/simple_story.rb', line 63 def run(n, init_ho = nil) return nil if n == nil u = nil on = nil @stack = Array.new # reset @hand_over = init_ho while n != nil @prev_label = on on = n raise MiyakoValueError, "Illegal Script-label name! : #{n}" unless Scene.has_scene?(n.to_s) raise MiyakoValueError, "This scene cannot use for Standard Scene! : #{n}" if n.scene_type != :scene and !@@sub_scenes.include?(n.scene_type) u = n.new(self, @hand_over) if u == nil @hand_over = nil u.init_inner(@prev_label, self.upper_label) n = u.execute n, @hand_over = n if n and n.kind_of?(Array) next if on.eql?(n) u.clear_hand_over u.next = n @next_label = n if n.nil? if @@sub_scenes.include?(u.class.scene_type) && @stack.empty? == false n, u = @stack.pop next end u.dispose break elsif @@sub_scenes.include?(n.scene_type) @stack.push([on, u]) u = nil else u.dispose u = nil end end end |
#upper_label ⇒ Object
:nodoc:
40 41 42 |
# File 'lib/Miyako/API/simple_story.rb', line 40 def upper_label #:nodoc: return @stack.empty? ? nil : @stack.last[0] end |