This describes an individual game. This may be part of an Alexandria.Engine, or may directly be related to a AlexandriaPlugin.
상속: AlexandriaPluginFormatAsset
예제 #1
0
 /// <summary>
 /// Add a game to the engine.
 /// </summary>
 /// <param name="game">The game to add.</param>
 protected void AddGame(Game game)
 {
     if (game == null)
         throw new ArgumentNullException("game");
     if (GamesMutable.Contains(game))
         throw new ArgumentException(game.Name + " is already added to this " + Name + ".");
     if (game.Engine != this)
         throw new ArgumentException(game.Name + " does not have this " + Name + " as its Engine.");
     GamesMutable.Add(game);
 }
예제 #2
0
        /// <summary>Initialise the instance.</summary>
        /// <param name="game"></param>
        /// <param name="path"></param>
        public GameInstance(Game game, string path)
        {
            if (game == null)
                throw new ArgumentNullException("game");
            if (path == null)
                throw new ArgumentNullException("path");

            Game = game;
            Path = path;
            GameGuid = game.Guid;
            GameName = game.DisplayName;
        }
예제 #3
0
        /// <summary>Get a <see cref="PathState"/> for the given combination of parameters, creating one if necessary.</summary>
        /// <param name="game"></param>
        /// <param name="fileManager"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public PathState GetPathState(Game game, FileManager fileManager, string path)
        {
            if (game == null)
                throw new ArgumentNullException("game");
            if (fileManager == null)
                throw new ArgumentNullException("fileManager");

            var id = Aggregate.Create(fileManager.Id, game, path);
            PathState state;

            path = path.Replace('\\', '/');
            if (!PathStates.TryGetValue(id, out state)) {
                Type stateType = game.StateType;
                if (stateType == null)
                    throw new ArgumentException(string.Format("The game {0} does not have an accepted {1} state type.", game, typeof(State).Name));

                ConstructorInfo constructor = stateType.GetConstructor(new Type[] { typeof(AlexandriaManager), typeof(string), typeof(FileManager) });

                if (constructor == null)
                    throw new Exception(string.Format("State type {0} does not have an appropriate constructor, like the one for {1}.", stateType.FullName, typeof(State).FullName));

                state = (PathState)constructor.Invoke(new object[] { this, path, fileManager });
                PathStates[id] = state;
            }

            return state;
        }
예제 #4
0
 /// <summary>Add a game to this plugin.</summary>
 /// <param name="game">The game to add.</param>
 /// <exception cref="ArgumentNullException"><paramref name="game"/> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException"><paramref name="game"/> is not part of this <see cref="AlexandriaPlugin"/>.</exception>
 /// <exception cref="ArgumentException"><paramref name="game"/> is already in this <see cref="AlexandriaPlugin"/>.</exception>
 protected void AddGame(Game game)
 {
     if (game == null)
         throw new ArgumentNullException("game");
     if (game.Plugin != this)
         throw new ArgumentException(game.Name + " is not part of this " + Name + ".");
     if (GamesMutable.Contains(game))
         throw new ArgumentException(game.Name + " is already added to this " + Name + ".");
     GamesMutable.Add(game);
 }