Ejemplo n.º 1
0
 public PickerTool(WorldViewModel worldViewModel)
     : base(worldViewModel)
 {
     Icon     = new BitmapImage(new Uri(@"pack://application:,,,/TEditXna;component/Images/Tools/eyedropper.png"));
     ToolType = ToolType.Pixel;
     Name     = "Picker";
 }
 public MainWindow()
 {
     InitializeComponent();
     DataContext = ViewModelLocator.WorldViewModel;
     _vm         = (WorldViewModel)DataContext;
     AddHandler(Keyboard.KeyDownEvent, (KeyEventHandler)HandleKeyDownEvent);
 }
 public HouseGenPluginView()
 {
     InitializeComponent();
     _wvm = null;
     _generatedSchematicSize = new(0, 0);
     HouseGenTemplates       = new List <HouseGenTemplate>();
 }
Ejemplo n.º 4
0
        private void OnNavigation(string destination)
        {
            switch (destination)
            {
            case "home":
                CurrentViewModel = new HomeViewModel();
                break;

            case "pvp":
                CurrentViewModel = new PvPViewModel();
                break;

            case "world":
                CurrentViewModel = new WorldViewModel();
                break;

            case "store":
                CurrentViewModel = new StoreViewModel();
                break;

            case "account":
                CurrentViewModel = new AccountViewModel();
                break;

            default:
                throw new ArgumentException($"Failed to navigate to '{destination}', the destination was not recognized");
            }
        }
 //This function resets the UV state for the specified tile locations (as well as nearby tiles) such that the UV cache must be re-evaluated
 public static void ResetUVCache(WorldViewModel _wvm, int tileStartX, int tileStartY, int regionWidth, int regionHeight)
 {
     if (_wvm.TilePicker.PaintMode == PaintMode.TileAndWall)
     {
         //Reset UV Cache for nearby tiles and walls
         for (int x = -1; x < regionWidth + 1; x++)
         {
             int tilex = x + tileStartX;
             for (int y = -1; y < regionHeight + 1; y++)
             {
                 int tiley = y + tileStartY;
                 if (tilex < 0 || tiley < 0 || tilex >= _wvm.CurrentWorld.TilesWide || tiley >= _wvm.CurrentWorld.TilesHigh)
                 {
                     continue;
                 }
                 Tile curtile = _wvm.CurrentWorld.Tiles[tilex, tiley];
                 if (_wvm.TilePicker.TileStyleActive)
                 {
                     curtile.uvTileCache    = 0xFFFF;
                     curtile.lazyMergeId    = 0xFF;
                     curtile.hasLazyChecked = false;
                 }
                 if (_wvm.TilePicker.WallStyleActive)
                 {
                     curtile.uvWallCache = 0xFFFF;
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 public SpriteTool(WorldViewModel worldViewModel) : base(worldViewModel)
 {
     Icon     = new BitmapImage(new Uri(@"pack://application:,,,/TEditXna;component/Images/Tools/sprite.png"));
     Name     = "Sprite";
     IsActive = false;
     ToolType = ToolType.Pixel;
 }
Ejemplo n.º 7
0
 public FillTool(WorldViewModel worldViewModel)
     : base(worldViewModel)
 {
     Icon     = new BitmapImage(new Uri(@"pack://application:,,,/TEditXna;component/Images/Tools/paintcan.png"));
     Name     = "Моід";
     ToolType = ToolType.Pixel;
 }
Ejemplo n.º 8
0
        public static void PlaceEntity(TileEntity te, WorldViewModel wvm)
        {
            if (te == null)
            {
                return;
            }
            if (wvm == null)
            {
                return;
            }
            if (wvm.CurrentWorld == null)
            {
                return;
            }

            var sprite = World.Sprites.FirstOrDefault(s => s.Tile == (ushort)te.TileType);

            if (sprite == null)
            {
                return;
            }

            AddEntityToWorld(te, wvm.CurrentWorld);

            Sprite.PlaceSprite(te.PosX, te.PosY, sprite, wvm);

            PostAddEntityToWorld(te, wvm.CurrentWorld);
        }
Ejemplo n.º 9
0
        internal void OnMouseClickCrunch(WorldViewModel world, CoordServiceModel bigCellCoord, CoordServiceModel cellCoord)
        {
            BigCellViewModel bigcell = world.BigCells[bigCellCoord.X, bigCellCoord.Y];
            CellViewModel    cell    = world.BigCells[bigCellCoord.X, bigCellCoord.Y].Cells[cellCoord.X, cellCoord.Y];

            if (bigcell.IsFocus)
            {
                if (cell.State == State.None)
                {
                    world.SetAllBigCellsToState(false);
                    world.BigCells[cellCoord.X, cellCoord.Y].IsFocus = true;

                    if (turn)
                    {
                        cell.State = State.Client;
                    }
                    else
                    {
                        cell.State = State.Enemy;
                    }

                    turn = !turn;

                    if (bigcell.IsFilled())
                    {
                        world.SetAllBigCellsToState(true);
                    }
                }
            }
        }
Ejemplo n.º 10
0
 public BrushTool(WorldViewModel worldViewModel)
     : base(worldViewModel)
 {
     Icon     = new BitmapImage(new Uri(@"pack://application:,,,/TEdit;component/Images/Tools/paintbrush.png"));
     Name     = "Brush";
     ToolType = ToolType.Brush;
 }
Ejemplo n.º 11
0
 protected BaseTool(WorldViewModel worldViewModel)
 {
     _wvm     = worldViewModel;
     _preview = new WriteableBitmap(1, 1, 96, 96, PixelFormats.Bgra32, null);
     _preview.Clear();
     _preview.SetPixel(0, 0, 127, 0, 90, 255);
 }
Ejemplo n.º 12
0
 public PointTool(WorldViewModel worldViewModel)
     : base(worldViewModel)
 {
     Icon     = new BitmapImage(new Uri(@"pack://application:,,,/TEditXna;component/Images/Tools/point.png"));
     Name     = "Point";
     IsActive = false;
     ToolType = ToolType.Npc;
 }
Ejemplo n.º 13
0
 public UndoManager(WorldViewModel viewModel)
 {
     if (!Directory.Exists(Dir))
     {
         Directory.CreateDirectory(Dir);
     }
     _wvm = viewModel;
 }
Ejemplo n.º 14
0
        private async void ComboBoxCountries_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxCities.SelectedIndex = -1;

            WorldViewModel.Country = ComboBoxCountries.SelectedValue.ToString();

            await WorldViewModel.GetAllCitiesOfACountryAsync();
        }
Ejemplo n.º 15
0
 public MorphTool(WorldViewModel worldViewModel)
     : base(worldViewModel)
 {
     CreateTileLookup();
     Icon     = new BitmapImage(new Uri(@"pack://application:,,,/TEditXna;component/Images/Tools/paintbrush.png"));
     Name     = "Morph";
     ToolType = ToolType.Brush;
 }
Ejemplo n.º 16
0
 public PencilTool(WorldViewModel worldViewModel)
     : base(worldViewModel)
 {
     Icon     = new BitmapImage(new Uri(@"pack://application:,,,/TEdit;component/Images/Tools/pencil.png"));
     Name     = "Pencil";
     IsActive = false;
     ToolType = ToolType.Pixel;
 }
Ejemplo n.º 17
0
 public MainWindow()
 {
     InitializeComponent();
     this.Width  = World.AppSize.X;
     this.Height = World.AppSize.Y;
     DataContext = ViewModelLocator.WorldViewModel;
     _vm         = (WorldViewModel)DataContext;
     AddHandler(Keyboard.KeyDownEvent, (KeyEventHandler)HandleKeyDownEvent);
 }
Ejemplo n.º 18
0
        public UndoManager(WorldViewModel viewModel)
        {
            if (!Directory.Exists(Dir))
            {
                Directory.CreateDirectory(Dir);
            }

            _wvm    = viewModel;
            _buffer = new UndoBuffer(GetUndoFileName());
        }
Ejemplo n.º 19
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            LogModel = new LogModel();
            Log.Info("Starting " + Assembly.GetExecutingAssembly().GetName().FullName);

            ServerConnection = new ServerConnection();
            WorldViewModel   = new WorldViewModel(ServerConnection);
            ChatLogModel     = new LogModel(ServerConnection.ChatListeners);
        }
Ejemplo n.º 20
0
        public void Place(int destinationX, int destinationY, WorldViewModel wvm)
        {
            ErrorLogging.TelemetryClient?.TrackEvent("PlaceSprite", new Dictionary <string, string> {
                ["Tile"] = Tile.ToString(), ["UV"] = UV.ToString()
            });

            if (Tile == (ushort)TileType.ChristmasTree)
            {
                for (int x = 0; x < SizeTiles.X; x++)
                {
                    int tilex = x + destinationX;
                    for (int y = 0; y < SizeTiles.Y; y++)
                    {
                        int tiley = y + destinationY;
                        wvm.UndoManager.SaveTile(tilex, tiley);
                        Tile curtile = wvm.CurrentWorld.Tiles[tilex, tiley];
                        curtile.IsActive = true;
                        curtile.Type     = Tile;
                        if (x == 0 && y == 0)
                        {
                            curtile.U = 10;
                        }
                        else
                        {
                            curtile.U = (short)x;
                        }
                        curtile.V = (short)y;

                        wvm.UpdateRenderPixel(tilex, tiley);
                        BlendRules.ResetUVCache(wvm, tilex, tiley, SizeTiles.X, SizeTiles.Y);
                    }
                }
            }
            else
            {
                for (int x = 0; x < SizeTiles.X; x++)
                {
                    Vector2Short[,] tiles = GetTiles();
                    int tilex = x + destinationX;
                    for (int y = 0; y < SizeTiles.Y; y++)
                    {
                        int tiley = y + destinationY;
                        wvm.UndoManager.SaveTile(tilex, tiley);
                        Tile curtile = wvm.CurrentWorld.Tiles[tilex, tiley];
                        curtile.IsActive = true;
                        curtile.Type     = Tile;
                        curtile.U        = tiles[x, y].X;
                        curtile.V        = tiles[x, y].Y;

                        wvm.UpdateRenderPixel(tilex, tiley);
                        BlendRules.ResetUVCache(wvm, tilex, tiley, SizeTiles.X, SizeTiles.Y);
                    }
                }
            }
        }
Ejemplo n.º 21
0
        public SelectionTool(WorldViewModel worldViewModel)
        {
            _wvm     = worldViewModel;
            _preview = new WriteableBitmap(1, 1, 96, 96, PixelFormats.Bgra32, null);
            _preview.Clear();
            _preview.SetPixel(0, 0, 127, 0, 90, 255);

            Icon     = new BitmapImage(new Uri(@"pack://application:,,,/TEditXna;component/Images/Tools/shape_square.png"));
            Name     = "Selection";
            IsActive = false;
        }
Ejemplo n.º 22
0
 public WorldPage(WorldViewModel viewModel)
 {
     ViewModel        = viewModel;
     BindingContext   = viewModel;
     ViewModel.ToPage = (page) =>
     {
         var vpage = new CountryPage(page);
         Navigation.PushAsync(vpage);
     };
     InitializeComponent();
 }
        public void Width_ShouldReturnWorldWidth()
        {
            // Arrange
            World          world     = CreateWorld();
            WorldViewModel viewModel = CreateWorldViewModel(world);

            // Act
            int width = viewModel.Width;

            // Assert
            width.Should().Be(300);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            this.gameHelper = new GameHelper();

            this.world          = new WorldViewModel(0, new BigCellViewModel[Configuration.BigCellRowCount, Configuration.BigCellColumnCount]);    // TODO map from logic
            this.IsMouseVisible = true;

            this.gameHelper.SetCellsCoords(this.world);

            base.Initialize();
        }
        //------------------------------------------------------------------------------
        // Public Functions:
        //------------------------------------------------------------------------------

        public MainWindow()
        {
            InitializeComponent();

            // Create view model
            viewModel   = new WorldViewModel();
            DataContext = viewModel;

            // Event handlers
            btnNewGame.Click  += btnNewGame_Click;
            btnContinue.Click += btnContinue_Click;
        }
        public void Height_ShouldReturnWorldHeight()
        {
            // Arrange
            World          world     = CreateWorld();
            WorldViewModel viewModel = CreateWorldViewModel(world);

            // Act
            int height = viewModel.Height;

            // Assert
            height.Should().Be(300);
        }
Ejemplo n.º 27
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                await WorldViewModel.GetAllCountriesInTheWorldAsync();
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.Message).ShowAsync();
            }

            await FindUserTypeAsync();
        }
Ejemplo n.º 28
0
 public PerspectiveView(WorldViewModel worldViewModel)
 {
     InitializeComponent();
     _worldViewModel = worldViewModel;
     Perspective     = new PerspectiveViewModel(worldViewModel, renderTarget.IsKeyPressed);
     renderTarget.AutomaticUpdateFPS = 60;
     renderTarget.Render            += renderTargetUserControl_Render;
     renderTarget.RenderUI          += PerspectiveViewControl_RenderUI;
     renderTarget.MouseEnter        += PerspectiveViewControl_MouseEnter;
     renderTarget.MouseDown         += PerspectiveViewControl_MouseDown;
     renderTarget.MouseUp           += PerspectiveViewControl_MouseUp;
     renderTarget.MouseMove         += PerspectiveViewControl_MouseMove;
 }
        //------------------------------------------------------------------------------
        // Public Functions:
        //------------------------------------------------------------------------------

        public GameWindow(WorldViewModel viewModel_)
        {
            viewModel   = viewModel_;
            DataContext = viewModel;
            InitializeComponent();

            Application.Current.MainWindow.Close();
            Application.Current.MainWindow = this;

            // Register events
            KeyDown += new KeyEventHandler(viewModel.OnKeyDown);
            Closing += new CancelEventHandler(viewModel.OnQuitGame);
        }
        public void Place(int destinationX, int destinationY, WorldViewModel wvm)
        {
            if (Tile == (ushort)TileType.ChristmasTree)
            {
                for (int x = 0; x < SizeTiles.X; x++)
                {
                    int tilex = x + destinationX;
                    for (int y = 0; y < SizeTiles.Y; y++)
                    {
                        int tiley = y + destinationY;
                        wvm.UndoManager.SaveTile(tilex, tiley);
                        Tile curtile = wvm.CurrentWorld.Tiles[tilex, tiley];
                        curtile.IsActive = true;
                        curtile.Type     = Tile;
                        if (x == 0 && y == 0)
                        {
                            curtile.U = 10;
                        }
                        else
                        {
                            curtile.U = (short)x;
                        }
                        curtile.V = (short)y;

                        wvm.UpdateRenderPixel(tilex, tiley);
                        BlendRules.ResetUVCache(wvm, tilex, tiley, SizeTiles.X, SizeTiles.Y);
                    }
                }
            }
            else
            {
                for (int x = 0; x < SizeTiles.X; x++)
                {
                    Vector2Short[,] tiles = GetTiles();
                    int tilex = x + destinationX;
                    for (int y = 0; y < SizeTiles.Y; y++)
                    {
                        int tiley = y + destinationY;
                        wvm.UndoManager.SaveTile(tilex, tiley);
                        Tile curtile = wvm.CurrentWorld.Tiles[tilex, tiley];
                        curtile.IsActive = true;
                        curtile.Type     = Tile;
                        curtile.U        = tiles[x, y].X;
                        curtile.V        = tiles[x, y].Y;

                        wvm.UpdateRenderPixel(tilex, tiley);
                        BlendRules.ResetUVCache(wvm, tilex, tiley, SizeTiles.X, SizeTiles.Y);
                    }
                }
            }
        }
Ejemplo n.º 31
0
 private void OnNavigation(string destination)
 {
     switch (destination)
     {
         case "home":
             CurrentViewModel = new HomeViewModel();
             break;
         case "pvp":
             CurrentViewModel = new PvPViewModel();
             break;
         case "world":
             CurrentViewModel = new WorldViewModel();
             break;
         case "store":
             CurrentViewModel = new StoreViewModel();
             break;
         case "account":
             CurrentViewModel = new AccountViewModel();
             break;
         default:
             throw new ArgumentException($"Failed to navigate to '{destination}', the destination was not recognized");
     }
 }