コード例 #1
0
ファイル: Game.cs プロジェクト: dmoonfire/wordplay
        /// <summary>
        /// Constructs a new game.
        /// </summary>
        public static void NewGame()
        {
            // Clear the display
            Display.Sprites.Clear();

            // Create the objects
            theme = Config.Theme;
            language = Config.Language;
            score = new Score();
            tokenGenerator = new TokenGenerator();
            gameState = GameState.Started;
            board = new Board(Config.BoardSize);

            // Register the vents
            board.TokenAdded += Display.OnTokenAdded;
            board.TokenRemoved += Display.OnTokenRemoved;
            board.TokenChanged += Display.OnTokenChanged;

            // Initialize the board
            board.Initialize();
        }
コード例 #2
0
ファイル: Theme.cs プロジェクト: dmoonfire/wordplay
        /// <summary>
        /// Returns all themes in the given directory.
        /// </summary>
        public static IList<Theme> GetThemes()
        {
            // Create the list
            LinkedList<Theme> list = new LinkedList<Theme>();

            // Go through the directories
            foreach (string din
                in Directory.GetDirectories(ThemeDirectory))
            {
                // Check for the theme.xml file
                if (!File.Exists(Path.Combine(din, "tileset.xml")))
                {
                    continue;
                }

                // We have a theme
                DirectoryInfo di = new DirectoryInfo(din);
                Theme theme = new Theme(di.Name);
                list.Add(theme);
            }

            // Return the results
            return list;
        }
コード例 #3
0
ファイル: Game.cs プロジェクト: dmoonfire/wordplay
        /// <summary>
        /// Loads the game configuration into memory.
        /// </summary>
        public static void LoadConfig()
        {
            // Load the high score list
            try
            {
                // Get the filename
                string filename = HighScoreFilename;
                FileInfo file = new FileInfo(filename);

                // Deserialize it
                TextReader reader = file.OpenText();
                XmlSerializer serializer = new XmlSerializer(typeof(HighScoreTableList));
                highScores = (HighScoreTableList) serializer.Deserialize(reader);
                reader.Close();
            }
            catch
            {
            }

            // Load our configuration
            try
            {
                // Get the filename
                string filename = ConfigFilename;
                FileInfo file = new FileInfo(filename);

                // Deserialize it
                TextReader reader = file.OpenText();
                XmlSerializer serializer = new XmlSerializer(typeof(Config));
                config = (Config) serializer.Deserialize(reader);
                reader.Close();

                // Set the theme
                theme = Config.Theme;
            }
            catch
            {
            }
        }