游戏☆疯狂游戏大亨☆疯狂游戏大亨助手

版本历史:

  1. 2016年10月05日 发布1.0版本
  2. 2016年10月07日 优化配置文件中技术和游戏性数值

软件界面:
mad-games-tycoon-2

运行环境:

.NET Framework 4 Client Profile

软件下载:

Mad Games Tycoon Mate.zip

使用效果:
mad-games-tycoon-1

源代码:
MainWindow.xaml.cs

/* ----------------------------------------------------------
 * 文件名称:MainWindow.xaml.cs
 * 
 * 作者:秦建辉
 * 
 * 微信:splashcn
 * 
 * 博客:http://www.firstsolver.com/wordpress/
 * 
 * 开发环境:
 *      Visual Studio V2015
 *      .NET Framework 4 Client Profile
 *      
 * 版本历史:
 *      V1.0	2016年10月05日
 *              疯狂游戏大亨游戏概念设置助手
------------------------------------------------------------ */
using Com.FirstSolver.Splash;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;

namespace Splash
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        /// 程序配置文件名称
        /// </summary>
        public string iniFileName = "Genres.ini";

        /// <summary>
        /// 分割字符集合
        /// </summary>
        public char[] Separator = new char[] { ',' };

        /// <summary>
        /// 游戏类型字典
        /// </summary>
        private Dictionary<string, GameGenre> AllGenreDictionary = new Dictionary<string, GameGenre>();

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (System.IO.File.Exists(iniFileName))
            {
                LINQToINI iniFile = new LINQToINI();
                if (iniFile.Load(iniFileName, true, Encoding.Unicode))
                {
                    List<KeyValuePair<string, string>> AllGenreList = new List<KeyValuePair<string, string>>();

                    // 获取分区列表
                    string[] SectionNames = iniFile.GetProfileSectionNames();
                    foreach (string cell in SectionNames)
                    {
                        GameGenre Genre = new GameGenre();
                        AllGenreDictionary.Add(cell, Genre);

                        string[] ResultSet;

                        // 类型全称
                        ResultSet = iniFile.GetProfileString(cell, "FullName");
                        Genre.FullName = ResultSet[0];

                        // 类型显示名称
                        ResultSet = iniFile.GetProfileString(cell, "DisplayName");
                        Genre.DisplayName = ResultSet[0];

                        // 目标客户
                        ResultSet = iniFile.GetProfileString(cell, "Customer");
                        Genre.Customer = ResultSet[0];

                        // 可混搭的游戏类型集合
                        ResultSet = iniFile.GetProfileString(cell, "MinorGenres");
                        Genre.MinorGenres = ResultSet[0].Split(Separator);

                        // 最佳参数
                        ResultSet = iniFile.GetProfileString(cell, "Scheme");
                        Genre.Scheme = ResultSet[0].Split(Separator);

                        // 适合的主题集合
                        ResultSet = iniFile.GetProfileString(cell, "Themes");
                        Genre.Themes = ResultSet[0].Split(Separator);

                        AllGenreList.Add(new KeyValuePair<string, string>(cell, Genre.DisplayName));
                    }

                    // 初始化主类型选择控件
                    KeyValuePair<string, string>[] AllGenres = AllGenreList.ToArray();
                    comboBoxMajorGenreA.ItemsSource = AllGenres;
                    comboBoxMajorGenreB.ItemsSource = AllGenres;
                    comboBoxMajorGenreC.ItemsSource = AllGenres;

                    return;
                }
            }

            // 读取配置文件失败
            MessageBox.Show("读取配置文件失败!程序退出……", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
            Close();
        }

        private void comboBoxMajorGenreA_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comboBoxMajorGenreA.SelectedIndex != -1)
            {
                comboBoxMajorGenreC.SelectedIndex = comboBoxMajorGenreA.SelectedIndex;

                List<KeyValuePair<string, string>> MinorGenreList = new List<KeyValuePair<string, string>>();

                string MajorGenre = comboBoxMajorGenreA.SelectedValue.ToString();
                foreach (string item in AllGenreDictionary[MajorGenre].MinorGenres)
                {
                    MinorGenreList.Add(new KeyValuePair<string, string>(item, AllGenreDictionary[item].DisplayName));
                }

                comboBoxMinorGenreA.ItemsSource = MinorGenreList.ToArray();

                if (comboBoxMinorGenreA.SelectedIndex != -1)
                {
                    RetrieveCommonThemes(MajorGenre, comboBoxMinorGenreA.SelectedValue.ToString());
                }
            }
        }

        private void comboBoxMinorGenreA_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comboBoxMajorGenreA.SelectedIndex != -1 && comboBoxMinorGenreA.SelectedIndex != -1)
            {
                RetrieveCommonThemes(comboBoxMajorGenreA.SelectedValue.ToString(), comboBoxMinorGenreA.SelectedValue.ToString());
            }
        }

        /// <summary>
        /// 选出主类型和子类型公共的主题集合
        /// </summary>
        private void RetrieveCommonThemes(string major, string minor)
        {
            // 获取主类型对应的主题集合
            string[] MajorThemes = AllGenreDictionary[major].Themes;

            // 获取子类型对应的主题集合
            string[] MinorThemes = AllGenreDictionary[minor].Themes;

            // 选出主类型和子类型公共的主题集合
            string[] CommonThemes = (from a in MajorThemes from b in MinorThemes where string.Equals(a, b) select a).ToArray();
            if (CommonThemes != null)
            {
                StringBuilder sb = new StringBuilder();
                foreach (string item in CommonThemes) sb.Append(item + " ");
                sb.Remove(sb.Length - 1, 1);
                textBoxThemes.Text = sb.ToString();
            }
        }

        private void comboBoxMajorGenreB_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comboBoxMajorGenreB.SelectedIndex != -1)
            {
                comboBoxMajorGenreC.SelectedIndex = comboBoxMajorGenreB.SelectedIndex;

                comboBoxFirstTheme.ItemsSource = AllGenreDictionary[comboBoxMajorGenreB.SelectedValue.ToString()].Themes;
            }
        }

        private void buttonMatch_Click(object sender, RoutedEventArgs e)
        {
            // 清空信息
            richTextBoxMinorGenreSecondTheme.Document.Blocks.Clear();

            if (comboBoxMajorGenreB.SelectedIndex != -1)
            {   // 获取主类型对应的主题集合
                string MajorGenre = comboBoxMajorGenreB.SelectedValue.ToString();
                string[] MajorThemes = AllGenreDictionary[MajorGenre].Themes;

                string FirstTheme = comboBoxFirstTheme.Text;
                if (!MajorThemes.Contains(FirstTheme)) return;

                FlowDocument document = richTextBoxMinorGenreSecondTheme.Document;
                foreach (string minorGenre in AllGenreDictionary[MajorGenre].MinorGenres)
                {
                    string[] MinorThemes = AllGenreDictionary[minorGenre].Themes;
                    if (MinorThemes.Contains(FirstTheme))
                    {
                        // 选出主类型和子类型公共的主题集合
                        string[] CommonThemes = (from a in MajorThemes from b in MinorThemes where !string.Equals(a, FirstTheme) && string.Equals(a, b) select a).ToArray();
                        if (CommonThemes != null)
                        {
                            StringBuilder sb = new StringBuilder();
                            foreach (string item in CommonThemes) sb.Append(item + " ");
                            sb.Remove(sb.Length - 1, 1);

                            AppendTextToDocument(AllGenreDictionary[minorGenre].DisplayName, Colors.Red, document);
                            AppendTextToDocument(sb.ToString(), Colors.Blue, document);
                        }
                    }
                }
            }
        }

        private void AppendTextToDocument(string content, Color color, FlowDocument document)
        {
            Run run = new Run(content);
            run.Foreground = new SolidColorBrush(color);
            document.Blocks.Add(new Paragraph(run));
        }

        private void comboBoxMajorGenreC_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comboBoxMajorGenreC.SelectedIndex != -1)
            {
                string MajorGenre = comboBoxMajorGenreC.SelectedValue.ToString();

                // 目标市场
                textBoxCustomer.Text = AllGenreDictionary[MajorGenre].Customer;

                // 游戏玩法|画质
                slider0.Value = int.Parse(AllGenreDictionary[MajorGenre].Scheme[0]);

                // 剧情|游戏时长
                slider1.Value = int.Parse(AllGenreDictionary[MajorGenre].Scheme[1]);

                // 气氛|功能
                slider2.Value = int.Parse(AllGenreDictionary[MajorGenre].Scheme[2]);

                // 游戏深度|新手玩家
                slider3.Value = int.Parse(AllGenreDictionary[MajorGenre].Scheme[3]);

                // 核心玩家|休闲玩家
                slider4.Value = int.Parse(AllGenreDictionary[MajorGenre].Scheme[4]);                

                // 画面
                textBoxGraphics.Text = AllGenreDictionary[MajorGenre].Scheme[5];

                // 音质
                textBoxSound.Text = AllGenreDictionary[MajorGenre].Scheme[6];

                // 技术
                textBoxTechnology.Text = AllGenreDictionary[MajorGenre].Scheme[7];

                // 游戏性
                textBoxControl.Text = AllGenreDictionary[MajorGenre].Scheme[8];
            }
        }
    }
}

Comments are closed.