Exemplo n.º 1
0
 public void showTileMenu(PlayableTile tile)
 {
     this.actionList.Visibility = Visibility.Visible;
     Canvas.SetLeft(actionList, Canvas.GetLeft(tile) + tile.Width);
     Canvas.SetTop(actionList, Canvas.GetTop(tile));
     this.actionList.TileModel = tile.model;
 }
Exemplo n.º 2
0
		public void initWithModel(SeppukuMapModel model)
		{
			this.model = model;
			this.model.destinationTileFieldModeSet += this.onSelectDestinationStateSet;

			int tileWidth = 101;
			int tileHeight = 82;
			int tileBaseHeight = 45;

			int minX = model.tiles.Min(tileInfo => tileInfo.x);
			int maxX = model.tiles.Max(tileInfo => tileInfo.x);
			int minY = model.tiles.Min(tileInfo => tileInfo.y);
			int maxY = model.tiles.Max(tileInfo => tileInfo.y);

			loadedTilesX = maxX - minX + 1 + 2;
			loadedTilesY = maxY - minY + 1 + 2;
		
			for(int i = 0; i <= maxY - minY + 2; i++)
			{
				for(int j = 0; j <= maxX - minX + 2; j++)
				{
					UserControl tile;

					if(model.tiles.Any(tileInfo => (tileInfo.x == j + minX - 1 && tileInfo.y == i + minY - 1)))
					{
						SeppukuMapTileModel tileModel = model.tiles.First(tileInfo => (tileInfo.x == j + minX - 1 && tileInfo.y == i + minY - 1));

						PlayableTile tempTile = new PlayableTile(this, tileModel);
						tempTile.TileName = tileModel.name;
						tile = tempTile;
						tile.MouseEnter += this.onTileOver;
						tile.MouseLeave += this.onTileOut;
						tile.MouseLeftButtonUp += this.onTileClicked;
						this.TileElements.Children.Add(tempTile.orderDecals);
						Canvas.SetLeft(tempTile.orderDecals, j * tileWidth);
						Canvas.SetTop(tempTile.orderDecals, i * tileHeight);
					}
					else
						tile = new Tile();

					Canvas.SetLeft(tile, j * tileWidth);
					Canvas.SetTop(tile, i * tileHeight);

					if((j + 1) * tileWidth > this.dynamicWidth)
						this.dynamicWidth = (j + 1) * tileWidth;
					
					if((i + 1) * tileHeight + tileBaseHeight > this.dynamicHeight)
						this.dynamicHeight = (i + 1) * tileHeight + tileBaseHeight;

					this.Tiles.Children.Add(tile);
				}
			}

			this.UpdateLayout();

			if(this.loadingFinished != null)
				this.loadingFinished(this, null);
		}
Exemplo n.º 3
0
		public void showTileMenu(PlayableTile tile)
		{
			this.actionList.Visibility = Visibility.Visible;
			Canvas.SetLeft(actionList, Canvas.GetLeft(tile) + tile.Width);
			Canvas.SetTop(actionList, Canvas.GetTop(tile));
			this.actionList.TileModel = tile.model;
		}
Exemplo n.º 4
0
        public void initWithModel(SeppukuMapModel model)
        {
            this.model = model;
            this.model.destinationTileFieldModeSet += this.onSelectDestinationStateSet;

            int tileWidth      = 101;
            int tileHeight     = 82;
            int tileBaseHeight = 45;

            int minX = model.tiles.Min(tileInfo => tileInfo.x);
            int maxX = model.tiles.Max(tileInfo => tileInfo.x);
            int minY = model.tiles.Min(tileInfo => tileInfo.y);
            int maxY = model.tiles.Max(tileInfo => tileInfo.y);

            loadedTilesX = maxX - minX + 1 + 2;
            loadedTilesY = maxY - minY + 1 + 2;

            for (int i = 0; i <= maxY - minY + 2; i++)
            {
                for (int j = 0; j <= maxX - minX + 2; j++)
                {
                    UserControl tile;

                    if (model.tiles.Any(tileInfo => (tileInfo.x == j + minX - 1 && tileInfo.y == i + minY - 1)))
                    {
                        SeppukuMapTileModel tileModel = model.tiles.First(tileInfo => (tileInfo.x == j + minX - 1 && tileInfo.y == i + minY - 1));

                        PlayableTile tempTile = new PlayableTile(this, tileModel);
                        tempTile.TileName = tileModel.name;
                        tile                    = tempTile;
                        tile.MouseEnter        += this.onTileOver;
                        tile.MouseLeave        += this.onTileOut;
                        tile.MouseLeftButtonUp += this.onTileClicked;
                        this.TileElements.Children.Add(tempTile.orderDecals);
                        Canvas.SetLeft(tempTile.orderDecals, j * tileWidth);
                        Canvas.SetTop(tempTile.orderDecals, i * tileHeight);
                    }
                    else
                    {
                        tile = new Tile();
                    }

                    Canvas.SetLeft(tile, j * tileWidth);
                    Canvas.SetTop(tile, i * tileHeight);

                    if ((j + 1) * tileWidth > this.dynamicWidth)
                    {
                        this.dynamicWidth = (j + 1) * tileWidth;
                    }

                    if ((i + 1) * tileHeight + tileBaseHeight > this.dynamicHeight)
                    {
                        this.dynamicHeight = (i + 1) * tileHeight + tileBaseHeight;
                    }

                    this.Tiles.Children.Add(tile);
                }
            }

            this.UpdateLayout();

            if (this.loadingFinished != null)
            {
                this.loadingFinished(this, null);
            }
        }