public void LoadCommands() { // create and attach child object GameObject obj = new GameObject("Commands"); obj.transform.parent = transform; obj.transform.localPosition = Vector3.zero; Commands = new Dictionary <CommandID, CommandInfo>(); // create all the commands CommandInfo ci = null; CsvStreamReader csv = CsvDataManager.Instance.GetTable("command_id"); CommandID cmdId = CommandID.BuildCity; string cmdName = cmdName = csv.GetValue((int)cmdId, "Name"); int actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } int order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdBuildCity>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.AbandonCity; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdAbandonCity>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.AbandonBuilding; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdAbandonBuilding>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.CreateFarmer; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdCreateFarmer>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.CreateSettler; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdCreateSettler>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.CreateSoldier1; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdCreateSoldier1>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.CreateSoldier2; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdCreateSoldier2>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.CreateSoldier3; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdCreateSoldier3>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.CreateSoldier4; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdCreateSoldier4>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.Lumberjack; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdLumberjack>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.Harvest; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdHarvest>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.Mining; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdMining>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.BuildRoad; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdBuildRoad>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.BuildBridge; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdBuildBridge>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.DismissTroop; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdDismissTroop>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.March; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdMarch>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.Attack; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdAttack>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.Guard; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdGuard>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.RapidMarch; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdRapidMarch>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.Charge; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdCharge>(), }; Commands.Add(cmdId, ci); cmdId = CommandID.Halt; cmdName = csv.GetValue((int)cmdId, "Name"); actionPointCost = csv.GetValueInt((int)cmdId, "ActionPointCost"); if (actionPointCost > 0) { cmdName += $"({actionPointCost})"; } order = csv.GetValueInt((int)cmdId, "Order"); ci = new CommandInfo() { CmdId = cmdId, Name = cmdName, Order = order, ActionPointCost = actionPointCost, Func = obj.AddComponent <CmdHalt>(), }; Commands.Add(cmdId, ci); }