Exemplo n.º 1
0
        public bool GenerateTiles(MTileSettings settings)
        {
            // delete previous tiles
            Tiles.Clear();

            double refWidth  = Extents.Width + settings.XPadding;
            double refHeight = Extents.Height + settings.YPadding;

            int nRows    = (int)Math.Ceiling(refHeight / settings.YSize);
            int nColumns = (int)Math.Ceiling(refWidth / settings.XSize);

            var _halfTileWidth  = 0.5 * settings.XSize;
            var _halfTileHeight = 0.5 * settings.YSize;
            var _centre         = Extents.Centre - new MarkGeometryPoint(0.5 * (nColumns * settings.XSize), 0.5 * (nRows * settings.YSize));

            for (int row = 0; row < nRows; row++)
            {
                for (int col = 0; col < nColumns; col++)
                {
                    var centrePoint = new MarkGeometryPoint(
                        (col * settings.XSize) + _halfTileWidth,
                        (row * settings.YSize) + _halfTileHeight
                        );

                    GeometricArithmeticModule.Translate(centrePoint, _centre.X + settings.XOffset, _centre.Y + settings.YOffset);

                    Tiles.Add(new MarkGeometryRectangle(centrePoint, settings.XSize, settings.YSize));
                }
            }

            return(true);
        }
Exemplo n.º 2
0
 public void AddTile(uint tileID)
 {
     if (!Contains(tileID))
     {
         Tiles.Add(new TileTemplate(this, tileID));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Updates graphics From a tileset image file.
        /// </summary>
        /// <param name="filename"></param>
        public void UpdateFromImage(string filename)
        {
            Bitmap    img  = (Bitmap)Image.FromFile(filename);
            Rectangle rect = new Rectangle(0, 0, TileWidth, TileHeight);

            int index = 0;

            for (int y = 0; y < img.Height; y += TileHeight)
            {
                rect.Y = y;
                for (int x = 0; x < img.Width; x += TileWidth, index++)
                {
                    rect.X = x;
                    if (index < Tiles.Count)
                    {
                        Tiles[index].Graphic.Dispose();
                        Tiles[index].Graphic = img.Clone(rect, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
                    }
                    else
                    {
                        Tile t = new Tile(img.Clone(rect, System.Drawing.Imaging.PixelFormat.Format32bppPArgb));
                        Tiles.Add(t);
                    }
                }
            }

            img.Dispose();
        }
Exemplo n.º 4
0
 public Data(string input)
 {
     using (StringReader sr = new StringReader(input))
     {
         StringBuilder sb = new StringBuilder();
         string        line;
         while (true)
         {
             line = sr.ReadLine();
             if (line == "")
             {
                 Tile t = new Tile(sb.ToString());
                 Tiles.Add(t);
                 sb.Clear();
             }
             else if (line == null)
             {
                 Tile t = new Tile(sb.ToString());
                 Tiles.Add(t);
                 break;
             }
             else
             {
                 sb.AppendLine(line);
             }
         }
     }
     InitMonster();
 }
Exemplo n.º 5
0
 public override void TileSet()
 {
     Tiles.Add(new SouthernForestTile()); //.林
     Tiles.Add(new SouthernDoorTile());   //.南
     //Tiles.Add(1).天
     //Tiles.Add(1).门
     Tiles.Add(new SouthernSteleTile());//.山
     //Tiles.Add(2).门
     //Tiles.Add(2).碑
     TileToMap = new MapTile[, ]
     {
         { Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0] },
         { Tiles[0], null, null, null, null, null, null, null, Tiles[1], Tiles[1], Tiles[1], null, null, null, null, null, null, null, Tiles[0] },
         { Tiles[0], null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, Tiles[0] },
         { Tiles[0], null, null, null, null, null, null, null, Tiles[0], null, null, null, null, null, null, null, null, null, Tiles[0] },
         { Tiles[0], null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, Tiles[0] },
         { Tiles[0], null, null, Tiles[2], null, null, null, Tiles[0], null, null, null, null, null, null, null, null, null, null, Tiles[0] },
         { Tiles[0], null, null, Tiles[2], null, null, null, null, null, null, null, null, null, null, null, null, null, null, Tiles[0] },
         { Tiles[0], null, null, Tiles[2], null, null, null, null, null, null, null, null, Tiles[0], null, null, null, null, null, Tiles[0] },
         { Tiles[0], null, null, null, null, null, null, Tiles[0], null, null, null, null, null, null, null, null, null, null, Tiles[0] },
         { Tiles[0], null, null, null, null, null, null, null, null, null, null, null, null, null, null, Tiles[0], null, null, Tiles[0] },
         { Tiles[0], null, null, null, null, null, null, null, null, null, null, Tiles[0], null, null, null, null, null, null, Tiles[0] },
         { Tiles[0], null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, Tiles[0] },
         { Tiles[0], null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, Tiles[0] },
         { Tiles[0], null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, Tiles[0] },
         { Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0], Tiles[0] },
     };
 }
Exemplo n.º 6
0
        //***********************************************************************
        //************************** Internal Methods ***************************
        //***********************************************************************

        private void AddTile(Tile tile)
        {
            tile.SetOwner(_accessKey);
            Tiles.Add(tile);
            //Set tile rendering orientation
            handRenderer.UpdateOrientation(tile);
        }
Exemplo n.º 7
0
    private void CreateGrid()
    {
        int tilesInX = 4;
        int tilesInY = 3;

        float tileSize = (rect.width - tileDistance * (tilesInX - 1)) / tilesInX;

        for (int x = 0; x < tilesInX; x++)
        {
            for (int y = 0; y < tilesInY; y++)
            {
                Tile newTile  = Instantiate(tilePrefab);
                var  tileRect = newTile.gameObject.GetComponent <RectTransform>();
                tileRect.sizeDelta = new Vector2(tileSize, tileSize);
                newTile.gameObject.transform.SetParent(gameObject.transform, false);
                newTile.gameObject.transform.position = new Vector3(
                    gameObject.transform.position.x - rect.width * 0.5f + tileRect.sizeDelta.x * 0.5f + tileRect.sizeDelta.x * x + tileDistance * x,
                    gameObject.transform.position.y + rect.height * 0.5f - tileRect.sizeDelta.y * 0.5f - tileRect.sizeDelta.y * y - tileDistance * y);
                var coordinate = new Vector2Int(x, tilesInY - 1 - y);
                newTile.SetCoordinate(coordinate);

                Tiles.Add(coordinate, newTile);
            }
        }

        tileRectTemplate.width = tileRectTemplate.height = tileSize;
    }
Exemplo n.º 8
0
        void GetTilesAndRoomsFromFlyweights()
        {
            foreach (Guid guid in flyweights.Keys)
            {
                JObject jObject       = flyweights[guid] as JObject;
                JToken  typeNameToken = jObject.GetValue("TypeName");
                string  typeName      = typeNameToken.ToString();
                switch (typeName)
                {
                case "MapCore.Tile":
                    Tile tile = jObject.ToObject <Tile>();
                    Tiles.Add(tile);
                    reconstitutedFlyweights[guid] = tile;
                    break;

                case "MapCore.MapRegion":
                    MapRegion mapRegion = jObject.ToObject <MapRegion>();
                    reconstitutedFlyweights[guid] = mapRegion;
                    if (mapRegion.RegionType == RegionType.Room)
                    {
                        Rooms.Add(mapRegion);
                    }
                    else if (mapRegion.RegionType == RegionType.Corridor)
                    {
                        Corridors.Add(mapRegion);
                    }
                    break;
                }
            }
        }
Exemplo n.º 9
0
    //Placeholder for tilecreation
    private void PlaceTile(int x, int y, Vector3 worldStart, int type)
    {
        GameObject newTile      = Instantiate(tilePrefabs[type]);
        Vector3    tilePosition = new Vector3(worldStart.x + TileSize / 2 + (TileSize * x), worldStart.y - TileSize / 2 - (TileSize * y));

        newTile.transform.position = tilePosition;

        // differentiate playing field-stadium
        if (type == 0 || type == 2)
        {
            Tiles.Add(newTile);
        }

        if (type == 2)
        {
            if (y > MaxYTiles / 2)
            {
                StartTilesTeam1.Add(newTile);
            }
            else
            {
                StartTilesTeam2.Add(newTile);
            }
        }

        if (type == 3)
        {
            WallTiles.Add(newTile);
        }
    }
Exemplo n.º 10
0
 private void readMapTexture()
 {
     Color[] pixels = mapTexture.GetPixels(0, 0, mapTexture.width, mapTexture.height);
     for (int y = 0; y < mapTexture.height; y++)
     {
         for (int x = 0; x < mapTexture.width; x++)
         {
             Color      c    = pixels [(y * mapTexture.width) + x];
             GameObject tile = new GameObject();
             tile.transform.position = new Vector3(x, y);
             tile.transform.SetParent(tile_dump.transform);
             if (c == Color.black)
             {
                 WallTiles.Add(tile);
                 tile.name = "Wall";
             }
             else if (c == Color.blue)
             {
                 StartTilesTeam1.Add(tile);
                 tile.name = "Team 1";
             }
             else if (c == Color.green)
             {
                 StartTilesTeam2.Add(tile);
                 tile.name = "Team 2";
             }
             else
             {
                 Tiles.Add(tile);
                 tile.name = "Walkable";
             }
         }
     }
 }
Exemplo n.º 11
0
        public override async Task Prepare()
        {
            await base.Prepare();

            IsLoading = true;

            RemainingCapacity = await tileManager.GetRemainingTileCapacityAsync();

            OnPropertyChanged("RemainingCapacity");

            var newTiles = (await tileManager.GetTilesAsync()).ToArray();
            var toAdd    = newTiles.Where(n => Tiles.All(o => o.Tile.Id != n.Id)).ToArray();
            var toRemove = Tiles.Where(o => newTiles.All(n => n.Id != o.Tile.Id)).ToArray();

            foreach (var tile in toAdd)
            {
                Tiles.Add(new TileViewModel(tile, tileManager));
            }
            foreach (var tile in toRemove)
            {
                Tiles.Remove(tile);
            }

            IsLoading = false;
        }
Exemplo n.º 12
0
    public void SetTileType(Vector2Int pos, Tile.Type type)
    {
        if (!Tiles.ContainsKey(pos))
        {
            Tiles.Add(pos, new Tile(pos, Tile.Type.Grass));
        }

        Tiles[pos].TileType = type;

        TileBase tileToRender = type == Tile.Type.Hearth ? TileTypes[(int)Tile.Type.Hearth].Variations[0].Normal : TileTypes[(int)type].GetRandomTile(Tiles[pos].IsInSnow);

        if (tileToRender == null)
        {
            Debug.LogError("Could not find a valid tile to render for type " + type);
            return;
        }

        Tilemaps[(int)type].SetTile(new Vector3Int(pos.x, pos.y, 0), tileToRender);
        Tiles[pos].SetIsInSnow(Tiles[pos].IsInSnow);
        if (type == Tile.Type.Grass)
        {
            // Clear props rendering
            for (int i = 0; i < (int)Tile.Type.MAX; i++)
            {
                if ((Tile.Type)i != Tile.Type.Grass && Tilemaps[i] != null)
                {
                    Tilemaps[i].SetTile(new Vector3Int(pos.x, pos.y, 0), null);
                }
            }
        }
    }
Exemplo n.º 13
0
        /// <summary>
        /// Creates a Collidable tile, Dynamic or Static.
        /// </summary>
        /// <param name="bodyType"></param>
        /// <param name="texture">Texture for the tile.</param>
        /// <param name="position">Position of the tile.</param>
        /// <param name="tileSize">Size of the file.</param>
        /// <param name="rotation">Rotation of the tile.</param>
        /// <param name="density">Density of it?</param>
        /// <returns>ICollidableTile</returns>
        public ICollidableTile CreateCollidableTile(BodyType bodyType, Texture2D texture, Vector2 position, Rectangle tileSize, float rotation, float density)
        {
            ICollidableTile collidableTile;
            Body            physicsBody = null;

            if (PhysicsBodyCache.Count == 0)
            {
                //If our cache is empty make a brand spankin' new one
                physicsBody = BodyFactory.CreateRectangle(m_physicsWorld,
                                                          ConvertUnits.ToSimUnits(tileSize.Width),
                                                          ConvertUnits.ToSimUnits(tileSize.Height),
                                                          density);
            }
            else
            {
                //If we have some phyasics bodies in our cache just grab the first one, they are all pretty much the same.
                physicsBody = PhysicsBodyCache[0];

                //and remove it so we don't try to use it again
                PhysicsBodyCache.Remove(physicsBody);
            }

            collidableTile = new Tiles.StaticCollidableTile(m_spriteBatch, texture, position, physicsBody, tileSize.Height, tileSize.Width, rotation, m_physicsWorld);
            CollidableTiles.Add(collidableTile);
            Tiles.Add(collidableTile);

            return(collidableTile);
        }
        public void Load()
        {
            var configutarionModel = LoadConfiguration();

            _configuration = _mapper.Map <ConfigurationModel, ConfigurationViewModel>(configutarionModel);

            Type       mapper = _mapper.GetType();
            MethodInfo map    = mapper.GetMethods().Where(m => m.Name == "Map" && m.GetParameters().Count() == 2).First();

            var tileModels = LoadTileData();

            foreach (var tileModel in tileModels)
            {
                string typeString  = String.Format("{0}{1}{2}", "widget3.ViewModels.Concrete.Common.", tileModel.Type.ToString(), "TileViewModel");
                Type   type        = Type.GetType(typeString);
                var    resolvedMap = map.MakeGenericMethod(typeof(TileModel), type);
                var    tile        = (TileViewModel)resolvedMap.Invoke(_mapper, new object[] { tileModel, new Action <TileModel, TileViewModel>(MapBackground) });
                tile.UserData = this;
                Tiles.Add(tile);
            }

            var backgroundModels = LoadBackgrounds();

            foreach (var backgroundModel in backgroundModels)
            {
                var background = _mapper.Map <BackgroundModel, BackgroundViewModel>(backgroundModel);
                Backgrounds.Add(background);
            }
        }
Exemplo n.º 15
0
        public Map(Environment env, int height = 5, int width = 5)
        {
            Environment = env;

            if (height != Height)
            {
                Height = height;
            }

            if (width != Width)
            {
                Width = width;
            }

            // Create the tiles
            Debug.Log("Initializing map with Height=" + Height + ", Width=" + Width, "MAP");
            for (int y = 0; y < Height; y++)
            {
                Tiles.Add(new List <Tile>());
                for (int x = 0; x < Width; x++)
                {
                    Tiles[y].Add(new Tile(x, y, this));
                }
            }
        }
Exemplo n.º 16
0
        public void Load(IEnumerable <XElement> tilesToLoad)
        {
            var availableItems   = AvailableItems.Instance;
            var availableMobiles = AvailableMobiles.Instance;

            Mobile mobile = null;
            Item   item   = null;

            foreach (XElement tile in tilesToLoad.Descendants("Tile"))
            {
                var top        = Int32.Parse(tile.Element("Location").Element("Top").Value);
                var left       = Int32.Parse(tile.Element("Location").Element("Left").Value);
                var tileTypeId = Int32.Parse(tile.Element("TypeId").Value);

                mobile = null;
                if (!string.IsNullOrEmpty(tile.Element("Mobile").Value))
                {
                    mobile = availableMobiles.GetMobileById((Int32.Parse(tile.Element("Mobile").Element("TypeId").Value)));
                    mobile.Load(tile.Element("Mobile"));
                }

                item = null;
                if (!string.IsNullOrEmpty(tile.Element("Item").Value))
                {
                    item = availableItems.GetItemById((Int32.Parse(tile.Element("Item").Element("ItemId").Value)));
                    item.Load(tile.Element("Item"));
                }

                Tiles.Add(new Tile {
                    Location = new Location(left, top), TypeId = tileTypeId, Mobile = mobile, Item = item
                });
            }
        }
Exemplo n.º 17
0
        public override void TileSet()
        {
            Tiles.Add(new TestBattleTile());
            Tiles.Add(new SouthernForestTile());
            Tiles.Add(new SouthernForestTile());
            Tiles.Add(new SouthernForestTile());
            Tiles.Add(new SouthernForestTile());
            Tiles.Add(new SouthernForestTile());
            Tiles.Add(new SouthernSteleTile());
            Tiles.Add(new SouthernSteleTile());
            Tiles.Add(new SouthernSteleTile());
            Tiles.Add(new SouthernSteleTile());
            Tiles.Add(new SouthernSteleTile());


            TileToMap = new MapTile[, ]
            {
                { null, null, null, null, Tiles[0], null, null, null, null, null },
                { null, null, null, null, Tiles[4], null, null, null, null, null },
                { null, null, null, null, null, null, null, null, null, null },
                { null, null, null, null, null, null, null, null, null, null },
                { null, null, null, null, null, null, null, null, Tiles[4], Tiles[3] },
                { Tiles[2], Tiles[4], null, null, null, null, null, null, null, null },
                { null, null, null, null, null, null, null, null, null, null },
                { null, null, null, null, null, null, null, null, null, null },
                { null, null, null, null, null, Tiles[4], null, null, null, null },
                { null, null, null, null, null, Tiles[1], null, null, null, null },
            };
        }
Exemplo n.º 18
0
        public MapShape AddVisitedItem(IMultiTileShape shape)
        {
            if (VisitedShapes.Contains(shape))
            {
                return(null);
            }
            else
            {
                Point position = new Point(shape.Rect.Location.X * Constants.TilePx / Scale.X, shape.Rect.Location.Y * Constants.TilePx / Scale.Y);
                Size  size     = new Size(shape.Rect.Size.Width * Constants.TilePx / Scale.X, shape.Rect.Size.Height * Constants.TilePx / Scale.Y);
                //position = new Point(position.X + Engine.MapWindow.Canvas_MiniMap.Margin.Left,position.Y +Engine.MapWindow.Canvas_MiniMap.Margin.Top);

                Rect     rectangle = new Rect(position, size);
                MapShape t         = new MapShape((Vector)position, size, shape is RoomModule ? MapShape.TypeEnum.Room : MapShape.TypeEnum.Road);
                Tiles.Add(t);
                VisitedShapes.Add(shape);

                if (shape is RoomModule)
                {
                    RoomModule s = (RoomModule)shape;
                    s.Roads.ForEach(road => AddVisitedItem(road));
                }

                return(t);
            }
        }
Exemplo n.º 19
0
        public CornerBet(Player player, double amount, Tile firstTile, Tile secondTile, Tile thirdTile, Tile fourthTile) : base(9, player, amount)
        {
            _first  = Int32.Parse(firstTile.Value);
            _second = Int32.Parse(secondTile.Value);
            _third  = Int32.Parse(thirdTile.Value);
            _fourth = Int32.Parse(fourthTile.Value);

            List <int> values = new List <int> {
                _first, _second, _third, _fourth
            };

            values.Sort();

            if (IsSquare(values[0], values[1], values[2], values[3]))
            {
                Tiles.Add(firstTile);
                Tiles.Add(secondTile);
                Tiles.Add(thirdTile);
                Tiles.Add(fourthTile);
            }
            else
            {
                throw new RouletteException($"No corner found for tiles {values[0]}, {values[1]}, {values[2]}, {values[3]}");
            }
        }
Exemplo n.º 20
0
 public Stack(Tile [] tiles)
 {
     foreach (var tile in tiles)
     {
         Tiles.Add(tile);
     }
 }
        public GameBag()
        {
            //  Tiles.AddRange(Generate<SheepTile>(3));
            //  Tiles.AddRange(Generate<MapTile>(3));
            //  Tiles.AddRange(Generate<KiwiTile>(3));
            //  Tiles.AddRange(Generate<FernTile>(3));
            //  Tiles.AddRange(Generate<CityTile>(4));
            Tiles.Add(new CityTile());
            Tiles.Add(new MapTile());
            Tiles.Add(new SheepTile());
            Tiles.Add(new SheepTile());
            Tiles.Add(new KiwiTile());
            Tiles.Add(new KiwiTile());
            Tiles.Add(new KiwiTile());

            Tiles.Add(new FernTile());
            Tiles.Add(new FernTile());
            Tiles.Add(new FernTile());

            Tiles.Add(new CityTile());
            Tiles.Add(new CityTile());
            Tiles.Add(new CityTile());

            Tiles.Add(new MapTile());
            Tiles.Add(new MapTile());
            Tiles.Add(new SheepTile());
        }
Exemplo n.º 22
0
 public void InitaliseTiles()
 {
     for (int i = 0; i < 140; i++)
     {
         Tiles.Add(new Tile(4));
     }
 }
        public override void TileSet()
        {
            Tiles.Add(new SouthernForestTile()); //0

            Tiles.Add(new SouthernSteleTile());  //1

            Tiles.Add(new StartMapDoorTile());   //2

            Tiles.Add(new TestBattleTile());     //3

            Tiles.Add(new MazeTile());           //4

            Tiles.Add(new QuestBaseTile());      //5

            Tiles.Add(new TestMapDoorTile());    //6


            TileToMap = new MapTile[, ]
            {
                { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, Tiles[5] },
                { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null },
                { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null },
                { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null },
                { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null },
                { Tiles[2], null, null, null, null, null, null, Tiles[3], null, null, null, null, null, null, null, null, null, null, null },
                { Tiles[2], null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null },
                { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null },
                { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null },
                { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null },
                { null, null, null, null, null, null, Tiles[4], null, null, null, null, null, null, null, null, null, null, null, null },
                { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null },
                { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, Tiles[6] },
            };
        }
Exemplo n.º 24
0
        public void CreateFloorPlan(int width, int height, int floorAmount, string description, string[] headers)
        {
            if (_floorPlanAlreadyExist)
            {
                return;
            }

            Width  = width;
            Height = height;

            FloorAmount = floorAmount;
            Description = description;
            Headers     = headers ?? new string[FloorAmount];

            for (int z = 0; z < FloorAmount; z++)
            {
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        Tiles.Add(Coordinate(x, y, z), new BuildingBlock(x, y, z));
                    }
                }
            }
            BuildingBlocks         = Tiles.ToDictionary(k => k.Key, v => v.Value as BuildingBlock);
            _floorPlanAlreadyExist = true;
        }
Exemplo n.º 25
0
        public MapViewModel(Map map)
        {
            // Set the model
            this.map = map;

            // Instantiate an atlas from the map.
            Atlas = new AtlasViewModel(map.Atlas);

            //Instantate the initial brush.
            brush = new BrushViewModel(this);

            // Instantiate the Tiles - Future tiles added should be done through the event
            tiles = new ObservableCollection <TileViewModel>();
            //map.Tiles.CollectionChanged += TilesCollectionChanged;

            foreach (Tile t in map.Tiles)
            {
                Tiles.Add(new TileViewModel(t));
                Tiles[Tiles.Count - 1].PropertyChanged += TileViewModel_PropertyChanged;
            }

            history = new History(map);

            // Add commands
            UndoAction = new RelayCommand(Command_UndoTilePlace);
            RedoAction = new RelayCommand(Command_RedoTilePlace);
            ClickMap   = new ParameterCommand(Command_ClickMap);
            DragMap    = new ParameterCommand(Command_DragMap);
        }
Exemplo n.º 26
0
    public void GenerateLevel()
    {
        int unixTimestamp = ((long)(System.DateTime.UtcNow.Subtract(new System.DateTime(1970, 1, 1))).TotalSeconds).GetHashCode();

        LevelGenerator levelGenerator = new LevelGenerator(CurrentDungeon.numberOfTiles, 0.9f, unixTimestamp, CurrentDungeon.frequencyOfHallwayDiversions, CurrentDungeon.lengthOfHallways);

        levelGenerator.GenerateLevel();

        foreach (var room in levelGenerator.AllRooms)
        {
            EncounterScriptableObject encounter = null;

            if (!(room.Position.x == 0 && room.Position.y == 0))
            {
                encounter = (Random.Range(0, 2) == 1) ? CurrentDungeon.encounters[Random.Range(0, CurrentDungeon.encounters.Length)] : null;
            }

            DungeonTile dt = new DungeonTile(room, encounter);

            if (room.Position.x == 0 && room.Position.y == 0)
            {
                currentTile = dt;
                currentTile.TileVisited();
                currentTile.TileSeen();
            }

            dt.TileSeen();

            Tiles.Add(dt);
        }
    }
Exemplo n.º 27
0
 public void AddTile(Texture texture, bool doesClip = false)
 {
     Tiles.Add(new Tile()
     {
         Clipping = doesClip,
         Texture  = texture
     });
 }
Exemplo n.º 28
0
 private void LoadSelectedMapTilesImages()
 {
     Tiles.Clear();
     foreach (var t in BlockSets.ElementAt((int)selectedMap.TileSetID).Tiles)
     {
         Tiles.Add(Bitmap2BitmapSource(t));
     }
 }
Exemplo n.º 29
0
 public void FillRack(int amount)
 {
     for (var i = 0; i < amount; i++)
     {
         var tile = new RackTile(Player, _ioc);
         Tiles.Add(tile);
     }
 }
Exemplo n.º 30
0
 private void DoSomething(string val)
 {
     Number = val;
     Tiles.Add(new BaseTile {
         TileLabel = $"Tile: {val}", TileValue = val
     });
     OnPropertyChanged(nameof(Tiles));
 }