コード例 #1
0
ファイル: Player.cs プロジェクト: ViMaSter/thearcadearcade
        private void OnRunning()
        {
            UpdateActScore();
            if (HasLost())
            {
                currentState = State.READY;
                LaunchGame();
                return;
                // @TODO: reduce life
            }

            if (HasWon())
            {
                // Try to finish this act...
                if (activeScene.FinishAct() == -1)
                {
                    // ... either there are no acts left
                    emulator = null;
                    Helper.WinAPI.SetForegroundWindow(Process.GetCurrentProcess().MainWindowHandle);
                    MessageBox.Show(string.Format("Current score: {0}", scorePerAct.Sum()), "Game completed!", MessageBoxButton.OK);
                    Environment.Exit(0);
                    // @TODO: Submit high-score
                }
                else
                {
                    // ... or we proceed to next game
                    nextGame     = activeScene.CurrentAct.Game;
                    currentState = State.READY;
                    LaunchGame();
                }

                return;
            }
        }
コード例 #2
0
ファイル: Scene.cs プロジェクト: ViMaSter/thearcadearcade
 /// <summary>
 /// Fill in additional game data like filename and memory regions
 /// </summary>
 /// <param name="gameData"></param>
 public void FillGameData(GameHooks.Game gameData)
 {
     Debug.Assert(!game.IsValid, "Game data already filled!", "Trying to set information about game {0} ({1}) for {2} which is already fileld!", game.Name, game.Region, game.Platform);
     if (!game.IsValid)
     {
         game = gameData;
     }
 }
コード例 #3
0
ファイル: Scene.cs プロジェクト: ViMaSter/thearcadearcade
        public bool IsFulfilled(GameHooks.Game game, GameHooks.Emulator emulator)
        {
            Debug.Assert(memoryStates.Length > 0, "No memory states available!", "IsFulfilled was called, but no memory states are defined! This is undefined behavior!");
            byte value = 0x00;

            foreach (MemoryState memoryState in memoryStates)
            {
                value = game.GetMemoryArea(memoryState.Area).GetByte(emulator);
                bool?statePassed = null;
                switch (memoryState.ComparisonOperator)
                {
                case "<":
                    statePassed = value < Convert.ToInt32(memoryState.Value);
                    break;

                case "<=":
                    statePassed = value <= Convert.ToInt32(memoryState.Value);
                    break;

                case ">":
                    statePassed = value > Convert.ToInt32(memoryState.Value);
                    break;

                case ">=":
                    statePassed = value >= Convert.ToInt32(memoryState.Value);
                    break;

                case "==":
                    statePassed = value == Convert.ToInt32(memoryState.Value);
                    break;
                }

                Debug.Assert(statePassed != null,
                             "Invalid comparision operator used; '{0}' is not supported (Comparing field {1} with value {2})",
                             memoryState.ComparisonOperator,
                             memoryState.Area,
                             memoryState.Value
                             );

                if (!statePassed.HasValue)
                {
                    break;
                }

                if (logicGate == "OR" && statePassed.Value)
                {
                    return(true);
                }

                if (logicGate == "AND" && !(statePassed.Value))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #4
0
        public PlatformGameList(string _platform)
        {
            platform = _platform;

            string[] gameConfigs = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "platforms", _platform, "games"), "*.json");
            foreach (string gameConfigFilePath in gameConfigs)
            {
                GameHooks.Game game = GameHooks.Game.FromJSON(gameConfigFilePath);
                if (game.Platform == platform)
                {
                    games.Add(game);
                }
            }
        }
コード例 #5
0
ファイル: Player.cs プロジェクト: ViMaSter/thearcadearcade
        private void LaunchGame()
        {
            nextGame     = activeScene.CurrentAct.Game;
            nextArgument = activeScene.CurrentAct.Arguments;
            currentState = State.READY;
            int gameStartStatus = emulator.StartGame(nextGame, Path.Combine(activeScene.RootPath, nextArgument));

            if (gameStartStatus == 0)
            {
                nextGame     = null;
                nextArgument = null;
            }
            else
            {
                Console.WriteLine("Couldn't launch game {0}: Error code {1}", nextGame.Name, gameStartStatus);
                currentState = State.ERROR;
                nextGame     = null;
            }
        }