Project1

标题: 战斗移位 [打印本页]

作者: qwe2121884    时间: 2010-8-1 09:58
标题: 战斗移位
请问各位前辈,战斗中移位是怎么做到的,需要脚本吗?
作者: liuxi0202    时间: 2010-8-1 10:34
  1. class Bitmap
  2.   def draw_number(x, y, number,o,picture = RPG::Cache.system("number"))
  3.     w = picture.width / 10
  4.     h = picture.height / 5
  5.     rect = Rect.new(0,0,w,h)
  6.     number = number.to_s
  7.     array = number.split(//)
  8.     for i in 0...array.size
  9.       array[i] = array[i].to_i
  10.     end
  11.     case o
  12.     when 1
  13.       x += 81 - (array.size * 9)
  14.     when 2
  15.     end
  16.     if number == "Miss"
  17.       self.blt(x,y,picture,Rect.new(0,h*3,picture.width,h))
  18.       return
  19.     end
  20.     for sz in array
  21.       rect.x = sz * w
  22.       self.blt(x,y,picture,rect)
  23.       x += w
  24.     end
  25.   end
  26. end
  27. module RPG
  28.   class Sprite < ::Sprite
  29.     def damage(value, critical)
  30.       dispose_damage
  31.       if value.is_a?(Numeric)
  32.         damage_string = value.abs.to_s
  33.       else
  34.         damage_string = value.to_s
  35.       end
  36.       bitmap = Bitmap.new(160, 48)
  37.       bitmap.font.name = "Arial Black"
  38.       bitmap.font.size = 32
  39.       if value.is_a?(Numeric) and value < 0
  40.         bitmap.font.color.set(176, 255, 144)
  41.       else
  42.         bitmap.font.color.set(255, 255, 255)
  43.       end
  44.       bitmap.draw_number(0, 12, damage_string,1)
  45.       if critical
  46.         bitmap.font.size = 20
  47.         bitmap.font.color.set(0, 0, 0)
  48.         bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  49.         bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  50.         bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  51.         bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  52.         bitmap.font.color.set(255, 255, 255)
  53.         bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  54.       end
  55.       @_damage_sprite = ::Sprite.new(self.viewport)
  56.       @_damage_sprite.bitmap = bitmap
  57.       @_damage_sprite.ox = 80
  58.       @_damage_sprite.oy = 20
  59.       @_damage_sprite.x = self.x
  60.       @_damage_sprite.y = self.y - self.oy / 2
  61.       @_damage_sprite.z = 3000
  62.       @_damage_duration = 40
  63.     end
  64.     def dispose_animation
  65.       if @_animation_sprites != nil
  66.         sprite = @_animation_sprites[0]
  67.         #if sprite != nil
  68.         #  @@_reference_count[sprite.bitmap] -= 1
  69.         #  if @@_reference_count[sprite.bitmap] == 0
  70.         #    sprite.bitmap.dispose
  71.         #  end
  72.         #end
  73.         for sprite in @_animation_sprites
  74.           sprite.dispose
  75.         end
  76.         @_animation_sprites = nil
  77.         @_animation = nil
  78.       end
  79.     end
  80.   end
  81. end
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1