コード例 #1
0
    public ClientController(IGameController controller)
    {
        _controller = controller;

        var clientProtocol = new ClientProtocol (this);
        _transport = new ClientTransport (clientProtocol);
    }
コード例 #2
0
        private static void AttachEvents(Engine engine, IGameController gameController)
        {
            gameController.OnMoveLeft += (sender, eventInfo) =>
            {
                engine.MoveMickeyLeft();
            };

            gameController.OnMoveRight += (sender, eventInfo) =>
            {
                engine.MoveMickeyRight();
            };

            gameController.OnMoveUp += (sender, eventInfo) =>
            {
                engine.MoveMickeyUp();
            };

            gameController.OnMoveDown += (sender, eventInfo) =>
            {
                engine.MoveMickeyDown();
            };

            gameController.ForbiddenKey += (sender, eventInfo) =>
            {
                throw new ForbiddenKeyException();
            };
        }
コード例 #3
0
 public Environment(IGameController gameController, EventFactory eventFactory)
 {
     _gameController = gameController;
     _eventFactory = eventFactory;
     _rnd = new Random (DateTime.Now.Millisecond);
     _ballProbability = 12;
 }
コード例 #4
0
 public void Init(IGameController controller)
 {
     _gameController = controller;
     _gameScoreKeeper.StartGame();
     _ship.Activate();
     StartNewRound();
 }
コード例 #5
0
        public GameViewModel(ViewModelMetadata viewModelMetadata) : base(viewModelMetadata)
        {
            BackToMainMenuCommand = new RelayCommand(x => OnChangeViewModel(typeof(StartViewModel)));
            KeyDownCommand = new RelayCommand(HandleKeyDownCommand);

            FieldHeight = 20;
            FieldWidth = 20;

            var test = new IField[FieldHeight, FieldWidth];
            for (int x = 0; x < 20; x++)
            {
                for (int y = 0; y < 20; y++)
                {
                    if (x == 10)
                        test[y, x] = new Field()
                        {
                            Background = Brushes.Yellow,
                            X = x,
                            Y = y,
                        };
                    else
                        test[y, x] = new Field()
                        {
                            Background = Brushes.Brown,
                            X = x,
                            Y = y
                        };
                }
            }
            Fields = new IField[FieldHeight, FieldWidth];
            Fields = test;
            GameController = new GameController.GameController(Fields, OnPropertyChanged);
        }
コード例 #6
0
 public GameContainer(GameCore core, IGameController controller, Environment environment, bool isServer)
 {
     GameCore = core;
     EventFactory = new EventFactory (GameCore);
     GameController = controller;
     Environment = environment;
     _hasEnvironment = isServer;
 }
コード例 #7
0
		public void SetUp()
		{
			this.State = new TestObjects.GameState();
			this.Controller = new ClassicGame();
			this.Controller.GameState = this.State;
			this.State.Controller = this.Controller;
			this.Controller.PreGameStarted();
			this.Controller.GameStarted();
		}
コード例 #8
0
    public ServerController(IGameController controller)
    {
        _controller = controller;

        var serverProtocol = new ServerProtocol (this);
        _transport = new ServerTransport (serverProtocol);

        _transport.StartListening ();
    }
コード例 #9
0
ファイル: Engine.cs プロジェクト: shristoff/TelerikAcademy
 // Constructors
 public Engine(IVisualizer visualizer, IGameController gameController, GameSpeed gameSpeed = GameSpeed.Slowest)
 {
     this.visualizer = visualizer;
     this.gameController = gameController;
     this.allObjects = new List<GameObject>();
     this.movingObjects = new List<MovingObject>();
     this.staticObjects = new List<GameObject>();
     this.textObjects = new List<TextObject>();
     this.gameSpeed = gameSpeed;
 }
コード例 #10
0
ファイル: GameEngine.cs プロジェクト: BattleField5/Project
        public GameEngine(IGameController gameController, IGameboardGenerator fieldGenerator, IDetonationPatternFactory detonationFactory)
        {
            this.gameController = gameController;
            int size = this.gameController.GetPlaygroundSizeFromUser();

            double minesPercentage = this.DetermineMinesPercentage();
            this.board = fieldGenerator.Generate(size, minesPercentage);
            this.board.SetDetonationFactory(detonationFactory);

            this.blownMines = 0;
        }
コード例 #11
0
        public ApplicationController(
            Game game,
            IGameController gameController,
            IInputService inputService)
        {
            this.game = game;
            this.gameController = gameController;
            this.inputService = inputService;

            var intro = new State<Action<double>>(
                "Intro",
                null,
                delegate
                    {
                        this.introGameState = new IntroGameState(this.game);
                        this.gameStateManager.Push(this.introGameState);
                    },
                () => this.gameStateManager.Pop());

            var menu = new State<Action<double>>(
                "Menu",
                null,
                delegate
                    {
                        this.menuGameState = new MenuGameState(this.game, this.inputService);
                        this.gameStateManager.Push(this.menuGameState);
                    },
                () => this.gameStateManager.Pop());

            var gameplay = new State<Action<double>>(
                "Gameplay",
                null,
                delegate
                    {
                        this.gameplayGameState = new GameplayGameState(this.gameController);
                        this.gameStateManager.Push(this.gameplayGameState);
                    },
                () => this.gameStateManager.Pop());

            var exit = new State<Action<double>>(
                "Exit",
                null,
                () => this.game.Exit(),
                null);

            intro.AddTransition(menu, () => this.introGameState.IsTransitionAllowed);
            menu.AddTransition(gameplay, () => this.menuGameState.IsTransitionAllowed && (string)this.menuGameState.TransitionTag == MenuItems.StartGame);
            menu.AddTransition(exit, () => this.menuGameState.IsTransitionAllowed && (string)this.menuGameState.TransitionTag == MenuItems.ExitGame);
            gameplay.AddTransition(menu, () => this.gameplayGameState.IsTransitionAllowed);

            this.applicationStateMachine = new StateMachine<Action<double>>(intro);
            //this.applicationStateMachine = new StateMachine<Action<double>>(gameplay); // Skipping intro and menu for faster startup
        }
コード例 #12
0
		/// <summary>
		/// Inicjalizuje stan gry.
		/// </summary>
		/// <param name="settings">Ustawienia gry.</param>
		public void Initialize(ISingleplayerSettings settings)
		{
			this.MainSettings = settings;
			this.Players = new IPlayer[]
			{
				new Player.Player(settings.PlayerA.Name, settings.PlayerA.Nation, 100),
				new Player.Player(settings.PlayerB.Name, settings.PlayerB.Nation, 100)
			};
			this.PlayerControllers[0] = settings.PlayerA.Controller;
			this.PlayerControllers[1] = settings.PlayerB.Controller;
			this.Map = settings.Map;
			this.Controller = settings.Controller;

			this.PlayerControllers[0].ShowStatistics = settings.PlayerA.ShowStatistics;
			this.PlayerControllers[1].ShowStatistics = settings.PlayerB.ShowStatistics;
		}
コード例 #13
0
 public Engine(IGameController gameController, IRenderer renderer, ISpaceUnitFactory spaceUnitFactory, int canvasRows, int canvasColumns)
 {
     this.gameController = gameController;
     this.renderer = renderer;
     this.spaceUnitFactory = spaceUnitFactory;
     this.gameObjects = new List<GameObject>();
     this.spaceUnits = new List<SpaceUnit>();
     this.producedSpaceUnits = new List<SpaceUnit>();
     this.healthUi = null;
     this.scoreUi = null;
     this.player = null;
     this.randomGenerator = new Random();
     this.lastSpawnedEnemy = DateTime.Now;
     this.canvasRows = canvasRows;
     this.canvasCols = canvasColumns;
 }
コード例 #14
0
        public Game()
        {
            this.mode = GameMode.MainMenu;
            this.menuItems = ConsoleUI.MainMenuItems;
            this.menuItemIndex = 0;
            this.cursorMoved = false;
            this.keyboard = new KeyboardController();
            this.renderer = new Renderer(ConsoleUI.BufferRows, ConsoleUI.BufferCols, new Coordinate(ConsoleUI.BufferPositionRow, ConsoleUI.BufferPositionCol));
            this.spaceUnitFactory = new SpaceUnitFactory();

            this.gameLogo = new GameObject(new Coordinate(ConsoleUI.LogoPositionRow, ConsoleUI.LogoPositionCol), ConsoleUI.LogoBody);
            this.bottomWall = new GameObject(new Coordinate(ConsoleUI.BottomWallPositionRow, ConsoleUI.BottomWallPositionCol), ConsoleUI.BottomWallBody);
            this.cursor = new GameObject(new Coordinate(ConsoleUI.MainMenuCursorPositionRow, ConsoleUI.MainMenuCursorPositionCol), ConsoleUI.CursorBody);
            this.mainMenu = new GameObject(new Coordinate(ConsoleUI.MainMenuPositionRow, ConsoleUI.MainMenuPositionCol), ConsoleUI.MainMenuBody);
            this.controlsMenu = new GameObject(new Coordinate(ConsoleUI.ConstrolsMenuPositionRow, ConsoleUI.ConstrolsMenuPositionCol), ConsoleUI.ControlsMenuBody);
            this.highScoreMenu = new GameObject(new Coordinate(ConsoleUI.HighScoreMenuPositionRow, ConsoleUI.HighScoreMenuPositionCol), ConsoleUI.HighScoreMenuBody);
            this.gameOverMenu = new GameObject(new Coordinate(ConsoleUI.GameOverMenuPositionRow, ConsoleUI.GameOverMenuPositionCol), ConsoleUI.GameOverMenuBody);
            this.hittedHighScore = new GameObject(new Coordinate(ConsoleUI.HittedHighScorePositionRow, ConsoleUI.HittedHighScorePositionCol), ConsoleUI.HittedHighScoreBody);

            this.highScore = FileManager.ParseHighScore();
            this.gameEngine = null;
            this.player = null;
        }
コード例 #15
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainWindowViewModel(
            IGameController gameController,
            IUIVisualizerService uiVisualizerService,
            Func<IPlayerConfigurationViewModel> playerConfigurationFactory,
            Func<ICollection<IPlayer>, IGame> gameFactory,
            Func<IRoundResult, IRoundResultViewModel> roundResultFactory)
        {
            Argument.IsNotNull(() => gameController);
            Argument.IsNotNull(() => uiVisualizerService);
            Argument.IsNotNull(() => playerConfigurationFactory);
            Argument.IsNotNull(() => gameFactory);
            Argument.IsNotNull(() => roundResultFactory);

            GameController = gameController;
            _uiVisualizerService = uiVisualizerService;
            _playerConfigurationFactory = playerConfigurationFactory;
            _gameFactory = gameFactory;
            _roundResultFactory = roundResultFactory;

            ConfigurePlayersCommand = new Command(OnConfigurePlayers, () => !GameController.IsGameStarted);
            StartRoundCommand = new Command(OnStartRound, () => GameController.IsGameStarted && !GameController.IsPlaying);
            EndRoundCommand = new Command(OnEndRound, () => GameController.IsGameStarted && GameController.IsPlaying);
        }
コード例 #16
0
 public FatigueHealthEffectsController(IGameController gc, HealthController health)
 {
     _gc = gc;
     _healthController = health;
 }
コード例 #17
0
 public Engine(IReader reader, IWriter writer, IMissionController missionController, IGameController gameController, IArmy army, IWareHouse wareHouse
               , ISoldierFactory soldierFactory, IMissionFactory missionFactory, IAmmunitionFactory ammunitionFactory)
 {
     this.reader            = reader;
     this.writer            = writer;
     this.missionController = missionController;
     this.gameController    = gameController;
     this.army              = army;
     this.wareHouse         = wareHouse;
     this.soldierFactory    = soldierFactory;
     this.missionFactory    = missionFactory;
     this.ammunitionFactory = ammunitionFactory;
 }
コード例 #18
0
 public LampShowMode(IGameController game)
     : base(game, 3)
 {
     this.Lampshow = new LampShow(game);
     this.ShowOver = true;
 }
コード例 #19
0
ファイル: AIBase.cs プロジェクト: trbarrett/Four-in-a-Row
        public void PlayTurn(IGameController gameController, Object player)
        {
            _isInteractive = false;

            //We basically need to consider each move based on the impact to the game, and how many turns
            //ahead it will need to be. Often it will be better to look at the best multi-turn move combination
            //rather than the single best move for this turn.
            //We could give each turn possibility a ranking, then decide from that. But that means we'll have
            //to process every option before we take one, which will take more time. If we can be certain
            //of the order in which we will want to implement each option then we don't need to process the
            //options. We jst need to consider them in order. I'm not sure method I'll take yet, but I'm
            //going to go ahead with the assumption that we can just do each check in a linear order unless
            //I encounter something that proves otherwise.

            //==== End Moves ====
            //===================

            //This turn compulsions
            //---------------------

            //Look for a winning possibility and complete it
            var potentialWinningTiles = AIHelper.FindDirectWinningPossibilities(
                gameController.Game.Board,
                player);

            if (potentialWinningTiles.Count != 0
                    && WillSeeImmediateWin(potentialWinningTiles.Count, gameController.Game.Board)) {
                //Depending on how easy the difficulty is, and how many tokens are on the board
                //the AI should be able to miss a chance to win. There should be more chance
                //to see the win the more potential winning tiles there are.
                PlaceTokenInOneOfTheseTiles(gameController, potentialWinningTiles);
                return;
            }

            //Look to see if the opponent will be able to complete his move next turn, and block it.
            var potentialLosingTiles = AIHelper.FindDirectWinningPossibilities(
                gameController.Game.Board,
                gameController.Game.GetOtherPlayer(player));

            if (potentialLosingTiles.Count != 0
                    && WillSeeImmediateLoss(potentialLosingTiles.Count, gameController.Game.Board)) {
                //Depending on how easy the difficulty is, and how many tokens are on the board
                //the AI should be able to miss a chance to stop the opponent. There should
                //be less chance to miss the more potential losing tiles there are.
                PlaceTokenInOneOfTheseTiles(gameController, potentialLosingTiles);
                return;
            }

            //Two turn compulstions
            //---------------------

            if (CanCreateCompulsion(gameController.Game.Board)) {
                //Look to see if we have a move that will force the other player into giving us the win
                //in the next turn, and do it.

                var compulsionTiles = AIHelper.FindTwoTurnCompulsionWin(gameController.Game, player);
                if (compulsionTiles.Count != 0) {
                    PlaceTokenInOneOfTheseTiles(gameController, compulsionTiles);
                    return;
                }
            }

            if (CanBlockOpponentCompulsion(gameController.Game.Board)) { //when there's a small amount of
                //Look for the above thing for the opponent. A move which will force us to make a defensive blocking
                //move, and give him the win on the next turn.
                //Note that FindCompulsionWinBlockingTiles() will not return any blocks if there is a compulsion
                //and it can't be blocked
                var compulsionBlocks = FindCompulsionWinBlockingTiles(gameController, player);
                if (compulsionBlocks.Count != 0) {
                    PlaceTokenInOneOfTheseTiles(gameController, compulsionBlocks);
                    return;
                }
            }

            //Three plus turn compulsions
            //---------------------------

            //Three turn compulsions are less likley to occur in the game, so I'm not going to consider them at
            //this point. Though doing so should just be a modification and additional search based on the
            //two-turn compulsion

            //==== Mid And Early Game Moves ====
            //==================================

            //Now go through and rate each of the playable tiles
            var ratings = RatePosibilePlacements(gameController.Game, player);

            if (ratings.Count != 0) {
                List<Tile> placementOptions = null;
                if (_UseFuzzyLogicOnRatings) {
                    placementOptions = ChoosePlacementBasedOnFuzzyLogic(ratings);
                } else {
                    placementOptions = ChoosePlacementTilesBasedOnHighestRating(ratings);
                }

                PlaceTokenInOneOfTheseTiles(gameController, placementOptions);
                return;
            }

            // If there are no good options, then place a token as low and centeral as possible.
            // (I'm not actually sure if this is a very optimial strategy. I would have to do some testing
            //with different options (random, low and sides, high and central, high and sides, third poins, etc))

            //For testing, just randomly place the token.

            //For testing we are going to make it interactive.
            _isInteractive = true;
        }
コード例 #20
0
 public StatController(IGameController gameController)
 {
     _gameController = gameController;
 }
コード例 #21
0
 public GameStateController(IGameController gameController, IGameInputCollector gameInputCollector)
 {
     _gameController = gameController;
     _gameInputCollector = gameInputCollector;
 }
コード例 #22
0
 public override void ApplyCondition(IGameController controller)
 {
     controller.AddCodeword(Value);
 }
コード例 #23
0
 public override void ApplyCondition(IGameController controller)
 {
     controller.MovePlayer(NextScene, null, string.Empty);
 }
コード例 #24
0
ファイル: Form1.cs プロジェクト: fernandozamoraj/AsteroidsGdi
 private void StartNewGame(IGameController gameController)
 {
     GameManager.TheGameManager.ReInitializeGame(gameController);
 }
コード例 #25
0
 public FluMonitor(IGameController gc) : base(gc)
 {
 }
		/// <summary>
		/// Pobiera nowy obiekt ustawień dla kontrolera.
		/// </summary>
		/// <remarks>
		/// Jeśli kontroler nie definiuje tego atrybutu zwracany jest obiekt <see cref="DefaultGameplaySettings"/>.
		/// </remarks>
		/// <param name="controller">Kontroler.</param>
		/// <returns>Nowy obiekt ustawień dla klasy.</returns>
		public static IGameplaySettings GetSettingsFor(IGameController controller)
		{
			return GetSettingsFor(controller.GetType());
		}
コード例 #27
0
 public void InitilizeController()
 {
     this.inputReader = new Mock<IInputReader>();
     this.messenger = new Mock<IControllerMessenger>();
     this.playgroundRender = new Mock<IPlaygroundRender>();
     this.gameController = new GameController(this.inputReader.Object, this.messenger.Object, this.playgroundRender.Object);
 }
コード例 #28
0
 public ServerProtocol(IGameController controller)
 {
     _controller = controller;
 }
コード例 #29
0
 public void Construct(IGameController gameController, IPlayerController playerController, IStatController statController)
 {
     _gameController   = gameController;
     _playerController = playerController;
     _statController   = statController;
 }
コード例 #30
0
 public override bool IsConditionFulfilled(IGameController controller, IEnemy enemy = null)
 {
     return(true);
 }
コード例 #31
0
 public Game(GameType type, IGameController controller, IMovementManager movementManager)
 {
     this.Type            = type;
     this.Controller      = controller;
     this.MovementManager = movementManager;
 }
コード例 #32
0
 void Awake()
 {
     m_gameController = SnapGameContext.GetGameController(this);
     m_gameController.StartNewGame();
 }
コード例 #33
0
 private void Start()
 {
     game = (IGameController)GameObject.FindGameObjectWithTag("gameController").GetComponent(typeof(IGameController));
 }
コード例 #34
0
 protected DiseaseMonitorBase(IGameController gc)
 {
     _gc = gc;
 }
コード例 #35
0
 public AsteroidsGame(IGameForm parent, IGameController gameController)
     : base(parent)
 {
     StartNewRound();
     _gameController = gameController;
 }
コード例 #36
0
 public void Init(IGameController gameController)
 {
     _gameController = gameController;
     _gameController.OnGameStateChange += HandleGameChange;
 }
コード例 #37
0
 public ClientProtocol(IGameController controller)
 {
     _controller = controller;
 }
コード例 #38
0
ファイル: SpaceGame.cs プロジェクト: scenex/SpaceFighter
        private void ComposeServices()
        {
            this.terrainService = new TerrainService(
                this);

            this.headUpDisplayService = new HeadUpDisplayService(
                this);

            this.audioService = new AudioService(
                this);

            this.enemyFactory = new EnemyFactory(
                this,
                terrainService);

            this.enemyService = new EnemyService(
                this,
                enemyFactory);

            this.playerFactory = new PlayerFactory(
                this);

            this.inputService = new InputService(
                this);

            this.playerService = new PlayerService(
                this,
                inputService,
                audioService,
                playerFactory,
                terrainService);

            this.collisionDetectionService = new CollisionDetectionService(
                this,
                playerService,
                enemyService,
                terrainService);

            this.gameController = new GameController(
                this,
                collisionDetectionService,
                playerService,
                enemyService,
                inputService,
                headUpDisplayService,
                terrainService,
                audioService);

            try
            {
                var consoleAssembly = Assembly.Load("SpaceFighter.Console");
                var consoleServiceType = consoleAssembly.GetType("SpaceFighter.Console.ConsoleService");
                var consoleService = Activator.CreateInstance(consoleServiceType, this);

                this.Components.Add(consoleService as IGameComponent);
            }
            catch(FileNotFoundException)
            {
                // No console support available
            }
        }
コード例 #39
0
 // IView interface implementation:
 public void SetController(IGameController controller)
 {
     this.controller = controller;
 }
コード例 #40
0
        public bool OnApplianceTaken(IGameController gc, ApplianceInfo applianceInfo, ActiveDisease disease)
        {
            if (IsFinished)
            {
                return(false);
            }

            if (!gc.WorldTime.HasValue)
            {
                return(false);
            }

            if (disease.IsSelfHealing)
            {
                return(false);
            }

            var treatedStage = disease.TreatedStage;

            if (treatedStage == null)
            {
                treatedStage = disease.GetActiveStage(gc.WorldTime.Value);
            }

            if (treatedStage == null)
            {
                return(false);
            }

            var isTreatedLevel = treatedStage.Level == _treatedLevel;

            if (applianceInfo.Appliance.Name == _applianceName && (_bodyPart == null || applianceInfo.BodyPart == _bodyPart))
            {
                var currentTime = gc.WorldTime.Value;

                if (_consumedTimes.Count == 0)
                {
                    // First consume
                    _inTimeConsumedCount++;
                    _consumedTimes.Add(currentTime);

                    if (isTreatedLevel)
                    {
                        IsFinished = false;

                        CheckIfTreatmentFinished(disease);

                        if (OnTreatmentStarted != null)
                        {
                            OnTreatmentStarted.Invoke();
                        }

                        //("Disease appliance treatment started.");

                        IsStarted = true;

                        if (!IsNodePart && !IsFinished)
                        {
                            //("Overall disease treatment started.");

                            Events.NotifyAll(l => l.DiseaseTreatmentStarted(disease.Disease));

                            // We're starting to heal
                            disease.Invert();
                        }
                    }
                }
                else
                {
                    IsFinished = false;

                    var lastTime = _consumedTimes.Last();
                    var minutes  = (currentTime - lastTime).TotalMinutes;

                    if (minutes <= _timingInGameMinutes + TimingDeltaBetweenAllowedConsuming && minutes >= _timingInGameMinutes - TimingDeltaBetweenAllowedConsuming)
                    {
                        _inTimeConsumedCount++;

                        _consumedTimes.Add(currentTime);

                        if (isTreatedLevel)
                        {
                            CheckIfTreatmentFinished(disease);
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
コード例 #41
0
ファイル: VenomPoisoning.cs プロジェクト: ArcticWolves/zara
 public override void Check(ActiveDisease disease, IGameController gc)
 {
     _progressingStageTreatment.Check(disease, gc);
     _worryingStageTreatment.Check(disease, gc);
     _criticalingStageTreatment.Check(disease, gc);
 }
コード例 #42
0
 public void SwitchToPauseMenu(IGameController gameController)
 {
     throw new NotImplementedException();
 }
コード例 #43
0
        public const int UnsafeWaterFoodPoisoningChance = 60; // percents

        public FoodPoisoningMonitor(IGameController gc) : base(gc)
        {
        }
コード例 #44
0
 public MoveDownCommand(IGameController gameController)
 {
     _gameController = gameController;
 }
コード例 #45
0
 public SoldierRegenerateCommand(IList <string> cmdArgs, IGameController gameController)
     : base(cmdArgs, gameController)
 {
 }
コード例 #46
0
 public ActiveController(IGameController controller)
 {
     Id   = controller.Game.Id;
     Game = controller.Game.CloneJson();
 }
コード例 #47
0
 public MedicalAgentsSideEffectsController(IGameController gc)
 {
     _gc = gc;
 }
コード例 #48
0
 public IGameView Create(IGameController gameController, ISolitaireGameModel gameModel) =>
 new ConsoleGameView(gameController, gameModel, _serviceProvider.GetRequiredService <IStringViewProvider <Card> >(),
                     _serviceProvider.GetRequiredService <IStringViewProvider <CardSuit> >());
コード例 #49
0
ファイル: AIBase.cs プロジェクト: trbarrett/Four-in-a-Row
 public void PlaceTokenInOneOfTheseTiles(IGameController gameController, List<Game.Tile> tiles)
 {
     if (tiles.Count == 1) {
         gameController.Game.DropTokenOnColumn(tiles[0].ColumnNo);
     } else {
         var rand = new Random();
         var randomTile = tiles[ rand.Next(tiles.Count - 1) ];
         gameController.Game.DropTokenOnColumn(randomTile.ColumnNo);
     }
 }
コード例 #50
0
 public void SetController(IGameController gameController)
 {
     GameController = gameController;
 }
コード例 #51
0
ファイル: GamesEditor.cs プロジェクト: BGnger/Playnite
        public void PlayGame(Game game)
        {
            if (!game.IsInstalled)
            {
                InstallGame(game);
                return;
            }

            logger.Info($"Starting {game.GetIdentifierInfo()}");
            var dbGame = Database.Games.Get(game.Id);

            if (dbGame == null)
            {
                Dialogs.ShowMessage(
                    string.Format(resources.GetString("LOCGameStartErrorNoGame"), game.Name),
                    resources.GetString("LOCGameError"),
                    MessageBoxButton.OK, MessageBoxImage.Error);
                UpdateJumpList();
                return;
            }

            IGameController controller = null;

            try
            {
                if (game.IsRunning)
                {
                    logger.Warn("Failed to start the game, game is already running.");
                    return;
                }

                if (game.PlayAction.IsHandledByPlugin)
                {
                    logger.Info("Using library plugin to start the game.");
                    controller = controllers.GetGameBasedController(game, Extensions);
                }
                else
                {
                    logger.Info("Using generic controller start the game.");
                    controller = controllers.GetGenericGameController(game);
                }

                if (controller == null)
                {
                    Dialogs.ShowErrorMessage(
                        resources.GetString("LOCErrorLibraryPluginNotFound"),
                        resources.GetString("LOCGameError"));
                    return;
                }

                controllers.RemoveController(game.Id);
                controllers.AddController(controller);
                UpdateGameState(game.Id, null, null, null, null, true);
                controller.Play();
            }
            catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors)
            {
                if (controller != null)
                {
                    controllers.RemoveController(game.Id);
                    UpdateGameState(game.Id, null, null, null, null, false);
                }

                logger.Error(exc, "Cannot start game: ");
                Dialogs.ShowMessage(
                    string.Format(resources.GetString("LOCGameStartError"), exc.Message),
                    resources.GetString("LOCGameError"),
                    MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try
            {
                UpdateJumpList();
            }
            catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors)
            {
                logger.Error(exc, "Failed to set jump list data: ");
            }
        }
コード例 #52
0
 public TimedEventByChance(IGameController gc, string name, Action <TimedEventByChance> eventStartHappenningAction, Action <TimedEventByChance> eventEndHappenningAction, TimeSpan eventDurationInGameTime, float realSecondsBetweenChecks) : this(gc, name, eventStartHappenningAction, eventEndHappenningAction, eventDurationInGameTime, null, 0, realSecondsBetweenChecks, 0)
 {
 }
コード例 #53
0
 public IGameBuilder GameController(IGameController gameController)
 {
     this._gameController = gameController;
     return(this);
 }
コード例 #54
0
 public TimedEventByChance(IGameController gc, string name, Action <TimedEventByChance> eventStartHappenningAction, Action <TimedEventByChance> eventEndHappenningAction, TimeSpan eventDurationInGameTime, Pair <int> durationPercentRandomizer, float realSecondsBetweenChecks) : this(gc, name, eventStartHappenningAction, eventEndHappenningAction, eventDurationInGameTime, durationPercentRandomizer, 0, realSecondsBetweenChecks, 0)
 {
 }
コード例 #55
0
ファイル: AIBase.cs プロジェクト: trbarrett/Four-in-a-Row
        public List<Tile> FindCompulsionWinBlockingTiles(IGameController gameController, Object player)
        {
            var opponentCompulsionTiles = AIHelper.FindTwoTurnCompulsionWin(gameController.Game,
                gameController.Game.GetOtherPlayer(player));

            //We may or may not be able to block this compulsion... We'll need to check each
            //column to see if placing a tile wouldn't create a direct win or compulsion. If we can find
            //one that doesn't we should drop a token there.
            var compulsionBlockingTiles = new List<Tile>();
            opponentCompulsionTiles.ForEach(tile => {
                var copyGame = gameController.Game.Copy();
                copyGame.DropTokenOnColumn(tile.ColumnNo);

                var winningPossiblities =
                    AIHelper.FindDirectWinningPossibilities(copyGame.Board, copyGame.CurrentPlayer);

                var twoTurnCompulsions = AIHelper.FindTwoTurnCompulsionWin(copyGame, copyGame.CurrentPlayer);

                if (winningPossiblities.Count == 0 && twoTurnCompulsions.Count == 0) {
                    compulsionBlockingTiles.Add(tile);
                }
            });

            return compulsionBlockingTiles;

            //Hmm this method is a bit brute forced. I wonder if there's different situations and cases we can
            //look at to block the compulsion... In many cases where the other player must place a tile to
            //start a compulsion, we could block by placing one there first. That's because it depends on
            //us building the final tile, which we can prematuraley stop. Other cases it doesn't matter
            //what we do, because placing the blocking tile gives them the opportunity to win straight away.

            //
            //
            //
            // . . x x . . .
            //////////////////
            //In the above case placing a token to either side of the x's will block the compulsion

            // x x x
            // t t t
            // t t t
            // t t t x
            // t t t x . . .
            /////////////////
            //In this case if we place a token above the 4th column we will block a compulsion. If
            //we don't then the user will force a compulsion on us

            //
            // x x x
            // t x t
            // x t t t . . .
            ////////////////
            //In this case there is nothing we can do to stop a compulsion. If we place a token in the
            //4th column the opponent will win in the next turn. If they place one there then we will
            //have to block it and they will win on the diagonal.

            //In all the above cases where we can block the compulsion, we do it by placing a token
            //on the same column that the opponent would. Are there situations where would need
            //to place a token elsewhere to stop the compulsion? None that I can think of...
        }
コード例 #56
0
 public GameControllerTest()
 {
     mockDisplay    = new Mock <IDisplayController>();
     mockLoader     = new Mock <ILoadController>();
     gameController = new GameController(mockDisplay.Object, mockLoader.Object);
 }
コード例 #57
0
        public GameplayGameState(IGameController gameController)
        {
            this.Visible = true;

            this.gameplayScreen = new GameplayScreen(gameController);
        }
コード例 #58
0
ファイル: Player.cs プロジェクト: trbarrett/Four-in-a-Row
 public void PlayTurn(IGameController gameController)
 {
     if (_ai != null) {
         _ai.PlayTurn(gameController, this);
     } else {
         //The the human player take their turn as they may
     }
 }
コード例 #59
0
ファイル: TileTypeTool.cs プロジェクト: MK4H/MHUrho
 protected TileTypeTool(IGameController input, IntRect iconRectangle)
     : base(input, iconRectangle)
 {
 }
コード例 #60
0
		/// <summary>
		/// Inicjalizuje grę.
		/// </summary>
		/// <param name="mp">Główny obiekt gry.</param>
		public MultiplayerGameState(IMultiplayer mp)
		{
			this.Game = mp;
			this.Entities = new ClashEngine.NET.EntitiesManager.EntitiesManager(mp.GameInfo);

			this.VictoryRules = System.Activator.CreateInstance(ServerConfiguration.Instance.VictoryRules) as IVictoryRules;
			this.Controller = System.Activator.CreateInstance(ServerConfiguration.Instance.GameController) as IGameController;
			this.Settings = ServerConfiguration.Instance.ControllerSettings;
			this.Map = new Maps.DefaultMap();
		}