示例#1
0
    public void SetSameAs(CombinedTile ct)
    {
        lightTile    = ct.lightTile;
        lightSprites = ct.lightSprites;
        darkSprites  = ct.darkSprites;
        isPreview    = true;

        SetType();
    }
示例#2
0
    // Level loader

    public void PlaceTile(CombinedTile tile)
    {
        tile.GameObject = Instantiate(tile.Tile.TileObject);
        tile.GameObject.transform.position = new Vector2(tile.Tile.X, tile.Tile.Y);
        tile.GameObject.transform.rotation = new Quaternion(0, 0, 0, 1);
        tile.GameObject.transform.Rotate(0, 0, 90 * tile.Tile.Rotation);
        if (tile.Tile.Category == "ConveyorBelt")
        {
            tile.GameObject.GetComponent <ConveyorBelt>().TileRotation = tile.Tile.Rotation;
        }

        Debug.Log("Tile " + tile.Tile.TileObject + " placed at " + tile.Tile.X + " " + tile.Tile.Y + " layer: " + tile.Tile.Layer);
    }
示例#3
0
    public void PlaceTile()
    {
        if (activeTileIndex != -1 && activeObject != null && activeObjectIndex != -1)
        {
            if (editorTexture.transform.position.x >= Mathf.Ceil(levelWidth / -2 + 0.5f) &&
                editorTexture.transform.position.x <= Mathf.Ceil(levelWidth / 2 - 0.5f) &&
                editorTexture.transform.position.y <= Mathf.Ceil(levelHeight / 2 - 0.5f) &&
                editorTexture.transform.position.y >= Mathf.Ceil(levelHeight / -2 + 0.5f))
            {
                CombinedTile temp = levelTiles.Where(obj => obj.Tile.X == (int)ray.x && obj.Tile.Y == (int)ray.y && obj.Tile.Layer == tileLayer).SingleOrDefault <CombinedTile>();
                if (temp == null)
                {
                    temp            = new CombinedTile(null, null);
                    temp.Tile       = new Tile(activeObjectIndex, activeObject, activeObject.name, tileRotation, tileLayer, (int)ray.x, (int)ray.y, activeObjectProperties.Dimensions, activeObjectProperties.Category);
                    temp.GameObject = Instantiate(activeObject);
                    temp.GameObject.transform.position = new Vector2(ray.x, ray.y);
                    levelTiles.Add(temp);

                    Debug.Log("Tile placed at " + ray.x + " " + ray.y + " layer: " + tileLayer);
                    Debug.Log("Number of tiles saved: " + levelTiles.Count);
                }
                else
                {
                    Debug.Log("Tile already exists. Overwriting...");

                    Destroy(temp.GameObject);
                    temp.Tile       = new Tile(activeObjectIndex, activeObject, activeObject.name, tileRotation, tileLayer, (int)ray.x, (int)ray.y, activeObjectProperties.Dimensions, activeObjectProperties.Category);
                    temp.GameObject = Instantiate(activeObject);
                    temp.GameObject.transform.position = new Vector2(ray.x, ray.y);

                    Debug.Log("Tile replaced at " + ray.x + " " + ray.y + " layer: " + tileLayer);
                    Debug.Log("Number of tiles saved: " + levelTiles.Count);
                }
                temp.Tile.Rotation = tileRotation;
                temp.GameObject.transform.rotation = new Quaternion(0, 0, 0, 1);
                temp.GameObject.transform.Rotate(0, 0, Mathf.Floor(tileRotation * 90));
            }
            else
            {
                Debug.Log("Editor texture is out of level bounds.");
            }
        }
    }
示例#4
0
    static void SwitchSprite()
    {
        Transform[] selection = Selection.transforms;

        if (selection.Length > 0)
        {
            for (int i = 0; i < selection.Length; i++)
            {
                CombinedTile dspr = selection[i].GetComponent <CombinedTile>();
                if (dspr != null)
                {
                    dspr.SwitchSprites();
                    Debug.Log("Switched sprites on selected tiles");
                }
            }
        }
        else
        {
            Debug.Log("Nothing selected");
        }
    }
示例#5
0
    static void FlipTileY()
    {
        Transform[] selection = Selection.transforms;

        if (selection.Length > 0)
        {
            for (int i = 0; i < selection.Length; i++)
            {
                CombinedTile dspr = selection[i].GetComponent <CombinedTile>();
                if (dspr != null)
                {
                    dspr.FlipY();
                    Debug.Log("Flipped tile on Y on selected tiles");
                }
            }
        }
        else
        {
            Debug.Log("Nothing selected");
        }
    }