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

Project1

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

[RM脚本] 一个绝好的银行系统(存取款、买卖债券)

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
2 小时
注册时间
2006-9-3
帖子
61
跳转到指定楼层
1
发表于 2006-10-1 11:30:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
一个绝好的银行系统,只是是英文版。我自己英语不好。呵呵!希望贴出来大家改进!
  1. #   Created By SephirothSpawn (12.03.05)
  2. #   Last Updated: 12.03.05
  3. # Banking System

  4. # ** Scene_Title

  5. class Scene_Title
  6.   
  7.   # * Alias Command: New Game
  8.   alias bank_command_new_game command_new_game
  9.   #-----------------------------------------------------
  10.   # * Command: New Game
  11.   #-----------------------------------------------------
  12.   def command_new_game
  13.     $game_bank = Game_BankSystem.new
  14.     bank_command_new_game
  15.   end
  16. end

  17. #==============================================================================
  18. # ** Window_RefreshCommand
  19. #==============================================================================
  20. class Window_RefreshCommand < Window_Selectable
  21.   #--------------------------------------------------------------------------
  22.   # * Object Initialization
  23.   #     width    : window width
  24.   #     commands : command text string array
  25.   #--------------------------------------------------------------------------
  26.   def initialize(width, commands)
  27.     # Compute window height from command quantity
  28.     super(0, 0, width, commands.size * 32 + 32)
  29.     @item_max = commands.size
  30.     @commands = commands
  31.     refresh
  32.     self.index = 0
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # * Refresh
  36.   #--------------------------------------------------------------------------
  37.   def refresh(commands = @commands)
  38.     @commands = commands
  39.     @item_max = commands.size
  40.     if self.contents != nil
  41.       self.contents.dispose
  42.       self.contents = nil
  43.     end
  44.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  45.     for i in 0...@item_max
  46.       draw_item(i, normal_color)
  47.     end
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # * Draw Item
  51.   #     index : item number
  52.   #     color : text color
  53.   #--------------------------------------------------------------------------
  54.   def draw_item(index, color)
  55.     self.contents.font.color = color
  56.     self.contents.draw_text(0, 32 * index, self.contents.width - 8, 32, @commands[index], 1)
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # * Disable Item
  60.   #     index : item number
  61.   #--------------------------------------------------------------------------
  62.   def disable_item(index)
  63.     draw_item(index, disabled_color)
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # * Undisable Item
  67.   #     index : item number
  68.   #--------------------------------------------------------------------------
  69.   def disable_item(index)
  70.     draw_item(index, normal_color)
  71.   end
  72. end

  73. #==============================================================================
  74. # ** Game_BankSystem
  75. #==============================================================================
  76. class Game_BankSystem
  77.   #--------------------------------------------------------------------------
  78.   # * Public Instance Variables
  79.   #--------------------------------------------------------------------------
  80.   attr_accessor :account_balance
  81.   attr_accessor :interest_rate
  82.   attr_accessor :saving_bonds
  83.   #--------------------------------------------------------------------------
  84.   # * Object Initialization
  85.   #--------------------------------------------------------------------------
  86.   def initialize
  87.     @account_balance = 0
  88.     @interest_rate = 1
  89.     @saving_bonds = []
  90.     @last_interest_time = 0
  91.   end

  92.   # * Update
  93.     def update
  94.     # Updates Deposited Amount
  95.     interest_time = (Graphics.frame_count / Graphics.frame_rate - @last_interest_time) / 3600.0
  96.     interest_amt = (@account_balance * @interest_rate / 100.0 * interest_time).to_i
  97.     if interest_amt > 0
  98.       @last_interest_time = Graphics.frame_count / Graphics.frame_rate
  99.       @account_balance += interest_amt
  100.       # Refreshes Data Windows
  101.       $scene.refresh_windows
  102.     end
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # * Deposit
  106.   #--------------------------------------------------------------------------
  107.   def deposit(amount)
  108.     $game_party.lose_gold(amount)
  109.     @account_balance += amount
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # * Withdraw
  113.   #--------------------------------------------------------------------------
  114.   def withdraw(amount)
  115.     @account_balance -= amount
  116.     $game_party.gain_gold(amount)
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # * Add Savings Bond
  120.   #--------------------------------------------------------------------------
  121.   def add_bond(bond)
  122.     @saving_bonds.push(bond)
  123.     @saving_bonds.sort! {|a, b| a.name <=> b.name}
  124.   end
  125. end

  126. #==============================================================================
  127. # ** Savings_Bond
  128. #==============================================================================
  129. class Savings_Bond
  130.   #--------------------------------------------------------------------------
  131.   # * Public Instance Variables
  132.   #--------------------------------------------------------------------------
  133.   attr_accessor :name
  134.   attr_accessor :cost
  135.   attr_accessor :interest_rate
  136.   attr_accessor :length
  137.   attr_accessor :time_bought
  138.   attr_accessor :time_finished
  139.   attr_accessor :mature_value
  140.   #--------------------------------------------------------------------------
  141.   # * Object Initialization
  142.   #     name           : Savings Bond Name
  143.   #     cost             : Savings Bond Cost
  144.   #     interest_rate : Savings Bond Interest Rate (In Percent)
  145.   #     length          : Length of Hours until Mature
  146.   #--------------------------------------------------------------------------
  147.   def initialize(name, cost, interest_rate, length)
  148.     @name = name
  149.     @cost = cost
  150.     @interest_rate = interest_rate
  151.     @length = length
  152.     @mature_value = (@cost * (1+ @interest_rate / 100.0)).to_i
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # * Set Times
  156.   #--------------------------------------------------------------------------
  157.   def set_times
  158.     @time_bought = Graphics.frame_count / Graphics.frame_rate
  159.     @time_finished = @time_bought + @length * 3600
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   # * Make Time to HH:MM:SS
  163.   #--------------------------------------------------------------------------
  164.   def return_time(time)
  165.     hours      = time / 60 / 60
  166.     minutes   = time / 60 % 60
  167.     seconds   = time % 60
  168.     return sprintf("%02d:%02d:%02d", hours, minutes, seconds)
  169.   end
  170. end

  171. #==============================================================================
  172. # ** Window_BankNumber
  173. #==============================================================================
  174. class Window_BankNumber < Window_Base
  175.   #--------------------------------------------------------------------------
  176.   # * Object Initialization
  177.   #--------------------------------------------------------------------------
  178.   def initialize
  179.     super(640, 272, 240, 192)
  180.       self.opacity = 175
  181.     self.contents = Bitmap.new(width - 32, height - 32)
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # * Refresh
  185.   #     money  : Gold being...
  186.   #     type      : Deposit or Withdraw
  187.   #--------------------------------------------------------------------------
  188.   def refresh(money, type)
  189.     contents.clear
  190.     # Deposit or Withdraw
  191.     contents.font.color = system_color
  192.     contents.draw_text(0, 0, contents.width, 24, "Amount to #{type}", 1)
  193.     if type == "Deposit"
  194.       # Draws Game Party Gold
  195.       contents.draw_text(4, 48, contents.width, 24, "Current #{$data_system.words.gold}:")
  196.       contents.font.color = normal_color
  197.       contents.draw_text(-4, 48, contents.width, 24, $game_party.gold.to_s, 2)
  198.     else
  199.       # Draws Account Balance
  200.       contents.draw_text(4, 48, contents.width, 24, "Account Balance:")
  201.       contents.font.color = normal_color
  202.       contents.draw_text(-4, 48, contents.width, 24, $game_bank.account_balance.to_s, 2)
  203.     end
  204.     # Draws Money Being Deposited or Withdrawn
  205.     contents.font.color = system_color
  206.     contents.draw_text(4, 72, contents.width, 24, "#{type} Amount:")
  207.     contents.font.color = normal_color
  208.     contents.draw_text(-4, 72, contents.width, 24, "- #{money}", 2)
  209.     # Draws Line
  210.     line = ""
  211.     while contents.text_size(line).width < contents.width
  212.       line += "-"
  213.     end
  214.     contents.draw_text(0, 96, contents.width, 24, line, 2)
  215.     # Draws Game Party Gold Amont
  216.     contents.font.color = system_color
  217.     contents.draw_text(4, 112, contents.width, 32, "#{$data_system.words.gold} After:")
  218.     amount = $game_party.gold
  219.     amount += type == "Deposit" ? -money : money
  220.     contents.font.color = normal_color
  221.     contents.draw_text(-4, 112, contents.width, 32, amount.to_s, 2)
  222.     # Draws Deposit Amont
  223.     amount = $game_bank.account_balance
  224.     amount += type == "Deposit" ? money : -money
  225.     contents.font.color = system_color
  226.     contents.draw_text(4, 136, contents.width, 32, "Balance After:")
  227.     contents.font.color = normal_color
  228.     contents.draw_text(-4, 136, contents.width, 32, amount.to_s, 2)
  229.   end
  230. end

  231. #==============================================================================
  232. # ** Window_BankBio
  233. #==============================================================================
  234. class Window_BankBio < Window_Base
  235.   #--------------------------------------------------------------------------
  236.   # * Object Initialization
  237.   #--------------------------------------------------------------------------
  238.   def initialize
  239.     super(-240, 272, 240, 192)
  240.       self.opacity = 175
  241.     self.contents = Bitmap.new(width - 32, height - 32)
  242.     refresh
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # * Refresh
  246.   #--------------------------------------------------------------------------
  247.   def refresh
  248.     contents.clear
  249.     # Deposit or Withdraw
  250.     contents.font.color = system_color
  251.     # Draws Actor Name in Postition 1
  252.     contents.font.color = normal_color
  253.     contents.draw_text(0, 0, contents.width, 24, "#{$game_party.actors[0].name}", 1)
  254.     # Draws Game Party Gold
  255.     contents.font.color = system_color
  256.     contents.draw_text(4, 32, contents.width, 24, "Current #{$data_system.words.gold}:")
  257.     contents.font.color = normal_color
  258.     contents.draw_text(-4, 32, contents.width, 24, $game_party.gold.to_s, 2)
  259.     # Draws Account Balance
  260.     contents.font.color = system_color
  261.     contents.draw_text(4, 56, contents.width, 24, "Account Balance:")
  262.     contents.font.color = normal_color
  263.     contents.draw_text(-4, 56, contents.width, 24, $game_bank.account_balance.to_s, 2)
  264.     # Draws Number of Savings Bond's
  265.     contents.font.color = system_color
  266.     contents.draw_text(4, 80, contents.width, 24, "Bonds Owned:")
  267.     contents.font.color = normal_color
  268.     contents.draw_text(-4, 80, contents.width, 24, $game_bank.saving_bonds.size.to_s, 2)
  269.     # Draws Value of Savings Bond's
  270.     value = 0
  271.     $game_bank.saving_bonds.each { |x| value += x.mature_value}
  272.     contents.font.color = system_color
  273.     contents.draw_text(4, 104, contents.width, 24, "Bonds Value:")
  274.     contents.font.color = normal_color
  275.     contents.draw_text(-4, 104, contents.width, 24, value.to_s, 2)
  276.     # Draws Current Interest Rate
  277.     contents.font.color = system_color
  278.     contents.draw_text(4, 136, contents.width, 24, "Interest Rate:")
  279.     contents.font.color = normal_color
  280.     contents.draw_text(-4, 136, contents.width, 24, "#{$game_bank.interest_rate} %", 2)
  281.   end
  282. end

  283. #==============================================================================
  284. # ** Window_Bond
  285. #==============================================================================
  286. class Window_Bond < Window_Base
  287.   #--------------------------------------------------------------------------
  288.   # * Object Initialization
  289.   #--------------------------------------------------------------------------
  290.   def initialize
  291.     super(-240, 264, 240, 200)
  292.       self.opacity = 175
  293.     self.contents = Bitmap.new(width - 32, height - 32)
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # * Refresh
  297.   #     bond    : Savings Bond
  298.   #--------------------------------------------------------------------------
  299.   def refresh(bond, bought = false)
  300.     contents.clear
  301.     unless bond == nil
  302.       # Draws Bond Name
  303.       contents.font.color = system_color
  304.       contents.draw_text(0, 0, contents.width, 24, bond.name, 1)
  305.       # Draws Bond Cost
  306.       contents.font.color = system_color
  307.       contents.draw_text(4, 24, contents.width, 24, "Bond Cost:")
  308.       contents.font.color = normal_color
  309.       contents.draw_text(-4, 24, contents.width, 24, bond.cost.to_s, 2)
  310.       # Draws Bond Mature Value
  311.       contents.font.color = system_color
  312.       contents.draw_text(4, 48, contents.width, 24, "Mature Value:")
  313.       contents.font.color = normal_color
  314.       contents.draw_text(-4, 48, contents.width, 24, "#{bond.mature_value}", 2)
  315.       # Draws Bond Interest Rate
  316.       contents.font.color = system_color
  317.       contents.draw_text(4, 72, contents.width, 24, "Interest Rate:")
  318.       contents.font.color = normal_color
  319.       contents.draw_text(-4, 72, contents.width, 24, "#{bond.interest_rate} %", 2)
  320.       # Draws Length until Maturity
  321.       contents.font.color = system_color
  322.       contents.draw_text(4, 96, contents.width, 24, "Maturity Time:")
  323.       contents.font.color = normal_color
  324.       contents.draw_text(-4, 96, contents.width, 24, "#{bond.length} Hours", 2)
  325.       # Display only if Purchased CD
  326.       if bought
  327.         # Draws Time Bought
  328.         contents.font.color = system_color
  329.         contents.draw_text(4, 120, contents.width, 24, "Time Bought:")
  330.         contents.font.color = normal_color
  331.         contents.draw_text(-4, 120, contents.width, 24, bond.return_time(bond.time_bought), 2)
  332.         # Draws Time Finished
  333.         contents.font.color = system_color
  334.         contents.draw_text(4, 144, contents.width, 24, "Time Finished:")
  335.         contents.font.color = normal_color
  336.         contents.draw_text(-4, 144, contents.width, 24, bond.return_time(bond.time_finished), 2)
  337.       end
  338.     end
  339.   end
  340. end

  341. #==============================================================================
  342. # ** Scene_Bank
  343. #==============================================================================
  344. class Scene_Bank
  345.   #--------------------------------------------------------------------------
  346.   # * Object Initialization
  347.   #     interest rate   :   Changes Current Interest Rate (Leave 0 for no Change)
  348.   #     bonds           :   Avaliable CD's For Purchasing
  349.   #--------------------------------------------------------------------------
  350.   def initialize(interest_rate = $game_bank.interest_rate,
  351.       bonds = [ Savings_Bond.new("CD-7", 100, 7.5, 7), Savings_Bond.new("CD-14", 500, 15, 14)])
  352.     $game_bank.interest_rate = interest_rate unless interest_rate == 0
  353.     @bonds = bonds
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # * Main Processing
  357.   #--------------------------------------------------------------------------
  358.   def main
  359.     # Current Phase
  360.     @phase = -1
  361.     # Refreshing Variables
  362.     @amount, @depositing = 0, true
  363.     @current_bond, @bond_bought = nil, false
  364.     # Make sprite set
  365.     @spriteset = Spriteset_Map.new
  366.     # Help Window
  367.     @help_window = Window_Help.new
  368.       @help_window.y, @help_window.opacity = -64, 175
  369.       @help_window.set_text("Welcome to the Bank", 1)
  370.     # Bank Bio
  371.     @bank_bio_window = Window_BankBio.new
  372.     # Avaliable Bond Information Display Window
  373.     @av_bond_display_window = Window_Bond.new
  374.     # Owned Bond Information Display Window
  375.     @own_bond_display_window = Window_Bond.new
  376.     # Main Command
  377.     @main_command = Window_RefreshCommand.new(180, [
  378.         "Deposit #{g_word = $data_system.words.gold}",
  379.         "Withdraw #{g_word}", "Purchase Bond", "Get Mature Bond", "Exit"])
  380.       @main_command.x, @main_command.y, @main_command.opacity = 644, 272, 175
  381.       @main_command.active = false
  382.     # Bank Number Window
  383.     @bank_number_window = Window_BankNumber.new
  384.     # Avaliable Bonds Command
  385.     commands = []
  386.     @bonds.each {|x| commands.push(x.name)}; commands.push("Back")
  387.     @av_bond_command = Window_RefreshCommand.new(180, commands)
  388.       @av_bond_command.x, @av_bond_command.y = 644, 272
  389.       @av_bond_command.height, @av_bond_command.opacity = 192, 175
  390.       @av_bond_command.active = false
  391.     # CD's Have
  392.     @own_bond_command = Window_RefreshCommand.new(180, get_cd_list)
  393.       @own_bond_command.x, @own_bond_command.y = 644, 272
  394.       @own_bond_command.height, @own_bond_command.opacity = 192, 175
  395.       @own_bond_command.active = false
  396.     # Scene Objects
  397.     @objects = [@spriteset, @help_window, @bank_bio_window, @av_bond_display_window,
  398.         @own_bond_display_window, @main_command, @bank_number_window,
  399.         @av_bond_command, @own_bond_command]
  400.     # Execute transition
  401.     Graphics.transition
  402.     # Main loop
  403.     while $scene == self
  404.       # Update game screen
  405.       Graphics.update
  406.       # Update input information
  407.       Input.update
  408.       # Update Objects
  409.       @objects.each {|x| x.update}
  410.       # Updates Bank System
  411.       $game_bank.update
  412.       # Frame update
  413.       update
  414.     end
  415.     # Prepare for transition
  416.     Graphics.freeze
  417.     # Dispose of windows
  418.     @objects.each {|x| x.dispose}
  419.   end
  420.   #--------------------------------------------------------------------------
  421.   # * Frame Update
  422.   #--------------------------------------------------------------------------
  423.   def update
  424.     # Splits Phases Up
  425.     case @phase
  426.     when -1 # Intro Phase
  427.       intro_update
  428.     when 0  # Main Phase
  429.       main_update
  430.     when 1  # Deposit or Withdraw Phase
  431.       account_update
  432.     when 2  # Buy CD Phase
  433.       buy_bond_update
  434.     when 3  # Get Mature CD Phse
  435.       get_bond_update
  436.     when 99 # Exit Phase
  437.       exit_update
  438.     end
  439.   end
  440.   #--------------------------------------------------------------------------
  441.   # * Intro Update
  442.   #--------------------------------------------------------------------------
  443.   def intro_update
  444.     # Moves Window Down
  445.     @help_window.y += 4 if @help_window.y < 0
  446.     if @help_window.y == 0
  447.       # Input Processing
  448.       if Input.trigger?(Input::B)
  449.         $game_system.se_play($data_system.cancel_se)
  450.         # Returns to Scene
  451.         @phase = 99
  452.       elsif Input.trigger?(Input::C)
  453.         $game_system.se_play($data_system.decision_se)
  454.         # Switchs to Main Phase
  455.         @phase = 0
  456.       end
  457.     end
  458.   end
  459.   #--------------------------------------------------------------------------
  460.   # * Main Update
  461.   #--------------------------------------------------------------------------
  462.   def main_update
  463.     # Turns On Main Command
  464.     @main_command.active = true
  465.     # Turns Off Other Command Windows
  466.     @av_bond_command.active = @own_bond_command.active = false
  467.     # Moves In Active Windows
  468.     @bank_bio_window.z = @main_command.z = 9999
  469.     @bank_bio_window.x += 32 if @bank_bio_window.x < 16
  470.     @main_command.x -= 25 if @main_command.x > 444
  471.     # Moves Out Inactive Windows
  472.     @av_bond_display_window.x -= 32 if @av_bond_display_window.x > - 240
  473.     [@av_bond_display_window, @own_bond_display_window, @bank_number_window,
  474.       @av_bond_command, @own_bond_command].each {|window| window.z = 9995}
  475.     [@av_bond_command, @own_bond_command].each {|command|
  476.       command.x += 25 if command.x < 644}
  477.     @own_bond_display_window.x -= 25 if @own_bond_display_window.x > - 240
  478.     @bank_number_window.x += 32 if @bank_number_window.x < 640
  479.     # Sets Help Window
  480.     case @main_command.index
  481.       when 0; @help_window.set_text("Deposit Money Into your Account", 1)
  482.       when 1; @help_window.set_text("Withdraw Money From your Account", 1)
  483.       when 2; @help_window.set_text("Purchase a Savings Bond", 1)
  484.       when 3; @help_window.set_text("Take Out Mature Savings Bond", 1)
  485.       when 4; @help_window.set_text("Exit Bank", 1)
  486.     end
  487.     # Input Processing
  488.     if Input.trigger?(Input::B) # Returns to Map
  489.       $game_system.se_play($data_system.cancel_se)
  490.       @phase = 99
  491.     elsif Input.trigger?(Input::C)
  492.       $game_system.se_play($data_system.decision_se)
  493.       case @main_command.index
  494.       when 0  # Deposit
  495.         @amount, @depositing = 0, true
  496.         refresh_windows
  497.         @help_window.set_text("Deposit #{@amount} #{$data_system.words.gold}", 1)
  498.         @phase = 1
  499.       when 1  # Withdraw
  500.         @amount, @depositing = 0, false
  501.         refresh_windows
  502.         @help_window.set_text("Withdraw #{@amount} #{$data_system.words.gold}", 1)
  503.         @phase = 1
  504.       when 2  # Buy CD
  505.         @current_bond = @bonds[@av_bond_command.index]
  506.         @bond_bought = false
  507.         refresh_windows
  508.         @phase = 2
  509.       when 3  # Get CD
  510.         @current_bond = $game_bank.saving_bonds[@own_bond_command.index]
  511.         @bond_bought = true
  512.         refresh_windows
  513.         @phase = 3
  514.       when 4  # Exit Bank
  515.         @phase = 99
  516.       end
  517.     end
  518.   end
  519.   #--------------------------------------------------------------------------
  520.   # * Accpunt Update
  521.   #--------------------------------------------------------------------------
  522.   def account_update
  523.     # Turns Off Command Windows
  524.     @main_command.active = @av_bond_command.active = @own_bond_command.active = false
  525.     # Moves In Active Windows
  526.     @bank_bio_window.z = @bank_number_window.z = 9999
  527.     @bank_bio_window.x += 32 if @bank_bio_window.x < 16
  528.     @bank_number_window.x -= 32 if @bank_number_window.x > 384
  529.     # Moves Out Inactive Windows
  530.     @av_bond_display_window.z = @own_bond_display_window.z =
  531.       @main_command.z = @av_bond_command.z = @own_bond_command.z = 9995
  532.     @av_bond_display_window.x -= 32 if @av_bond_display_window.x > - 240
  533.     [@own_bond_display_window].each {|window| window.x -= 25 if window.x > - 240}
  534.     [@main_command, @av_bond_command, @own_bond_command].each {|command|
  535.         command.x += 25 if command.x < 644}
  536.     # Input Processing
  537.     if Input.trigger?(Input::B)
  538.       $game_system.se_play($data_system.cancel_se)
  539.       @phase = 0
  540.     elsif Input.trigger?(Input::C)
  541.       $game_system.se_play($data_system.shop_se)
  542.       if @depositing
  543.         $game_bank.deposit(@amount)
  544.         refresh_windows
  545.         @phase = 0
  546.       else
  547.         $game_bank.withdraw(@amount)
  548.         refresh_windows
  549.         @phase = 0
  550.       end
  551.     elsif Input.repeat?(Input::LEFT) && Input.press?(Input::LEFT)
  552.       if @amount > 0
  553.         $game_system.se_play($data_system.cursor_se)
  554.         @amount -= 1
  555.         refresh_windows
  556.         @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  557.       else
  558.         $game_system.se_play($data_system.buzzer_se)
  559.       end
  560.     elsif Input.repeat?(Input::RIGHT) && Input.press?(Input::RIGHT)
  561.       if @depositing
  562.         if @amount < $game_party.gold
  563.           $game_system.se_play($data_system.cursor_se)
  564.           @amount += 1
  565.           refresh_windows
  566.           @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  567.         else
  568.           $game_system.se_play($data_system.buzzer_se)
  569.         end
  570.       else
  571.         if @amount < $game_bank.account_balance
  572.           $game_system.se_play($data_system.cursor_se)
  573.           @amount += 1
  574.           refresh_windows
  575.           @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  576.         else
  577.           $game_system.se_play($data_system.buzzer_se)
  578.         end
  579.       end
  580.     elsif Input.repeat?(Input::UP) && Input.press?(Input::UP)
  581.       if @amount == 0
  582.         $game_system.se_play($data_system.buzzer_se)
  583.       else
  584.         $game_system.se_play($data_system.cursor_se)
  585.         @amount > 10 ? @amount -= 10 : @amount = 0
  586.         refresh_windows
  587.         @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  588.       end
  589.     elsif Input.repeat?(Input::DOWN) && Input.press?(Input::DOWN)
  590.       if @depositing
  591.         if @amount < $game_party.gold
  592.           $game_system.se_play($data_system.cursor_se)
  593.           @amount < $game_party.gold - 10 ? @amount += 10 : @amount = $game_party.gold
  594.           refresh_windows
  595.           @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  596.         else
  597.           $game_system.se_play($data_system.buzzer_se)
  598.         end
  599.       else
  600.         if @amount < $game_bank.account_balance
  601.           $game_system.se_play($data_system.cursor_se)
  602.           @amount < $game_bank.account_balance - 10 ? @amount += 10 : @amount = $game_bank.account_balance
  603.           refresh_windows
  604.           @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  605.         else
  606.           $game_system.se_play($data_system.buzzer_se)
  607.         end
  608.       end
  609.     elsif Input.repeat?(Input::L) && Input.press?(Input::L)
  610.       if @amount == 0
  611.         $game_system.se_play($data_system.buzzer_se)
  612.       else
  613.         $game_system.se_play($data_system.cursor_se)
  614.         @amount > 100 ? @amount -= 100 : @amount = 0
  615.         refresh_windows
  616.         @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  617.       end
  618.     elsif Input.repeat?(Input::R) && Input.press?(Input::R)
  619.       if @depositing
  620.         if @amount < $game_party.gold
  621.           $game_system.se_play($data_system.cursor_se)
  622.           @amount < $game_party.gold - 100 ? @amount += 100 : @amount = $game_party.gold
  623.           refresh_windows
  624.           @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  625.         else
  626.           $game_system.se_play($data_system.buzzer_se)
  627.         end
  628.       else
  629.         if @amount < $game_bank.account_balance
  630.           $game_system.se_play($data_system.cursor_se)
  631.           @amount < $game_bank.account_balance - 100 ? @amount += 100 : @amount = $game_bank.account_balance
  632.           refresh_windows
  633.           @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  634.         else
  635.           $game_system.se_play($data_system.buzzer_se)
  636.         end
  637.       end
  638.     end
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # * Buy Bond Update
  642.   #--------------------------------------------------------------------------
  643.   def buy_bond_update
  644.     # Turns On Avaliable Bond Window
  645.     @av_bond_command.active = true
  646.     # Turns Off Other Command Windows
  647.     @main_command.active = @own_bond_command.active = false
  648.     # Moves In Active Windows
  649.     @av_bond_display_window.z = @av_bond_command.z = 9999
  650.     @av_bond_display_window.x += 32 if @av_bond_display_window.x < 16
  651.     @av_bond_command.x -= 25 if @av_bond_command.x > 444
  652.     # Moves Out Inactive Windows
  653.     [@bank_bio_window, @bank_number_window, @own_bond_display_window,
  654.       @main_command, @own_bond_command].each {|window| window.z = 9995}
  655.     @bank_bio_window.x -= 32 if @bank_bio_window.x > - 240
  656.     @bank_number_window.x += 32 if @bank_number_window.x < 640
  657.     @own_bond_display_window.x -= 25 if @own_bond_display_window.x > - 240
  658.     [@main_command, @own_bond_command].each {|command| command.x += 25 if command.x < 644}
  659.     # Input Processing
  660.     if Input.trigger?(Input::B)
  661.       $game_system.se_play($data_system.cancel_se)
  662.       @phase = 0
  663.     elsif Input.trigger?(Input::C)
  664.       if @av_bond_command.index == @bonds.size
  665.         $game_system.se_play($data_system.cancel_se)
  666.         @phase = 0
  667.       else
  668.         current_bond = @bonds[@av_bond_command.index].dup
  669.         if current_bond.cost > $game_party.gold
  670.           $game_system.se_play($data_system.buzzer_se)
  671.         else
  672.           $game_system.se_play($data_system.decision_se)
  673.           $game_party.lose_gold(current_bond.cost)
  674.           current_bond.set_times
  675.           $game_bank.add_bond(current_bond)
  676.           refresh_windows
  677.           @phase = 0
  678.         end
  679.       end
  680.     # Updates Current Bond
  681.     elsif Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
  682.       @current_bond = @bonds[@av_bond_command.index]
  683.       refresh_windows
  684.     end
  685.   end
  686.   #--------------------------------------------------------------------------
  687.   # * Get Bond Update
  688.   #--------------------------------------------------------------------------
  689.   def get_bond_update
  690.     # Turns On Avaliable Bond Window
  691.     @own_bond_command.active = true
  692.     # Turns Off Other Command Windows
  693.     @main_command.active = @av_bond_command.active = false
  694.     # Moves In Active Windows
  695.     [@own_bond_display_window, @own_bond_command].each {|window| window.z = 9999}
  696.     @own_bond_display_window.x += 32 if @own_bond_display_window.x < 16
  697.     @own_bond_command.x -= 25 if @own_bond_command.x > 444
  698.     # Moves Out Inactive Windows
  699.     [@bank_bio_window, @av_bond_display_window, @main_command, @bank_number_window,
  700.       @av_bond_command].each {|window| window.z = 9995}
  701.     [@bank_bio_window, @av_bond_display_window].each {|window|
  702.       window.x -= 32 if window.x > - 240}
  703.     [@main_command, @av_bond_command].each {|window|
  704.       window.x += 25 if window.x < 640}
  705.     @bank_number_window.x += 32 if @bank_number_window.x < 640
  706.     # Input Processing
  707.     if Input.trigger?(Input::B)
  708.       $game_system.se_play($data_system.cancel_se)
  709.       @phase = 0
  710.     elsif Input.trigger?(Input::C)
  711.       if @own_bond_command.index == $game_bank.saving_bonds.size
  712.         $game_system.se_play($data_system.cancel_se)
  713.         @phase = 0
  714.       else
  715.         current_bond = $game_bank.saving_bonds[@own_bond_command.index]
  716.         if current_bond.time_finished > Graphics.frame_count / Graphics.frame_rate
  717.           $game_system.se_play($data_system.buzzer_se)
  718.           @help_window.set_text("Savings Bond Not Mature Yet!", 1)
  719.         else
  720.           $game_system.se_play($data_system.decision_se)
  721.           $game_party.gain_gold(current_bond.mature_value)
  722.           $game_bank.saving_bonds.delete_at[@own_bond_command.index]
  723.           refresh_windows
  724.           @phase = 0
  725.         end
  726.       end
  727.     elsif Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
  728.       @current_bond = $game_bank.saving_bonds[@own_bond_command.index]
  729.       refresh_windows
  730.     end
  731.   end

  732.   # * Exit Update

  733.   def exit_update
  734.     # Moves Out Windows
  735.     @help_window.y -= 4 if @help_window.y > - 64
  736.     [@bank_bio_window, @av_bond_display_window].each {|window| window.x -= 32 if window.x > - 240}
  737.     [@own_bond_display_window].each {|window| window.x -= 25 if window.x > - 240}
  738.     [@main_command, @bank_number_window, @av_bond_command,
  739.       @own_bond_command].each {|window| window.x += 25 if window.x < 640}
  740.     # Checks To Make Sure All Windows Are Out
  741.     if @help_window.y <= - 64 && @bank_bio_window.x <= - 240 && @av_bond_display_window.x <= - 240 &&
  742.         @own_bond_display_window.x <= - 240 && @main_command.x >= 644 &&
  743.         @bank_number_window.x >= 640 && @av_bond_command.x >= 640 && @own_bond_command.x >= 640
  744.       $scene = Scene_Map.new
  745.     end
  746.   end
  747.   #--------------------------------------------------------------------------
  748.   # * Get CD List
  749.   #--------------------------------------------------------------------------
  750.   def get_cd_list
  751.     commands = []
  752.     $game_bank.saving_bonds.each {|x| commands.push(x.name)}
  753.     commands.push("Back")
  754.     return commands
  755.   end
  756.   #--------------------------------------------------------------------------
  757.   # * Refresh Windows
  758.   #--------------------------------------------------------------------------
  759.   def refresh_windows
  760.     @bank_bio_window.refresh
  761.     @av_bond_display_window.refresh(@current_bond, @bond_bought)
  762.     @own_bond_display_window.refresh(@current_bond, @bond_bought)
  763.     @bank_number_window.refresh(@amount, @depositing ? "Deposit" : "Withdraw")
  764.     @own_bond_command.refresh(get_cd_list)
  765.   end
  766. end
复制代码

效果图,由美兽提供 friday5xue添加!

Lv1.梦旅人

梦石
0
星屑
50
在线时间
2 小时
注册时间
2006-9-3
帖子
61
2
 楼主| 发表于 2006-10-1 11:30:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
一个绝好的银行系统,只是是英文版。我自己英语不好。呵呵!希望贴出来大家改进!
  1. #   Created By SephirothSpawn (12.03.05)
  2. #   Last Updated: 12.03.05
  3. # Banking System

  4. # ** Scene_Title

  5. class Scene_Title
  6.   
  7.   # * Alias Command: New Game
  8.   alias bank_command_new_game command_new_game
  9.   #-----------------------------------------------------
  10.   # * Command: New Game
  11.   #-----------------------------------------------------
  12.   def command_new_game
  13.     $game_bank = Game_BankSystem.new
  14.     bank_command_new_game
  15.   end
  16. end

  17. #==============================================================================
  18. # ** Window_RefreshCommand
  19. #==============================================================================
  20. class Window_RefreshCommand < Window_Selectable
  21.   #--------------------------------------------------------------------------
  22.   # * Object Initialization
  23.   #     width    : window width
  24.   #     commands : command text string array
  25.   #--------------------------------------------------------------------------
  26.   def initialize(width, commands)
  27.     # Compute window height from command quantity
  28.     super(0, 0, width, commands.size * 32 + 32)
  29.     @item_max = commands.size
  30.     @commands = commands
  31.     refresh
  32.     self.index = 0
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # * Refresh
  36.   #--------------------------------------------------------------------------
  37.   def refresh(commands = @commands)
  38.     @commands = commands
  39.     @item_max = commands.size
  40.     if self.contents != nil
  41.       self.contents.dispose
  42.       self.contents = nil
  43.     end
  44.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  45.     for i in 0...@item_max
  46.       draw_item(i, normal_color)
  47.     end
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # * Draw Item
  51.   #     index : item number
  52.   #     color : text color
  53.   #--------------------------------------------------------------------------
  54.   def draw_item(index, color)
  55.     self.contents.font.color = color
  56.     self.contents.draw_text(0, 32 * index, self.contents.width - 8, 32, @commands[index], 1)
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # * Disable Item
  60.   #     index : item number
  61.   #--------------------------------------------------------------------------
  62.   def disable_item(index)
  63.     draw_item(index, disabled_color)
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # * Undisable Item
  67.   #     index : item number
  68.   #--------------------------------------------------------------------------
  69.   def disable_item(index)
  70.     draw_item(index, normal_color)
  71.   end
  72. end

  73. #==============================================================================
  74. # ** Game_BankSystem
  75. #==============================================================================
  76. class Game_BankSystem
  77.   #--------------------------------------------------------------------------
  78.   # * Public Instance Variables
  79.   #--------------------------------------------------------------------------
  80.   attr_accessor :account_balance
  81.   attr_accessor :interest_rate
  82.   attr_accessor :saving_bonds
  83.   #--------------------------------------------------------------------------
  84.   # * Object Initialization
  85.   #--------------------------------------------------------------------------
  86.   def initialize
  87.     @account_balance = 0
  88.     @interest_rate = 1
  89.     @saving_bonds = []
  90.     @last_interest_time = 0
  91.   end

  92.   # * Update
  93.     def update
  94.     # Updates Deposited Amount
  95.     interest_time = (Graphics.frame_count / Graphics.frame_rate - @last_interest_time) / 3600.0
  96.     interest_amt = (@account_balance * @interest_rate / 100.0 * interest_time).to_i
  97.     if interest_amt > 0
  98.       @last_interest_time = Graphics.frame_count / Graphics.frame_rate
  99.       @account_balance += interest_amt
  100.       # Refreshes Data Windows
  101.       $scene.refresh_windows
  102.     end
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # * Deposit
  106.   #--------------------------------------------------------------------------
  107.   def deposit(amount)
  108.     $game_party.lose_gold(amount)
  109.     @account_balance += amount
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # * Withdraw
  113.   #--------------------------------------------------------------------------
  114.   def withdraw(amount)
  115.     @account_balance -= amount
  116.     $game_party.gain_gold(amount)
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # * Add Savings Bond
  120.   #--------------------------------------------------------------------------
  121.   def add_bond(bond)
  122.     @saving_bonds.push(bond)
  123.     @saving_bonds.sort! {|a, b| a.name <=> b.name}
  124.   end
  125. end

  126. #==============================================================================
  127. # ** Savings_Bond
  128. #==============================================================================
  129. class Savings_Bond
  130.   #--------------------------------------------------------------------------
  131.   # * Public Instance Variables
  132.   #--------------------------------------------------------------------------
  133.   attr_accessor :name
  134.   attr_accessor :cost
  135.   attr_accessor :interest_rate
  136.   attr_accessor :length
  137.   attr_accessor :time_bought
  138.   attr_accessor :time_finished
  139.   attr_accessor :mature_value
  140.   #--------------------------------------------------------------------------
  141.   # * Object Initialization
  142.   #     name           : Savings Bond Name
  143.   #     cost             : Savings Bond Cost
  144.   #     interest_rate : Savings Bond Interest Rate (In Percent)
  145.   #     length          : Length of Hours until Mature
  146.   #--------------------------------------------------------------------------
  147.   def initialize(name, cost, interest_rate, length)
  148.     @name = name
  149.     @cost = cost
  150.     @interest_rate = interest_rate
  151.     @length = length
  152.     @mature_value = (@cost * (1+ @interest_rate / 100.0)).to_i
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # * Set Times
  156.   #--------------------------------------------------------------------------
  157.   def set_times
  158.     @time_bought = Graphics.frame_count / Graphics.frame_rate
  159.     @time_finished = @time_bought + @length * 3600
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   # * Make Time to HH:MM:SS
  163.   #--------------------------------------------------------------------------
  164.   def return_time(time)
  165.     hours      = time / 60 / 60
  166.     minutes   = time / 60 % 60
  167.     seconds   = time % 60
  168.     return sprintf("%02d:%02d:%02d", hours, minutes, seconds)
  169.   end
  170. end

  171. #==============================================================================
  172. # ** Window_BankNumber
  173. #==============================================================================
  174. class Window_BankNumber < Window_Base
  175.   #--------------------------------------------------------------------------
  176.   # * Object Initialization
  177.   #--------------------------------------------------------------------------
  178.   def initialize
  179.     super(640, 272, 240, 192)
  180.       self.opacity = 175
  181.     self.contents = Bitmap.new(width - 32, height - 32)
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # * Refresh
  185.   #     money  : Gold being...
  186.   #     type      : Deposit or Withdraw
  187.   #--------------------------------------------------------------------------
  188.   def refresh(money, type)
  189.     contents.clear
  190.     # Deposit or Withdraw
  191.     contents.font.color = system_color
  192.     contents.draw_text(0, 0, contents.width, 24, "Amount to #{type}", 1)
  193.     if type == "Deposit"
  194.       # Draws Game Party Gold
  195.       contents.draw_text(4, 48, contents.width, 24, "Current #{$data_system.words.gold}:")
  196.       contents.font.color = normal_color
  197.       contents.draw_text(-4, 48, contents.width, 24, $game_party.gold.to_s, 2)
  198.     else
  199.       # Draws Account Balance
  200.       contents.draw_text(4, 48, contents.width, 24, "Account Balance:")
  201.       contents.font.color = normal_color
  202.       contents.draw_text(-4, 48, contents.width, 24, $game_bank.account_balance.to_s, 2)
  203.     end
  204.     # Draws Money Being Deposited or Withdrawn
  205.     contents.font.color = system_color
  206.     contents.draw_text(4, 72, contents.width, 24, "#{type} Amount:")
  207.     contents.font.color = normal_color
  208.     contents.draw_text(-4, 72, contents.width, 24, "- #{money}", 2)
  209.     # Draws Line
  210.     line = ""
  211.     while contents.text_size(line).width < contents.width
  212.       line += "-"
  213.     end
  214.     contents.draw_text(0, 96, contents.width, 24, line, 2)
  215.     # Draws Game Party Gold Amont
  216.     contents.font.color = system_color
  217.     contents.draw_text(4, 112, contents.width, 32, "#{$data_system.words.gold} After:")
  218.     amount = $game_party.gold
  219.     amount += type == "Deposit" ? -money : money
  220.     contents.font.color = normal_color
  221.     contents.draw_text(-4, 112, contents.width, 32, amount.to_s, 2)
  222.     # Draws Deposit Amont
  223.     amount = $game_bank.account_balance
  224.     amount += type == "Deposit" ? money : -money
  225.     contents.font.color = system_color
  226.     contents.draw_text(4, 136, contents.width, 32, "Balance After:")
  227.     contents.font.color = normal_color
  228.     contents.draw_text(-4, 136, contents.width, 32, amount.to_s, 2)
  229.   end
  230. end

  231. #==============================================================================
  232. # ** Window_BankBio
  233. #==============================================================================
  234. class Window_BankBio < Window_Base
  235.   #--------------------------------------------------------------------------
  236.   # * Object Initialization
  237.   #--------------------------------------------------------------------------
  238.   def initialize
  239.     super(-240, 272, 240, 192)
  240.       self.opacity = 175
  241.     self.contents = Bitmap.new(width - 32, height - 32)
  242.     refresh
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # * Refresh
  246.   #--------------------------------------------------------------------------
  247.   def refresh
  248.     contents.clear
  249.     # Deposit or Withdraw
  250.     contents.font.color = system_color
  251.     # Draws Actor Name in Postition 1
  252.     contents.font.color = normal_color
  253.     contents.draw_text(0, 0, contents.width, 24, "#{$game_party.actors[0].name}", 1)
  254.     # Draws Game Party Gold
  255.     contents.font.color = system_color
  256.     contents.draw_text(4, 32, contents.width, 24, "Current #{$data_system.words.gold}:")
  257.     contents.font.color = normal_color
  258.     contents.draw_text(-4, 32, contents.width, 24, $game_party.gold.to_s, 2)
  259.     # Draws Account Balance
  260.     contents.font.color = system_color
  261.     contents.draw_text(4, 56, contents.width, 24, "Account Balance:")
  262.     contents.font.color = normal_color
  263.     contents.draw_text(-4, 56, contents.width, 24, $game_bank.account_balance.to_s, 2)
  264.     # Draws Number of Savings Bond's
  265.     contents.font.color = system_color
  266.     contents.draw_text(4, 80, contents.width, 24, "Bonds Owned:")
  267.     contents.font.color = normal_color
  268.     contents.draw_text(-4, 80, contents.width, 24, $game_bank.saving_bonds.size.to_s, 2)
  269.     # Draws Value of Savings Bond's
  270.     value = 0
  271.     $game_bank.saving_bonds.each { |x| value += x.mature_value}
  272.     contents.font.color = system_color
  273.     contents.draw_text(4, 104, contents.width, 24, "Bonds Value:")
  274.     contents.font.color = normal_color
  275.     contents.draw_text(-4, 104, contents.width, 24, value.to_s, 2)
  276.     # Draws Current Interest Rate
  277.     contents.font.color = system_color
  278.     contents.draw_text(4, 136, contents.width, 24, "Interest Rate:")
  279.     contents.font.color = normal_color
  280.     contents.draw_text(-4, 136, contents.width, 24, "#{$game_bank.interest_rate} %", 2)
  281.   end
  282. end

  283. #==============================================================================
  284. # ** Window_Bond
  285. #==============================================================================
  286. class Window_Bond < Window_Base
  287.   #--------------------------------------------------------------------------
  288.   # * Object Initialization
  289.   #--------------------------------------------------------------------------
  290.   def initialize
  291.     super(-240, 264, 240, 200)
  292.       self.opacity = 175
  293.     self.contents = Bitmap.new(width - 32, height - 32)
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # * Refresh
  297.   #     bond    : Savings Bond
  298.   #--------------------------------------------------------------------------
  299.   def refresh(bond, bought = false)
  300.     contents.clear
  301.     unless bond == nil
  302.       # Draws Bond Name
  303.       contents.font.color = system_color
  304.       contents.draw_text(0, 0, contents.width, 24, bond.name, 1)
  305.       # Draws Bond Cost
  306.       contents.font.color = system_color
  307.       contents.draw_text(4, 24, contents.width, 24, "Bond Cost:")
  308.       contents.font.color = normal_color
  309.       contents.draw_text(-4, 24, contents.width, 24, bond.cost.to_s, 2)
  310.       # Draws Bond Mature Value
  311.       contents.font.color = system_color
  312.       contents.draw_text(4, 48, contents.width, 24, "Mature Value:")
  313.       contents.font.color = normal_color
  314.       contents.draw_text(-4, 48, contents.width, 24, "#{bond.mature_value}", 2)
  315.       # Draws Bond Interest Rate
  316.       contents.font.color = system_color
  317.       contents.draw_text(4, 72, contents.width, 24, "Interest Rate:")
  318.       contents.font.color = normal_color
  319.       contents.draw_text(-4, 72, contents.width, 24, "#{bond.interest_rate} %", 2)
  320.       # Draws Length until Maturity
  321.       contents.font.color = system_color
  322.       contents.draw_text(4, 96, contents.width, 24, "Maturity Time:")
  323.       contents.font.color = normal_color
  324.       contents.draw_text(-4, 96, contents.width, 24, "#{bond.length} Hours", 2)
  325.       # Display only if Purchased CD
  326.       if bought
  327.         # Draws Time Bought
  328.         contents.font.color = system_color
  329.         contents.draw_text(4, 120, contents.width, 24, "Time Bought:")
  330.         contents.font.color = normal_color
  331.         contents.draw_text(-4, 120, contents.width, 24, bond.return_time(bond.time_bought), 2)
  332.         # Draws Time Finished
  333.         contents.font.color = system_color
  334.         contents.draw_text(4, 144, contents.width, 24, "Time Finished:")
  335.         contents.font.color = normal_color
  336.         contents.draw_text(-4, 144, contents.width, 24, bond.return_time(bond.time_finished), 2)
  337.       end
  338.     end
  339.   end
  340. end

  341. #==============================================================================
  342. # ** Scene_Bank
  343. #==============================================================================
  344. class Scene_Bank
  345.   #--------------------------------------------------------------------------
  346.   # * Object Initialization
  347.   #     interest rate   :   Changes Current Interest Rate (Leave 0 for no Change)
  348.   #     bonds           :   Avaliable CD's For Purchasing
  349.   #--------------------------------------------------------------------------
  350.   def initialize(interest_rate = $game_bank.interest_rate,
  351.       bonds = [ Savings_Bond.new("CD-7", 100, 7.5, 7), Savings_Bond.new("CD-14", 500, 15, 14)])
  352.     $game_bank.interest_rate = interest_rate unless interest_rate == 0
  353.     @bonds = bonds
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # * Main Processing
  357.   #--------------------------------------------------------------------------
  358.   def main
  359.     # Current Phase
  360.     @phase = -1
  361.     # Refreshing Variables
  362.     @amount, @depositing = 0, true
  363.     @current_bond, @bond_bought = nil, false
  364.     # Make sprite set
  365.     @spriteset = Spriteset_Map.new
  366.     # Help Window
  367.     @help_window = Window_Help.new
  368.       @help_window.y, @help_window.opacity = -64, 175
  369.       @help_window.set_text("Welcome to the Bank", 1)
  370.     # Bank Bio
  371.     @bank_bio_window = Window_BankBio.new
  372.     # Avaliable Bond Information Display Window
  373.     @av_bond_display_window = Window_Bond.new
  374.     # Owned Bond Information Display Window
  375.     @own_bond_display_window = Window_Bond.new
  376.     # Main Command
  377.     @main_command = Window_RefreshCommand.new(180, [
  378.         "Deposit #{g_word = $data_system.words.gold}",
  379.         "Withdraw #{g_word}", "Purchase Bond", "Get Mature Bond", "Exit"])
  380.       @main_command.x, @main_command.y, @main_command.opacity = 644, 272, 175
  381.       @main_command.active = false
  382.     # Bank Number Window
  383.     @bank_number_window = Window_BankNumber.new
  384.     # Avaliable Bonds Command
  385.     commands = []
  386.     @bonds.each {|x| commands.push(x.name)}; commands.push("Back")
  387.     @av_bond_command = Window_RefreshCommand.new(180, commands)
  388.       @av_bond_command.x, @av_bond_command.y = 644, 272
  389.       @av_bond_command.height, @av_bond_command.opacity = 192, 175
  390.       @av_bond_command.active = false
  391.     # CD's Have
  392.     @own_bond_command = Window_RefreshCommand.new(180, get_cd_list)
  393.       @own_bond_command.x, @own_bond_command.y = 644, 272
  394.       @own_bond_command.height, @own_bond_command.opacity = 192, 175
  395.       @own_bond_command.active = false
  396.     # Scene Objects
  397.     @objects = [@spriteset, @help_window, @bank_bio_window, @av_bond_display_window,
  398.         @own_bond_display_window, @main_command, @bank_number_window,
  399.         @av_bond_command, @own_bond_command]
  400.     # Execute transition
  401.     Graphics.transition
  402.     # Main loop
  403.     while $scene == self
  404.       # Update game screen
  405.       Graphics.update
  406.       # Update input information
  407.       Input.update
  408.       # Update Objects
  409.       @objects.each {|x| x.update}
  410.       # Updates Bank System
  411.       $game_bank.update
  412.       # Frame update
  413.       update
  414.     end
  415.     # Prepare for transition
  416.     Graphics.freeze
  417.     # Dispose of windows
  418.     @objects.each {|x| x.dispose}
  419.   end
  420.   #--------------------------------------------------------------------------
  421.   # * Frame Update
  422.   #--------------------------------------------------------------------------
  423.   def update
  424.     # Splits Phases Up
  425.     case @phase
  426.     when -1 # Intro Phase
  427.       intro_update
  428.     when 0  # Main Phase
  429.       main_update
  430.     when 1  # Deposit or Withdraw Phase
  431.       account_update
  432.     when 2  # Buy CD Phase
  433.       buy_bond_update
  434.     when 3  # Get Mature CD Phse
  435.       get_bond_update
  436.     when 99 # Exit Phase
  437.       exit_update
  438.     end
  439.   end
  440.   #--------------------------------------------------------------------------
  441.   # * Intro Update
  442.   #--------------------------------------------------------------------------
  443.   def intro_update
  444.     # Moves Window Down
  445.     @help_window.y += 4 if @help_window.y < 0
  446.     if @help_window.y == 0
  447.       # Input Processing
  448.       if Input.trigger?(Input::B)
  449.         $game_system.se_play($data_system.cancel_se)
  450.         # Returns to Scene
  451.         @phase = 99
  452.       elsif Input.trigger?(Input::C)
  453.         $game_system.se_play($data_system.decision_se)
  454.         # Switchs to Main Phase
  455.         @phase = 0
  456.       end
  457.     end
  458.   end
  459.   #--------------------------------------------------------------------------
  460.   # * Main Update
  461.   #--------------------------------------------------------------------------
  462.   def main_update
  463.     # Turns On Main Command
  464.     @main_command.active = true
  465.     # Turns Off Other Command Windows
  466.     @av_bond_command.active = @own_bond_command.active = false
  467.     # Moves In Active Windows
  468.     @bank_bio_window.z = @main_command.z = 9999
  469.     @bank_bio_window.x += 32 if @bank_bio_window.x < 16
  470.     @main_command.x -= 25 if @main_command.x > 444
  471.     # Moves Out Inactive Windows
  472.     @av_bond_display_window.x -= 32 if @av_bond_display_window.x > - 240
  473.     [@av_bond_display_window, @own_bond_display_window, @bank_number_window,
  474.       @av_bond_command, @own_bond_command].each {|window| window.z = 9995}
  475.     [@av_bond_command, @own_bond_command].each {|command|
  476.       command.x += 25 if command.x < 644}
  477.     @own_bond_display_window.x -= 25 if @own_bond_display_window.x > - 240
  478.     @bank_number_window.x += 32 if @bank_number_window.x < 640
  479.     # Sets Help Window
  480.     case @main_command.index
  481.       when 0; @help_window.set_text("Deposit Money Into your Account", 1)
  482.       when 1; @help_window.set_text("Withdraw Money From your Account", 1)
  483.       when 2; @help_window.set_text("Purchase a Savings Bond", 1)
  484.       when 3; @help_window.set_text("Take Out Mature Savings Bond", 1)
  485.       when 4; @help_window.set_text("Exit Bank", 1)
  486.     end
  487.     # Input Processing
  488.     if Input.trigger?(Input::B) # Returns to Map
  489.       $game_system.se_play($data_system.cancel_se)
  490.       @phase = 99
  491.     elsif Input.trigger?(Input::C)
  492.       $game_system.se_play($data_system.decision_se)
  493.       case @main_command.index
  494.       when 0  # Deposit
  495.         @amount, @depositing = 0, true
  496.         refresh_windows
  497.         @help_window.set_text("Deposit #{@amount} #{$data_system.words.gold}", 1)
  498.         @phase = 1
  499.       when 1  # Withdraw
  500.         @amount, @depositing = 0, false
  501.         refresh_windows
  502.         @help_window.set_text("Withdraw #{@amount} #{$data_system.words.gold}", 1)
  503.         @phase = 1
  504.       when 2  # Buy CD
  505.         @current_bond = @bonds[@av_bond_command.index]
  506.         @bond_bought = false
  507.         refresh_windows
  508.         @phase = 2
  509.       when 3  # Get CD
  510.         @current_bond = $game_bank.saving_bonds[@own_bond_command.index]
  511.         @bond_bought = true
  512.         refresh_windows
  513.         @phase = 3
  514.       when 4  # Exit Bank
  515.         @phase = 99
  516.       end
  517.     end
  518.   end
  519.   #--------------------------------------------------------------------------
  520.   # * Accpunt Update
  521.   #--------------------------------------------------------------------------
  522.   def account_update
  523.     # Turns Off Command Windows
  524.     @main_command.active = @av_bond_command.active = @own_bond_command.active = false
  525.     # Moves In Active Windows
  526.     @bank_bio_window.z = @bank_number_window.z = 9999
  527.     @bank_bio_window.x += 32 if @bank_bio_window.x < 16
  528.     @bank_number_window.x -= 32 if @bank_number_window.x > 384
  529.     # Moves Out Inactive Windows
  530.     @av_bond_display_window.z = @own_bond_display_window.z =
  531.       @main_command.z = @av_bond_command.z = @own_bond_command.z = 9995
  532.     @av_bond_display_window.x -= 32 if @av_bond_display_window.x > - 240
  533.     [@own_bond_display_window].each {|window| window.x -= 25 if window.x > - 240}
  534.     [@main_command, @av_bond_command, @own_bond_command].each {|command|
  535.         command.x += 25 if command.x < 644}
  536.     # Input Processing
  537.     if Input.trigger?(Input::B)
  538.       $game_system.se_play($data_system.cancel_se)
  539.       @phase = 0
  540.     elsif Input.trigger?(Input::C)
  541.       $game_system.se_play($data_system.shop_se)
  542.       if @depositing
  543.         $game_bank.deposit(@amount)
  544.         refresh_windows
  545.         @phase = 0
  546.       else
  547.         $game_bank.withdraw(@amount)
  548.         refresh_windows
  549.         @phase = 0
  550.       end
  551.     elsif Input.repeat?(Input::LEFT) && Input.press?(Input::LEFT)
  552.       if @amount > 0
  553.         $game_system.se_play($data_system.cursor_se)
  554.         @amount -= 1
  555.         refresh_windows
  556.         @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  557.       else
  558.         $game_system.se_play($data_system.buzzer_se)
  559.       end
  560.     elsif Input.repeat?(Input::RIGHT) && Input.press?(Input::RIGHT)
  561.       if @depositing
  562.         if @amount < $game_party.gold
  563.           $game_system.se_play($data_system.cursor_se)
  564.           @amount += 1
  565.           refresh_windows
  566.           @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  567.         else
  568.           $game_system.se_play($data_system.buzzer_se)
  569.         end
  570.       else
  571.         if @amount < $game_bank.account_balance
  572.           $game_system.se_play($data_system.cursor_se)
  573.           @amount += 1
  574.           refresh_windows
  575.           @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  576.         else
  577.           $game_system.se_play($data_system.buzzer_se)
  578.         end
  579.       end
  580.     elsif Input.repeat?(Input::UP) && Input.press?(Input::UP)
  581.       if @amount == 0
  582.         $game_system.se_play($data_system.buzzer_se)
  583.       else
  584.         $game_system.se_play($data_system.cursor_se)
  585.         @amount > 10 ? @amount -= 10 : @amount = 0
  586.         refresh_windows
  587.         @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  588.       end
  589.     elsif Input.repeat?(Input::DOWN) && Input.press?(Input::DOWN)
  590.       if @depositing
  591.         if @amount < $game_party.gold
  592.           $game_system.se_play($data_system.cursor_se)
  593.           @amount < $game_party.gold - 10 ? @amount += 10 : @amount = $game_party.gold
  594.           refresh_windows
  595.           @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  596.         else
  597.           $game_system.se_play($data_system.buzzer_se)
  598.         end
  599.       else
  600.         if @amount < $game_bank.account_balance
  601.           $game_system.se_play($data_system.cursor_se)
  602.           @amount < $game_bank.account_balance - 10 ? @amount += 10 : @amount = $game_bank.account_balance
  603.           refresh_windows
  604.           @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  605.         else
  606.           $game_system.se_play($data_system.buzzer_se)
  607.         end
  608.       end
  609.     elsif Input.repeat?(Input::L) && Input.press?(Input::L)
  610.       if @amount == 0
  611.         $game_system.se_play($data_system.buzzer_se)
  612.       else
  613.         $game_system.se_play($data_system.cursor_se)
  614.         @amount > 100 ? @amount -= 100 : @amount = 0
  615.         refresh_windows
  616.         @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  617.       end
  618.     elsif Input.repeat?(Input::R) && Input.press?(Input::R)
  619.       if @depositing
  620.         if @amount < $game_party.gold
  621.           $game_system.se_play($data_system.cursor_se)
  622.           @amount < $game_party.gold - 100 ? @amount += 100 : @amount = $game_party.gold
  623.           refresh_windows
  624.           @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  625.         else
  626.           $game_system.se_play($data_system.buzzer_se)
  627.         end
  628.       else
  629.         if @amount < $game_bank.account_balance
  630.           $game_system.se_play($data_system.cursor_se)
  631.           @amount < $game_bank.account_balance - 100 ? @amount += 100 : @amount = $game_bank.account_balance
  632.           refresh_windows
  633.           @help_window.set_text("#{@depositing ? 'Deposit' : 'Withdraw'} #{@amount} #{$data_system.words.gold}", 1)
  634.         else
  635.           $game_system.se_play($data_system.buzzer_se)
  636.         end
  637.       end
  638.     end
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # * Buy Bond Update
  642.   #--------------------------------------------------------------------------
  643.   def buy_bond_update
  644.     # Turns On Avaliable Bond Window
  645.     @av_bond_command.active = true
  646.     # Turns Off Other Command Windows
  647.     @main_command.active = @own_bond_command.active = false
  648.     # Moves In Active Windows
  649.     @av_bond_display_window.z = @av_bond_command.z = 9999
  650.     @av_bond_display_window.x += 32 if @av_bond_display_window.x < 16
  651.     @av_bond_command.x -= 25 if @av_bond_command.x > 444
  652.     # Moves Out Inactive Windows
  653.     [@bank_bio_window, @bank_number_window, @own_bond_display_window,
  654.       @main_command, @own_bond_command].each {|window| window.z = 9995}
  655.     @bank_bio_window.x -= 32 if @bank_bio_window.x > - 240
  656.     @bank_number_window.x += 32 if @bank_number_window.x < 640
  657.     @own_bond_display_window.x -= 25 if @own_bond_display_window.x > - 240
  658.     [@main_command, @own_bond_command].each {|command| command.x += 25 if command.x < 644}
  659.     # Input Processing
  660.     if Input.trigger?(Input::B)
  661.       $game_system.se_play($data_system.cancel_se)
  662.       @phase = 0
  663.     elsif Input.trigger?(Input::C)
  664.       if @av_bond_command.index == @bonds.size
  665.         $game_system.se_play($data_system.cancel_se)
  666.         @phase = 0
  667.       else
  668.         current_bond = @bonds[@av_bond_command.index].dup
  669.         if current_bond.cost > $game_party.gold
  670.           $game_system.se_play($data_system.buzzer_se)
  671.         else
  672.           $game_system.se_play($data_system.decision_se)
  673.           $game_party.lose_gold(current_bond.cost)
  674.           current_bond.set_times
  675.           $game_bank.add_bond(current_bond)
  676.           refresh_windows
  677.           @phase = 0
  678.         end
  679.       end
  680.     # Updates Current Bond
  681.     elsif Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
  682.       @current_bond = @bonds[@av_bond_command.index]
  683.       refresh_windows
  684.     end
  685.   end
  686.   #--------------------------------------------------------------------------
  687.   # * Get Bond Update
  688.   #--------------------------------------------------------------------------
  689.   def get_bond_update
  690.     # Turns On Avaliable Bond Window
  691.     @own_bond_command.active = true
  692.     # Turns Off Other Command Windows
  693.     @main_command.active = @av_bond_command.active = false
  694.     # Moves In Active Windows
  695.     [@own_bond_display_window, @own_bond_command].each {|window| window.z = 9999}
  696.     @own_bond_display_window.x += 32 if @own_bond_display_window.x < 16
  697.     @own_bond_command.x -= 25 if @own_bond_command.x > 444
  698.     # Moves Out Inactive Windows
  699.     [@bank_bio_window, @av_bond_display_window, @main_command, @bank_number_window,
  700.       @av_bond_command].each {|window| window.z = 9995}
  701.     [@bank_bio_window, @av_bond_display_window].each {|window|
  702.       window.x -= 32 if window.x > - 240}
  703.     [@main_command, @av_bond_command].each {|window|
  704.       window.x += 25 if window.x < 640}
  705.     @bank_number_window.x += 32 if @bank_number_window.x < 640
  706.     # Input Processing
  707.     if Input.trigger?(Input::B)
  708.       $game_system.se_play($data_system.cancel_se)
  709.       @phase = 0
  710.     elsif Input.trigger?(Input::C)
  711.       if @own_bond_command.index == $game_bank.saving_bonds.size
  712.         $game_system.se_play($data_system.cancel_se)
  713.         @phase = 0
  714.       else
  715.         current_bond = $game_bank.saving_bonds[@own_bond_command.index]
  716.         if current_bond.time_finished > Graphics.frame_count / Graphics.frame_rate
  717.           $game_system.se_play($data_system.buzzer_se)
  718.           @help_window.set_text("Savings Bond Not Mature Yet!", 1)
  719.         else
  720.           $game_system.se_play($data_system.decision_se)
  721.           $game_party.gain_gold(current_bond.mature_value)
  722.           $game_bank.saving_bonds.delete_at[@own_bond_command.index]
  723.           refresh_windows
  724.           @phase = 0
  725.         end
  726.       end
  727.     elsif Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
  728.       @current_bond = $game_bank.saving_bonds[@own_bond_command.index]
  729.       refresh_windows
  730.     end
  731.   end

  732.   # * Exit Update

  733.   def exit_update
  734.     # Moves Out Windows
  735.     @help_window.y -= 4 if @help_window.y > - 64
  736.     [@bank_bio_window, @av_bond_display_window].each {|window| window.x -= 32 if window.x > - 240}
  737.     [@own_bond_display_window].each {|window| window.x -= 25 if window.x > - 240}
  738.     [@main_command, @bank_number_window, @av_bond_command,
  739.       @own_bond_command].each {|window| window.x += 25 if window.x < 640}
  740.     # Checks To Make Sure All Windows Are Out
  741.     if @help_window.y <= - 64 && @bank_bio_window.x <= - 240 && @av_bond_display_window.x <= - 240 &&
  742.         @own_bond_display_window.x <= - 240 && @main_command.x >= 644 &&
  743.         @bank_number_window.x >= 640 && @av_bond_command.x >= 640 && @own_bond_command.x >= 640
  744.       $scene = Scene_Map.new
  745.     end
  746.   end
  747.   #--------------------------------------------------------------------------
  748.   # * Get CD List
  749.   #--------------------------------------------------------------------------
  750.   def get_cd_list
  751.     commands = []
  752.     $game_bank.saving_bonds.each {|x| commands.push(x.name)}
  753.     commands.push("Back")
  754.     return commands
  755.   end
  756.   #--------------------------------------------------------------------------
  757.   # * Refresh Windows
  758.   #--------------------------------------------------------------------------
  759.   def refresh_windows
  760.     @bank_bio_window.refresh
  761.     @av_bond_display_window.refresh(@current_bond, @bond_bought)
  762.     @own_bond_display_window.refresh(@current_bond, @bond_bought)
  763.     @bank_number_window.refresh(@amount, @depositing ? "Deposit" : "Withdraw")
  764.     @own_bond_command.refresh(get_cd_list)
  765.   end
  766. end
复制代码

效果图,由美兽提供 friday5xue添加!

Lv1.梦旅人

梦石
0
星屑
50
在线时间
2 小时
注册时间
2006-9-3
帖子
61
3
 楼主| 发表于 2006-10-1 11:31:28 | 只看该作者
还有就是要调用的话:
$scene = Scene_Bank.new
{/cy}{/cy}{/cy}
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
111
在线时间
74 小时
注册时间
2006-5-29
帖子
453
4
发表于 2006-10-29 04:01:24 | 只看该作者
恩恩{/se},好喜欢这个那!!!那个我来翻译个!{/hx}


  1. #   Created By SephirothSpawn (12.03.05)
  2. #   Last Updated: 12.03.05
  3. # Banking System

  4. =begin

  5. =^^=HI~~

  6. 这个我只作个界面胡乱翻译啊……
  7. 大概的内容翻译完成,只是不太了解债券= =||||,所以……

  8. 这个脚本主要功能是:存款,取款,购买债券,债券查看……
  9. 汉字的部分大家可以在脚本里替换~~~~基本的界面都汉化了,不影响使用滴~

  10. 调用请用此脚本:$scene = Scene_Bank.new

  11. by 秋弦月

  12. =end


  13. # ** Scene_Title
  14. #==============================================================================
  15. class Scene_Title

  16. # * Alias Command: New Game
  17. #--------------------------------------------------------------------------
  18. alias bank_command_new_game command_new_game
  19. #--------------------------------------------------------------------------
  20. # * Command: New Game
  21. #--------------------------------------------------------------------------
  22. def command_new_game
  23.    $game_bank = Game_BankSystem.new
  24.    bank_command_new_game
  25. end
  26. end

  27. #==============================================================================
  28. # ** Window_RefreshCommand
  29. #==============================================================================
  30. class Window_RefreshCommand < Window_Selectable
  31. #--------------------------------------------------------------------------
  32. # * Object Initialization
  33. #     width    : window width
  34. #     commands : command text string array
  35. #--------------------------------------------------------------------------
  36. def initialize(width, commands)
  37.    # Compute window height from command quantity
  38.    super(0, 0, width, commands.size * 32 + 32)
  39.    @item_max = commands.size
  40.    @commands = commands
  41.    refresh
  42.    self.index = 0
  43. end
  44. #--------------------------------------------------------------------------
  45. # * Refresh
  46. #--------------------------------------------------------------------------
  47. def refresh(commands = @commands)
  48.    @commands = commands
  49.    @item_max = commands.size
  50.    if self.contents != nil
  51.      self.contents.dispose
  52.      self.contents = nil
  53.    end
  54.    self.contents = Bitmap.new(width - 32, @item_max * 32)
  55.    for i in 0...@item_max
  56.      draw_item(i, normal_color)
  57.    end
  58. end
  59. #--------------------------------------------------------------------------
  60. # * Draw Item
  61. #     index : item number
  62. #     color : text color
  63. #--------------------------------------------------------------------------
  64. def draw_item(index, color)
  65.    self.contents.font.color = color
  66.    self.contents.draw_text(0, 32 * index, self.contents.width - 8, 32, @commands[index], 1)
  67. end
  68. #--------------------------------------------------------------------------
  69. # * Disable Item
  70. #     index : item number
  71. #--------------------------------------------------------------------------
  72. def disable_item(index)
  73.    draw_item(index, disabled_color)
  74. end
  75. #--------------------------------------------------------------------------
  76. # * Undisable Item
  77. #     index : item number
  78. #--------------------------------------------------------------------------
  79. def disable_item(index)
  80.    draw_item(index, normal_color)
  81. end
  82. end

  83. #==============================================================================
  84. # ** Game_BankSystem
  85. #==============================================================================
  86. class Game_BankSystem
  87. #--------------------------------------------------------------------------
  88. # * Public Instance Variables
  89. #--------------------------------------------------------------------------
  90. attr_accessor :account_balance
  91. attr_accessor :interest_rate
  92. attr_accessor :saving_bonds
  93. #--------------------------------------------------------------------------
  94. # * Object Initialization
  95. #--------------------------------------------------------------------------
  96. def initialize
  97.    @account_balance = 0
  98.    @interest_rate = 1
  99.    @saving_bonds = []
  100.    @last_interest_time = 0
  101. end

  102. # * Update
  103.    def update
  104.    # Updates Deposited Amount
  105.    interest_time = (Graphics.frame_count / Graphics.frame_rate - @last_interest_time) / 3600.0
  106.    interest_amt = (@account_balance * @interest_rate / 100.0 * interest_time).to_i
  107.    if interest_amt > 0
  108.      @last_interest_time = Graphics.frame_count / Graphics.frame_rate
  109.      @account_balance += interest_amt
  110.      # Refreshes Data Windows
  111.      $scene.refresh_windows
  112.    end
  113. end
  114. #--------------------------------------------------------------------------
  115. # * Deposit
  116. #--------------------------------------------------------------------------
  117. def deposit(amount)
  118.    $game_party.lose_gold(amount)
  119.    @account_balance += amount
  120. end
  121. #--------------------------------------------------------------------------
  122. # * Withdraw
  123. #--------------------------------------------------------------------------
  124. def withdraw(amount)
  125.    @account_balance -= amount
  126.    $game_party.gain_gold(amount)
  127. end
  128. #--------------------------------------------------------------------------
  129. # * Add Savings Bond
  130. #--------------------------------------------------------------------------
  131. def add_bond(bond)
  132.    @saving_bonds.push(bond)
  133.    @saving_bonds.sort! {|a, b| a.name <=> b.name}
  134. end
  135. end

  136. #==============================================================================
  137. # ** Savings_Bond
  138. #==============================================================================
  139. class Savings_Bond
  140. #--------------------------------------------------------------------------
  141. # * Public Instance Variables
  142. #--------------------------------------------------------------------------
  143. attr_accessor :name
  144. attr_accessor :cost
  145. attr_accessor :interest_rate
  146. attr_accessor :length
  147. attr_accessor :time_bought
  148. attr_accessor :time_finished
  149. attr_accessor :mature_value
  150. #--------------------------------------------------------------------------
  151. # * Object Initialization
  152. #     name           : Savings Bond Name
  153. #     cost             : Savings Bond Cost
  154. #     interest_rate : Savings Bond Interest Rate (In Percent)
  155. #     length          : Length of Hours until Mature
  156. #--------------------------------------------------------------------------
  157. def initialize(name, cost, interest_rate, length)
  158.    @name = name
  159.    @cost = cost
  160.    @interest_rate = interest_rate
  161.    @length = length
  162.    @mature_value = (@cost * (1+ @interest_rate / 100.0)).to_i
  163. end
  164. #--------------------------------------------------------------------------
  165. # * Set Times
  166. #--------------------------------------------------------------------------
  167. def set_times
  168.    @time_bought = Graphics.frame_count / Graphics.frame_rate
  169.    @time_finished = @time_bought + @length * 3600
  170. end
  171. #--------------------------------------------------------------------------
  172. # * Make Time to HH:MM:SS
  173. #--------------------------------------------------------------------------
  174. def return_time(time)
  175.    hours      = time / 60 / 60
  176.    minutes   = time / 60 % 60
  177.    seconds   = time % 60
  178.    return sprintf("%02d:%02d:%02d", hours, minutes, seconds)
  179. end
  180. end

  181. #==============================================================================
  182. # ** Window_BankNumber
  183. #==============================================================================
  184. class Window_BankNumber < Window_Base
  185. #--------------------------------------------------------------------------
  186. # * Object Initialization
  187. #--------------------------------------------------------------------------
  188. def initialize
  189.    super(640, 272, 240, 192)
  190.      self.opacity = 175
  191.    self.contents = Bitmap.new(width - 32, height - 32)
  192. end
  193. #--------------------------------------------------------------------------
  194. # * Refresh
  195. #     money  : Gold being...
  196. #     type      : Deposit or Withdraw
  197. #--------------------------------------------------------------------------
  198. def refresh(money, type)
  199.    contents.clear
  200.    # Deposit or Withdraw
  201.    contents.font.color = system_color
  202.    contents.draw_text(0, 0, contents.width, 24, "存款信息", 1)
  203.    if type == "存入"
  204.      # Draws Game Party Gold
  205.      contents.draw_text(4, 48, contents.width, 24, "所持金钱:")
  206.      contents.font.color = normal_color
  207.      contents.draw_text(-4, 48, contents.width, 24, $game_party.gold.to_s, 2)
  208.    else
  209.      # Draws Account Balance
  210.      contents.draw_text(4, 48, contents.width, 24, "银行余额:")
  211.      contents.font.color = normal_color
  212.      contents.draw_text(-4, 48, contents.width, 24, $game_bank.account_balance.to_s, 2)
  213.    end
  214.    # Draws Money Being Deposited or Withdrawn
  215.    contents.font.color = system_color
  216.    contents.draw_text(4, 72, contents.width, 24, "预存金钱:")
  217.    contents.font.color = normal_color
  218.    contents.draw_text(-4, 72, contents.width, 24, "- #{money}", 2)
  219.    # Draws Line
  220.    line = ""
  221.    while contents.text_size(line).width < contents.width
  222.      line += "-"
  223.    end
  224.    contents.draw_text(0, 96, contents.width, 24, line, 2)
  225.    # Draws Game Party Gold Amont
  226.    contents.font.color = system_color
  227.    contents.draw_text(4, 112, contents.width, 32, "存后金钱:")
  228.    amount = $game_party.gold
  229.    amount += type == "存入" ? -money : money
  230.    contents.font.color = normal_color
  231.    contents.draw_text(-4, 112, contents.width, 32, amount.to_s, 2)
  232.    # Draws Deposit Amont
  233.    amount = $game_bank.account_balance
  234.    amount += type == "存入" ? money : -money
  235.    contents.font.color = system_color
  236.    contents.draw_text(4, 136, contents.width, 32, "存入余额:")
  237.    contents.font.color = normal_color
  238.    contents.draw_text(-4, 136, contents.width, 32, amount.to_s, 2)
  239. end
  240. end

  241. #==============================================================================
  242. # ** Window_BankBio
  243. #==============================================================================
  244. class Window_BankBio < Window_Base
  245. #--------------------------------------------------------------------------
  246. # * Object Initialization
  247. #--------------------------------------------------------------------------
  248. def initialize
  249.    super(-240, 272, 240, 192)
  250.      self.opacity = 175
  251.    self.contents = Bitmap.new(width - 32, height - 32)
  252.    refresh
  253. end
  254. #--------------------------------------------------------------------------
  255. # * Refresh
  256. #--------------------------------------------------------------------------
  257. def refresh
  258.    contents.clear
  259.    # Deposit or Withdraw
  260.    contents.font.color = system_color
  261.    # Draws Actor Name in Postition 1
  262.    contents.font.color = normal_color
  263.    contents.draw_text(0, 0, contents.width, 24, "#{$game_party.actors[0].name}", 1)
  264.    # Draws Game Party Gold
  265.    contents.font.color = system_color
  266.    contents.draw_text(4, 32, contents.width, 24, "持有 #{$data_system.words.gold}:")
  267.    contents.font.color = normal_color
  268.    contents.draw_text(-4, 32, contents.width, 24, $game_party.gold.to_s, 2)
  269.    # Draws Account Balance
  270.    contents.font.color = system_color
  271.    contents.draw_text(4, 56, contents.width, 24, "银行余额:")
  272.    contents.font.color = normal_color
  273.    contents.draw_text(-4, 56, contents.width, 24, $game_bank.account_balance.to_s, 2)
  274.    # Draws Number of Savings Bond's
  275.    contents.font.color = system_color
  276.    contents.draw_text(4, 80, contents.width, 24, "债券持有:")
  277.    contents.font.color = normal_color
  278.    contents.draw_text(-4, 80, contents.width, 24, $game_bank.saving_bonds.size.to_s, 2)
  279.    # Draws Value of Savings Bond's
  280.    ;value = 0
  281.    $game_bank.saving_bonds.each { |x| value += x.mature_value}
  282.    contents.font.color = system_color
  283.    contents.draw_text(4, 104, contents.width, 24, "债券价值:")
  284.    contents.font.color = normal_color
  285.    contents.draw_text(-4, 104, contents.width, 24, value.to_s, 2)
  286.    # Draws Current Interest Rate
  287.    contents.font.color = system_color
  288.    contents.draw_text(4, 136, contents.width, 24, "利率:")
  289.    contents.font.color = normal_color
  290.    contents.draw_text(-4, 136, contents.width, 24, "#{$game_bank.interest_rate} %", 2)
  291. end
  292. end

  293. #==============================================================================
  294. # ** Window_Bond
  295. #==============================================================================
  296. class Window_Bond < Window_Base
  297. #--------------------------------------------------------------------------
  298. # * Object Initialization
  299. #--------------------------------------------------------------------------
  300. def initialize
  301.    super(-240, 264, 240, 200)
  302.      self.opacity = 175
  303.    self.contents = Bitmap.new(width - 32, height - 32)
  304. end
  305. #--------------------------------------------------------------------------
  306. # * Refresh
  307. #     bond    : Savings Bond
  308. #--------------------------------------------------------------------------
  309. def refresh(bond, bought = false)
  310.    contents.clear
  311.    unless bond == nil
  312.      # Draws Bond Name
  313.      contents.font.color = system_color
  314.      contents.draw_text(0, 0, contents.width, 24, bond.name, 1)
  315.      # Draws Bond Cost
  316.      contents.font.color = system_color
  317.      contents.draw_text(4, 24, contents.width, 24, "债券价格:")
  318.      contents.font.color = normal_color
  319.      contents.draw_text(-4, 24, contents.width, 24, bond.cost.to_s, 2)
  320.      # Draws Bond Mature Value
  321.      contents.font.color = system_color
  322.      contents.draw_text(4, 48, contents.width, 24, "成熟价值:")
  323.      contents.font.color = normal_color
  324.      contents.draw_text(-4, 48, contents.width, 24, "#{bond.mature_value}", 2)
  325.      # Draws Bond Interest Rate
  326.      contents.font.color = system_color
  327.      contents.draw_text(4, 72, contents.width, 24, "利率:")
  328.      contents.font.color = normal_color
  329.      contents.draw_text(-4, 72, contents.width, 24, "#{bond.interest_rate} %", 2)
  330.      # Draws Length until Maturity
  331.      contents.font.color = system_color
  332.      contents.draw_text(4, 96, contents.width, 24, "到期时间:")
  333.      contents.font.color = normal_color
  334.      contents.draw_text(-4, 96, contents.width, 24, "#{bond.length} 小时", 2)
  335.      # Display only if Purchased CD
  336.      if bought
  337.        # Draws Time Bought
  338.        contents.font.color = system_color
  339.        contents.draw_text(4, 120, contents.width, 24, "购买时间:")
  340.        contents.font.color = normal_color
  341.        contents.draw_text(-4, 120, contents.width, 24, bond.return_time(bond.time_bought), 2)
  342.        # Draws Time Finished
  343.        contents.font.color = system_color
  344.        contents.draw_text(4, 144, contents.width, 24, "结束时间:")
  345.        contents.font.color = normal_color
  346.        contents.draw_text(-4, 144, contents.width, 24, bond.return_time(bond.time_finished), 2)
  347.      end
  348.    end
  349. end
  350. end

  351. #==============================================================================
  352. # ** Scene_Bank
  353. #==============================================================================
  354. class Scene_Bank
  355. #--------------------------------------------------------------------------
  356. # * Object Initialization
  357. #     interest rate   :   Changes Current Interest Rate (Leave 0 for no Change)
  358. #     bonds           :   Avaliable CD's For Purchasing
  359. #--------------------------------------------------------------------------
  360. def initialize(interest_rate = $game_bank.interest_rate,
  361.      bonds = [ Savings_Bond.new("CD-7", 100, 7.5, 7), Savings_Bond.new("CD-14", 500, 15, 14)])
  362.    $game_bank.interest_rate = interest_rate unless interest_rate == 0
  363.    @bonds = bonds
  364. end
  365. #--------------------------------------------------------------------------
  366. # * Main Processing
  367. #--------------------------------------------------------------------------
  368. def main
  369.    # Current Phase
  370.    @phase = -1
  371.    # Refreshing Variables
  372.    @amount, @depositing = 0, true
  373.    @current_bond, @bond_bought = nil, false
  374.    # Make sprite set
  375.    @spriteset = Spriteset_Map.new
  376.    # Help Window
  377.    @help_window = Window_Help.new
  378.      @help_window.y, @help_window.opacity = -64, 175
  379.      @help_window.set_text("欢迎来到银行!你可以在这里存取金钱!=^^=", 1)
  380.    # Bank Bio
  381.    @bank_bio_window = Window_BankBio.new
  382.    # Avaliable Bond Information Display Window
  383.    @av_bond_display_window = Window_Bond.new
  384.    # Owned Bond Information Display Window
  385.    @own_bond_display_window = Window_Bond.new
  386.    # Main Command
  387.    @main_command = Window_RefreshCommand.new(180, [
  388.        "存款",
  389.        "取款", "购买债券", "债券查看", "退出"])
  390.      @main_command.x, @main_command.y, @main_command.opacity = 644, 272, 175
  391.      @main_command.active = false
  392.    # Bank Number Window
  393.    @bank_number_window = Window_BankNumber.new
  394.    # Avaliable Bonds Command
  395.    commands = []
  396.    @bonds.each {|x| commands.push(x.name)}; commands.push("返回")
  397.    @av_bond_command = Window_RefreshCommand.new(180, commands)
  398.      @av_bond_command.x, @av_bond_command.y = 644, 272
  399.      @av_bond_command.height, @av_bond_command.opacity = 192, 175
  400.      @av_bond_command.active = false
  401.    # CD's Have
  402.    @own_bond_command = Window_RefreshCommand.new(180, get_cd_list)
  403.      @own_bond_command.x, @own_bond_command.y = 644, 272
  404.      @own_bond_command.height, @own_bond_command.opacity = 192, 175
  405.      @own_bond_command.active = false
  406.    # Scene Objects
  407.    @objects = [@spriteset, @help_window, @bank_bio_window, @av_bond_display_window,
  408.        @own_bond_display_window, @main_command, @bank_number_window,
  409.        @av_bond_command, @own_bond_command]
  410.    # Execute transition
  411.    Graphics.transition
  412.    # Main loop
  413.    while $scene == self
  414.      # Update game screen
  415.      Graphics.update
  416.      # Update input information
  417.      Input.update
  418.      # Update Objects
  419.      @objects.each {|x| x.update}
  420.      # Updates Bank System
  421.      $game_bank.update
  422.      # Frame update
  423.      update
  424.    end
  425.    # Prepare for transition
  426.    Graphics.freeze
  427.    # Dispose of windows
  428.    @objects.each {|x| x.dispose}
  429. end
  430. #--------------------------------------------------------------------------
  431. # * Frame Update
  432. #--------------------------------------------------------------------------
  433. def update
  434.    # Splits Phases Up
  435.    case @phase
  436.    when -1 # Intro Phase
  437.      intro_update
  438.    when 0  # Main Phase
  439.      main_update
  440.    when 1  # Deposit or Withdraw Phase
  441.      account_update
  442.    when 2  # Buy CD Phase
  443.      buy_bond_update
  444.    when 3  # Get Mature CD Phse
  445.      get_bond_update
  446.    when 99 # Exit Phase
  447.      exit_update
  448.    end
  449. end
  450. #--------------------------------------------------------------------------
  451. # * Intro Update
  452. #--------------------------------------------------------------------------
  453. def intro_update
  454.    # Moves Window Down
  455.    @help_window.y += 4 if @help_window.y < 0
  456.    if @help_window.y == 0
  457.      # Input Processing
  458.      if Input.trigger?(Input::B)
  459.        $game_system.se_play($data_system.cancel_se)
  460.        # Returns to Scene
  461.        @phase = 99
  462.      elsif Input.trigger?(Input::C)
  463.        $game_system.se_play($data_system.decision_se)
  464.        # Switchs to Main Phase
  465.        @phase = 0
  466.      end
  467.    end
  468. end
  469. #--------------------------------------------------------------------------
  470. # * Main Update
  471. #--------------------------------------------------------------------------
  472. def main_update
  473.    # Turns On Main Command
  474.    @main_command.active = true
  475.    # Turns Off Other Command Windows
  476.    @av_bond_command.active = @own_bond_command.active = false
  477.    # Moves In Active Windows
  478.    @bank_bio_window.z = @main_command.z = 9999
  479.    @bank_bio_window.x += 32 if @bank_bio_window.x < 16
  480.    @main_command.x -= 25 if @main_command.x > 444
  481.    # Moves Out Inactive Windows
  482.    @av_bond_display_window.x -= 32 if @av_bond_display_window.x > - 240
  483.    [@av_bond_display_window, @own_bond_display_window, @bank_number_window,
  484.      @av_bond_command, @own_bond_command].each {|window| window.z = 9995}
  485.    [@av_bond_command, @own_bond_command].each {|command|
  486.      command.x += 25 if command.x < 644}
  487.    @own_bond_display_window.x -= 25 if @own_bond_display_window.x > - 240
  488.    @bank_number_window.x += 32 if @bank_number_window.x < 640
  489.    # Sets Help Window
  490.    case @main_command.index
  491.      when 0; @help_window.set_text("要 存款 从这里...", 1)
  492.      when 1; @help_window.set_text("要 提款 从这里...", 1)
  493.      when 2; @help_window.set_text("要 购买债券 从这里...", 1)
  494.      when 3; @help_window.set_text("要 查看债券 从这里...", 1)
  495.      when 4; @help_window.set_text("亲爱的顾客,您要离开银行吗?", 1)
  496.    end
  497.    # Input Processing
  498.    if Input.trigger?(Input::B) # Returns to Map
  499.      $game_system.se_play($data_system.cancel_se)
  500.      @phase = 99
  501.    elsif Input.trigger?(Input::C)
  502.      $game_system.se_play($data_system.decision_se)
  503.      case @main_command.index
  504.      when 0  # Deposit
  505.        @amount, @depositing = 0, true
  506.        refresh_windows
  507.        @help_window.set_text("存入 #{@amount} #{$data_system.words.gold}", 1)
  508.        @phase = 1
  509.      when 1  # Withdraw
  510.        @amount, @depositing = 0, false
  511.        refresh_windows
  512.        @help_window.set_text("取出 #{@amount} #{$data_system.words.gold}", 1)
  513.        @phase = 1
  514.      when 2  # Buy CD
  515.        @current_bond = @bonds[@av_bond_command.index]
  516.        @bond_bought = false
  517.        refresh_windows
  518.        @phase = 2
  519.      when 3  # Get CD
  520.        @current_bond = $game_bank.saving_bonds[@own_bond_command.index]
  521.        @bond_bought = true
  522.        refresh_windows
  523.        @phase = 3
  524.      when 4  # Exit Bank
  525.        @phase = 99
  526.      end
  527.    end
  528. end
  529. #--------------------------------------------------------------------------
  530. # * Accpunt Update
  531. #--------------------------------------------------------------------------
  532. def account_update
  533.    # Turns Off Command Windows
  534.    @main_command.active = @av_bond_command.active = @own_bond_command.active = false
  535.    # Moves In Active Windows
  536.    @bank_bio_window.z = @bank_number_window.z = 9999
  537.    @bank_bio_window.x += 32 if @bank_bio_window.x < 16
  538.    @bank_number_window.x -= 32 if @bank_number_window.x > 384
  539.    # Moves Out Inactive Windows
  540.    @av_bond_display_window.z = @own_bond_display_window.z =
  541.      @main_command.z = @av_bond_command.z = @own_bond_command.z = 9995
  542.    @av_bond_display_window.x -= 32 if @av_bond_display_window.x > - 240
  543.    [@own_bond_display_window].each {|window| window.x -= 25 if window.x > - 240}
  544.    [@main_command, @av_bond_command, @own_bond_command].each {|command|
  545.        command.x += 25 if command.x < 644}
  546.    # Input Processing
  547.    if Input.trigger?(Input::B)
  548.      $game_system.se_play($data_system.cancel_se)
  549.      @phase = 0
  550.    elsif Input.trigger?(Input::C)
  551.      $game_system.se_play($data_system.shop_se)
  552.      if @depositing
  553.        $game_bank.deposit(@amount)
  554.        refresh_windows
  555.        @phase = 0
  556.      else
  557.        $game_bank.withdraw(@amount)
  558.        refresh_windows
  559.        @phase = 0
  560.      end
  561.    elsif Input.repeat?(Input::LEFT) && Input.press?(Input::LEFT)
  562.      if @amount > 0
  563.        $game_system.se_play($data_system.cursor_se)
  564.        @amount -= 1
  565.        refresh_windows
  566.        @help_window.set_text("#{@depositing ? '存入' : '取出'} #{@amount} #{$data_system.words.gold}", 1)
  567.      else
  568.        $game_system.se_play($data_system.buzzer_se)
  569.      end
  570.    elsif Input.repeat?(Input::RIGHT) && Input.press?(Input::RIGHT)
  571.      if @depositing
  572.        if @amount < $game_party.gold
  573.          $game_system.se_play($data_system.cursor_se)
  574.          @amount += 1
  575.          refresh_windows
  576.          @help_window.set_text("#{@depositing ? '存入' : '取出'} #{@amount} #{$data_system.words.gold}", 1)
  577.        else
  578.          $game_system.se_play($data_system.buzzer_se)
  579.        end
  580.      else
  581.        if @amount < $game_bank.account_balance
  582.          $game_system.se_play($data_system.cursor_se)
  583.          @amount += 1
  584.          refresh_windows
  585.          @help_window.set_text("#{@depositing ? '存入' : '取出'} #{@amount} #{$data_system.words.gold}", 1)
  586.        else
  587.          $game_system.se_play($data_system.buzzer_se)
  588.        end
  589.      end
  590.    elsif Input.repeat?(Input::UP) && Input.press?(Input::UP)
  591.      if @amount == 0
  592.        $game_system.se_play($data_system.buzzer_se)
  593.      else
  594.        $game_system.se_play($data_system.cursor_se)
  595.        @amount > 10 ? @amount -= 10 : @amount = 0
  596.        refresh_windows
  597.        @help_window.set_text("#{@depositing ? '存入' : '取出'} #{@amount} #{$data_system.words.gold}", 1)
  598.      end
  599.    elsif Input.repeat?(Input::DOWN) && Input.press?(Input::DOWN)
  600.      if @depositing
  601.        if @amount < $game_party.gold
  602.          $game_system.se_play($data_system.cursor_se)
  603.          @amount < $game_party.gold - 10 ? @amount += 10 : @amount = $game_party.gold
  604.          refresh_windows
  605.          @help_window.set_text("#{@depositing ? '存入' : '取出'} #{@amount} #{$data_system.words.gold}", 1)
  606.        else
  607.          $game_system.se_play($data_system.buzzer_se)
  608.        end
  609.      else
  610.        if @amount < $game_bank.account_balance
  611.          $game_system.se_play($data_system.cursor_se)
  612.          @amount < $game_bank.account_balance - 10 ? @amount += 10 : @amount = $game_bank.account_balance
  613.          refresh_windows
  614.          @help_window.set_text("#{@depositing ? '存入' : '取出'} #{@amount} #{$data_system.words.gold}", 1)
  615.        else
  616.          $game_system.se_play($data_system.buzzer_se)
  617.        end
  618.      end
  619.    elsif Input.repeat?(Input::L) && Input.press?(Input::L)
  620.      if @amount == 0
  621.        $game_system.se_play($data_system.buzzer_se)
  622.      else
  623.        $game_system.se_play($data_system.cursor_se)
  624.        @amount > 100 ? @amount -= 100 : @amount = 0
  625.        refresh_windows
  626.        @help_window.set_text("#{@depositing ? '存入' : '取出'} #{@amount} #{$data_system.words.gold}", 1)
  627.      end
  628.    elsif Input.repeat?(Input::R) && Input.press?(Input::R)
  629.      if @depositing
  630.        if @amount < $game_party.gold
  631.          $game_system.se_play($data_system.cursor_se)
  632.          @amount < $game_party.gold - 100 ? @amount += 100 : @amount = $game_party.gold
  633.          refresh_windows
  634.          @help_window.set_text("#{@depositing ? '存入' : '取出'} #{@amount} #{$data_system.words.gold}", 1)
  635.        else
  636.          $game_system.se_play($data_system.buzzer_se)
  637.        end
  638.      else
  639.        if @amount < $game_bank.account_balance
  640.          $game_system.se_play($data_system.cursor_se)
  641.          @amount < $game_bank.account_balance - 100 ? @amount += 100 : @amount = $game_bank.account_balance
  642.          refresh_windows
  643.          @help_window.set_text("#{@depositing ? '存入' : '取出'} #{@amount} #{$data_system.words.gold}", 1)
  644.        else
  645.          $game_system.se_play($data_system.buzzer_se)
  646.        end
  647.      end
  648.    end
  649. end
  650. #--------------------------------------------------------------------------
  651. # * Buy Bond Update
  652. #--------------------------------------------------------------------------
  653. def buy_bond_update
  654.    # Turns On Avaliable Bond Window
  655.    @av_bond_command.active = true
  656.    # Turns Off Other Command Windows
  657.    @main_command.active = @own_bond_command.active = false
  658.    # Moves In Active Windows
  659.    @av_bond_display_window.z = @av_bond_command.z = 9999
  660.    @av_bond_display_window.x += 32 if @av_bond_display_window.x < 16
  661.    @av_bond_command.x -= 25 if @av_bond_command.x > 444
  662.    # Moves Out Inactive Windows
  663.    [@bank_bio_window, @bank_number_window, @own_bond_display_window,
  664.      @main_command, @own_bond_command].each {|window| window.z = 9995}
  665.    @bank_bio_window.x -= 32 if @bank_bio_window.x > - 240
  666.    @bank_number_window.x += 32 if @bank_number_window.x < 640
  667.    @own_bond_display_window.x -= 25 if @own_bond_display_window.x > - 240
  668.    [@main_command, @own_bond_command].each {|command| command.x += 25 if command.x < 644}
  669.    # Input Processing
  670.    if Input.trigger?(Input::B)
  671.      $game_system.se_play($data_system.cancel_se)
  672.      @phase = 0
  673.    elsif Input.trigger?(Input::C)
  674.      if @av_bond_command.index == @bonds.size
  675.        $game_system.se_play($data_system.cancel_se)
  676.        @phase = 0
  677.      else
  678.        current_bond = @bonds[@av_bond_command.index].dup
  679.        if current_bond.cost > $game_party.gold
  680.          $game_system.se_play($data_system.buzzer_se)
  681.        else
  682.          $game_system.se_play($data_system.decision_se)
  683.          $game_party.lose_gold(current_bond.cost)
  684.          current_bond.set_times
  685.          $game_bank.add_bond(current_bond)
  686.          refresh_windows
  687.          @phase = 0
  688.        end
  689.      end
  690.    # Updates Current Bond
  691.    elsif Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
  692.      @current_bond = @bonds[@av_bond_command.index]
  693.      refresh_windows
  694.    end
  695. end
  696. #--------------------------------------------------------------------------
  697. # * Get Bond Update
  698. #--------------------------------------------------------------------------
  699. def get_bond_update
  700.    # Turns On Avaliable Bond Window
  701.    @own_bond_command.active = true
  702.    # Turns Off Other Command Windows
  703.    @main_command.active = @av_bond_command.active = false
  704.    # Moves In Active Windows
  705.    [@own_bond_display_window, @own_bond_command].each {|window| window.z = 9999}
  706.    @own_bond_display_window.x += 32 if @own_bond_display_window.x < 16
  707.    @own_bond_command.x -= 25 if @own_bond_command.x > 444
  708.    # Moves Out Inactive Windows
  709.    [@bank_bio_window, @av_bond_display_window, @main_command, @bank_number_window,
  710.      @av_bond_command].each {|window| window.z = 9995}
  711.    [@bank_bio_window, @av_bond_display_window].each {|window|
  712.      window.x -= 32 if window.x > - 240}
  713.    [@main_command, @av_bond_command].each {|window|
  714.      window.x += 25 if window.x < 640}
  715.    @bank_number_window.x += 32 if @bank_number_window.x < 640
  716.    # Input Processing
  717.    if Input.trigger?(Input::B)
  718.      $game_system.se_play($data_system.cancel_se)
  719.      @phase = 0
  720.    elsif Input.trigger?(Input::C)
  721.      if @own_bond_command.index == $game_bank.saving_bonds.size
  722.        $game_system.se_play($data_system.cancel_se)
  723.        @phase = 0
  724.      else
  725.        current_bond = $game_bank.saving_bonds[@own_bond_command.index]
  726.        if current_bond.time_finished > Graphics.frame_count / Graphics.frame_rate
  727.          $game_system.se_play($data_system.buzzer_se)
  728.          @help_window.set_text("储蓄债券还未成熟!", 1)
  729.        else
  730.          $game_system.se_play($data_system.decision_se)
  731.          $game_party.gain_gold(current_bond.mature_value)
  732.          $game_bank.saving_bonds.delete_at[@own_bond_command.index]
  733.          refresh_windows
  734.          @phase = 0
  735.        end
  736.      end
  737.    elsif Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
  738.      @current_bond = $game_bank.saving_bonds[@own_bond_command.index]
  739.      refresh_windows
  740.    end
  741. end

  742. # * Exit Update

  743. def exit_update
  744.    # Moves Out Windows
  745.    @help_window.y -= 4 if @help_window.y > - 64
  746.    [@bank_bio_window, @av_bond_display_window].each {|window| window.x -= 32 if window.x > - 240}
  747.    [@own_bond_display_window].each {|window| window.x -= 25 if window.x > - 240}
  748.    [@main_command, @bank_number_window, @av_bond_command,
  749.      @own_bond_command].each {|window| window.x += 25 if window.x < 640}
  750.    # Checks To Make Sure All Windows Are Out
  751.    if @help_window.y <= - 64 && @bank_bio_window.x <= - 240 && @av_bond_display_window.x <= - 240 &&
  752.        @own_bond_display_window.x <= - 240 && @main_command.x >= 644 &&
  753.        @bank_number_window.x >= 640 && @av_bond_command.x >= 640 && @own_bond_command.x >= 640
  754.      $scene = Scene_Map.new
  755.    end
  756. end
  757. #--------------------------------------------------------------------------
  758. # * Get CD List
  759. #--------------------------------------------------------------------------
  760. def get_cd_list
  761.    commands = []
  762.    $game_bank.saving_bonds.each {|x| commands.push(x.name)}
  763.    commands.push("返回")
  764.    return commands
  765. end
  766. #--------------------------------------------------------------------------
  767. # * Refresh Windows
  768. #--------------------------------------------------------------------------
  769. def refresh_windows
  770.    @bank_bio_window.refresh
  771.    @av_bond_display_window.refresh(@current_bond, @bond_bought)
  772.    @own_bond_display_window.refresh(@current_bond, @bond_bought)
  773.    @bank_number_window.refresh(@amount, @depositing ? "存入" : "取出")
  774.    @own_bond_command.refresh(get_cd_list)
  775. end
  776. end
复制代码


【我的百度空间】
 不定时更新绘画或像素图~~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

月下可怜人

梦石
0
星屑
50
在线时间
10 小时
注册时间
2005-11-23
帖子
4085

第1届短篇游戏比赛亚军

5
发表于 2006-10-29 04:36:51 | 只看该作者
很漂亮的银行,帮LS截个图.

纵然千里外,我等雁归来。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

查无此人

梦石
0
星屑
50
在线时间
9 小时
注册时间
2006-5-8
帖子
1399
6
发表于 2006-10-29 04:52:43 | 只看该作者
为什么转载的时候去掉了作者和版本信息{/fd}

#   Created By SephirothSpawn (12.03.05)
#   Last Updated: 12.03.05

2005年12月3日(应该不是3月12日吧...美洲那里是用美式表达法....)
KRKR + NS 学习中..........
回复 支持 反对

使用道具 举报

Lv1.梦旅人

邪恶小龙包

梦石
0
星屑
55
在线时间
17 小时
注册时间
2006-5-22
帖子
7006

第2届短篇游戏比赛冠军第3届短篇游戏大赛小游戏及其他组冠军RMVX自由创作大赛冠军

7
发表于 2006-10-29 11:07:48 | 只看该作者
晕啊...好象把这个加进模拟人生中....但是脚本冲突了...
虚无  堕落
回复 支持 反对

使用道具 举报

Lv1.梦旅人

月下可怜人

梦石
0
星屑
50
在线时间
10 小时
注册时间
2005-11-23
帖子
4085

第1届短篇游戏比赛亚军

8
发表于 2006-10-29 18:50:58 | 只看该作者
希望LS赋有创新意识的游戏能出生,具体有什么问题,我帮你解决.
纵然千里外,我等雁归来。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
1 小时
注册时间
2006-8-9
帖子
510
9
发表于 2006-10-29 19:18:13 | 只看该作者
试试吧...还有翻译后的版本..
回复 支持 反对

使用道具 举报

Lv1.梦旅人

邪恶小龙包

梦石
0
星屑
55
在线时间
17 小时
注册时间
2006-5-22
帖子
7006

第2届短篇游戏比赛冠军第3届短篇游戏大赛小游戏及其他组冠军RMVX自由创作大赛冠军

10
发表于 2006-10-30 14:57:03 | 只看该作者
以下引用美兽于2006-10-29 10:50:58的发言:

希望LS赋有创新意识的游戏能出生,具体有什么问题,我帮你解决.

万分感谢!{/ll}如果有空我把用过的脚本发给你帮我看看?
虚无  堕落
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 08:50

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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