class Main

Constants

Idle
Lost
Place
Shoot
Wait
Won

Attributes

setup[R]
state[R]

Public Class Methods

new() click to toggle source
Calls superclass method
# File bin/tactical_fighter, line 647
def initialize
        super()
        @server=DRb.start_service(nil,self)
        @remote_server=nil
        @state=Idle
        add(@setup=Setup.new(self))
        
        signal_connect('delete-event') {|me,ev|
                end_game
                true
        }

        show_all
end

Public Instance Methods

dont_shoot() click to toggle source
# File bin/tactical_fighter, line 733
def dont_shoot
        @state=Wait
        @maps.local.redraw_map
        @maps.remote.redraw_map
end
dont_wait() click to toggle source
# File bin/tactical_fighter, line 744
def dont_wait
        @state=Shoot
        @maps.local.redraw_map
        @maps.remote.redraw_map
        @maps.remote.fifo_shoot
end
end_game() click to toggle source
# File bin/tactical_fighter, line 685
def end_game
        unless idle?
                @maps.destroy
                add(@setup)
                show_all
                @state=Idle
                @remote_server.end_game
                @remote_server=nil
        end
end
ended?() click to toggle source
# File bin/tactical_fighter, line 675
def ended?
        @state == Won || @state == Lost
end
enemy_shoot(x,y) click to toggle source
# File bin/tactical_fighter, line 756
def enemy_shoot(x,y)
        @maps.local.hit?(x,y)
end
hello(remote_server) click to toggle source
# File bin/tactical_fighter, line 713
def hello(remote_server)
        @remote_server=remote_server
        @setup.remote_address.set_text(@remote_server.uri)
        remove(child)
        add(@maps=MultiMap.new(self,setup.nxw.value,setup.nyw.value))
        @state=Place
        true
end
idle?() click to toggle source
# File bin/tactical_fighter, line 663
def idle?
        @state == Idle
end
lost() click to toggle source
# File bin/tactical_fighter, line 759
def lost
        @state=Lost
        @remote_server.won
        @maps.local.redraw_map
        @maps.remote.redraw_map
end
lost?() click to toggle source
# File bin/tactical_fighter, line 681
def lost?
        @state == Lost
end
place?() click to toggle source
# File bin/tactical_fighter, line 666
def place?
        @state == Place
end
ready() click to toggle source
# File bin/tactical_fighter, line 721
def ready
        if @remote_server.ready?
                wait
        end
end
ready?() click to toggle source
# File bin/tactical_fighter, line 750
def ready?
        @maps.local.all_set?
end
shoot() click to toggle source
# File bin/tactical_fighter, line 726
def shoot
        @state=Shoot
        @remote_server.dont_shoot
        @maps.local.redraw_map
        @maps.remote.redraw_map
        @maps.remote.fifo_shoot
end
shoot?() click to toggle source
# File bin/tactical_fighter, line 669
def shoot?
        @state == Shoot
end
shoot_enemy(x,y) click to toggle source
# File bin/tactical_fighter, line 753
def shoot_enemy(x,y)
        @remote_server.enemy_shoot(x,y)
end
start_game() click to toggle source
# File bin/tactical_fighter, line 696
def start_game
        begin
                helloed=false
                @remote_server=DRbObject.new(nil, "druby://#{@setup.remote_address.text}")
                @remote_server.setup.set_map_size(@setup.nxw.value,@setup.nyw.value)
                helloed=@remote_server.hello(self)
                @setup.remote_address.set_text(@remote_server.uri)
        rescue =>e
                print e.message,"\n",e.backtrace.join("\n\t")
        end
        if helloed
                remove(child)
                add(@maps=MultiMap.new(self,setup.nxw.value,setup.nyw.value))
                @state=Place
        end
end
uri() click to toggle source
# File bin/tactical_fighter, line 770
def uri
        @server.uri[@server.uri.rindex('/')+1 .. @server.uri.length]
end
wait() click to toggle source
# File bin/tactical_fighter, line 738
def wait
        @state=Wait
        @remote_server.dont_wait
        @maps.local.redraw_map
        @maps.remote.redraw_map
end
wait?() click to toggle source
# File bin/tactical_fighter, line 672
def wait?
        @state == Wait
end
won() click to toggle source
# File bin/tactical_fighter, line 765
def won
        @state=Won
        @maps.local.redraw_map
        @maps.remote.redraw_map
end
won?() click to toggle source
# File bin/tactical_fighter, line 678
def won?
        @state == Won
end