示例#1
0
        public static Tile GetByName(string tileName)
        {
            Tile newTile = null;

            foreach (Tile tile in Tile.loadedTiles)
            {
                if (tile.GetName() == tileName)
                {
                    //return (Tile)Helpah.Clone(tile);
                    newTile = new Tile(tileName, tile.GetWalkable(), tile.GetBuildable());
                    return newTile;
                }
            }

            if (newTile == null)
            {
                newTile = new Tile(tileName, true, true);
            }

            return newTile;
        }
示例#2
0
        /// <summary>
        /// Each of the parameters is nullable. The most complete set of data possible will be built from any non-null parameters.
        /// </summary>
        /// <param name="sendingTile"></param>
        /// <param name="sendingGameEntity"></param>
        /// <param name="sendingElement"></param>
        /// <param name="triggeringPosition"></param>
        /// <param name="triggeringScreenPosition"></param>
        /// <returns></returns>
        public static GuiEvent FromPartialData(Tile sendingTile, GameEntity sendingGameEntity, GuiElement sendingElement, Point triggeringPosition, Point triggeringScreenPosition)
        {
            GuiEvent eventToReturn = new GuiEvent(0, 0);

            //check each of the parameters for non-null values and set them in the event to return
            if (sendingTile != null)
            {
                eventToReturn.clickedTiles.Add(sendingTile);
            }
            if (sendingGameEntity != null)
            {
                eventToReturn.clickedEntities.Add(sendingGameEntity);
            }
            if (sendingElement != null)
            {
                eventToReturn.clickedElement = sendingElement;
            }
            if (triggeringPosition != null)
            {
                eventToReturn.eventPos = triggeringPosition;
            }
            if (triggeringScreenPosition != null)
            {
                eventToReturn.eventPixelPos = triggeringScreenPosition;
            }

            //go through the values, and determine values for those that are null
            if (eventToReturn.eventPos == null)
            {
                //get the position from one of the properties that we have...
            }

            //gotta do this for the other stuff too
            //eventToReturn.clickedElement = gLayer.GetElementAt(returnEvent.eventPos.x, returnEvent.eventPos.y);
            //eventToReturn.clickedEntities = gLayer.GetEntitiesAt(returnEvent.eventPos.x, returnEvent.eventPos.y);
            //eventToReturn.clickedTiles = gLayer.GetTilesAt(returnEvent.eventPos.x, returnEvent.eventPos.y);

            return eventToReturn;
        }
示例#3
0
 public void SetBackgroundTile(Tile tile)
 {
     for (short row = 0; row < this.size.height; row++)
     {
         for (short col = 0; col < this.size.width; col++)
         {
             Tile newTile = new Tile(tile.GetName(), tile.GetWalkable(), tile.GetBuildable());
             newTile.SetPosition(col, row);
             this.stageTiles.Add(newTile);
             newTile.SetParentStage(this);
         }
     }
 }
示例#4
0
 /// <summary>
 /// Fill the map with empty visible tiles.
 /// </summary>
 public void FillTiles()
 {
     for (int h = 0; h < this.size.height; h++)
     {
         for (int w = 0; w < this.size.width; w++)
         {
             Tile aTile = new Tile("", true, true);
             aTile.SetParentStage(this);
             aTile.SetPosition(w, h);
             stageTiles.Add(aTile);
         }
     }
 }
示例#5
0
 public void CreateRandomTiles()
 {
     for (int h = 0; h < this.size.height; h++)
     {
         for (int w = 0; w < this.size.width; w++)
         {
             //with the randomization of the tiles, we're going to randomize whether or not this is buildiable
             int rand = JsMath.round(JsMath.random());
             //int rand = (new Random()).Next(0, 1);
             //check whether the random # is 0 or 1, the long way, because apparently boolean.parse won't figure it out
             bool buildable = false;
             if (rand == 1)
             {
                 buildable = true;
             }
             Tile aTile = new Tile("", true, buildable);
             aTile.SetParentStage(this);
             aTile.SetPosition(w, h);
             stageTiles.Add(aTile);
         }
     }
 }
示例#6
0
 public void AppendTile(Tile tileToAdd)
 {
     this.stageTiles.Add(tileToAdd);
 }
示例#7
0
        public Tile AddTile(string name, bool walkable, bool buildable, Point tilePos)
        {
            // If a tile already exists at this position, destroy it (for now)...
            foreach(Tile tile in this.stageTiles)
            {
                if(tile.GetPosition().x == tilePos.x && tile.GetPosition().y == tilePos.y)
                {
                    //this.stageTiles.Remove(tile);
                    //tile.Destroy();
                    tile.SetBuildable(buildable);
                    tile.SetWalkable(walkable);
                    tile.SetSprite(Sprite.GetSpriteByName(name));

                    return tile;
                }
            }

            // (else)
            Tile newTile = new Tile(name, walkable, buildable);
            newTile.SetPosition(tilePos.x, tilePos.y);
            this.stageTiles.Add(newTile);
            newTile.SetParentStage(this);

            return newTile;
        }