示例#1
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;
    }
示例#2
0
 private void AddTeleporter(TeleporterColor color)
 {
     if (gridCreator.teleportTiles[color].Count > 1)
     {
         gridCreator.teleportTiles[color][0].UpdateTile(TileType.Standard);
         gridCreator.teleportTiles[color].RemoveAt(0);
     }
     if (gridCreator.teleportTiles[color].Count == 1)
     {
         SetTeleportDesination(gridCreator.teleportTiles[color][0], (int)color);
     }
     gridCreator.teleportTiles[color].Add(this);
 }
示例#3
0
    public void UpdateTile(TileType type, int tileVariant = 0)
    {
        if (type != tileType)
        {
            if (gridCreator.currentGridFile != null)
            {
                gridCreator.currentGridFile = null;
            }

            tileType = type;
            foreach (GameObject model in activeModels)
            {
                if (model != null)
                {
                    model.SetActive(false);
                }
            }

            if (type != TileType.Removed)
            {
                TeleporterColor color     = gridCreator.editorParams.GetTeleColor();
                int             tileIndex = (int)type;

                if (tileIndex < 6)
                {
                    activeModels[0] = transform.GetChild(tileIndex).gameObject;
                }
                else if (tileIndex > 6)
                {
                    activeModels[0] = transform.GetChild(tileIndex - 1).gameObject;
                }

                activeModels[0].SetActive(true);
                if (type == TileType.Teleport)
                {
                    activeModels[1] = transform.GetChild(0).gameObject;
                    activeModels[1].SetActive(true);
                    AddTeleporter(color);
                }
                else if (tileType == TileType.Teleport && gridCreator.teleportTiles[color].Count > 1)
                {
                    RemoveTeleportPartner(color);
                }

                tileType = type;
                if (gridCreator.editorParams.tileVariants.ContainsKey(tileType))
                {
                    SetVariant(gridCreator.editorParams.tileVariants[tileType].variant);
                }

                //Removes Character if the tile has been replaced with a wall
                if (type == TileType.UnbreakableWall)
                {
                    RemoveGridObject();
                }
            }
            else
            {
                RemoveGridObject();
                if (gridCreator.editorParams.tile == TileType.Removed)
                {
                    gridButton.SetActive(true);
                }
                gameObject.SetActive(false);
            }
        }
        else if (gridCreator.editorParams.tileVariants.ContainsKey(type) && variant != tileVariant)
        {
            if (gridCreator.currentGridFile != null)
            {
                gridCreator.currentGridFile = null;
            }

            SetVariant(tileVariant);
            if (type == TileType.Teleport)
            {
                TeleporterColor color = (TeleporterColor)tileVariant;
                RemoveTeleportPartner(color);
                AddTeleporter(color);
            }
        }
    }