コード例 #1
0
        public GameStateViewModel([NotNull] States.GameState state, Genes.ActorChromosome brain)
        {
            _state = state ?? throw new ArgumentNullException(nameof(state));

            foreach (var actor in _state.World.Actors.Where(a => a.IsActive))
            {
                Actors.Add(new ActorViewModel(actor));
            }

            var values = new Dictionary <WorldPos.WorldPos, double>();

            for (int y = 1; y <= state.World.MaxY; y++)
            {
                for (int x = 1; x <= state.World.MaxX; x++)
                {
                    var pos = new WorldPos.WorldPos(x, y);
                    values[pos] = Genes.evaluateTile(brain, state.World, pos);
                }
            }

            var min = values.Values.Min();
            var max = values.Values.Max();

            foreach (var(pos, value) in values)
            {
                HeatMap.Add(new HeatMapViewModel(pos, value, min, max));
            }
        }
コード例 #2
0
        public GeneticModels.SimulationResult Move(States.GameState currentState, string?direction)
        {
            // Parameter validation/cleansing.
            currentState.ThrowIfNull(nameof(currentState));
            direction = direction is null
                ? string.Empty
                : direction.ToLowerInvariant();

            // Translate from the command parameter to the GameCommand in F#.
            Commands.GameCommand command = direction switch
            {
                "nw" => Commands.GameCommand.MoveUpLeft,

                "n" => Commands.GameCommand.MoveUp,

                "ne" => Commands.GameCommand.MoveUpRight,

                "w" => Commands.GameCommand.MoveLeft,

                "e" => Commands.GameCommand.MoveRight,

                "sw" => Commands.GameCommand.MoveDownLeft,

                "s" => Commands.GameCommand.MoveDown,

                "se" => Commands.GameCommand.MoveDownRight,

                _ => Commands.GameCommand.Wait
            };

            // Process the action and update our new state.
            var newState = Simulator.simulateTurn(currentState, command);

            return(WrapStateToResult(newState));
        }
コード例 #3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            //Camera
            Camera = new Camera2D(this, GraphicsDevice.Viewport);

            // Factories - item and sprite
            SFactory = new SpriteFactory();
            IFactory = new ItemFactory(this);

            // Collision Detector
            Detection    = new CollisionDetection(this);
            soundEffects = new List <SoundEffect>();

            // Adding all of the commands into the keyboard controller
            keyboardCommands[0]  = new LinkWalkUp(this);
            keyboardCommands[1]  = new LinkWalkDown(this);
            keyboardCommands[2]  = new LinkWalkLeft(this);
            keyboardCommands[3]  = new LinkWalkRight(this);
            keyboardCommands[4]  = new LinkAttack(this);
            keyboardCommands[5]  = new LinkBomb(this);
            keyboardCommands[6]  = new LinkArrow(this);
            keyboardCommands[7]  = new LinkCandle(this);
            keyboardCommands[8]  = new LinkBoomerang(this);
            keyboardCommands[9]  = new Reset(this);
            keyboardCommands[10] = new Quit(this);
            keyboardCommands[11] = new Pause(this);
            keyboardCommands[13] = new LinkGun(this);

            keyboardController = new KeyboardController(this, keyboardKeys, keyboardCommands);
            keyboardCheater    = new KeyboardCheater(this);

            mouseCommands[0] = new ChangeRoom(this);
            mouseController  = new MouseController(this, mouseCommands);
            vsbag            = new VisualBag();

            //Game State
            PlayingState   = new GamePlayingState(this);
            InventoryState = new GameInventoryState(this);
            PauseState     = new GamePausedState(this);



            CurrentGameState = PlayingState;
            GameEnumState    = States.GameState.GamePlayingState;

            // Game base
            base.Initialize();
        }
コード例 #4
0
        private static GeneticModels.SimulationResult WrapStateToResult(States.GameState state)
        {
            // Use dirty trick with wrapping state into simulation result to use it in view.

            var states = new FSharpList <States.GameState>(
                state, FSharpList <States.GameState> .Empty
                );

            var indiviaualWorld = new GeneticModels.IndividualWorldResult(0.0, states);

            var results = new FSharpList <GeneticModels.IndividualWorldResult>(
                indiviaualWorld, FSharpList <GeneticModels.IndividualWorldResult> .Empty
                );

            var brain = new GeneticModels.ActorChromosome(FSharpList <double> .Empty, 0);

            return(new GeneticModels.SimulationResult(0.0, results, brain));
        }
コード例 #5
0
 public BulletController(States.GameState game)
 {
     Game = game;
 }
コード例 #6
0
 public StarController(States.GameState game)
 {
     Game  = game;
     stars = new List <Object.Star>();
     rnd   = new Random();
 }
コード例 #7
0
 public BossFightController(States.GameState game)
 {
     Game = game;
 }
コード例 #8
0
 public SpaceShipController(States.GameState game)
 {
     Game = game;
     X    = 100;
     Y    = 35;
 }
コード例 #9
0
 public PowerUpController(States.GameState game)
 {
     Game = game;
 }
コード例 #10
0
 public EnemyController(States.GameState game)
 {
     Game = game;
 }
コード例 #11
0
 public MeteorController(States.GameState game)
 {
     Game    = game;
     Meteors = new List <Meteor>();
 }