Já viram qual a arte dessa semana?Exposição dos Artistas #8
6 Respostas   226 Visualizações
0 Membros e 1 Visitante estão vendo este tópico.
class Game_Followers attr_reader :switch_one attr_reader :switch_two alias prev_initialize initialize def initialize(leader) prev_initialize(leader) @switch_one = false @switch_two = false end alias prev_update update def update prev_update if Input.trigger?(:X) @switch_two = false gather @switch_one = true end if !moving? && !gathering? && @switch_one triangle_formation end end def move if @switch_two == false reverse_each {|follower| follower.chase_preceding_character } elsif @switch_two == true reverse_each {|follower| self.triangle_formation_follow } end end def triangle_formation case $game_player.direction when 2 self[0].move_straight(4) self[0].set_direction(2) self[1].move_straight(6) self[1].set_direction(2) self[2].move_straight(2) self[2].set_direction(2) when 4 self[0].move_straight(8) self[0].set_direction(4) self[1].move_straight(2) self[1].set_direction(4) self[2].move_straight(4) self[2].set_direction(4) when 6 self[0].move_straight(8) self[0].set_direction(6) self[1].move_straight(2) self[1].set_direction(6) self[2].move_straight(6) self[2].set_direction(6) when 8 self[0].move_straight(4) self[0].set_direction(8) self[1].move_straight(6) self[1].set_direction(8) self[2].move_straight(8) self[2].set_direction(8) end @switch_one = false; @switch_two = true end def triangle_formation_follow unless moving? case $game_player.direction when 2 $game_player.followers[0].move_straight(2) $game_player.followers[1].move_straight(2) $game_player.followers[2].move_straight(2) when 4 $game_player.followers[0].move_straight(4) $game_player.followers[1].move_straight(4) $game_player.followers[2].move_straight(4) when 6 $game_player.followers[0].move_straight(6) $game_player.followers[1].move_straight(6) $game_player.followers[2].move_straight(6) when 8 $game_player.followers[0].move_straight(8) $game_player.followers[1].move_straight(8) $game_player.followers[2].move_straight(8) end end endend=beginABAIXO TEM UMAS DAS MINHAS TENTATIVAS DE SOLUÇÃO, DEIXEI PARA VOCÊS ANALISAREMO CAMINHO QUE EU ESTOU TOMANDO (não funciona, obviamente).=endclass Game_Follower < Game_Character def chase_preceding_character unless moving? if @switch_two == false sx = distance_x_from(@preceding_character.x) sy = distance_y_from(@preceding_character.y) elsif @switch_two == true sx = nil sy = nil end if sx != 0 && sy != 0 move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2) elsif sx != 0 move_straight(sx > 0 ? 4 : 6) elsif sy != 0 move_straight(sy > 0 ? 8 : 2) end end endend
def move_straight(d, turn_ok = true) @followers.move if passable?(@x, @y, d) superend
def chase_preceding_character unless moving? sx = distance_x_from(@preceding_character.x) sy = distance_y_from(@preceding_character.y) if sx != 0 && sy != 0 move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2) elsif sx != 0 move_straight(sx > 0 ? 4 : 6) elsif sy != 0 move_straight(sy > 0 ? 8 : 2) end endend
def triangle_formation_follow unless moving? each do |follower| follower.move_straight(Input.dir4) if Input.dir4 > 0 end endend
def move_straight(d, turn_ok = true) @move_succeed = passable?(@x, @y, d) if @move_succeed set_direction(d) @x = $game_map.round_x_with_direction(@x, d) @y = $game_map.round_y_with_direction(@y, d) @real_x = $game_map.x_with_direction(@x, reverse_dir(d)) @real_y = $game_map.y_with_direction(@y, reverse_dir(d)) increase_steps elsif turn_ok set_direction(d) check_event_trigger_touch_front endend
def move_by_input return if !movable? || $game_map.interpreter.running? move_straight(Input.dir4) if Input.dir4 > 0end
def each @data.each {|follower| yield follower } if block_given?end
each do |follower| puts follower.actor.nameendself.each do |follower| puts follower.actor.nameend@data.each do |follower| puts follower.actor.nameend
#--------------------------------------------------------------------------# * Movement#--------------------------------------------------------------------------alias move_201611032221 movedef move if @switch_two reverse_each {|follower| follower.triangle_formation_follow } return end move_201611032221end
#--------------------------------------------------------------------------# * Triangle Formation Follow#--------------------------------------------------------------------------def triangle_formation_follow unless moving? move_straight(Input.dir4) if Input.dir4 endend
def triangle_formation_follow unless moving? each do |follower| follower.move_straight(Input.dir4) if Input.dir4 > 0 end end end
@followers.move if passable?(@x, @y, d)
self.move_straight(Input.dir4)
def move_straight(*args) each {|follower| follower.move_straight(*args) }end