设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2745|回复: 3
打印 上一主题 下一主题

[原创发布] 【脚写脚本】简易跑步时长限制

[复制链接]

Lv5.捕梦者

梦石
10
星屑
39440
在线时间
1914 小时
注册时间
2010-11-14
帖子
3315

R考场第七期纪念奖

跳转到指定楼层
1
发表于 2020-5-2 12:29:34 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
嗯,功能如题目所说,其他的不多说了,直接放图放脚本。
希望收脚本的客官能留个评论。



RUBY 代码复制
  1. ##
  2. # 跑步时长限制 by Calendar99
  3. #
  4. module CLD99
  5.   module DASH_TIME_LIMIT
  6.     # 跑步最长持续时间(单位:帧)
  7.     MAX_DASH_TIME = 90
  8.  
  9.     # 显示体力
  10.     DISPLAY_TIME_LIMIT = true
  11.  
  12.     # 体力较多时的颜色
  13.     COLOR1 = Color.new(0, 0, 255)
  14.  
  15.     # 体力较少时的颜色
  16.     COLOR2 = Color.new(255, 0, 0)
  17.   end
  18. end
  19.  
  20. class Game_Player
  21.   attr_reader :dash_time
  22.   alias initialize_for_dash_with_time_limit initialize
  23.   def initialize
  24.     initialize_for_dash_with_time_limit
  25.     @dash_time = CLD99::DASH_TIME_LIMIT::MAX_DASH_TIME
  26.   end
  27.   alias dash_without_time_limit dash?
  28.   def dash?
  29.     dash_without_time_limit && @dash_time > 0
  30.   end
  31.   alias update_for_dash_with_time_limit update
  32.   def update
  33.     update_for_dash_with_time_limit
  34.     if moving? && dash_without_time_limit
  35.       @dash_time = [@dash_time - 1, 0].max
  36.     else
  37.       @dash_time = [@dash_time + 1, CLD99::DASH_TIME_LIMIT::MAX_DASH_TIME].min
  38.     end
  39.   end
  40. end
  41.  
  42. class Sprite_Character
  43.   alias update_for_dash_time update
  44.   def update
  45.     update_for_dash_time
  46.     return unless character.is_a?(Game_Player)
  47.     return unless CLD99::DASH_TIME_LIMIT::DISPLAY_TIME_LIMIT
  48.     if character.dash_time < CLD99::DASH_TIME_LIMIT::MAX_DASH_TIME
  49.       display_dash_time
  50.     else
  51.       hide_dash_time
  52.     end
  53.   end
  54.   def display_dash_time
  55.     if !@sprite_dash_time
  56.       @sprite_dash_time = Sprite.new
  57.       @sprite_dash_time.ox = 16
  58.       @sprite_dash_time.oy = 4
  59.     end
  60.     if !@sprite_dash_time.bitmap
  61.       @bmp_dash_time1 = Bitmap.new(32, 8)
  62.       @bmp_dash_time1.fill_rect(0, 0, 32, 8, CLD99::DASH_TIME_LIMIT::COLOR1)
  63.       @bmp_dash_time2 = Bitmap.new(32, 8)
  64.       @bmp_dash_time2.fill_rect(0, 0, 32, 8, CLD99::DASH_TIME_LIMIT::COLOR2)
  65.     end
  66.     @sprite_dash_time.x = self.x
  67.     @sprite_dash_time.y = self.y + 4
  68.     rate = character.dash_time / CLD99::DASH_TIME_LIMIT::MAX_DASH_TIME.to_f
  69.     @sprite_dash_time.bitmap = rate < 0.3 ? @bmp_dash_time2 : @bmp_dash_time1
  70.     @sprite_dash_time.src_rect.width = 32 * rate
  71.     @sprite_dash_time.visible = true
  72.   end
  73.   def hide_dash_time
  74.     return unless @sprite_dash_time
  75.     @sprite_dash_time.visible = false   
  76.   end
  77.   alias dispose_for_dash_time dispose
  78.   def dispose
  79.     dispose_for_dash_time
  80.     @sprite_dash_time.dispose if @sprite_dash_time
  81.     @bmp_dash_time1.dispose if @bmp_dash_time1
  82.     @bmp_dash_time2.dispose if @bmp_dash_time2
  83.   end
  84. end

评分

参与人数 2+2 收起 理由
枻白白 + 1 塞糖
刈飒的风 + 1 我很赞同

查看全部评分

用头画头像,用脚写脚本

Lv4.逐梦者

梦石
2
星屑
6639
在线时间
501 小时
注册时间
2018-3-23
帖子
533

R考场第七期银奖

2
发表于 2020-5-2 14:03:53 | 只看该作者
熟悉的四字前缀hhhh
顶一个!虽然貌似没看懂怎么用(逃

点评

这也太强了,中午还在讨论怎么做,下午就有脚本了  发表于 2020-5-2 14:24
祝好。
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv4.逐梦者 (禁止发言)

梦石
0
星屑
5701
在线时间
922 小时
注册时间
2013-8-29
帖子
1468
3
发表于 2020-5-10 01:44:57 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-24 17:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表