//-------------------------------------------------------------------------- // ● 变量操作 //-------------------------------------------------------------------------- public bool command_122() { // 初始化值 var value = 0.0; // 操作数的分支 switch ((int)this.parameters[3]) { case 0: // 恒量 value = (int)this.parameters[4]; break; case 1: // 变量 value = Global.game_variables[(int)this.parameters[4]]; break; case 2: // 随机数 value = (int)this.parameters[4] + Global.rand((int)this.parameters[5] - (int)this.parameters[4] + 1); break; case 3: // 物品 value = Global.game_party.item_number((int)this.parameters[4]); break; case 4: // 角色 { var actor = Global.game_actors[(int)this.parameters[4]]; if (actor != null) { switch ((int)this.parameters[5]) { case 0: // 等级 value = actor.level; break; case 1: // EXP value = actor.exp; break; case 2: // HP value = actor.hp; break; case 3: // SP value = actor.sp; break; case 4: // MaxHP value = actor.maxhp; break; case 5: // MaxSP value = actor.maxsp; break; case 6: // 力量 value = actor.str; break; case 7: // 灵巧 value = actor.dex; break; case 8: // 速度 value = actor.agi; break; case 9: // 魔力 value = actor.int1; break; case 10: // 攻击力 value = actor.atk; break; case 11: // 物理防御 value = actor.pdef; break; case 12: // 魔法防御 value = actor.mdef; break; case 13: // 回避修正 value = actor.eva; break; } } } break; case 5: // 敌人 { var enemy = Global.game_troop.enemies[(int)this.parameters[4]]; if (enemy != null) { switch ((int)this.parameters[5]) { case 0: // HP value = enemy.hp; break; case 1: // SP value = enemy.sp; break; case 2: // MaxHP value = enemy.maxhp; break; case 3: // MaxSP value = enemy.maxsp; break; case 4: // 力量 value = enemy.str; break; case 5: // 灵巧 value = enemy.dex; break; case 6: // 速度 value = enemy.agi; break; case 7: // 魔力 value = enemy.int1; break; case 8: // 攻击力 value = enemy.atk; break; case 9: // 物理防御 value = enemy.pdef; break; case 10: // 魔法防御 value = enemy.mdef; break; case 11: // 回避修正 value = enemy.eva; break; } } } break; case 6: // 角色 { var character = get_character((int)this.parameters[4]); if (character != null) { switch ((int)this.parameters[5]) { case 0: // X 坐标 value = character.x; break; case 1: // Y 坐标 value = character.y; break; case 2: // 朝向 value = character.direction; break; case 3: // 画面 X 坐标 value = character.screen_x; break; case 4: // 画面 Y 坐标 value = character.screen_y; break; case 5: // 地形标记 value = character.terrain_tag; break; } } } break; case 7: // 其它 switch ((int)this.parameters[4]) { case 0: // 地图 ID value = Global.game_map.map_id; break; case 1: // 同伴人数 value = Global.game_party.actors.Count; break; case 2: // 金钱 value = Global.game_party.gold; break; case 3: // 步数 value = Global.game_party.steps; break; case 4: // 游戏时间 value = Graphics.frame_count / Graphics.frame_rate; break; case 5: // 计时器 value = Global.game_system.timer / Graphics.frame_rate; break; case 6: // 存档次数 value = Global.game_system.save_count; break; } break; } // 循环全部操作 for (var i = (int)this.parameters[0]; i <= (int)this.parameters[1]; i++) { // 操作分支 switch ((int)this.parameters[2]) { case 0: // 代入 Global.game_variables[i] = (int)value; break; case 1: // 加法 Global.game_variables[i] += (int)value; break; case 2: // 减法 Global.game_variables[i] -= (int)value; break; case 3: // 乘法 Global.game_variables[i] *= (int)value; break; case 4: // 除法 if (value != 0) { Global.game_variables[i] /= (int)value; } break; case 5: // 剩余 if (value != 0) { Global.game_variables[i] %= (int)value; } break; } // 检查上限 if (Global.game_variables[i] > 99999999) { Global.game_variables[i] = 99999999; } // 检查下限 if (Global.game_variables[i] < -99999999) { Global.game_variables[i] = -99999999; } } // 刷新地图 Global.game_map.need_refresh = true; // 继续 return(true); }
public override void Initialize() { Global.PreviewKeyDown += OnKeyDown; // 战斗测试的情况下 if (Global.BTEST) { battle_test(); return; } // 载入数据库 if (!Global.DataInXml) { Global.data_actors = (List <RPG.Actor>)Global.load_data("Data/Actors.rxdata"); Global.data_classes = (List <RPG.Class>)Global.load_data("Data/Classes.rxdata"); Global.data_skills = (List <RPG.Skill>)Global.load_data("Data/Skills.rxdata"); Global.data_items = (List <RPG.Item>)Global.load_data("Data/Items.rxdata"); Global.data_weapons = (List <RPG.Weapon>)Global.load_data("Data/Weapons.rxdata"); Global.data_armors = (List <RPG.Armor>)Global.load_data("Data/Armors.rxdata"); Global.data_enemies = (List <RPG.Enemy>)Global.load_data("Data/Enemies.rxdata"); Global.data_troops = (List <RPG.Troop>)Global.load_data("Data/Troops.rxdata"); Global.data_states = (List <RPG.State>)Global.load_data("Data/States.rxdata"); Global.data_animations = (List <RPG.Animation>)Global.load_data("Data/Animations.rxdata"); Global.data_tilesets = (List <RPG.Tileset>)Global.load_data("Data/Tilesets.rxdata"); Global.data_common_events = (List <RPG.CommonEvent>)Global.load_data("Data/CommonEvents.rxdata"); Global.data_system = (RPG.System)Global.load_data("Data/System.rxdata"); } else { Global.LoadData(); } // 生成系统对像 Global.game_system = new Game_System(); // 生成标题图形 this.sprite = new XP.Internal.Sprite(); this.sprite.bitmap = RPG.Cache.title(Global.data_system.title_name); // 生成命令窗口 var s1 = "新游戏"; var s2 = "继续"; var s3 = "退出"; this.command_window = new Window_Command(192, new string[] { s1, s2, s3 }); this.command_window.back_opacity = 160; this.command_window.x = 320 - this.command_window.width / 2; this.command_window.y = 288; // 判定继续的有效性 // 存档文件一个也不存在的时候也调查 // 有効为 this.continue_enabled 为 true、无效为 false this.continue_enabled = false; for (var i = 0; i <= 3; i++) { if (File.is_exist("Save//{i+1}.rxdata")) { this.continue_enabled = true; } } // 继续为有效的情况下、光标停止在继续上 // 无效的情况下、继续的文字显示为灰色 if (this.continue_enabled) { this.command_window.index = 1; } else { this.command_window.disable_item(1); } // 演奏标题 RPG.AudioFile Global.game_system.bgm_play(Global.data_system.title_bgm); // 停止演奏 ME、BGS Audio.me_stop(); Audio.bgs_stop(); // 执行过渡 Graphics.transition(); }