Exemple #1
0
        public static DialogResult Show(string text)
        {
            if (!Disable)
            {
                var gameRunner = GameRunner.Singleton;
                var activity   = gameRunner.Activity;
                if (gameRunner.InModal || activity == null ||
                    android.os.Looper.getMainLooper().getThread()
                    == java.lang.Thread.currentThread())
                {
                    GameRunner.Log(text);
                }
                else
                {
                    gameRunner.PauseGame(true);

                    var waitObj = new android.os.ConditionVariable();
                    Show(activity, text, (_) => waitObj.open());
                    waitObj.block();

                    gameRunner.ResumeGame(true);
                }
            }
            return(DialogResult.OK);
        }
        protected virtual GameRunner GetRunner(string map = null)
        {
            if (_runner != null)
            {
                return(_runner);
            }

            map ??= Map;
            if (string.IsNullOrWhiteSpace(map))
            {
                Assert.Inconclusive("Missing Map-argument!");
            }
            try
            {
                _logger.LogInformation("Initializing runner");
                var runner = GameRunner.New(ApiKey, map, _loggerFactory);
                _runner = runner;
                return(runner);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Exception when initializing runner: {ex}");
                throw;
            }
        }
Exemple #3
0
 public FooBarSystem(GameRunner game, FooSystem foo, TestSystem test, EmptySystem empty) : base(game)
 {
     TestSwitch = false;
     _foo       = foo;
     _test      = test;
     _empty     = empty;
 }
Exemple #4
0
        public LevelScene(GameRunner _game, List <TilesetWorldLayer> _tileSetList = null) : base(_game)
        {
            TileSetList = _tileSetList;

            player             = new Player(this);
            player.Position.X += 16;
        }
 public static void NotEnoughQuestions()
 {
     Assert.Throws <System.InvalidOperationException>(() =>
     {
         GameRunner.StartGame(bound => bound == 9 ? 7 : 0);
     });
 }
Exemple #6
0
        /// <summary>Create a temporary game instance for the unpacker.</summary>
        /// <param name="platform">The platform-specific context.</param>
        /// <param name="contentPath">The absolute path to the content folder to import.</param>
        private static GameRunner CreateTemporaryGameInstance(PlatformContext platform, string contentPath)
        {
            var foregroundColor = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.DarkGray;

            try
            {
                GameRunner game = new GameRunner();
                GameRunner.instance = game;

                if (platform.Is(Platform.Windows))
                {
                    game.Content.RootDirectory = contentPath;
                    MethodInfo startGameLoop = typeof(GameRunner).GetMethod("StartGameLoop", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
                    if (startGameLoop == null)
                    {
                        throw new InvalidOperationException("Can't locate game method 'StartGameLoop' to initialise internal game instance.");
                    }
                    startGameLoop.Invoke(game, new object[0]);
                }
                else
                {
                    game.RunOneFrame();
                }

                return(game);
            }
            finally
            {
                Console.ForegroundColor = foregroundColor;
                Console.WriteLine();
            }
        }
Exemple #7
0
        static void Main()
        {
            // Setup
            var maxTrainingTime = TimeSpan.FromMinutes(2);

            var agent0 = new RandomAgent();
            var agent1 = new IfElseAgent();

            var startPlayerDeterminer = new RandomStartPlayerDeterminer();

            // Training
            Train(agent0, agent1, startPlayerDeterminer, maxTrainingTime);

            // Run trained agent
            var runner = new GameRunner(agent0, agent1, startPlayerDeterminer);

            var status = runner.RunGame();

            runner.Moves.ForEach(PrintMove);

            Console.WriteLine($"Game finished: {status.GameStatus}");

            // Running tournament
            Console.WriteLine("starting tournament mode");
            var tournamentRunner = new TournamentRunner(agent0, agent1, startPlayerDeterminer);
            var result           = tournamentRunner.RunGame(TournamentRuns);

            Console.WriteLine($"player 0 : {result.Player0Won} player 1 : {result.Player1Won} draw : {result.Draw}");

            Console.ReadLine();
        }
Exemple #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DanmakuNoKyojin.BulletEngine.Mover"/> class.
        /// </summary>
        /// <param name="gameRef">Game reference</param>
        /// <param name="myBulletManager">My bullet manager.</param>
        public Mover(GameRunner gameRef, IBulletManager myBulletManager) : base(gameRef, myBulletManager)
        {
            Position = Vector2.Zero;
            Rotation = 0f;

            IsAlive = true;
        }
Exemple #9
0
        public BossStructure(GameRunner game, Entity parent, int iteration = 50, float step = 25, PolygonShape polygonShape = null)
        {
            _gameRef = game;
            _parent  = parent;

            _iteration = iteration;
            _step      = step;
            _iteration = iteration;

            _bottomRightVertices = new List <Vector2>();
            _bottomLeftVertices  = new List <Vector2>();
            _topRightVertices    = new List <Vector2>();
            _topLeftVertices     = new List <Vector2>();

            _bottomRightLastDirection = Direction.Left;
            _topRightLastDirection    = Direction.Left;

            if (polygonShape != null)
            {
                _polygonShape = polygonShape;
                _size         = polygonShape.GetSize();
            }
            else
            {
                _polygonShape = new PolygonShape(_gameRef, null);
                GenerateBaseStructure();
            }
        }
Exemple #10
0
    public void FinishedMovement()
    {
        // Just To be sure
        if (database == null)
        {
            GameRunner gr = Manager.GetComponent <GameRunner>();
            this.database = gr.database;
        }

        if (PropAction == Database.PROPERTY_ACTION.INJAIL)     // If he was supposed to go to jail, no action is needed
        {
            NoPlayTurns = 3;
            done();
            return;
        }


        // Get Property
        Property prop = database.GetProperty(playerInfo.x, playerInfo.y);

        PropAction = database.GetNextAction(prop, playerInfo);

        Menu.SetActive(true);

        bpm = Menu.GetComponent <BuyPropertyMenu>();
        bpm.PropertyArriveMessage(prop, playerInfo, database);
        bpm.done = MenuAnswer;
    }
 public GameRunner(GameRunner another)
 {
     this.GameBoard     = another.GameBoard.Clone();
     this.AI            = another.AI;
     this.PlayerManager = another.PlayerManager;
     this.UnplayedTiles = another.UnplayedTiles.Select(item => (Tile)item.Clone()).ToList();
 }
Exemple #12
0
 static void Main(string[] args)
 {
     using (var runner = new GameRunner())
     {
         runner.Run();
     }
 }
Exemple #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameBuilder"/> class.
 /// </summary>
 public GameBuilder()
 {
     _commandBindings = new Dictionary <string, Type>();
     ServerLog.LogInfo($"Game server {Assembly.GetCallingAssembly().GetName().Name} is now building...");
     // Prime our game runner, and add to it as we construct the builder
     _game = new GameRunner();
 }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            GameRunner.loadingMessage();
            Application.LoadLevel("_Start_Screen");
        }

        if (Application.loadedLevelName == "_Start_Screen")
        {
            StartScreenRun();
        }
        else if (Application.loadedLevelName == "_Level_Selection")
        {
            LevelSelection();
        }
        else if (Application.loadedLevelName == "_Success")
        {
            Success();
        }

        if (Application.loadedLevelName == "_Instructions")
        {
            if (Input.GetKey(KeyCode.Return))
            {
                GameRunner.loadingMessage();
                Application.LoadLevel("_Start_Screen");
            }
        }
    }
Exemple #15
0
        public void GivenGame_WhenRunWithGoldenMasterInput_ThenOutputIsTheSameAsGoldenMasterOutput()
        {
            using (var istrm = new FileStream("Input.txt", FileMode.Open, FileAccess.Read))
                using (var gstrm = new FileStream("GoldenMaster.txt", FileMode.Open, FileAccess.Read))
                    using (var input = new StreamReader(istrm))
                        using (var goldenMaster = new StreamReader(gstrm))
                            using (var output = new StringWriter())
                            {
                                var @out = Console.Out;
                                Console.SetOut(output);
                                var values = input.ReadToEnd().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);

                                var randomizer = new RandomStub(values);

                                for (var i = 0; i < 5000; i++)
                                {
                                    GameRunner.Run(randomizer);
                                    Console.WriteLine("Exiting " + randomizer.Count + Environment.NewLine);
                                }

                                var runOutput = output.ToString();
                                File.WriteAllText("Output.txt", runOutput);

                                Console.SetOut(@out);

                                Assert.That(runOutput, Is.EqualTo(goldenMaster.ReadToEnd()));
                            }
        }
        public void CompareOutputAgainstGoldenSource([Range(0, 99)] int seed)
        {
            // Arrange
            var gameOutputStringBuilder = new StringBuilder();

            using (var gameOutput = new StringWriter(gameOutputStringBuilder))
            {
                Console.SetOut(gameOutput);
                var dice = new Dice();
                var consoleGameLogger = new ConsoleGameLogger();
                var categorySelector  = new CategorySelector();
                var questionFactory   = new QuestionFactory();
                var game   = new Game(consoleGameLogger, categorySelector, questionFactory);
                var random = new Random(seed);
                var randomAnsweringStrategy = new RandomAnsweringStrategy(random);

                var gameRunner = new GameRunner(dice, randomAnsweringStrategy, random, game);

                // Act
                gameRunner.Start();

                // Assert
                var actualGameOutput   = gameOutputStringBuilder.ToString();
                var expectedGameOutput = File.ReadAllText($@"c:\TestData\GoldenData_{seed}.txt");
                actualGameOutput.Should().BeEquivalentTo(expectedGameOutput);
            }
        }
Exemple #17
0
        public void OnPost()
        {
            List <Competitor> competitors = _db.Competitors.ToList();

            if (!competitors.Any())
            {
                competitors = GetDefaultCompetitors();
                _db.Competitors.AddRange(competitors);
                _db.SaveChanges();
            }

            var gameRunner = new GameRunner();

            foreach (var competitor in competitors)
            {
                BaseBot bot = CreateBotFromCompetitor(competitor);
                gameRunner.AddBot(bot);
            }

            GameRunnerResult gameRunnerResult = gameRunner.StartAllMatches();

            SaveResults(gameRunnerResult);
            BotRankings    = gameRunnerResult.GameRecord.BotRecords.OrderByDescending(x => x.Wins).ToList();
            AllFullResults = gameRunnerResult.AllMatchResults.OrderBy(x => x.Competitor.Name).ToList();
        }
    public void SetSelectedShipAction(int actionID)
    {
        if (selectedObject != null && canUpdateCmds)
        {
            ShipController shipController = selectedObject.GetComponent <ShipController>();

            if (shipController != null && shipController.shipOwner == playerID)
            {
                ShipCommand shipCommand = GetShipCommand(shipController);

                List <ShipAction> shipActions = new List <ShipAction>(GlobalShipActions.ShipActions());

                if (shipActions.Count > actionID && 0 <= actionID)
                {
                    List <ShipActionAvailablityEnum> actionAvailability = GameRunner.GetShipActionAvailability(shipController, shipCommand);

                    if (actionAvailability[actionID] == ShipActionAvailablityEnum.ENABLED)
                    {
                        shipCommand.shipAction = shipActions[actionID];
                        shipController.UpdateActionVisual();
                    }
                }
            }
        }

        UpdateCommandUI();
        UpdateInfoUI();
    }
Exemple #19
0
        private static void RegisterAccount()
        {
            Console.Clear();
            Console.WriteLine("-=Регистрация аккаунта=-");
            Console.Write("Введите логин: ");
            var userName = Console.ReadLine();

            Console.Write("Введите пароль: ");
            var password = Console.ReadLine();

            Console.Write("Подтвердите пароль: ");
            var confirmPassword = Console.ReadLine();

            var serverInfoUrl = ApiHelper.GetApiServerUri(_serverInfo, userName, _serverPort);

            var authApi = new AuthApiClient(new PasswordOAuthContext()
            {
                BaseUri = serverInfoUrl
            });

            try
            {
                var result = authApi.Register(new RegisterAccountModel()
                {
                    Login           = userName,
                    Password        = password,
                    ConfirmPassword = confirmPassword
                }).Result;
            }
            catch (AggregateException loginException)
            {
                ErrorCode = GameRunner.HandleClientException(loginException.InnerException as IClientException <ErrorData>);
            }
        }
Exemple #20
0
        public void CompareMaster()
        {
            TextWriter oldConsole = Console.Out;

            using (var fs = new FileStream("testRun.txt", FileMode.Create))
            {
                using (var sw = new StreamWriter(fs))
                {
                    Console.SetOut(sw);

                    // begin capture  output
                    for (int i = 0; i < 1000; i++)
                    {
                        Random r = new Random(i);
                        GameRunner.RunGame(r);
                    }
                    // save output

                    sw.Flush();
                    fs.Flush();
                }
            }
            Console.SetOut(oldConsole);

            var master  = File.ReadAllText("gameResult.txt");
            var testRun = File.ReadAllText("testRun.txt");

            Assert.AreEqual(master, testRun);
        }
Exemple #21
0
        static void Main(string[] args)
        {
            var runner = new GameRunner();

            runner.PreStart += AttachHooks;
            runner.Main(args);
        }
Exemple #22
0
 public static void Main()
 {
     using (var runner = new GameRunner())
     {
         runner.Run();
     }
 }
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main()
 {
     using (var game = new GameRunner())
     {
         game.Run();
     }
 }
Exemple #24
0
        public void GenerateTestData([Range(0, 99)] int testRunId)
        {
            if (!Directory.Exists(TestDataPath))
            {
                Directory.CreateDirectory(TestDataPath);
            }

            var filePath = Path.Combine(TestDataPath, $@"GoldenData_{testRunId}.txt");

            if (!File.Exists(filePath))
            {
                using (var gameOutput = File.CreateText(filePath))
                {
                    Console.SetOut(gameOutput);

                    var dice = new Dice();
                    var consoleGameLogger = new ConsoleGameLogger();
                    var game   = new Game(consoleGameLogger, new DefaultGameRegion());
                    var random = new Random(testRunId);
                    var randomAnsweringStrategy = new RandomAnsweringStrategy(random);

                    var gameRunner = new GameRunner(dice, randomAnsweringStrategy, random, game);
                    gameRunner.Start();

                    gameOutput.Flush();
                }

                Assert.Pass("Master data file created successfully.");
            }
            else
            {
                Assert.Pass("Master data already exists.");
            }
        }
Exemple #25
0
 public GameRunnerTests()
 {
     _gameManagerMock       = new Mock <IGameManager>();
     _gamePrinterMock       = new Mock <IGamePrinter>();
     _userInputProviderMock = new Mock <IUserInputProvider>();
     _gameRunner            = new GameRunner(_gameManagerMock.Object, _gamePrinterMock.Object, _userInputProviderMock.Object);
 }
Exemple #26
0
        static void Main(string[] args)
        {
            GameRunner runner = new GameRunner();

            runner.Setup();
            runner.Run();
        }
        private static void Run()
        {
            Console.WriteLine("Resize your terminal and press any key if you are ready!");
            Console.ReadKey();

            var gameSettings = new GameSettings(
                new Vector2(18.0f, 10.0f),
                60.0f,
                1.0f,
                0.1f,
                0.2f,
                new Vector2(0.2f, 0.5f),
                4.0f
                );

            var consoleView = new ConsoleView(gameSettings);

            var runner = new GameRunner();

            var leftController  = new Controller.JanReinhardt.NaiveController();
            var rightController = new Controller.JanReinhardt.NaiveController();

            runner.Run(gameSettings, consoleView, leftController, rightController);

            Console.WriteLine("Press any key to exit:");
            Console.ReadKey();
        }
Exemple #28
0
        private static void TryLogin()
        {
            Tuple <PasswordOAuthContext, string> loginResultTuple;

            if (string.IsNullOrEmpty(_userName))
            {
                Console.Write("Введите логин: ");
                _userName = Console.ReadLine();

                Console.Write("Введите пароль: ");
                _userPassword = Console.ReadLine();
            }
            try
            {
                Console.Clear();
                Console.WriteLine("-=Вход=-");
                loginResultTuple = ApiHelper.UserLogin(_serverInfo, _serverPort, _userName, _userPassword).Result;
            }
            catch (AggregateException loginException)
            {
                GameRunner.HandleClientException(loginException.InnerException as IClientException <ErrorData>);
                loginResultTuple = null;
                _userName        = null;
            }

            if (loginResultTuple != null)
            {
                EnterGame(loginResultTuple);
                Console.Clear();
            }
        }
Exemple #29
0
        public GameRunnerTest()
        {
            var uiMock = new Mock <IUserInterface>();

            _gameMock        = new Mock <IGame <GameState> >();
            _strategyFactory = new Mock <IStrategyFactory>();
            _sut             = new GameRunner(_gameMock.Object, uiMock.Object, _strategyFactory.Object);
        }
Exemple #30
0
 // Use this for initialization
 void Start()
 {
     scriptObject = GameObject.Find("ScriptObject");
     gameRunner   = scriptObject.GetComponent <GameRunner>();
     //
     handObject = GameObject.Find("HandRunner");
     handRunner = handObject.GetComponent <HandScript>();
 }
        public void Run_until_there_is_a_winner()
        {
            GameRunner.Main(new string[] { "Louis is handsome" });

            var expectedOutput = File.ReadAllText(@"C:\Users\Charlie.Crisp\Documents\trivia\C#\Trivia\Trivia.Tests\expectedOutput.txt");

            Assert.That(_output.ToString(), Is.EqualTo(expectedOutput));
        }
Exemple #32
0
    void Start()
    {
        S = this;
        curPlayer = 0;
        //error checking
        if(playerMat.Length != 3){
            Debug.Log("Error with player Material Array size");
        }
        if(butNodeInputs.Length!=9){
            Debug.Log("Error with button node inputs length");
        }
        if(butDirInputs.Length!=4){
            Debug.Log("Error with button direction inputs length");
        }
        //load player inputs if avalible
        playerNames=new string[4];
        playerNames[2]="It is a draw";
        playerNames[3]="Both players win...so its a draw";
        //dont destroy on load object from menu
        if(Game_Loader.S!= null){
            playerNames [0] = Game_Loader.S.playNames[0];
            playerNames [1] = Game_Loader.S.playNames [1];

            playerMat[0].color = Game_Loader.S.playCol[0];
            playerMat[1].color = Game_Loader.S.playCol[1];
            }

        playerTurnIndicator [0].color = playerMat [0].color;
        playerTurnIndicator [1].color = turnNotActive;
        playerTurnIndicator [0].enabled = false;
        playerTurnIndicator [1].enabled = false;

        StartCoroutine (waitToStart());
    }
Exemple #33
0
        public void RunGameWithSpecificSeed()
        {
            var builder = new StringBuilder();
            var writer = new StringWriter(builder);

            var gameRunner = new GameRunner();
            foreach (var seed in Enumerable.Range(0, 100))
            {
                gameRunner.RunGame(writer, seed);
            }

            var result = builder.ToString();

            var resultLines = result.Split(new[] {Environment.NewLine}, StringSplitOptions.None);
            var expectedLines = expectedOutput.Split(new[] {Environment.NewLine}, StringSplitOptions.None);

            resultLines.Length.Should().Be(expectedLines.Length);

            foreach (var pair in expectedLines.Zip(resultLines, (expectedLine, resultLine) => new {expectedLine, resultLine}))
            {
                pair.resultLine.Should().Be(pair.expectedLine);
            }
        }