Esempio n. 1
0
        // alustaa layerin tilet ja samalla huukkaa tileille viitteen sheetistä
        public virtual void Initialize(TileParameters tileParameters)
        {
            // luo uuden tile tehtaan geneerisen tyypin perusteella
            TileFactory factory = new TileFactory(typeof(T));

            tiles = new T[Size.Height][];
            for (int h = 0; h < Size.Height; h++)
            {
                tiles[h] = new T[Size.Width];
                for (int w = 0; w < Size.Width; w++)
                {
                    // hakee parametri listan indeksistä
                    object[] parameters = tileParameters.GetParameters(new Index
                                                                       (
                                                                           w,
                                                                           h
                                                                       ));

                    // jos parametri lista on null, tekee defaul muodostimelle oikeanlaisen listan joka
                    // käy kaikille tileille
                    if (parameters != null)
                    {
                        tiles[h][w] = (T)factory.MakeNew(parameters);
                    }
                }
            }
            // asettaa viitteen sheetistä vain jos layeri on animaatio tai
            // tile, rule ja objekti sheetti eivät käytä sheettiä
            if (typeof(T).Equals(typeof(Tile)) || typeof(T).Equals(typeof(AnimationTile)))
            {
                HookSheetToTiles();
            }
        }
Esempio n. 2
0
        public TileUI(MapEditorController controller, CellComponent observable)
        {
            InitializeComponent();
            this.controller = controller;
            this.cell       = observable;

            // Initialize Image
            if (observable != null)
            {
                // Register for TileChange event.
                observable.TileChangedEvent += this.ChangeTile;
                observable.UnitAddedEvent   += this.UnitAddedToCell;
                observable.UnitRemovedEvent += this.UnitRemovedFromCell;

                TileFactory tf = TileFactory.Instance;
                this.Image = tf.getBitmapImproved(observable.GetTile());

                foreach (ModelComponent m in observable.EntitiesContainedWithin)
                {
                    if (m is UnitComponent)
                    {
                        UnitUI unitUI = new UnitUI(controller, m as UnitComponent);
                        Controls.Add(unitUI);
                        unitUI.MouseClick += TileUI_MouseDown;
                    }
                }
            }



            AllowDrop = true;
        }
        public Tile GetNext()
        {
            var tileNumber = _random.Next(0, 5);
            var tile       = TileFactory.CreateTile((TileType)tileNumber);

            return(tile);
        }
Esempio n. 4
0
        public void render()
        {
            TileFactory tf = TileFactory.Instance;

            Bitmap   pg = new Bitmap(800, 600);
            Graphics gr = Graphics.FromImage(pg);

            ZRTSModel.Map map = gameworld.GetMap();
            // TODO: Change to include the scrolling model.
            for (int x = 0; x < map.GetWidth(); x++)
            {
                for (int y = 0; y < map.GetHeight(); y++)
                {
                    ZRTSModel.Tile tile = map.GetCellAt(x, y).GetTile();
                    if (tile != null)
                    {
                        gr.DrawImage(tf.getBitmapImproved(tile), x * 16, y * 16, 16, 16);
                    }
                    //if (map.cells[x, y] != null && map.cells[x, y].tile != null && map.cells[x, y].tile.tileType != null)
                    //gr.DrawImage(tf.getBitmap(map.cells[x, y].tile.tileType), x * 16, y * 16, 16, 16);
                    else
                    {
                        gr.DrawRectangle(new Pen(Color.Black), x * 16, y * 16, 16, 16);
                    }
                }
            }
            pictureBox1.Image = pg;
        }
Esempio n. 5
0
 public static TileFactory SharedInstance(GameObject go)
 {
     if (_sharedInstance == null) {
         _sharedInstance = new TileFactory(go);
     }
     return _sharedInstance;
 }
Esempio n. 6
0
 public Map(int width, int height, TileFactory game)
 {
     this.Width   = width;
     this.Height  = height;
     this.Game    = game;
     this.Terrain = new TerrainLibrary(game);
 }
Esempio n. 7
0
 public Character(int id, int posX, int posY, Map mp) : base(id, mp)
 {
     positionX      = posX;
     positionY      = posY;
     standingOnTile = TileFactory.Get(0, posX, posY, mp);
     passable       = false;
 }
Esempio n. 8
0
    private void InstantiateTiles()
    {
        var tile = Instantiate(Resources.Load("Tiles/tile")) as GameObject;

        var tileFactory = TileFactory.SharedInstance(tile);

        _tiles = tileFactory.CreateTilesPul();

        Shuffle <Tile>(_tiles);

        tileSize  = tile.GetComponent <SpriteRenderer>().bounds.size;
        tileWidht = tileSize.x;
        tileHeigh = tileSize.y;

        var diceRollControl = GetComponent <DiceRollControl>();

        for (int q = 0; q < _tilesPositions.Count; q++)
        {
            var old = _tilesPositions[q];
            _tilesPositions[q] = new Vector3(old.x * tileWidht, old.y * tileHeigh, old.z);
        }

        int i = 0;

        foreach (Vector3 position in _tilesPositions)
        {
            var t = _tiles[i];
            t.Num = i++;
            t.GetGameObject.transform.position = new Vector3(position.x, position.y, position.z);
            diceRollControl.OnValue           += new DiceRollControl.MethodContainer(t.OnSelect);
            t.GetGameObject.transform.parent   = tilesContainer.transform;
        }
    }
Esempio n. 9
0
	public PrototypeBoard(int dimension, TileFactory tileFactory) {
		_dimensionOfBoard = dimension;
		_tileFactory = tileFactory;
		_tileArray = new Tile[dimension, dimension];

		BuildBoard (dimension);
	} 
Esempio n. 10
0
        public MapImpl(int s)
        {
            //Utilisation de la dll cpp pour remplir
            //un tableau d'entier
            Algo a = new Algo();

            size = s;
            int nbTiles = size * size;

            int[] tab = a.FillMap(size);

            //Utilisation de ce tableau pour générer le
            //tableau de Tiles
            tiles = new Tile[nbTiles];
            TileFactory tf = TileFactoryImpl.getTileFactory();

            for (int i = 0; i < nbTiles; i++)
            {
                tiles[i] = tf.getTile(tab[i]);
            }

            int j, k;

            units = new Dictionary <Position, List <Unit> >();
            for (k = 0; k < size; k++)
            {
                for (j = 0; j < size; j++)
                {
                    units.Add(PositionImpl.getPosition(k, j), new List <Unit>());
                }
            }

            _instance = this;
        }
        public void ShipDestroyTest()
        {
            //arrange
            var shipType    = ShipTypeEnum.Battleship;
            var ship        = new Ship(shipType);
            var tileFactory = new TileFactory();
            var tile1       = tileFactory.Create(new Coordinate(0, 1), OwnerTypeEnum.Player) as PlayerTile;
            var tile2       = tileFactory.Create(new Coordinate(0, 2), OwnerTypeEnum.Player) as PlayerTile;
            var tile3       = tileFactory.Create(new Coordinate(0, 3), OwnerTypeEnum.Player) as PlayerTile;
            var tile4       = tileFactory.Create(new Coordinate(0, 4), OwnerTypeEnum.Player) as PlayerTile;
            var tile5       = tileFactory.Create(new Coordinate(0, 5), OwnerTypeEnum.Player) as PlayerTile;

            //act
            tile1.AssignShip(ship);
            tile2.AssignShip(ship);
            tile3.AssignShip(ship);
            tile4.AssignShip(ship);
            tile5.AssignShip(ship);

            tile1.Shoot();
            tile2.Shoot();
            tile3.Shoot();
            tile4.Shoot();
            tile5.Shoot();
            //Assert
            Assert.True(ship.IsDestroyed);
        }
Esempio n. 12
0
        public void OnChunkRecieve(ChunkPacket packet)
        {
            var chunkX = packet.X;
            var chunkY = packet.Y;
            var data   = packet.ChunkData;

            var chunkParent = new GameObject("chunk_" + chunkX + "_" + chunkY);

            Chunk c = new Chunk()
            {
                x = chunkX,
                y = chunkY
            };

            Debug.Log("Rendering Chunk " + chunkX + " " + chunkY);
            for (var x = 0; x < 16; x++)
            {
                for (var y = 0; y < 16; y++)
                {
                    var tileId = data[x, y];
                    c.SetTile(x, y, tileId);
                    TileFactory.BuildAndInstantiate(chunkX * 16 + x, chunkY * 16 + y, tileId, chunkParent);
                }
            }

            // To be a tracked chunk
            UnityClient.Map.AddChunk(c);
        }
 void IfIsConsumable(Tile tile)
 {
     if (tile is Consumable)
     {
         bool freeSpace = false;
         int  i;
         for (i = 0; i < 6; i++)
         {
             if (equipment[i] == null)
             {
                 freeSpace = true;
                 break;
             }
         }
         if (freeSpace)
         {
             Consumable cons = (Consumable)tile;
             AddItem(i, cons);
             currentMap.SendLog("You picked up " + cons.name + "!");
             standingOnTile = TileFactory.Get(0, positionX, positionY, currentMap);
         }
         else
         {
             Consumable cons = (Consumable)tile;
             currentMap.SendLog("You have no room for " + cons.name + "!");
         }
     }
 }
        public Map(int[][] intMap, DisplayConsole display, GameHandler gm, int rowAmmount, int ColumnAmmount)
        {
            dontShow       = false;
            gameMaster     = gm;
            mapRowLimit    = rowAmmount;
            mapColumnLimit = ColumnAmmount;
            this.display   = display;
            this.tileMap   = new Tile[mapRowLimit][];
            int rowCounter = 0;

            foreach (int[] intRow in intMap)
            {
                this.tileMap[rowCounter] = new Tile[mapColumnLimit];
                int columnCounter = 0;
                foreach (int integer in intRow)
                {
                    if (integer == 2)
                    {
                        tileMap[rowCounter][columnCounter]     = gameMaster.hero;
                        gameMaster.hero.positionX              = columnCounter;
                        gameMaster.hero.positionY              = rowCounter;
                        gameMaster.hero.currentCenterPositionX = columnCounter;
                        gameMaster.hero.currentCenterPositionY = rowCounter;
                    }
                    else
                    {
                        this.tileMap[rowCounter][columnCounter] = TileFactory.Get(integer, columnCounter, rowCounter, this);
                    }

                    columnCounter++;
                }
                rowCounter++;
            }
            enemies = new EnemyIterator(tileMap);
        }
Esempio n. 15
0
    public void Reset()
    {
        loader.Reset();
        world.Reset();
        TileFactory.Clear();
        GameUtils.Seed = 0;
        Serialization.Reset();

        player.transform.position = new Vector3(0f, -3f, 10f);
        player.GetComponent <Rigidbody>().isKinematic = true;
        Active = false;
        boids.StopBoids();
        boids.StartBoids();

        menuGlow.color          = Tile.Brighten(RenderSettings.fogColor, 0.5f);
        RenderSettings.fogColor = Tile.Brighten(Color.Lerp(RenderSettings.fogColor, Color.black, 0.9f), 0.05f);
        RenderSettings.skybox.SetColor("_Tint", RenderSettings.fogColor);
        RenderSettings.fogDensity       = 10f;
        RenderSettings.ambientIntensity = 0f;
        sun.intensity = 0f;
        afterburner.SetActive(false);

        clockText.text  = "";
        chunkText.text  = "";
        dayText.text    = "";
        scoreText.text  = "";
        nameText.text   = "";
        logMessage.text = "";

        startGame.playMusic.StopPlaying();

        StartCoroutine(GetRandomWord());

        showPanels.ShowMenu();
    }
Esempio n. 16
0
 public static void AddFullWidthWall(int ty)
 {
     for (int tx = 0; tx < Board.currBoard.width; tx++)
     {
         TileFactory.CreateAndAddTile(TileType.INVISIBLE_WALL, tx, ty);
     }
 }
Esempio n. 17
0
    public override Tile[][] SpawnBoard(int[] rowLengths, TileFactory tileFactory)
    {
        var board = new Tile[rowLengths.Length][];

        for (var row = 0; row < rowLengths.Length; row++)
        {
            board[row] = new Tile[rowLengths[row]];

            var zPos = ((rowLengths.Length * _tileOffset) / 2) - (_tileOffset * row) - (_tileOffset / 2.0f);

            for (var column = 0; column < rowLengths[row]; column++)
            {
                var tile = tileFactory.Create(column, row);

                var xPos = (-(rowLengths[row] * _tileOffset) / 2) + (_tileOffset * column) + (_tileOffset / 2.0f);

                tile.transform.position = new Vector3(xPos, YPos, zPos);
                tile.transform.rotation = new Quaternion(-90.0f, 0.0f, 0.0f, tile.transform.rotation.w);

                board[row][column] = tile;
            }
        }

        ConnectBoard(board);

        return(board);
    }
Esempio n. 18
0
        public override void CreateEmptyBoard(Point origin, int tileWidth, int tileHeight)
        {
            TileFactory tileFactory = BasicTileFactory;
            List <Tile> tiles       = new List <Tile>();

            for (int row = 0; row < 8; row++)
            {
                if (row == 0)
                {
                    tileFactory = WhitePawnPromotionTileFactory;
                }
                else if (row == 7)
                {
                    tileFactory = BlackPawnPromotionTileFactory;
                }
                else
                {
                    tileFactory = BasicTileFactory;
                }
                for (int column = 0; column < 8; column++)
                {
                    if ((row + column) % 2 == 0)
                    {
                        tiles.Add(tileFactory.GetTile(row, column, TileColor.LightSquare, BoardTextures.LightSquare));
                    }
                    else
                    {
                        tiles.Add(tileFactory.GetTile(row, column, TileColor.DarkSquare, BoardTextures.DarkSquare));
                    }
                }
            }
            StandardBoardState initialState = new StandardBoardState(tiles);

            Board = new ChessBoard(origin, tileWidth, tileHeight, initialState);
        }
Esempio n. 19
0
        public void Awake()
        {
            var tileStyleRepository = new TileStyleRepository();
            var tileStyle           = tileStyleRepository.ObtainDefault();
            var tileFactory         = new TileFactory();
            var boardFactory        = new BoardFactory(tileFactory);

            var boardSettingsRepository = new BoardSettingsRepository();
            var boardSettings           = boardSettingsRepository.ObtainDefault();
            var board = boardFactory.Create(boardSettings, tileStyle);

            var boardMouseEventsNotifier = new MouseEventsNotifier(board);

            boardMouseEventsNotifier.Enable();

            var ballSelectionEventsNotifier = new BallSelectionEventsNotifier(boardMouseEventsNotifier);

            ballSelectionEventsNotifier.Enable();

            var pathfinder = new Pathfinder();
            var ballMoveControllerFactory = new BallMoveControllerFactory(pathfinder);
            var ballMoveController        = ballMoveControllerFactory.Create(ballSelectionEventsNotifier);

            ballMoveController.Enable();

            var ballBounceManager    = new BallBounceManager(board);
            var ballBounceController = new BallBounceController(ballSelectionEventsNotifier, ballBounceManager);

            ballBounceController.Enable();

            var ballMaterialSettingsRepository        = new BallMaterialSettingsRepository();
            var ballStyleRepository                   = new BallStyleRepositoryFactory(ballMaterialSettingsRepository).Create();
            var ballLifetimeManagerSettingsRepository = new BallLifetimeManagerSettingsRepository();
            var ballLifetimeManagerSettings           = ballLifetimeManagerSettingsRepository.ObtainDefault();
            var ballFactory             = new BallFactory();
            var random                  = new System.Random();
            var ballSpawnManagerFactory = new BallSpawnManagerFactory(
                ballLifetimeManagerSettings,
                ballStyleRepository,
                ballFactory,
                random
                );
            var ballColorPool = new BallColorPoolRepository().ObtainDefault();

            ballSpawnManager = ballSpawnManagerFactory.Create(board, ballColorPool);
            var ballPopManager         = new BallPopManager(board);
            var ballLifespanController = new BallLifespanController(ballSpawnManager, ballPopManager);

            ballLifespanController.Enable();

            var tileColorStyle = new TileColorStyle(
                TileColorStyleHelper.CreateVariantColorGroup(
                    tileStyle.ColorStyle.ForegroundColorGroup.IdleColor
                    ),
                tileStyle.ColorStyle.BorderColorGroup
                );
            var boardHighlightController = new BoardHighlightController(boardMouseEventsNotifier, tileColorStyle);

            boardHighlightController.Enable();
        }
Esempio n. 20
0
        public virtual GeoPosition convertPointToGeoPosition(Point2D paramPoint2D)
        {
            Rectangle rectangle = ViewportBounds;

            Point2D.Double double = new Point2D.Double(paramPoint2D.X + rectangle.X, paramPoint2D.Y + rectangle.Y);
            return(TileFactory.pixelToGeo(double, Zoom));
        }
Esempio n. 21
0
        public virtual Point2D convertGeoPositionToPoint(GeoPosition paramGeoPosition)
        {
            Point2D   point2D   = TileFactory.geoToPixel(paramGeoPosition, Zoom);
            Rectangle rectangle = ViewportBounds;

            return(new Point2D.Double(point2D.X - rectangle.X, point2D.Y - rectangle.Y));
        }
Esempio n. 22
0
        private void SetBuildList()
        {
            var tileFactroy         = new TileFactory();
            var buildingNodeFactory = new BuildingNodeFactory();
            var buildings           = PhotonNetwork.CurrentRoom.GetBuild();

            foreach (int buildId in buildings)
            {
                var tileObj         = tileFactroy.Create(buildId.ToString());
                var buildingNodeObj = buildingNodeFactory.Create();
                var tile            = tileObj.GetComponent <Tile>();
                var buildingNode    = buildingNodeObj.GetComponent <BuildingNode>();
                var tmp             = buildingNode.OwnerNameObj.transform.GetChild(0).gameObject;
                Nodes.Add(buildingNode);
                buildingNode.Tile      = tile;
                buildingNode.OwnerName = "勝利点:" + tile.Points + "\nコスト\n";
                foreach (var cost in tile.BuildCost)
                {
                    var go = Instantiate(tmp);
                    go.GetComponent <Image>().sprite = Resources.Load("Textures/" + Enum.GetName(typeof(ResourceType), cost), typeof(Sprite)) as Sprite;
                    go.transform.SetParent(buildingNode.OwnerNameObj.transform);
                    go.SetActive(true);
                }
                buildingNode.ExecuteButton.onClick.AddListener(() => Builder.BuildSetup(tile));
                buildingNodeObj.transform.SetParent(Contents.transform);
                Destroy(tileObj);
            }
        }
Esempio n. 23
0
        public void CreateCorrectTile(string expected, TileFactory sut)
        {
            var tile = sut.GetTile(expected);
            var t    = Assert.IsAssignableFrom <ITile>(tile);

            Assert.Equal(expected, t.Print());
        }
Esempio n. 24
0
 public static TileFactory getTileFactory()
 {
     if (_instance == null)
     {
         _instance = new TileFactoryImpl();
     }
     return(_instance);
 }
Esempio n. 25
0
 static public TileFactory SharedInstance(GameObject go)
 {
     if (_sharedInstance == null)
     {
         _sharedInstance = new TileFactory(go);
     }
     return(_sharedInstance);
 }
Esempio n. 26
0
 public static TileFactory GetInstance()
 {
     if (_instance == null)
     {
         _instance = new TileFactory();
     }
     return(_instance);
 }
Esempio n. 27
0
 public void Draw_StoneTile()
 {
     for (var i = 0; i < 20; i++)
     {
         var tile = TileFactory.GetTile(TileType.Stone);
         tile.Draw(_graphics, x: RandomNumber, y: RandomNumber, width: RandomNumber, height: RandomNumber);
     }
 }
Esempio n. 28
0
 private void buildTilePool()
 {
     for (int count = 0; count < maxTiles; count++)
     {
         var tempTile = TileFactory.Instance().CreateTile();
         tempTile.SetActive(false);
         tilePool.Enqueue(tempTile);
     }
 }
Esempio n. 29
0
        private void BoardModelOnTileSpawned(Tile tile, TilePosition position)
        {
            var destination = GetTileDrawPosition(position.Row, position.Col);
            var tileView    = TileFactory.CreateTileView(tile);

            tileView.Position = new Vector2(destination.X, -TileView.TextureSize.Y);
            _matrix[position.Row, position.Col] = tileView;
            _animations.Add(new MoveTileAnimation(350, _matrix[position.Row, position.Col], destination));
        }
Esempio n. 30
0
        private Vector2 createTiles()
        {
            Vector2 returnPosition = Vector2.Zero;

            int width  = 10;
            int height = 10;

            int scale = 2;

            MazeGenerator gen = new MazeGenerator(width, height, new Point(1, 1), false);

            byte[,] maze = gen.CreateMaze();
            bool hasStartTile = false;
            bool hasEndTile   = false;

            for (int x = 0; x < width; ++x)
            {
                for (int y = 0; y < height; ++y)
                {
                    for (int i = 0; i < scale; ++i)
                    {
                        for (int j = 0; j < scale; ++j)
                        {
                            if (maze[x, y] == 1)
                            {
                                this.entityContainer.Add(TileFactory.CreateWallTile(new Vector2(x * scale + i, y * scale + j) * 32));
                            }
                            else
                            {
                                if (gen.FurthestPoint == new Point(x, y) && !hasEndTile)
                                {
                                    Entity endTile = TileFactory.CreateEndTile(new Vector2(x * scale + i, y * scale + j) * 32);
                                    this.entityContainer.Add(endTile);
                                    hasEndTile = true;
                                }
                                else if ((x == 1 && y == 1) && !hasStartTile)
                                {
                                    returnPosition = new Vector2(x * scale + i, y * scale + j) * 32;
                                    Entity startTile = TileFactory.CreateStartTile(returnPosition);
                                    this.entityContainer.Add(startTile);
                                    hasStartTile = true;
                                }
                                else
                                {
                                    this.entityContainer.Add(TileFactory.CreateFloorTile(new Vector2(x * scale + i, y * scale + j) * 32));
                                }
                                if (rng.NextDouble() > 0.9d)
                                {
                                    this.entityContainer.Add(TorchFactory.CreateTorch(50, new Vector2(x * scale + i, y * scale + j) * 32));
                                }
                            }
                        }
                    }
                }
            }
            return(returnPosition);
        }
Esempio n. 31
0
    public static TileFactory Instance()
    {
        if (m_instance == null)
        {
            m_instance = new TileFactory();
        }

        return(m_instance);
    }
Esempio n. 32
0
 /// <summary>
 /// The method that all Tile must implement to describe their own behavior
 /// It return a Tile :
 /// - Either itself, if no change has been made
 /// - Either a new Tile, depending on the transformation it got (condition of transformation in the ExecuteStep of the inherited Tile classes)
 /// </summary>
 /// <param name="neighbors">The list of neighbors of the tile</param>
 public override Tile ExecuteStep(List <Tile> neighbors)
 {
     // Become "Rock" if the "Ice" touches "Lava"
     if (neighbors.Any(n => n.Type == EnumTileType.Lava))
     {
         return(TileFactory.CreateTileAt(this.Position, EnumTileType.Rock));
     }
     return(this);
 }
Esempio n. 33
0
	public void CreateTileMap()
	{
		this.width = MapController.mapController.width;
		this.height = MapController.mapController.height;

		tiles = new Tile[width,height];
		tileFactory = new TileFactory ();

		//Temporary
		setExampleStartingPosition();

		Debug.Log ("Map created: " + width + "x" + height);
		Debug.Log (width * height + " total tiles");
	}
        /// <summary>
        /// The method choose FrameBuilder.
        /// </summary>
        /// <param name="tileFactory">The Tile factory.</param>
        /// <param name="selectedPattern">The selected pattern.</param>
        /// <returns>New FrameBuilder.</returns>
        public FrameBuilder ChoosePattern(TileFactory tileFactory, string selectedPattern)
        {
            FrameBuilder frameBuilder;
            PatternTypes patterType = (PatternTypes)Enum.Parse(typeof(PatternTypes), selectedPattern, true);

            switch (patterType)
            {
                case PatternTypes.Column:
                    frameBuilder = new ColumnsPatternFrameBuilder(tileFactory);
                    break;
                default:
                    frameBuilder = new ClassicPatternFrameBuilder(tileFactory);
                    break;
            }

            return frameBuilder;
        }
Esempio n. 35
0
 public TerrainLibrary(TileFactory tf)
 {
     Mountains = new Terrain() {
         Material = tf.rocky,
         Name = "Mountains",
         MovementCost = 3
     };
     Grass = new Terrain() {
         Material = tf.grassy,
         Name = "Plains",
         MovementCost = 1
     };
     Forest = new Terrain() {
         Material = tf.forest,
         Name = "Forest",
         MovementCost = 2
     };
 }
Esempio n. 36
0
        //HEY!  groups[index] = subexpression for regexpression.
        public static Map CreateMap(Game game, Texture2D spriteMap, String[] gameDesc)
        {
            Map ret = null;

            //int subMapCounter = 0;
            Regex tileRegex = new Regex(@"t (?:(\d+),(\d+)) (?:(\d+),(\d+)|null) (?:(\d+),(\d+)|null) (true)?");    //This is looking at specific locations in the original tile map.  The 2nd to last entry is a 'refernce' to be used for the submap, and the string is a reference to determine what the tile corresponds to.
            Regex subMapRegex = new Regex(@"(\d+)\-(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)  ?(\d+)"); //This is defined to be the tiles specified for a submap
            Regex mapDefine = new Regex(@"md (\d+) (\d+)"); //This is defined as the dimensions of the map.
            //Regex subMapModeRegex = new Regex(@"(?:(\d),(\d)|null) (?:(\d),(\d)|null) (?:(\d),(\d)|null) (true|false)");
            Regex mapSet = new Regex(@"ms (\d+) (\d+) (\d+)");
            //Regex mapCreate = new Regex(
            //Regex tileRegex = new Regex(@"(?:(\d),(\d)|null) (?:(\d),(\d)|null) (?:(\d),(\d)|null) (true|false)");
            MatchCollection matches;
            MapFactory mapFact = null;
            TileFactory tiles = new TileFactory(spriteMap);
            SubMapFactory subMaps = new SubMapFactory(tiles);

            //For each string of lines in the textual map
            foreach (String line in gameDesc)
            {
                //If this is defined to be a map,
                if (mapDefine.IsMatch(line))
                {
                    matches = mapDefine.Matches(line);
                    mapFact = new MapFactory(subMaps, int.Parse(matches[0].Groups[1].Value), int.Parse(matches[0].Groups[2].Value));
                }

                //If it is information for a tile,
                else if (tileRegex.IsMatch(line))
                {
                    matches = tileRegex.Matches(line);  //Collection of matches based on regex

                    //[1],[2] = first set of (\d+),(\d+)
                    tiles.SetBaseSprite(new Rectangle(int.Parse(matches[0].Groups[1].Value) * 32, int.Parse(matches[0].Groups[2].Value) * 32, 32, 32));

                    //[3] [4] = second set of (\d+),(\d+).  Most often, both are null.
                    if (matches[0].Groups[3].Success)
                    {
                        tiles.SetAccentSprite(new Rectangle(int.Parse(matches[0].Groups[3].Value) * 32, int.Parse(matches[0].Groups[4].Value) * 32, 32, 32));
                    }

                    //[5] = passability [6] = third set of (\d+),(\d+).  Most often, both are null.
                    if (matches[0].Groups[5].Success)
                    {
                        tiles.SetTopSprite(new Rectangle(int.Parse(matches[0].Groups[5].Value) * 32, int.Parse(matches[0].Groups[6].Value) * 32, 32, 32));
                    }

                    //[7] = Passability
                    tiles.SetPassible(matches[0].Groups[7].Success);
                    tiles.AddTile();
                }

                //Or if it is information for a submap,
                else if (subMapRegex.IsMatch(line))
                {
                    matches = subMapRegex.Matches(line);

                    //From the first tile entry onward...
                    for (int x = 0; x < 32; x++)
                    {
                        //[2] = row entry, [x+3] = col entry, [1] = sub-map
                        subMaps.setTile(x, int.Parse(matches[0].Groups[2].Value), int.Parse(matches[0].Groups[x + 3].Value), int.Parse(matches[0].Groups[1].Value));
                    }
                    if (int.Parse(matches[0].Groups[1].Value) == 31) subMaps.AddSubMap();
                }

                //If it is defined for a specific submap (Submap 1-2, Submap 2-2, etc...),
                else if (mapSet.IsMatch(line))
                {
                    matches = mapSet.Matches(line);
                    mapFact.setSubSector(int.Parse(matches[0].Groups[1].Value), int.Parse(matches[0].Groups[2].Value), int.Parse(matches[0].Groups[3].Value));
                }
                else
                {
                    throw new System.ArgumentException("Line does not match known regex lines", "line");
                }
            }

            //Generate the sprite map based on the map returned.  spriteMap is the 2D map used as a reference.
            ret = mapFact.generate(spriteMap);
            return ret;
        }
 /// <summary>
 /// Initializes a new instance of the FrameBuilder class.
 /// </summary>
 /// <param name="tileFactory">TileFactory parameter.</param>
 protected FrameBuilder(TileFactory tileFactory)
 {
     this.TileFactory = tileFactory;
 }
 /// <summary>
 /// Initializes a new instance of the ColumnsPatternFrameBuilder class.
 /// </summary>
 /// <param name="tileFactory">TileFactory parameter.</param>
 public ColumnsPatternFrameBuilder(TileFactory tileFactory)
     : base(tileFactory)
 {
 }
Esempio n. 39
0
 public static TileFactory getTileFactory()
 {
     if (_instance == null)
         _instance = new TileFactoryImpl();
     return _instance;
 }
 public void InitData()
 {
     tf = new TileFactory(MAXWIDTH, MAXHEIGHT);
     bf = new BuildingFactory(tf.TileData);
 }
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            if (randomize.Pressed())
            {
                tf = new TileFactory(MAXWIDTH, MAXHEIGHT);
                bf = new BuildingFactory(tf.TileData);
            }
            camera.Update();

            base.Update(gameTime);
        }
 /// <summary>
 /// Initializes a new instance of the ClassicPatternFrameBuilder class.
 /// </summary>
 /// <param name="tileFactory">TileFactory parameter.</param>
 public ClassicPatternFrameBuilder(TileFactory tileFactory) : base(tileFactory)
 {
 }
Esempio n. 43
0
 public SubMapFactory(TileFactory factory)
 {
     fact = factory;
     def.Add(new int[32, 32]);
 }
Esempio n. 44
0
 public Map(int width, int height, TileFactory game)
 {
     this.Width = width;
     this.Height = height;
     this.Game = game;
     this.Terrain = new TerrainLibrary(game);
 }
Esempio n. 45
0
    private void Start() {
		_figureFactory = this.GetComponent<FigureFactory> ();
		_tileFactory = this.GetComponent<TileFactory> ();
		_board = new PrototypeBoard (_dimensionOfBoard, _tileFactory);
        SetupPrototypeBoardFigures();
    }