Advertisement
nio_kasgami

Emoji Battle Grid beta

Aug 4th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.82 KB | None | 0 0
  1. module Emoji
  2.     module To_Battle!
  3.         Battle_Grid ={
  4.             # set grid cell size
  5.             :cell_height => 32,
  6.             :cell_width => 32,
  7.             # set grid size {duplicate by 2 for each side so for example
  8.             # for make 10 cell use 5}
  9.             :range_x => 5,
  10.             :range_y => 2,
  11.  
  12.             #Battle Range type {set by skill,item}
  13.  
  14.             #linear_type {go in front of the user vertically or horizontaly}
  15.             # it's use mostly for regular_attack
  16.             # you can edit it via notetag but
  17.             # you still need a default base
  18.                            # x_range,y_range, vertical or hori
  19.             :linear_type => [2,0,false],
  20.  
  21.             #cross_type {do a vertical and horizontal range in same time}
  22.             # serve for doing a small radius of damage around the target it's do a cross
  23.             # lines style
  24.                           #x_range,y_range,widht,height
  25.             :cross_type => [2,2,2,2],
  26.  
  27.             #square_type { do a square area around the target in the 8 direction}
  28.             # will do a small square radius of damage around the target.
  29.                           #x_range, y_range
  30.             :square_type =[3,3],
  31.  
  32.             # default actor and enemy move range {move in the 8 direction movement}
  33.             # values works for x and y
  34.             :default_actor_move_range = 3,
  35.             :default_enemy_move_range = 3
  36.  
  37.  
  38.  
  39.         }
  40.     end
  41. end
  42.  
  43. class Game_Grid
  44.     include Emoji::To_Battle!
  45.  
  46.     attr_accessor :cell_width
  47.     attr_accessor :cell_height
  48.  
  49.     attr_accessor :range_x
  50.     attr_accessor :range_y
  51.     attr_accessor :x
  52.     attr_accessor :y
  53.     attr_accessor :real_x
  54.     attr_accessor :real_y
  55.  
  56.     attr_accessor :range_type
  57.     attr_accessor :linear_type
  58.     attr_accessor :cross_type
  59.     attr_accessor :square_type
  60.  
  61.     attr_accessor :move_flag
  62.     attr_accessor :move_range
  63.  
  64.     attr_reader   :last_pos #for cursor sake
  65.  
  66.     def initialize
  67.         @cell_width =  0
  68.         @cell_height = 0
  69.  
  70.         @range_x = 0
  71.         @range_y = 0
  72.         @x = 0
  73.         @y = 0
  74.         @real_x = 0
  75.         @real_y = 0
  76.  
  77.         @range_type  = nil
  78.         @linear_type = [ ]
  79.         @cross_type  = [ ]
  80.         @square_type = [ ]
  81.  
  82.         @move_flag  = false
  83.         @move_range = 0
  84.  
  85.         @last_pos = nil
  86.         init_grid
  87.     end
  88.  
  89.     def init_grid
  90.         @cell_height = Battle_Grid[:cell_height]
  91.         @cell_width  = Battle_Grid[:cell_width]
  92.         @range_x     = Battle_Grid[:range_x]
  93.         @range_y     = Battle_Grid[:range_y]
  94.         @grid_center = [Graphics.width /2, Graphics.height /2 ]
  95.         set_type
  96.     end
  97.  
  98.     def set_type
  99.         set_linear_type
  100.         set_cross_type
  101.         set_square_type
  102.     end
  103.  
  104.     def set_linear_type
  105.         if @skill.note =~ /<battle_range : i,c>/
  106.             @battle_range_x = i
  107.             @battle_range_y = c
  108.     @battle_range_x = Battle_Grid[:linear_type[0]]
  109.     @battle_range_y = Battle_Grid[:linear_type[1]]
  110.     @hori_verti     = Battle_Grid[:linear_type[2]]
  111.  
  112.         @linear_type.push(@battle_range_x,@battle_range_y,@hori_verti)
  113.  
  114.     def out_of_grid_range?
  115.        @x > @range_x || @y > @range_y
  116.     end
  117.  
  118.     def max_grid_size
  119.         return (@range_x + @range_y) * 2
  120.     end
  121.  
  122. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement