赞 | 12 |
VIP | 107 |
好人卡 | 6 |
积分 | 4 |
经验 | 31122 |
最后登录 | 2024-6-29 |
在线时间 | 1606 小时 |
Lv2.观梦者 傻♂逼
- 梦石
- 0
- 星屑
- 374
- 在线时间
- 1606 小时
- 注册时间
- 2007-3-13
- 帖子
- 6562
|
3楼
楼主 |
发表于 2008-5-30 05:31:21
|
只看该作者
Class_Gu
- $最大波动 = 20
- $最小波动 = 5
- class Class_Gu
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :shellmonny # 股价
- attr_accessor :getgu # 持股
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def init
- @shellmonny = 100
- @getgu = 0
- end
- def buy
- if $game_party.gold > @shellmonny
- $game_party.gain_gold(-@shellmonny)
- @getgu += 1
- end
- end
- def shell
- if @getgu >= 1
- $game_party.gain_gold(@shellmonny)
- @getgu -= 1
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新对像
- #--------------------------------------------------------------------------
- def updata
- rnd = rand($最大波动-($最小波动+1))+($最小波动-1)
- if rand(2) == 1
- @shellmonny = @shellmonny + rnd
- else
- @shellmonny = @shellmonny - rnd
- end
- end
-
- end
- class Window_Gu < Window_Base
- #窗口对象开始
- #--------------------------------------------------------------------------
- # ● 初始化窗口对像
- #--------------------------------------------------------------------------
- def initialize
- super(4*32, 4*32, 7*32-16, 4*32)
- self.contents = Bitmap.new(width - 32, height - 32)
- @index = 1
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- cx = contents.text_size($data_system.words.gold).width
- cc = contents.text_size($Gu.shellmonny.to_s).width
- @cp = contents.text_size($Gu.getgu.to_s).width
- self.contents.font.color = normal_color
- self.contents.draw_text(4, 0, 120-cx-2, 32, "今日股价:", 2)
- self.contents.draw_text(32, 0, 120-cx-2, 32, $Gu.shellmonny.to_s, 2)
- self.contents.font.color = system_color
- self.contents.draw_text(124+cc, 0, cx, 32, $data_system.words.gold, 2)
- self.contents.draw_text(4, 32, 60-cx-2, 32, "买入", 2)
- self.contents.draw_text(4+64+4,32,@cp,32,$Gu.getgu.to_s,2)
- self.contents.draw_text(4+64+@cp+4, 32, 60-cx-2, 32, "卖出", 2)
- #~ @x = 4
- #~ @y = 32
- end
- def update
- super
- if Input.repeat?(Input::LEFT)
- @index= @index-1
- if @index <= 0
- @index = 2
- end
- end
- if Input.repeat?(Input::RIGHT)
- @index = @index+1
- if @index >= 3
- @index = 1
- end
- end
- if @index == 1
-
- self.cursor_rect.set(4, 32, 64, 32)
- end
- if @index == 2
- self.cursor_rect.set(4+64+@cp+4, 32, 64, 32)
- end
- if Input.trigger?(Input::C)
- if @index == 1
- $Gu.buy
- else
- $Gu.shell
- end
- #画面再生成
- refresh
- end
- end
- end
复制代码 |
|