Exemple #1
0
 public Tile(OgmoTile tile, bool useSourceIndex)
 {
     this.Tint     = Color.White;
     this.Position = tile.Position;
     tileset       = tile.Tileset;
     this.Texture  = tileset.Texture;
     if (useSourceIndex)
     {
         this.Source = tileset.Sources[tile.SourceIndex];
     }
     else
     {
         this.Source = new Rectangle(tile.TextureOffset.X,
                                     tile.TextureOffset.Y,
                                     tileset.TileWidth,
                                     tileset.TileHeight);
     }
 }
            /// <summary>
            /// Constructor.
            /// </summary>
            /// <param name="tile">The tile as read in from the Ogmo library.</param>
            /// <param name="useSourceIndex">Not sure.</param>
            public Tile(OgmoTile tile, bool useSourceIndex)
            {
                mTint     = Color.White;
                mPosition = tile.Position;
                mTileSet  = tile.Tileset;
                mTexture  = mTileSet.Texture;

                if (useSourceIndex)
                {
                    mSource = mTileSet.Sources[tile.SourceIndex];
                }
                else
                {
                    mSource = new Rectangle(tile.TextureOffset.X,
                                            tile.TextureOffset.Y,
                                            mTileSet.TileWidth,
                                            mTileSet.TileHeight);
                }
            }
    private void LoadTile(OgmoTile tile, OTContainer container, float height)
    {
        string tileName = string.Format ("frame{0}", tile.id);
        string tilePath = (zoneFolder ?? "") + tileName;
        var go = GetPrefab (tilePath);
        if (go != null) {
            go = (GameObject)GameObject.Instantiate (go);
            go.transform.parent = lvl.transform;
            OTSprite ot = go.GetComponent<OTSprite> ();

            go.transform.localPosition = new Vector3 (tile.x, height, 15 - tile.y);
            if (ot != null) {
                ot.position = new Vector2 (go.transform.localPosition.x, go.transform.localPosition.z);
                ot.depth = (int)height;
                int id = ot.frameIndex;
                ot.spriteContainer = container;
                ot.frameIndex = id;
                ot.otTransform = ot.transform;
                ot.transform.localScale = Vector3.one;
            }
        }
    }