Exemplo n.º 1
0
    public void SetTeleportDesination(EditorTile tile, int color)
    {
        if (tile != null)
        {
            int x = tile.Position.x;
            if (gridCreator.grid.Count > x && x > -1 && gridCreator.grid[x].Contains(tile))
            {
                if (tile.Type == TileType.Teleport && tileType == TileType.Teleport)
                {
                    if (!CheckTeleportPosition(tile.Position))
                    {
                        teleportPartner = tile;
                    }
                    SetVariant(color);

                    if (!tile.CheckTeleportPosition(Position))
                    {
                        tile.SetTeleportDesination(this, color);
                    }
                    return;
                }
            }
        }
        //Teleport Desination Removed
        teleportPartner = null;
    }
Exemplo n.º 2
0
    private void RemoveTeleportPartner(TeleporterColor color)
    {
        if (teleportPartner != null)
        {
            teleportPartner.SetTeleportDesination(null, this.variant);
        }

        if (gridCreator.teleportTiles[color].Contains(this))
        {
            gridCreator.teleportTiles[color].Remove(this);
        }
        teleportPartner = null;
    }
Exemplo n.º 3
0
    /// <summary>Creates a row of editor tiles based on the given parameters.</summary>
    /// <param name="tiles">List of tile info that could be included in the row (used primarily for loading grids).</param>
    /// <param name="xOffset">The x position of teh first tile.</param>
    /// <param name="zOffset">The z position of all tiles in the row.</param>
    /// <param name="gridIndex">The index of the row in the grid.</param>
    /// <param name="numHexes">The number of desired tiles in the row.</param>
    private void CreateRow(List <TileInfo> tiles, float xOffset, float zOffset, int gridIndex, int numHexes)
    {
        EditorList list = new EditorList();

        if (gridIndex > grid.Count - 1)
        {
            grid.Add(list);
        }
        else if (gridIndex > -1)
        {
            grid.Insert(gridIndex, list);
        }
        else
        {
            return;
        }

        for (int n = 0; n < numHexes; n++)
        {
            EditorTile tile = CreateTile(list, xOffset - (n * gridSpacing), zOffset);

            if (tile != null)
            {
                bool       teleport    = false;
                Vector2Int teleportPos = Vector2Int.left;
                list.Add(tile);
                if (tiles != null && tiles.Count > 0)
                {
                    while (tiles.Count > 0 && tiles[0].IsInvalid())
                    {
                        tiles.RemoveAt(0);
                    }

                    if (tiles.Count > 0 && MatchSpace(gridIndex, n, tiles[0].GetPosition()))
                    {
                        TileType type = tiles[0].GetInfoType();
                        if (type == TileType.Teleport)
                        {
                            //Sets teleporter parner Position
                            teleportPos = tiles[0].GetTeleportPosition();
                            //Sets teleporter's color
                            editorParams.tileVariants[TileType.Teleport].variant = tiles[0].GetVariant();
                            teleport = true;
                        }
                        else if (type == TileType.Removed)
                        {
                            removedTileButtons.Add(tile.gridButton);
                        }



                        tile.UpdateTile(type, tiles[0].GetVariant());
                        tiles.RemoveAt(0);
                    }
                }

                if (teleport)
                {
                    if (CheckTilePosition(teleportPos))
                    {
                        tile.SetTeleportDesination(GetTile(teleportPos), editorParams.tileVariants[TileType.Teleport].variant);
                    }
                }
            }
            else
            {
                Debug.LogError("Error: Grid Creator's Editor Tile prefab does not have a EditorTile component!");
            }
        }
    }