Exemplo n.º 1
0
        private void MapInteractionOverlay_TextChanged(object sender, TextChangedEventArgs e)
        {
            MapTileInteraction selectedInteraction = (MapTileInteraction)MapInteractionList.SelectedItem;

            if (selectedInteraction != null)
            {
                try
                {
                    TileBlockOverlay overlay = JsonConvert.DeserializeObject <TileBlockOverlay>(MapInteractionOverlay.Text);

                    if (overlay != null && (overlay.PaletteIndex < 0 || overlay.PaletteIndex >= 8))
                    {
                        throw new Exception();
                    }

                    MapInteractionOverlay.Foreground = new SolidColorBrush(Colors.White);
                    selectedInteraction.Overlay      = overlay;

                    BlockSelector.Update(tileIndex: BlockSelector.SelectedBlockValue);
                    UpdateTileBlock();
                    SetUnsaved();
                }
                catch
                {
                    MapInteractionOverlay.Foreground = new SolidColorBrush(Colors.Red);
                }
            }
        }
Exemplo n.º 2
0
        public void Update(BlockSelector blockSelector)
        {
            if (player.LeftClick && !game.ExitedMenu)
            {
                player.SetLastClickTime();
                RemoveBlock();
            }

            else if (player.RightClick)
            {
                player.SetLastClickTime();
                AddBlock();
            }

            if (y != -1 && region[position][x, y, z] != null)
            {
                bool[] visibleFaces = new bool[6];
                region[position].GetVisibleFaces(visibleFaces, y, x, z);

                blockSelector.Update(visibleFaces, new Vector3(x, y, z) - position, player.Camera.Direction);
            }
            else
            {
                blockSelector.Clear();
            }
        }
Exemplo n.º 3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            CommitInteractions();

            _tileService.CommitTileSet(_currentLevel?.TileSetIndex ?? _currentWorld.TileSetIndex, _localTileSet, _localTileTerrain, _localMapTileInteraction);
            BlockSelector.Update();
            UpdateTileBlock();
            SetSaved();
            _projectService.SaveProject();
        }
Exemplo n.º 4
0
        private void TileBlockImage_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Point clickPoint = Snap(e.GetPosition((Image)sender));

            if (clickPoint.X <= 15 && clickPoint.Y <= 15)
            {
                BlockSelector.SelectedTileBlock.UpperLeft = _graphicTileIndexSelected;
                if (_isQuadSelected)
                {
                    BlockSelector.SelectedTileBlock.UpperRight = _graphicTileIndexSelected + 1;
                    BlockSelector.SelectedTileBlock.LowerLeft  = _graphicTileIndexSelected + 0x10;
                    BlockSelector.SelectedTileBlock.LowerRight = _graphicTileIndexSelected + 0x11;
                }
            }
            else if (clickPoint.X <= 15 && clickPoint.Y >= 16)
            {
                BlockSelector.SelectedTileBlock.LowerLeft = _graphicTileIndexSelected;

                if (_isQuadSelected)
                {
                    BlockSelector.SelectedTileBlock.LowerRight = _graphicTileIndexSelected + 1;
                    BlockSelector.SelectedTileBlock.UpperLeft  = _graphicTileIndexSelected + 0x10;
                    BlockSelector.SelectedTileBlock.UpperRight = _graphicTileIndexSelected + 0x11;
                }
            }
            else if (clickPoint.X >= 16 && clickPoint.Y <= 15)
            {
                BlockSelector.SelectedTileBlock.UpperRight = _graphicTileIndexSelected;

                if (_isQuadSelected)
                {
                    BlockSelector.SelectedTileBlock.UpperLeft  = _graphicTileIndexSelected + 0x1;
                    BlockSelector.SelectedTileBlock.LowerRight = _graphicTileIndexSelected + 0x10;
                    BlockSelector.SelectedTileBlock.LowerLeft  = _graphicTileIndexSelected + 0x11;
                }
            }
            else if (clickPoint.X >= 16 && clickPoint.Y >= 16)
            {
                BlockSelector.SelectedTileBlock.LowerRight = _graphicTileIndexSelected;

                if (_isQuadSelected)
                {
                    BlockSelector.SelectedTileBlock.LowerLeft  = _graphicTileIndexSelected + 0x1;
                    BlockSelector.SelectedTileBlock.UpperRight = _graphicTileIndexSelected + 0x10;
                    BlockSelector.SelectedTileBlock.UpperLeft  = _graphicTileIndexSelected + 0x11;
                }
            }

            BlockSelector.Update(tileIndex: BlockSelector.SelectedBlockValue);
            UpdateTileBlock();
            SetUnsaved();
        }
Exemplo n.º 5
0
        private void MapInteractionList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MapTileInteraction selectedIteraction = (MapTileInteraction)MapInteractionList.SelectedItem;

            if (selectedIteraction != null)
            {
                BlockSelector.SelectedTileBlock.Property = ((MapTileInteraction)MapInteractionList.SelectedItem).Value;
                MapInteractionOverlay.Text = JsonConvert.SerializeObject(selectedIteraction.Overlay, Formatting.Indented);

                BlockSelector.Update(tileIndex: BlockSelector.SelectedBlockValue);
                UpdateTileBlock();
                SetUnsaved();
            }
        }
Exemplo n.º 6
0
        private void TerrainList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TileTerrain selectedTerrain = (TileTerrain)TerrainList.SelectedItem;

            InteractionList.ItemsSource   = selectedTerrain.Interactions;
            InteractionList.SelectedIndex = (int)(BlockSelector.SelectedTileBlock.Property & TileInteraction.Mask);

            BlockSelector.SelectedTileBlock.Property = selectedTerrain.Value | ((TileInteraction)InteractionList.SelectedItem).Value;
            TerrainOverlay.Text = JsonConvert.SerializeObject(selectedTerrain.Overlay, Formatting.Indented);

            BlockSelector.Update(tileIndex: BlockSelector.SelectedBlockValue);
            UpdateTileBlock();
            SetUnsaved();
        }
Exemplo n.º 7
0
        private void BlockSelectorBorder_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if ((e.ButtonState & e.RightButton) > 0)
            {
                _copiedblock = BlockSelector.SelectedTileBlock;
            }

            if ((e.ButtonState & e.MiddleButton) > 0)
            {
                BlockSelector.SelectedTileBlock.UpperLeft  = _copiedblock.UpperLeft;
                BlockSelector.SelectedTileBlock.UpperRight = _copiedblock.UpperRight;
                BlockSelector.SelectedTileBlock.LowerLeft  = _copiedblock.LowerLeft;
                BlockSelector.SelectedTileBlock.LowerRight = _copiedblock.LowerRight;
                BlockSelector.Update();
                UpdateTileBlock();
                SetUnsaved();
            }
        }
Exemplo n.º 8
0
        private void _graphicsService_GraphicsUpdated()
        {
            if (_currentLevel != null)
            {
                _graphicsAccessor.SetBottomTable(_graphicsService.GetTileSection(_currentLevel.AnimationTileTableIndex));
                _graphicsAccessor.SetTopTable(_graphicsService.GetTileSection(_currentLevel.StaticTileTableIndex));
            }
            else if (_currentWorld != null)
            {
                Tile[] staticTiles   = _graphicsService.GetTileSection(_currentWorld.TileTableIndex);
                Tile[] animatedTiles = _graphicsService.GetTileSection(_currentWorld.AnimationTileTableIndex);

                _graphicsAccessor.SetBottomTable(staticTiles);
                _graphicsAccessor.SetTopTable(animatedTiles);
            }

            _graphicsAccessor.SetGlobalTiles(_graphicsService.GetGlobalTiles(), _graphicsService.GetExtraTiles());
            UpdateTileBlock();
            UpdateGraphics();
            BlockSelector.Update();
        }
Exemplo n.º 9
0
 private void ShowTerrain_Click(object sender, RoutedEventArgs e)
 {
     BlockSelector.Update(withMapInteractionOverlay: _currentLevel != null ? ShowTerrain.IsChecked.Value : false);
     UpdateTileBlock();
 }
Exemplo n.º 10
0
        private void LevelList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            _ignoreChanges = true;
            if (LevelList.SelectedItem is LevelInfo)
            {
                PSwitchSection.IsEnabled      = IceballSection.IsEnabled = FireballSection.IsEnabled = true;
                TileDefinitions.Visibility    = LevelTileSection.Visibility = Visibility.Visible;
                MapTileDefinitions.Visibility = MapTileSection.Visibility = Visibility.Collapsed;

                LevelInfo levelInfo = (LevelInfo)LevelList.SelectedItem;
                _currentLevel = _levelService.LoadLevel(levelInfo);
                _currentWorld = null;

                Tile[]  staticTiles   = _graphicsService.GetTileSection(_currentLevel.StaticTileTableIndex);
                Tile[]  animatedTiles = _graphicsService.GetTileSection(_currentLevel.AnimationTileTableIndex);
                Palette palette       = _palettesService.GetPalette(_currentLevel.PaletteId);

                _graphicsAccessor.SetBottomTable(animatedTiles);
                _graphicsAccessor.SetTopTable(staticTiles);

                _localTileSet = JsonConvert.DeserializeObject <TileSet>(JsonConvert.SerializeObject(_tileService.GetTileSet(_currentLevel.TileSetIndex)));

                _ignoreChanges = false;
                _graphicsSetRenderer.Update(palette);
                BlockSelector.Update(tileSet: _localTileSet, palette: palette, withProjectileInteractions: false);
                UpdateGraphics();
                UpdateTileBlock();
                LoadInteractions();
            }
            else if (LevelList.SelectedItem is WorldInfo)
            {
                PSwitchSection.IsEnabled      = IceballSection.IsEnabled = FireballSection.IsEnabled = false;
                TileDefinitions.Visibility    = LevelTileSection.Visibility = Visibility.Collapsed;
                MapTileDefinitions.Visibility = MapTileSection.Visibility = Visibility.Visible;

                if (MapInteractionList.SelectedIndex == -1)
                {
                    MapInteractionList.SelectedIndex = 0;
                }

                WorldInfo worldInfo = (WorldInfo)LevelList.SelectedItem;
                _currentWorld = _worldService.LoadWorld(worldInfo);
                _currentLevel = null;

                Tile[]  staticTiles   = _graphicsService.GetTileSection(_currentWorld.TileTableIndex);
                Tile[]  animatedTiles = _graphicsService.GetTileSection(_currentWorld.AnimationTileTableIndex);
                Palette palette       = _palettesService.GetPalette(_currentWorld.PaletteId);

                _graphicsAccessor.SetBottomTable(staticTiles);
                _graphicsAccessor.SetTopTable(animatedTiles);

                _localTileSet = JsonConvert.DeserializeObject <TileSet>(JsonConvert.SerializeObject(_tileService.GetTileSet(0)));
                _graphicsSetRenderer.Update(palette);

                _ignoreChanges = false;

                _graphicsSetRenderer.Update(palette);
                BlockSelector.Update(tileSet: _localTileSet, palette: palette, withProjectileInteractions: false);
                UpdateGraphics();
                UpdateTileBlock();
            }
        }