diff --git a/Desktop/FunGame.Testing.Desktop.csproj b/Desktop/FunGame.Testing.Desktop.csproj index 10a0230..c224fef 100644 --- a/Desktop/FunGame.Testing.Desktop.csproj +++ b/Desktop/FunGame.Testing.Desktop.csproj @@ -7,6 +7,7 @@ true enable ..\bin\ + Milimoe.$(MSBuildProjectName.Replace(" ", "_")) diff --git a/Desktop/Program.cs b/Desktop/Program.cs index 6105b88..c6fa213 100644 --- a/Desktop/Program.cs +++ b/Desktop/Program.cs @@ -1,3 +1,5 @@ +using Milimoe.FunGame.Testing.Desktop.Solutions; + namespace Desktop { internal static class Program @@ -11,7 +13,8 @@ namespace Desktop // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new ChessBoardExample.ChessBoardExample()); + //Application.Run(new ChessBoardExample.ChessBoardExample()); + Application.Run(new EntityCreator()); } } } \ No newline at end of file diff --git a/Desktop/Solutions/CharacterCreator.cs b/Desktop/Solutions/CharacterCreator.cs new file mode 100644 index 0000000..651607f --- /dev/null +++ b/Desktop/Solutions/CharacterCreator.cs @@ -0,0 +1,37 @@ +using Milimoe.FunGame.Core.Api.Utility; +using Milimoe.FunGame.Core.Entity; + +namespace Milimoe.FunGame.Testing.Desktop.Solutions +{ + public class CharacterCreator + { + public Dictionary LoadedCharacters { get; set; } = []; + + public void Load() + { + EntityModuleConfig config = new("redbud.fun.entitycreator", "charactercreator"); + config.LoadConfig(); + LoadedCharacters = new(config); + } + + public bool Add(string name, Character character) + { + return LoadedCharacters.TryAdd(name, character); + } + + public bool Remove(string name) + { + return LoadedCharacters.Remove(name); + } + + public void Save() + { + EntityModuleConfig config = new("redbud.fun.entitycreator", "charactercreator"); + foreach (string key in LoadedCharacters.Keys) + { + config.Add(key, LoadedCharacters[key]); + } + config.SaveConfig(); + } + } +} diff --git a/Desktop/Solutions/EntityCreator.Designer.cs b/Desktop/Solutions/EntityCreator.Designer.cs new file mode 100644 index 0000000..494e187 --- /dev/null +++ b/Desktop/Solutions/EntityCreator.Designer.cs @@ -0,0 +1,301 @@ +namespace Milimoe.FunGame.Testing.Desktop.Solutions +{ + partial class EntityCreator + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 查看现有角色 = new Button(); + 查看现有技能 = new Button(); + 查看现有物品 = new Button(); + 创建角色 = new Button(); + 创建技能 = new Button(); + 创建物品 = new Button(); + 删除物品 = new Button(); + 删除技能 = new Button(); + 删除角色 = new Button(); + 列表 = new GroupBox(); + 实际列表 = new ListBox(); + 全部保存 = new Button(); + 保存角色 = new Button(); + 保存技能 = new Button(); + 保存物品 = new Button(); + 为角色添加技能 = new Button(); + 为角色添加物品 = new Button(); + 重新读取全部 = new Button(); + 列表.SuspendLayout(); + SuspendLayout(); + // + // 查看现有角色 + // + 查看现有角色.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 查看现有角色.Location = new Point(460, 103); + 查看现有角色.Name = "查看现有角色"; + 查看现有角色.Size = new Size(98, 35); + 查看现有角色.TabIndex = 0; + 查看现有角色.Text = "查看现有角色"; + 查看现有角色.UseVisualStyleBackColor = true; + 查看现有角色.Click += 查看现有角色_Click; + // + // 查看现有技能 + // + 查看现有技能.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 查看现有技能.Location = new Point(460, 144); + 查看现有技能.Name = "查看现有技能"; + 查看现有技能.Size = new Size(98, 35); + 查看现有技能.TabIndex = 1; + 查看现有技能.Text = "查看现有技能"; + 查看现有技能.UseVisualStyleBackColor = true; + 查看现有技能.Click += 查看现有技能_Click; + // + // 查看现有物品 + // + 查看现有物品.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 查看现有物品.Location = new Point(460, 185); + 查看现有物品.Name = "查看现有物品"; + 查看现有物品.Size = new Size(98, 35); + 查看现有物品.TabIndex = 2; + 查看现有物品.Text = "查看现有物品"; + 查看现有物品.UseVisualStyleBackColor = true; + 查看现有物品.Click += 查看现有物品_Click; + // + // 创建角色 + // + 创建角色.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 创建角色.Location = new Point(564, 226); + 创建角色.Name = "创建角色"; + 创建角色.Size = new Size(98, 35); + 创建角色.TabIndex = 3; + 创建角色.Text = "创建角色"; + 创建角色.UseVisualStyleBackColor = true; + 创建角色.Click += 创建角色_Click; + // + // 创建技能 + // + 创建技能.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 创建技能.Location = new Point(564, 267); + 创建技能.Name = "创建技能"; + 创建技能.Size = new Size(98, 35); + 创建技能.TabIndex = 4; + 创建技能.Text = "创建技能"; + 创建技能.UseVisualStyleBackColor = true; + 创建技能.Click += 创建技能_Click; + // + // 创建物品 + // + 创建物品.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 创建物品.Location = new Point(564, 308); + 创建物品.Name = "创建物品"; + 创建物品.Size = new Size(98, 35); + 创建物品.TabIndex = 5; + 创建物品.Text = "创建物品"; + 创建物品.UseVisualStyleBackColor = true; + 创建物品.Click += 创建物品_Click; + // + // 删除物品 + // + 删除物品.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 删除物品.Location = new Point(460, 308); + 删除物品.Name = "删除物品"; + 删除物品.Size = new Size(98, 35); + 删除物品.TabIndex = 8; + 删除物品.Text = "删除物品"; + 删除物品.UseVisualStyleBackColor = true; + 删除物品.Click += 删除物品_Click; + // + // 删除技能 + // + 删除技能.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 删除技能.Location = new Point(460, 267); + 删除技能.Name = "删除技能"; + 删除技能.Size = new Size(98, 35); + 删除技能.TabIndex = 7; + 删除技能.Text = "删除技能"; + 删除技能.UseVisualStyleBackColor = true; + 删除技能.Click += 删除技能_Click; + // + // 删除角色 + // + 删除角色.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 删除角色.Location = new Point(460, 226); + 删除角色.Name = "删除角色"; + 删除角色.Size = new Size(98, 35); + 删除角色.TabIndex = 6; + 删除角色.Text = "删除角色"; + 删除角色.UseVisualStyleBackColor = true; + 删除角色.Click += 删除角色_Click; + // + // 列表 + // + 列表.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + 列表.Controls.Add(实际列表); + 列表.Location = new Point(16, 12); + 列表.Name = "列表"; + 列表.Size = new Size(431, 413); + 列表.TabIndex = 9; + 列表.TabStop = false; + 列表.Text = "列表"; + // + // 实际列表 + // + 实际列表.FormattingEnabled = true; + 实际列表.ItemHeight = 17; + 实际列表.Location = new Point(6, 24); + 实际列表.Name = "实际列表"; + 实际列表.Size = new Size(419, 378); + 实际列表.TabIndex = 0; + 实际列表.MouseDoubleClick += 实际列表_MouseDoubleClick; + // + // 全部保存 + // + 全部保存.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 全部保存.Location = new Point(460, 349); + 全部保存.Name = "全部保存"; + 全部保存.Size = new Size(98, 35); + 全部保存.TabIndex = 12; + 全部保存.Text = "全部保存"; + 全部保存.UseVisualStyleBackColor = true; + 全部保存.Click += 全部保存_Click; + // + // 保存角色 + // + 保存角色.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 保存角色.Location = new Point(564, 349); + 保存角色.Name = "保存角色"; + 保存角色.Size = new Size(98, 35); + 保存角色.TabIndex = 11; + 保存角色.Text = "保存角色"; + 保存角色.UseVisualStyleBackColor = true; + 保存角色.Click += 保存角色_Click; + // + // 保存技能 + // + 保存技能.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 保存技能.Location = new Point(460, 390); + 保存技能.Name = "保存技能"; + 保存技能.Size = new Size(98, 35); + 保存技能.TabIndex = 10; + 保存技能.Text = "保存技能"; + 保存技能.UseVisualStyleBackColor = true; + 保存技能.Click += 保存技能_Click; + // + // 保存物品 + // + 保存物品.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 保存物品.Location = new Point(564, 390); + 保存物品.Name = "保存物品"; + 保存物品.Size = new Size(98, 35); + 保存物品.TabIndex = 13; + 保存物品.Text = "保存物品"; + 保存物品.UseVisualStyleBackColor = true; + 保存物品.Click += 保存物品_Click; + // + // 为角色添加技能 + // + 为角色添加技能.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 为角色添加技能.Font = new Font("Microsoft YaHei UI", 8F); + 为角色添加技能.Location = new Point(564, 103); + 为角色添加技能.Name = "为角色添加技能"; + 为角色添加技能.Size = new Size(98, 35); + 为角色添加技能.TabIndex = 14; + 为角色添加技能.Text = "为角色添加技能"; + 为角色添加技能.UseVisualStyleBackColor = true; + 为角色添加技能.Click += 为角色添加技能_Click; + // + // 为角色添加物品 + // + 为角色添加物品.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 为角色添加物品.Font = new Font("Microsoft YaHei UI", 8F); + 为角色添加物品.Location = new Point(564, 144); + 为角色添加物品.Name = "为角色添加物品"; + 为角色添加物品.Size = new Size(98, 35); + 为角色添加物品.TabIndex = 15; + 为角色添加物品.Text = "为角色添加物品"; + 为角色添加物品.UseVisualStyleBackColor = true; + 为角色添加物品.Click += 为角色添加物品_Click; + // + // 重新读取全部 + // + 重新读取全部.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + 重新读取全部.Font = new Font("Microsoft YaHei UI", 8F); + 重新读取全部.Location = new Point(564, 185); + 重新读取全部.Name = "重新读取全部"; + 重新读取全部.Size = new Size(98, 35); + 重新读取全部.TabIndex = 16; + 重新读取全部.Text = "重新读取全部"; + 重新读取全部.UseVisualStyleBackColor = true; + 重新读取全部.Click += 重新读取全部_Click; + // + // EntityCreator + // + AutoScaleDimensions = new SizeF(7F, 17F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(674, 437); + Controls.Add(重新读取全部); + Controls.Add(为角色添加物品); + Controls.Add(为角色添加技能); + Controls.Add(保存物品); + Controls.Add(全部保存); + Controls.Add(保存角色); + Controls.Add(保存技能); + Controls.Add(列表); + Controls.Add(删除物品); + Controls.Add(删除技能); + Controls.Add(删除角色); + Controls.Add(创建物品); + Controls.Add(创建技能); + Controls.Add(创建角色); + Controls.Add(查看现有物品); + Controls.Add(查看现有技能); + Controls.Add(查看现有角色); + Name = "EntityCreator"; + Text = "实体创建器"; + 列表.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private Button 查看现有角色; + private Button 查看现有技能; + private Button 查看现有物品; + private Button 创建角色; + private Button 创建技能; + private Button 创建物品; + private Button 删除物品; + private Button 删除技能; + private Button 删除角色; + private GroupBox 列表; + private Button 全部保存; + private Button 保存角色; + private Button 保存技能; + private Button 保存物品; + private ListBox 实际列表; + private Button 为角色添加技能; + private Button 为角色添加物品; + private Button 重新读取全部; + } +} \ No newline at end of file diff --git a/Desktop/Solutions/EntityCreator.cs b/Desktop/Solutions/EntityCreator.cs new file mode 100644 index 0000000..883ddd3 --- /dev/null +++ b/Desktop/Solutions/EntityCreator.cs @@ -0,0 +1,388 @@ +using Microsoft.VisualBasic; +using Milimoe.FunGame.Core.Api.Utility; +using Milimoe.FunGame.Core.Entity; +using Milimoe.FunGame.Core.Interface.Entity; +using Milimoe.FunGame.Core.Library.Common.Addon; +using Milimoe.FunGame.Core.Library.Constant; + +namespace Milimoe.FunGame.Testing.Desktop.Solutions +{ + public partial class EntityCreator : Form + { + private CharacterCreator CharacterCreator { get; } = new(); + private SkillCreator SkillCreator { get; } = new(); + private ItemCreator ItemCreator { get; } = new(); + private GameModuleLoader GameModuleLoader { get; } + private bool CheckSelectedIndex => 实际列表.SelectedIndex != -1 && 实际列表.SelectedIndex < 实际列表.Items.Count; + private int nowClick = 0; + + public EntityCreator() + { + InitializeComponent(); + GameModuleLoader = LoadModules(); + CharacterCreator.Load(); + SkillCreator.Load(); + ItemCreator.Load(); + 查看现有技能方法(); + 查看现有物品方法(); + 查看现有角色方法(); + } + + private void 查看现有角色方法() + { + 实际列表.Items.Clear(); + foreach (string name in CharacterCreator.LoadedCharacters.Keys) + { + 实际列表.Items.Add(CharacterCreator.LoadedCharacters[name]); + } + nowClick = 0; + } + + private void 查看现有技能方法() + { + 实际列表.Items.Clear(); + foreach (string name in SkillCreator.LoadedSkills.Keys) + { + 实际列表.Items.Add(SkillCreator.LoadedSkills[name].GetIdName()); + } + nowClick = 1; + } + + private void 查看现有物品方法() + { + 实际列表.Items.Clear(); + foreach (string name in ItemCreator.LoadedItems.Keys) + { + 实际列表.Items.Add(ItemCreator.LoadedItems[name].GetIdName()); + } + nowClick = 2; + } + + private void 查看现有角色_Click(object sender, EventArgs e) + { + if (nowClick != 0) + { + 查看现有角色方法(); + } + } + + private void 查看现有技能_Click(object sender, EventArgs e) + { + if (nowClick != 1) + { + 查看现有技能方法(); + } + } + + private void 查看现有物品_Click(object sender, EventArgs e) + { + if (nowClick != 2) + { + 查看现有物品方法(); + } + } + + private void 全部保存_Click(object sender, EventArgs e) + { + CharacterCreator.Save(); + SkillCreator.Save(); + ItemCreator.Save(); + MessageBox.Show("保存成功!"); + } + + private void 保存角色_Click(object sender, EventArgs e) + { + CharacterCreator.Save(); + MessageBox.Show("保存成功!"); + } + + private void 保存技能_Click(object sender, EventArgs e) + { + SkillCreator.Save(); + MessageBox.Show("保存成功!"); + } + + private void 保存物品_Click(object sender, EventArgs e) + { + ItemCreator.Save(); + MessageBox.Show("保存成功!"); + } + + private Skill? 从模组加载器中获取技能(long id, string name) + { + foreach (SkillModule module in GameModuleLoader.Skills.Values) + { + Skill? s = module.GetSkill(id, name); + if (s != null) + { + return s; + } + } + return null; + } + + private Item? 从模组加载器中获取物品(long id, string name) + { + foreach (ItemModule module in GameModuleLoader.Items.Values) + { + Item? i = module.GetItem(id, name); + if (i != null) + { + return i; + } + } + return null; + } + + private void 实际列表_MouseDoubleClick(object sender, EventArgs e) + { + if (CheckSelectedIndex) + { + ShowDetail d = new(); + switch (nowClick) + { + case 0: + d.SetText(CharacterCreator.LoadedCharacters.Values.Where(c => c.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault()?.GetInfo() ?? ""); + d.ShowDialog(); + break; + case 1: + Skill? s = SkillCreator.LoadedSkills.Values.Where(c => c.GetIdName() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault(); + if (s != null) + { + s = 从模组加载器中获取技能(s.Id, s.Name); + if (s != null) + { + d.SetText(s.ToString() ?? ""); + d.ShowDialog(); + } + } + break; + case 2: + Item? i = ItemCreator.LoadedItems.Values.Where(c => c.GetIdName() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault(); + if (i != null) + { + i = 从模组加载器中获取物品(i.Id, i.Name); + if (i != null) + { + d.SetText(i.ToString() ?? ""); + d.ShowDialog(); + } + } + break; + default: + break; + } + d.Dispose(); + } + } + + private void 为角色添加技能_Click(object sender, EventArgs e) + { + if (CheckSelectedIndex && nowClick == 0) + { + if (SkillCreator.LoadedSkills.Count != 0) + { + Showlist l = new(); + l.AddListItem(SkillCreator.LoadedSkills.Values.Select(s => s.GetIdName()).ToArray()); + l.ShowDialog(); + string selected = l.SelectItem; + Character? c = CharacterCreator.LoadedCharacters.Values.Where(c => c.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault(); + Skill? s = SkillCreator.LoadedSkills.Values.Where(s => s.GetIdName() == selected).FirstOrDefault(); + if (c != null && s != null) + { + s = 从模组加载器中获取技能(s.Id, s.Name); + if (s != null) c.Skills.Add(s); + } + } + else + { + MessageBox.Show("技能列表为空!"); + } + } + } + + private void 为角色添加物品_Click(object sender, EventArgs e) + { + if (CheckSelectedIndex && nowClick == 0) + { + if (ItemCreator.LoadedItems.Count != 0) + { + Showlist l = new(); + l.AddListItem(ItemCreator.LoadedItems.Values.Select(i => i.GetIdName()).ToArray()); + l.ShowDialog(); + string selected = l.SelectItem; + Character? c = CharacterCreator.LoadedCharacters.Values.Where(c => c.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault(); + Item? i = ItemCreator.LoadedItems.Values.Where(i => i.GetIdName() == selected).FirstOrDefault(); + if (c != null && i != null) + { + i = 从模组加载器中获取物品(i.Id, i.Name); + if (i != null) c.Items.Add(i); + } + } + else + { + MessageBox.Show("物品列表为空!"); + } + } + } + + private void 创建角色_Click(object sender, EventArgs e) + { + Character c = Factory.GetCharacter(); + c.Name = Interaction.InputBox("输入姓", "姓", ""); + c.FirstName = Interaction.InputBox("输入名", "名", ""); + c.NickName = Interaction.InputBox("输入昵称", "昵称", ""); + + string primaryAttributeInput = Interaction.InputBox("输入核心属性 (STR, AGI, INT)", "核心属性", "None"); + c.PrimaryAttribute = Enum.TryParse(primaryAttributeInput, out PrimaryAttribute primaryAttribute) ? primaryAttribute : PrimaryAttribute.None; + + // 解析 double 类型的输入 + c.InitialATK = double.Parse(Interaction.InputBox("输入初始攻击力", "初始攻击力", "0.0")); + c.InitialHP = double.Parse(Interaction.InputBox("输入初始生命值", "初始生命值", "1.0")); + c.InitialMP = double.Parse(Interaction.InputBox("输入初始魔法值", "初始魔法值", "0.0")); + c.InitialSTR = double.Parse(Interaction.InputBox("输入初始力量", "初始力量", "0.0")); + c.STRGrowth = double.Parse(Interaction.InputBox("输入力量成长", "力量成长", "0.0")); + c.InitialAGI = double.Parse(Interaction.InputBox("输入初始敏捷", "初始敏捷", "0.0")); + c.AGIGrowth = double.Parse(Interaction.InputBox("输入敏捷成长", "敏捷成长", "0.0")); + c.InitialINT = double.Parse(Interaction.InputBox("输入初始智力", "初始智力", "0.0")); + c.INTGrowth = double.Parse(Interaction.InputBox("输入智力成长", "智力成长", "0.0")); + c.InitialSPD = double.Parse(Interaction.InputBox("输入初始行动速度", "初始行动速度", "0.0")); + c.InitialHR = double.Parse(Interaction.InputBox("输入初始生命回复", "初始生命回复", "0.0")); + c.InitialMR = double.Parse(Interaction.InputBox("输入初始魔法回复", "初始魔法回复", "0.0")); + + string name = Interaction.InputBox("输入角色代号以确认创建", "角色代号", ""); + if (name != "" && c.Name != "" && CharacterCreator.Add(name, c)) + { + MessageBox.Show("创建成功!"); + 查看现有角色方法(); + ShowDetail d = new(); + d.SetText(c.GetInfo()); + d.ShowDialog(); + d.Dispose(); + } + else + { + MessageBox.Show("创建已取消。"); + } + } + + private void 创建技能_Click(object sender, EventArgs e) + { + Skill s = Factory.GetSkill(); + s.Id = long.Parse(Interaction.InputBox("输入技能编号", "技能编号", "0")); + s.Name = Interaction.InputBox("输入技能名称", "技能名称", ""); + + string name = Interaction.InputBox("输入技能代号以确认创建", "技能代号", ""); + if (name != "" && s.Id != 0 && s.Name != "" && SkillCreator.Add(name, s)) + { + MessageBox.Show("创建成功!"); + 查看现有技能方法(); + ShowDetail d = new(); + d.SetText(s.ToString()); + d.ShowDialog(); + d.Dispose(); + } + else + { + MessageBox.Show("创建已取消。"); + } + } + + private void 创建物品_Click(object sender, EventArgs e) + { + Item i = Factory.GetItem(); + i.Id = long.Parse(Interaction.InputBox("输入物品编号", "物品编号", "0")); + i.Name = Interaction.InputBox("输入物品名称", "物品名称", ""); + + string name = Interaction.InputBox("输入物品代号以确认创建", "物品代号", ""); + if (name != "" && i.Id != 0 && i.Name != "" && ItemCreator.Add(name, i)) + { + MessageBox.Show("创建成功!"); + 查看现有物品方法(); + ShowDetail d = new(); + d.SetText(i.ToString()); + d.ShowDialog(); + d.Dispose(); + } + else + { + MessageBox.Show("创建已取消。"); + } + } + + private void 删除角色_Click(object sender, EventArgs e) + { + if (CheckSelectedIndex && MessageBox.Show("是否删除", "删除", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + string name = CharacterCreator.LoadedCharacters.Where(ky => ky.Value.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault().Key ?? ""; + if (CharacterCreator.Remove(name)) + { + MessageBox.Show("删除成功!"); + 查看现有角色方法(); + } + else + { + MessageBox.Show("删除失败!"); + } + } + } + + private void 删除技能_Click(object sender, EventArgs e) + { + if (CheckSelectedIndex && MessageBox.Show("是否删除", "删除", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + string name = SkillCreator.LoadedSkills.Where(ky => ky.Value.GetIdName() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault().Key ?? ""; + if (SkillCreator.Remove(name)) + { + MessageBox.Show("删除成功!"); + 查看现有技能方法(); + } + else + { + MessageBox.Show("删除失败!"); + } + } + } + + private void 删除物品_Click(object sender, EventArgs e) + { + if (CheckSelectedIndex && MessageBox.Show("是否删除", "删除", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + string name = ItemCreator.LoadedItems.Where(ky => ky.Value.GetIdName() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault().Key ?? ""; + if (ItemCreator.Remove(name)) + { + MessageBox.Show("删除成功!"); + 查看现有物品方法(); + } + else + { + MessageBox.Show("删除失败!"); + } + } + } + + private void 重新读取全部_Click(object sender, EventArgs e) + { + if (MessageBox.Show("重新读取会丢失未保存的数据,是否确认重新读取全部?", "重新读取全部", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + CharacterCreator.Load(); + SkillCreator.Load(); + ItemCreator.Load(); + 查看现有技能方法(); + 查看现有物品方法(); + 查看现有角色方法(); + } + } + + private static GameModuleLoader LoadModules() + { + PluginLoader plugins = PluginLoader.LoadPlugins([]); + foreach (string plugin in plugins.Plugins.Keys) + { + Console.WriteLine(plugin + " is loaded."); + } + + return GameModuleLoader.LoadGameModules(FunGameInfo.FunGame.FunGame_Desktop, []); + } + } +} diff --git a/Desktop/Solutions/EntityCreator.resx b/Desktop/Solutions/EntityCreator.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/Desktop/Solutions/EntityCreator.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Desktop/Solutions/ItemCreator.cs b/Desktop/Solutions/ItemCreator.cs new file mode 100644 index 0000000..376de6e --- /dev/null +++ b/Desktop/Solutions/ItemCreator.cs @@ -0,0 +1,37 @@ +using Milimoe.FunGame.Core.Api.Utility; +using Milimoe.FunGame.Core.Entity; + +namespace Milimoe.FunGame.Testing.Desktop.Solutions +{ + public class ItemCreator + { + public Dictionary LoadedItems { get; set; } = []; + + public void Load() + { + EntityModuleConfig config = new("redbud.fun.entitycreator", "itemcreator"); + config.LoadConfig(); + LoadedItems = new(config); + } + + public bool Add(string name, Item item) + { + return LoadedItems.TryAdd(name, item); + } + + public bool Remove(string name) + { + return LoadedItems.Remove(name); + } + + public void Save() + { + EntityModuleConfig config = new("redbud.fun.entitycreator", "itemcreator"); + foreach (string key in LoadedItems.Keys) + { + config.Add(key, LoadedItems[key]); + } + config.SaveConfig(); + } + } +} diff --git a/Desktop/Solutions/ShowDetail.Designer.cs b/Desktop/Solutions/ShowDetail.Designer.cs new file mode 100644 index 0000000..34dd5b8 --- /dev/null +++ b/Desktop/Solutions/ShowDetail.Designer.cs @@ -0,0 +1,59 @@ +namespace Milimoe.FunGame.Testing.Desktop.Solutions +{ + partial class ShowDetail + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + richTextBox1 = new RichTextBox(); + SuspendLayout(); + // + // richTextBox1 + // + richTextBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + richTextBox1.Location = new Point(12, 12); + richTextBox1.Name = "richTextBox1"; + richTextBox1.ReadOnly = true; + richTextBox1.Size = new Size(622, 453); + richTextBox1.TabIndex = 0; + richTextBox1.Text = ""; + // + // ShowDetail + // + AutoScaleDimensions = new SizeF(7F, 17F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(646, 477); + Controls.Add(richTextBox1); + Name = "ShowDetail"; + Text = "ShowDetail"; + ResumeLayout(false); + } + + #endregion + + private RichTextBox richTextBox1; + } +} \ No newline at end of file diff --git a/Desktop/Solutions/ShowDetail.cs b/Desktop/Solutions/ShowDetail.cs new file mode 100644 index 0000000..07187fd --- /dev/null +++ b/Desktop/Solutions/ShowDetail.cs @@ -0,0 +1,15 @@ +namespace Milimoe.FunGame.Testing.Desktop.Solutions +{ + public partial class ShowDetail : Form + { + public ShowDetail() + { + InitializeComponent(); + } + + public void SetText(string text) + { + richTextBox1.Text = text; + } + } +} diff --git a/Desktop/Solutions/ShowDetail.resx b/Desktop/Solutions/ShowDetail.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/Desktop/Solutions/ShowDetail.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Desktop/Solutions/Showlist.Designer.cs b/Desktop/Solutions/Showlist.Designer.cs new file mode 100644 index 0000000..4d60293 --- /dev/null +++ b/Desktop/Solutions/Showlist.Designer.cs @@ -0,0 +1,60 @@ +namespace Milimoe.FunGame.Testing.Desktop.Solutions +{ + partial class Showlist + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 选择表 = new ListBox(); + SuspendLayout(); + // + // 选择表 + // + 选择表.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + 选择表.FormattingEnabled = true; + 选择表.ItemHeight = 17; + 选择表.Location = new Point(12, 12); + 选择表.Name = "选择表"; + 选择表.Size = new Size(484, 429); + 选择表.TabIndex = 0; + 选择表.MouseDoubleClick += 选择表_MouseDoubleClick; + // + // Showlist + // + AutoScaleDimensions = new SizeF(7F, 17F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(508, 450); + Controls.Add(选择表); + Name = "Showlist"; + Text = "Showlist"; + ResumeLayout(false); + } + + #endregion + + private ListBox 选择表; + } +} \ No newline at end of file diff --git a/Desktop/Solutions/Showlist.cs b/Desktop/Solutions/Showlist.cs new file mode 100644 index 0000000..ac10e31 --- /dev/null +++ b/Desktop/Solutions/Showlist.cs @@ -0,0 +1,24 @@ +namespace Milimoe.FunGame.Testing.Desktop.Solutions +{ + public partial class Showlist : Form + { + public string SelectItem { get; set; } = ""; + + public Showlist() + { + InitializeComponent(); + } + + public void AddListItem(object[] items) + { + 选择表.Items.Clear(); + 选择表.Items.AddRange(items); + } + + private void 选择表_MouseDoubleClick(object sender, EventArgs e) + { + SelectItem = 选择表.SelectedItem?.ToString() ?? ""; + Dispose(); + } + } +} diff --git a/Desktop/Solutions/Showlist.resx b/Desktop/Solutions/Showlist.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/Desktop/Solutions/Showlist.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Desktop/Solutions/SkillCreator.cs b/Desktop/Solutions/SkillCreator.cs new file mode 100644 index 0000000..b31e6c7 --- /dev/null +++ b/Desktop/Solutions/SkillCreator.cs @@ -0,0 +1,37 @@ +using Milimoe.FunGame.Core.Api.Utility; +using Milimoe.FunGame.Core.Entity; + +namespace Milimoe.FunGame.Testing.Desktop.Solutions +{ + public class SkillCreator + { + public Dictionary LoadedSkills { get; set; } = []; + + public void Load() + { + EntityModuleConfig config = new("redbud.fun.entitycreator", "skillcreator"); + config.LoadConfig(); + LoadedSkills = new(config); + } + + public bool Add(string name, Skill skill) + { + return LoadedSkills.TryAdd(name, skill); + } + + public bool Remove(string name) + { + return LoadedSkills.Remove(name); + } + + public void Save() + { + EntityModuleConfig config = new("redbud.fun.entitycreator", "skillcreator"); + foreach (string key in LoadedSkills.Keys) + { + config.Add(key, LoadedSkills[key]); + } + config.SaveConfig(); + } + } +} diff --git a/Library/Characters/Characters.cs b/Library/Characters/Characters.cs index 0e62c74..b8ab791 100644 --- a/Library/Characters/Characters.cs +++ b/Library/Characters/Characters.cs @@ -2,9 +2,9 @@ using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Constant; -namespace FunGame.Testing.Characters +namespace MilimoeFunGame.Testing.Characters { - public class Characters + public class OshimaCharacters { public static Character Oshima { diff --git a/Library/Effects/ItemEffects/冷却缩减加成.cs b/Library/Effects/ItemEffects/冷却缩减加成.cs index 45fce40..ce8155b 100644 --- a/Library/Effects/ItemEffects/冷却缩减加成.cs +++ b/Library/Effects/ItemEffects/冷却缩减加成.cs @@ -1,7 +1,7 @@ using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Constant; -namespace FunGame.Testing.Effects +namespace Milimoe.FunGame.Testing.Effects { public class 冷却缩减加成 : Effect { diff --git a/Library/Effects/ItemEffects/技能硬直时间减少.cs b/Library/Effects/ItemEffects/技能硬直时间减少.cs index 9956578..1a33ed3 100644 --- a/Library/Effects/ItemEffects/技能硬直时间减少.cs +++ b/Library/Effects/ItemEffects/技能硬直时间减少.cs @@ -2,7 +2,7 @@ using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Constant; -namespace FunGame.Testing.Effects +namespace Milimoe.FunGame.Testing.Effects { public class 技能硬直时间减少 : Effect { diff --git a/Library/Effects/ItemEffects/攻击力加成.cs b/Library/Effects/ItemEffects/攻击力加成.cs index 8ecc721..d625d0e 100644 --- a/Library/Effects/ItemEffects/攻击力加成.cs +++ b/Library/Effects/ItemEffects/攻击力加成.cs @@ -1,7 +1,7 @@ using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Constant; -namespace FunGame.Testing.Effects +namespace Milimoe.FunGame.Testing.Effects { public class 攻击力加成 : Effect { diff --git a/Library/Effects/ItemEffects/普攻硬直时间减少.cs b/Library/Effects/ItemEffects/普攻硬直时间减少.cs index 71ef664..fe5f96a 100644 --- a/Library/Effects/ItemEffects/普攻硬直时间减少.cs +++ b/Library/Effects/ItemEffects/普攻硬直时间减少.cs @@ -2,7 +2,7 @@ using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Constant; -namespace FunGame.Testing.Effects +namespace Milimoe.FunGame.Testing.Effects { public class 普攻硬直时间减少 : Effect { diff --git a/Library/Effects/ItemEffects/物理护甲加成.cs b/Library/Effects/ItemEffects/物理护甲加成.cs index 0842168..e6e4947 100644 --- a/Library/Effects/ItemEffects/物理护甲加成.cs +++ b/Library/Effects/ItemEffects/物理护甲加成.cs @@ -1,7 +1,7 @@ using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Constant; -namespace FunGame.Testing.Effects +namespace Milimoe.FunGame.Testing.Effects { public class 物理护甲加成 : Effect { diff --git a/Library/FunGame.Testing.csproj b/Library/FunGame.Testing.csproj index 3b33b84..dd695a6 100644 --- a/Library/FunGame.Testing.csproj +++ b/Library/FunGame.Testing.csproj @@ -6,6 +6,7 @@ enable enable ..\bin\ + Milimoe.$(MSBuildProjectName.Replace(" ", "_")) diff --git a/Library/Items/Accessory/攻击之爪.cs b/Library/Items/Accessory/攻击之爪.cs index 80c42db..da4ec1e 100644 --- a/Library/Items/Accessory/攻击之爪.cs +++ b/Library/Items/Accessory/攻击之爪.cs @@ -1,8 +1,8 @@ -using FunGame.Testing.Effects; +using Milimoe.FunGame.Testing.Effects; using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Constant; -namespace FunGame.Testing.Items +namespace Milimoe.FunGame.Testing.Items { public class 攻击之爪10 : Item { diff --git a/Library/Items/Weapon/独奏弓.cs b/Library/Items/Weapon/独奏弓.cs index b57dfb6..970ce72 100644 --- a/Library/Items/Weapon/独奏弓.cs +++ b/Library/Items/Weapon/独奏弓.cs @@ -1,4 +1,4 @@ -using FunGame.Testing.Effects; +using Milimoe.FunGame.Testing.Effects; using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Constant; diff --git a/Library/Solutions/TestModule.cs b/Library/Solutions/TestModule.cs index a03a53b..03fc18a 100644 --- a/Library/Solutions/TestModule.cs +++ b/Library/Solutions/TestModule.cs @@ -1,6 +1,8 @@ using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Common.Addon; +using Milimoe.FunGame.Testing.Items; +using Milimoe.FunGame.Testing.Skills; namespace Addons { @@ -47,10 +49,49 @@ namespace Addons { get { + Character c = Factory.GetCharacter(); List list = []; + list.Add(new 冰霜攻击(c)); + list.Add(new 疾风步(c)); + list.Add(new META马(c)); + list.Add(new 力量爆发(c)); + list.Add(new 心灵之火(c)); + list.Add(new 天赐之力(c)); + list.Add(new 魔法震荡(c)); + list.Add(new 魔法涌流(c)); + list.Add(new 灵能反射(c)); + list.Add(new 三重叠加(c)); + list.Add(new 智慧与力量(c)); + list.Add(new 变幻之心(c)); + list.Add(new 致命打击(c)); + list.Add(new 精准打击(c)); + list.Add(new 毁灭之势(c)); + list.Add(new 绝对领域(c)); + list.Add(new 枯竭打击(c)); + list.Add(new 能量毁灭(c)); + list.Add(new 玻璃大炮(c)); + list.Add(new 迅捷之势(c)); + list.Add(new 累积之压(c)); + list.Add(new 嗜血本能(c)); + list.Add(new 敏捷之刃(c)); + list.Add(new 平衡强化(c)); + list.Add(new 弱者猎手(c)); + list.Add(new 血之狂欢(c)); + list.Add(new 冰霜攻击(c)); + list.Add(new 疾风步(c)); return list; } } + + public override Skill? GetSkill(long id, string name) + { + string str = id + "." + name; + if (Skills.Where(s => s.GetIdName() == str).FirstOrDefault() is Skill s) + { + return s; + } + return null; + } } public class ExampleItemModule : ItemModule @@ -68,12 +109,19 @@ namespace Addons get { List list = []; - Item i = Factory.GetItem(); - i.Name = "Example Item"; - i.Price = 20; - list.Add(i); + list.Add(new 攻击之爪50()); return list; } } + + public override Item? GetItem(long id, string name) + { + string str = id + "." + name; + if (Items.Where(s => s.GetIdName() == str).FirstOrDefault() is Item i) + { + return i; + } + return null; + } } } diff --git a/Library/Solutions/TestPlugin.cs b/Library/Solutions/TestPlugin.cs index 7873b42..e1909ef 100644 --- a/Library/Solutions/TestPlugin.cs +++ b/Library/Solutions/TestPlugin.cs @@ -1,9 +1,12 @@ -using FunGame.Testing.Characters; +using System.Collections.Generic; using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Interface; using Milimoe.FunGame.Core.Library.Common.Addon; using Milimoe.FunGame.Core.Library.Common.Event; +using Milimoe.FunGame.Testing.Items; +using Milimoe.FunGame.Testing.Skills; +using MilimoeFunGame.Testing.Characters; namespace Addons { @@ -21,27 +24,70 @@ namespace Addons { EntityModuleConfig config = new(ExampleGameModuleConstant.Example, ExampleGameModuleConstant.ExampleCharacter) { - { "Oshima", Characters.Oshima }, - { "Xinyin", Characters.Xinyin }, - { "Yang", Characters.Yang }, - { "NanGanyu", Characters.NanGanyu }, - { "NiuNan", Characters.NiuNan }, - { "Mayor", Characters.Mayor }, - { "马猴烧酒", Characters.马猴烧酒 }, - { "QingXiang", Characters.QingXiang }, - { "QWQAQW", Characters.QWQAQW }, - { "ColdBlue", Characters.ColdBlue }, - { "绿拱门", Characters.绿拱门 }, - { "QuDuoduo", Characters.QuDuoduo } + { "Oshima", OshimaCharacters.Oshima }, + { "Xinyin", OshimaCharacters.Xinyin }, + { "Yang", OshimaCharacters.Yang }, + { "NanGanyu", OshimaCharacters.NanGanyu }, + { "NiuNan", OshimaCharacters.NiuNan }, + { "Mayor", OshimaCharacters.Mayor }, + { "马猴烧酒", OshimaCharacters.马猴烧酒 }, + { "QingXiang", OshimaCharacters.QingXiang }, + { "QWQAQW", OshimaCharacters.QWQAQW }, + { "ColdBlue", OshimaCharacters.ColdBlue }, + { "绿拱门", OshimaCharacters.绿拱门 }, + { "QuDuoduo", OshimaCharacters.QuDuoduo } }; - config.SaveConfig(); - PluginConfig config2 = new(Name, "config") + + EntityModuleConfig config2 = new(ExampleGameModuleConstant.Example, ExampleGameModuleConstant.ExampleSkill); + Character c = Factory.GetCharacter(); + List listSkill = []; + listSkill.Add(new 冰霜攻击(c)); + listSkill.Add(new 疾风步(c)); + listSkill.Add(new META马(c)); + listSkill.Add(new 力量爆发(c)); + listSkill.Add(new 心灵之火(c)); + listSkill.Add(new 天赐之力(c)); + listSkill.Add(new 魔法震荡(c)); + listSkill.Add(new 魔法涌流(c)); + listSkill.Add(new 灵能反射(c)); + listSkill.Add(new 三重叠加(c)); + listSkill.Add(new 智慧与力量(c)); + listSkill.Add(new 变幻之心(c)); + listSkill.Add(new 致命打击(c)); + listSkill.Add(new 精准打击(c)); + listSkill.Add(new 毁灭之势(c)); + listSkill.Add(new 绝对领域(c)); + listSkill.Add(new 枯竭打击(c)); + listSkill.Add(new 能量毁灭(c)); + listSkill.Add(new 玻璃大炮(c)); + listSkill.Add(new 迅捷之势(c)); + listSkill.Add(new 累积之压(c)); + listSkill.Add(new 嗜血本能(c)); + listSkill.Add(new 敏捷之刃(c)); + listSkill.Add(new 平衡强化(c)); + listSkill.Add(new 弱者猎手(c)); + listSkill.Add(new 血之狂欢(c)); + listSkill.Add(new 冰霜攻击(c)); + listSkill.Add(new 疾风步(c)); + foreach (Skill s in listSkill) + { + config2.Add(s.Name, s); + } + config2.SaveConfig(); + + EntityModuleConfig config3 = new(ExampleGameModuleConstant.Example, ExampleGameModuleConstant.ExampleItem) + { + { "攻击之爪50", new 攻击之爪50() } + }; + config3.SaveConfig(); + + PluginConfig config4 = new(Name, "config") { { "flush", 10000 }, { "oshima", "呵呵了" } }; - config2.SaveConfig(); + config4.SaveConfig(); return true; } diff --git a/Library/Tests/FunGame.cs b/Library/Tests/FunGame.cs index 0690189..f28af28 100644 --- a/Library/Tests/FunGame.cs +++ b/Library/Tests/FunGame.cs @@ -1,5 +1,5 @@ using System.Text; -using FunGame.Testing.Items; +using Milimoe.FunGame.Testing.Items; using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Library.Common.Addon;