Пример #1
0
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            SequencePath.IsEnabled    = false;
            MarkerPath.IsEnabled      = false;
            FromIndex.IsEnabled       = false;
            ToIndex.IsEnabled         = false;
            ChunkSize.IsEnabled       = false;
            MaxChunks.IsEnabled       = false;
            ThresholdSlider.IsEnabled = false;

            StartButton.Content = "Stop";
            StartButton.Click  -= StartButton_Click;
            StartButton.Click  += StopButton_Click;

            var sequencePath = SequencePath.Text;
            var markerPath   = MarkerPath.Text;
            var threshold    = ThresholdSlider.Value / 100;
            var chunkSize    = 0;
            var maxChunks    = 0;
            var fromIndex    = 0;
            var toIndex      = -1;

            int.TryParse(FromIndex.Text, out fromIndex);
            int.TryParse(ToIndex.Text, out toIndex);
            int.TryParse(ChunkSize.Text, out chunkSize);
            int.TryParse(MaxChunks.Text, out maxChunks);

            dispatcherTimer          = new DispatcherTimer();
            dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = TimeSpan.FromMilliseconds(100);
            dispatcherTimer.Start();
            ticks = 0;

            var markers              = MarkerParser.ParseFile(markerPath);
            var chunk                = Math.Max(markers.Max(m => m.Length) * 3, chunkSize);
            var concurrentMax        = Math.Max(64, maxChunks);
            var slidingStepRemainder = (int)((3 - threshold * 2) * markers.Max(m => m.Length) - 1);

            ChunkSize.Text = chunk.ToString();
            MaxChunks.Text = concurrentMax.ToString();

            cancellationTokenSource = new CancellationTokenSource();
            CancellationToken token = cancellationTokenSource.Token;

            task = Task <List <ParsingResult> > .Run(() => {
                var results = new List <ParsingResult>();

                foreach (var marker in markers)
                {
                    results.Add(new ParsingResult(marker));
                }

                context           = new ParsingContext(results);
                context.Threshold = threshold;

                AnalysisParser.ParseFile(sequencePath, fromIndex, toIndex, chunk, slidingStepRemainder, concurrentMax, context, cancellationTokenSource);

                return(context.parsingResults);
            }, token);
        }
Пример #2
0
 /* Install a special processing method for COM or APPn markers. */
 public void SetMarkerProcessor(int markerCode, MarkerParser routine)
 {
     jpeg_decompress_struct.jpeg_marker_parser_method f = delegate { return(routine(this)); };
     m_decompressor.jpeg_set_marker_processor(markerCode, f);
 }
Пример #3
0
		/* Install a special processing method for COM or APPn markers. */
		public void SetMarkerProcessor(int markerCode, MarkerParser routine)
		{
			jpeg_decompress_struct.jpeg_marker_parser_method f = delegate { return routine(this); };
			m_decompressor.jpeg_set_marker_processor(markerCode, f);
		}
Пример #4
0
        /* Install a special processing method for COM or APPn markers. */
        public void SetMarkerProcessor(int markerCode, MarkerParser routine)
        {
            bool f(JpegDecompressStruct _) => routine(this);

            ClassicDecompressor.JpegSetMarkerProcessor(markerCode, f);
        }
Пример #5
0
        public void LoadMap(bool fullReset, string atDoor = "")
        {
            var map = Map.LoadFromFile(this.mapPath);

            var doors = map.Tiles.FindAll(x => x.TileType == TileType.Door);

            if (this.mapPath.Contains("mudtrap") || this.mapPath.Contains("mushroom"))
            {
                SceneManager.SoundManager.PlaySong("theme", 0.8f);
            }
            else if (this.mapPath.Contains("dungeon"))
            {
                SceneManager.SoundManager.PlaySong("adventure", 0.7f);
            }
            else
            {
                SceneManager.SoundManager.PlaySong("clora", 0.8f);
            }

            //whacky
            if (atDoor == "LAST")
            {
                atDoor = lastDoor;
            }

            this.lightSources.Clear();
            this.ClearTiles();
            if (fullReset) // use if not the first loading
            {
                this.gameObjects.RemoveAll(x => x.Name != "player");
            }

            // load tiles
            foreach (Tile tile in map.Tiles)
            {
                try
                {
                    // load the texture
                    if (tile.TileType != TileType.Door)
                    {
                        tile.Sprite.Texture = AssetLoader.LoadTexture("Assets/Textures/tiles/" + tile.Name + ".png");
                    }
                    else
                    {
                        tile.Sprite.Texture = AssetLoader.LoadTexture("Assets/Textures/tiles/" + tile.Name.Split(';')[0] + ".png");
                    }
                }
                catch (System.IO.FileNotFoundException fnfe)
                {
                    var a = 0;
                }

                /*if (tile.Name == "ocean1" || tile.Name == "wood_base" || tile.Name == "wood_wall")
                 *  tile.SetType(TileType.Block);*/
                tile.SetMapCoords(50);



                if (tile.Name != null && tile.Name != "delete")
                {
                    // check for an animation tile and add it
                    if (tile.Sprite.Texture.Width > 50)
                    {
                        var animtile = new AnimationTile(tile.Name, tile.Transform.Position, tile.Sprite.Texture, tile.TileType);
                        animtile.SetMapCoords(50);
                        this.AddTile(animtile);
                    }
                    else
                    {
                        this.AddTile(tile);
                    }
                }
            }
            // try to find the player's starting position
            var playerStart = map.Markers.Find(x => x.MarkerType == MarkerType.PlayerSpawnPoint);

            if (playerStart != null && atDoor == "")
            {
                player.Transform.Position = playerStart.StartingPosition;
            }
            else if (atDoor != "" || (atDoor == "" && lastDoor != "")) // if loading in at a door
            {
                if (atDoor == "")
                {
                    atDoor = lastDoor;
                }
                else
                {
                    lastDoor = atDoor;
                }
                // find the specific door with the specific given door data name
                var door = doors.Find(x => x.Data != null && x.Data.Contains(atDoor));
                if (door != null)
                {
                    player.Transform.Position = new Vector2(door.Transform.Position.X, door.Transform.Position.Y + player.Sprite.Texture.Height);
                }
            }

            // parse through enemies
            var enemies = MarkerParser.ParseEnemies(map.Markers);

            foreach (Enemy enemy in enemies)
            {
                // if it's a boss, start the attack
                if (enemy.GetType() == typeof(MushroomBoss))
                {
                    enemy.StartAttack(player);
                }
                this.AddGameObject(enemy);
            }



            // parse through npcs
            var npcs = MarkerParser.ParseNPCs(map.Markers);

            foreach (NPC npc in npcs)
            {
                this.AddGameObject(npc);
            }

            // get light sources
            var lights = MarkerParser.ParseLightsources(map.Markers);

            foreach (LightSource ls in lights)
            {
                this.AddLightSource(ls);
            }

            // reset player
            player.Reset();
            if (player.EntityStats != null)
            {
                player.EntityStats.HP = player.EntityStats.FullStats.MaxHP;
            }

            statsFrame.player = player;

            // reload
            base.Load();

            //this.AddLightSource(new LightSource(Vector2.One, Vector2.One, Color.White));

            /*Pickup pickup = new Pickup();
             * pickup.Transform.Position = player.Transform.Position;
             * pickup.PickupItem = ItemData.ironHelmet;
             * this.AddGameObject(pickup);*/
            /*MushroomMinion mush = new MushroomMinion();
             * mush.Transform.Position = new Vector2(500, 500);
             * mush.Load();
             * this.AddGameObject(mush);*/
        }