class Object_Handler
def initialize
@enemies = {}
@springs = {}
@itens = {}
@pit={}
@enemy_move_right = false
@enemy_move_left = false
end
def update
@playerx = $game_player.x if $game_player != nil
@playery = $game_player.y if $game_player != nil
return
end
#------------------------------------------------------------------------------
#this handles the objec selection it gets the definitions from the platformer
#-----------------------------------------------------------------------------
def object_selector(object_type, id, opt1, opt2, opt3)
@eventid = id
if object_type == "Spring"
@spring_power = opt1
elsif object_type == "Enemy"
@enemy_sight = opt1
@enemy_move_pattern = opt2
@enemy_life_points = opt3
enemy
elsif object_type = "Itens"
end
end
#------------------------------------------------------------------------------
#Enemy Handler
#-----------------------------------------------------------------------------
def enemy
@enemy = $game_map.events[@eventid]
p @eventid
@enemyx = @enemy.x
@enemyy = @enemy.y
@distancex = ((@playerx.to_i - @enemyx.to_i)**2).to_i
@distancey = ((@playery.to_i - @enemyy.to_i)**2).to_i
@distance = Math.sqrt(@distancex + @distancey).to_i
p @distance.to_s
in_sight?
enemy_move_patern
end
#------------------------------------------------------------------------------
#In sight
#---------------------------------------------------
# Check if The player is in enemy sight!
#-----------------------------------------------------------------------------
def in_sight?
if @distance - @enemy_sight.to_i <= 0
return true
else
return false
end
end
#------------------------------------------------------------------------------
#Enemy movimentation
#---------------------------------------------------
# Check if The player is in enemy sight!
#-----------------------------------------------------------------------------
def enemy_move_patern
if @enemy_move_pattern == "Stay"
@enemy.move_speed = 0
@enemy_move_right = false
@enemy_move_left = false
elsif @enemy_move_pattern == "Horizontal"
horizontal_moving
elsif @enemy_move_pattern == "Custom"
@enemy.move_type = 3
else
@enemy.move_speed = 0
end
enemy
end
#------------------------------------------------------------------------------
#Enemy movimentation
#------------------------------------------------------------------------------
def horizontal_moving
@enemy.move_speed = 4
@enemy.move_frequency = 6
if $game_map.passable?(@enemy.x+1,@enemy.y, 4) or @enemy_move_left == true
@enemy.move_right
@enemy_move_right = true
@enemy_move_left = false
else
if $game_map.passable?(@enemy.x - 1,@enemy.y, 4)
@enemy.move_left
@enemy_move_right = false
@enemy_move_left = true
else
@enemy_move_right =false
@enemy_move_left = false
return
end
end
enemy
end
end#class end
#------------------------------------------------------------------------------
#**Class Game Player
#------------------------------------------------------------------------------
class Scene_Map
alias chaosg1_enemy_handler_scene_map_update update
def update
chaosg1_enemy_handler_scene_map_update
for i in 0..$object_handler.size
next if $object_handler[i] == nil
$object_handler[i].update
end
end
end
end#sdk end