查看: 3561|回复: 3

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

[复制链接]
梦石
10
星屑
39550
在线时间
1919 小时
注册时间
2010-11-14
回帖
3214

R考场第七期纪念奖

发表于 2020-5-2 12:29:34 | 显示全部楼层 |阅读模式

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

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

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

11.gif

[pre lang="ruby"]##
# 跑步时长限制 by Calendar99
#
module CLD99
  module DASH_TIME_LIMIT
    # 跑步最长持续时间(单位:帧)
    MAX_DASH_TIME = 90
   
    # 显示体力
    DISPLAY_TIME_LIMIT = true
   
    # 体力较多时的颜色
    COLOR1 = Color.new(0, 0, 255)
   
    # 体力较少时的颜色
    COLOR2 = Color.new(255, 0, 0)
  end
end

class Game_Player
  attr_reader :dash_time
  alias initialize_for_dash_with_time_limit initialize
  def initialize
    initialize_for_dash_with_time_limit
    @dash_time = CLD99::DASH_TIME_LIMIT::MAX_DASH_TIME
  end
  alias dash_without_time_limit dash?
  def dash?
    dash_without_time_limit && @dash_time > 0
  end
  alias update_for_dash_with_time_limit update
  def update
    update_for_dash_with_time_limit
    if moving? && dash_without_time_limit
      @dash_time = [@dash_time - 1, 0].max
    else
      @dash_time = [@dash_time + 1, CLD99::DASH_TIME_LIMIT::MAX_DASH_TIME].min
    end
  end
end

class Sprite_Character
  alias update_for_dash_time update
  def update
    update_for_dash_time
    return unless character.is_a?(Game_Player)
    return unless CLD99::DASH_TIME_LIMIT::DISPLAY_TIME_LIMIT
    if character.dash_time < CLD99::DASH_TIME_LIMIT::MAX_DASH_TIME
      display_dash_time
    else
      hide_dash_time
    end
  end
  def display_dash_time
    if !@sprite_dash_time
      @sprite_dash_time = Sprite.new
      @sprite_dash_time.ox = 16
      @sprite_dash_time.oy = 4
    end
    if !@sprite_dash_time.bitmap
      @bmp_dash_time1 = Bitmap.new(32, 8)
      @bmp_dash_time1.fill_rect(0, 0, 32, 8, CLD99::DASH_TIME_LIMIT::COLOR1)
      @bmp_dash_time2 = Bitmap.new(32, 8)
      @bmp_dash_time2.fill_rect(0, 0, 32, 8, CLD99::DASH_TIME_LIMIT::COLOR2)
    end
    @sprite_dash_time.x = self.x
    @sprite_dash_time.y = self.y + 4
    rate = character.dash_time / CLD99::DASH_TIME_LIMIT::MAX_DASH_TIME.to_f
    @sprite_dash_time.bitmap = rate < 0.3 ? @bmp_dash_time2 : @bmp_dash_time1
    @sprite_dash_time.src_rect.width = 32 * rate
    @sprite_dash_time.visible = true
  end
  def hide_dash_time
    return unless @sprite_dash_time
    @sprite_dash_time.visible = false   
  end
  alias dispose_for_dash_time dispose
  def dispose
    dispose_for_dash_time
    @sprite_dash_time.dispose if @sprite_dash_time
    @bmp_dash_time1.dispose if @bmp_dash_time1
    @bmp_dash_time2.dispose if @bmp_dash_time2
  end
end[/pre]

评分

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

查看全部评分

用头画头像,用脚写脚本
梦石
2
星屑
6767
在线时间
501 小时
注册时间
2018-3-23
回帖
487

R考场第七期银奖

发表于 2020-5-2 14:03:53 | 显示全部楼层
熟悉的四字前缀hhhh
顶一个!虽然貌似没看懂怎么用(逃

点评

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

使用道具 举报

头像被屏蔽
梦石
0
星屑
5706
在线时间
922 小时
注册时间
2013-8-29
回帖
1401
发表于 2020-5-10 01:44:57 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部