FindTileByName() public static method

Finds a tile in the current level by name
public static FindTileByName ( string tileName ) : GameObject
tileName string Tile name.
return GameObject
コード例 #1
0
    public override void ExecuteTrap(int triggerX, int triggerY, int State)
    {
        Vector3 Dist = new Vector3(-64 * 1.2f, 0, 0);

        for (int i = 0; i <= X; i++)
        {
            for (int j = 0; j <= Y; j++)
            {
                //Find the tile at the location.
                GameObject ExistingTile = GameWorldController.FindTile(triggerX + i, triggerY + j, 1);
                //string Tilename = GameWorldController.GetTileName(TileX+i,TileY+j,1); //Var.GetTileName (TileX+i,TileY+j,1); //ExistingTile.name;
                //Find the tile that becomes the tile at that location.
                GameObject CTTile          = GameWorldController.FindTileByName(this.name + "_" + (i).ToString("D2") + "_" + (j).ToString("D2"));
                GameObject ReplacementTile = Instantiate(CTTile, CTTile.transform.position, CTTile.transform.rotation) as GameObject;
                ReplacementTile.transform.parent = CTTile.transform.parent;
                ReplacementTile.name             = ExistingTile.name;
                if (ExistingTile != null)
                {
                    //Debug.Log ("Destroying " + ExistingTile.name );
                    Destroy(ExistingTile);
                }
                if (ReplacementTile != null)
                {
                    //Debug.Log ("Moving " + ReplacementTile.name );
                    //ReplacementTile.name = Tilename;
                    Vector3 StartPos = ReplacementTile.transform.position;
                    Vector3 EndPos   = StartPos + Dist;
                    ReplacementTile.transform.position = Vector3.Lerp(StartPos, EndPos, 1.0f);
                }
                //Change the tile type for the automap
                GameWorldController.instance.Tilemap.tileType[triggerX + i, triggerY + j] = objInt.Quality & 0x1;
                GameWorldController.instance.Tilemap.Render[triggerX + i, triggerY + j]   = 1;
            }
        }
    }