Exemplo n.º 1
0
    private void OnFileCreated(object source, FileSystemEventArgs e)
    {
        // Debug.Log($"New JSON Frame File: {e.FullPath} {e.ChangeType}");
        if (e.ChangeType == WatcherChangeTypes.Created)
        {
            var        text = File.OpenText(e.FullPath);
            SlippiGame game = JsonUtility.FromJson <SlippiGame>(text.ReadToEnd());
            // Debug.Log("Adding " + game.frames.Count);
            // Debug.Log("Total Frames: " + framesForCurrentMatch.Count);

            if (parser.game.gameFinished)
            {
                parser.nextGame.frames.AddRange(game.frames);
            }
            else
            {
                parser.game.frames.AddRange(game.frames);
            }

            if (e.FullPath.Contains("_FINAL"))
            {
                parser.game.gameFinished = true;
            }
        }
    }
Exemplo n.º 2
0
        void EndMatch()
        {
            Debug.Log("END MATCH");
            matchStarted     = false;
            game             = null;
            counter          = 0;
            world.localScale = new Vector3(1, 1, 1);
            // Remove all Smash Objects from the scene
            foreach (Transform child in world.transform)
            {
                GameObject.Destroy(child.gameObject);
            }
            ShowWaitingForNextMatch();

            if (nextGame != null)
            {
                game     = nextGame;
                nextGame = null;
                //matchStarted = true;
            }
        }
Exemplo n.º 3
0
    // Define the event handlers.
    private void OnChangedDirectory(object source, FileSystemEventArgs e)
    {
        // Specify what is done when a file is changed, created, or deleted.
        //Debug.Log($"File: {e.FullPath} {e.ChangeType}");
        if (e.ChangeType == WatcherChangeTypes.Created)
        {
            Debug.Log("New Match Started");

            framesForCurrentMatch = new List <SlippiFramePlayerInfo>();

            liveMatchWatcher      = new FileSystemWatcher();
            liveMatchWatcher.Path = e.FullPath;

            liveMatchWatcher.NotifyFilter = NotifyFilters.LastAccess
                                            | NotifyFilters.LastWrite
                                            | NotifyFilters.FileName
                                            | NotifyFilters.DirectoryName;

            liveMatchWatcher.Created            += OnFileCreated;
            liveMatchWatcher.EnableRaisingEvents = true;

            var        text = File.OpenText(e.FullPath + "/init.json");
            SlippiGame game = JsonUtility.FromJson <SlippiGame>(text.ReadToEnd());


            if (parser.game != null && parser.game.gameFinished)
            {
                parser.nextGame = game;
            }
            else
            {
                parser.game = game;
                parser.StartMatch();
            }
        }
    }