Module: Cukunity::Unity::CommandFacade

Included in:
ClientMethods
Defined in:
lib/cukunity/unity/command_facade.rb

Instance Method Summary collapse

Instance Method Details

#components(options = {}) ⇒ Object



46
47
48
49
50
51
# File 'lib/cukunity/unity/command_facade.rb', line 46

def components(options = {})
  options = merge_options(options, { :recursive => true })
  gameobjects.inject([]) do |components, gameobject|
    components + gameobject.components(options)
  end
end

#gameobject(name) ⇒ Object



40
41
42
43
44
# File 'lib/cukunity/unity/command_facade.rb', line 40

def gameobject(name)
  gameobjects.find do |gameobject|
    gameobject.value_of('name') == name
  end
end

#gameobjectsObject



36
37
38
# File 'lib/cukunity/unity/command_facade.rb', line 36

def gameobjects
  scene.gameobjects
end

#hint(options = {}) ⇒ Object



60
61
62
63
64
# File 'lib/cukunity/unity/command_facade.rb', line 60

def hint(options = {})
  hints(options).find do |h|
    yield h
  end
end

#hints(options = {}) ⇒ Object



53
54
55
56
57
58
# File 'lib/cukunity/unity/command_facade.rb', line 53

def hints(options = {})
  options = merge_options(options, { :recursive => true })
  gameobjects.inject([]) do |hints, gameobject|
    hints + gameobject.hints(options)
  end
end

#levelObject



8
9
10
# File 'lib/cukunity/unity/command_facade.rb', line 8

def level
  Unity::Level.new(command('get_level'))
end

#load_level(level, max_time = 30) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cukunity/unity/command_facade.rb', line 12

def load_level(level, max_time = 30)
  level_was_loaded = nil
  options = 
    if level.is_a? String
      level_was_loaded = lambda do
        self.level.name == level
      end
      { 'name' => level }
    else
      level_was_loaded = lambda do
        self.level.number == level.to_i
      end
      { 'number' => level.to_i }
    end
  Unity::Scene.new(self, command('load_level', options))
  raise Exception::UnityCommandError.new if check_timeout(max_time) do
    level_was_loaded.call
  end
end

#sceneObject



32
33
34
# File 'lib/cukunity/unity/command_facade.rb', line 32

def scene 
  Unity::Scene.new(self, command('get_scene'))
end

#screenObject



4
5
6
# File 'lib/cukunity/unity/command_facade.rb', line 4

def screen
  Unity::Screen.new(self, command('get_screen'))
end