コード例 #1
0
    // Create a new tile
    public TileBase RequestNewTile(int x, int y, TileBase.TileType type, bool instant = false, int iMetalCost = 0, Resource.ResourceType resource = Resource.ResourceType.METAL)
    {
        TileBase newTile = Instantiate <TileBase>(prefabs[(int)type]);

        newTile.SetCoords(-100, -100);
        tiles[x, y].replacingTile = newTile;

        if (instant)
        {
            tiles[x, y].Replace();
            tiles[x, y].isConstructed = true;
        }
        else
        {
            Task task = new Task(Task.Type.BUILD, new Dictionary <Resource.ResourceType, int>()
            {
                { resource, iMetalCost }
            });
            task.associatedTile   = tiles[x, y];
            newTile.isConstructed = false;
            Player.thePlayer.pendingTasks[(int)Lizard.Assignment.WORKER].Add(task);
        }

        return(newTile);
    }
コード例 #2
0
    public virtual void Replace()
    {
        if (replacingTile == null)
        {
            return;
        }
        GetComponentInParent <TileManager>().tiles[x, y] = replacingTile;
        replacingTile.SetCoords(x, y);
        replacingTile.transform.SetParent(transform.parent);

        if (Core.theCore != null)
        {
            Core.theTM.AddAssignmnets(GetAss(), -GetNumAss());
            Core.theTM.AddAssignmnets(replacingTile.GetAss(), replacingTile.GetNumAss());
        }

        // Stage on this list to avoid concurrent modification death!
        List <Resource> stuffToMove = new List <Resource>();

        foreach (Resource resource in clutteredResources)
        {
            stuffToMove.Add(resource);
        }

        foreach (Resource resource in tidyResources)
        {
            stuffToMove.Add(resource);
        }

        foreach (Resource resource in stuffToMove)
        {
            if (resource != null)
            {
                resource.PutInRoom(replacingTile);
            }
        }

        replacingTile.bWarning = bWarning;
        replacingTile.SetTaskActive(taskbar.gameObject.activeSelf);

        GetComponentInParent <TileManager>().UpdateEdges(x, y);

        while (lizardsOnTile.Count != 0)
        {
            lizardsOnTile[0].SetTile(replacingTile);
        }
        Destroy();
    }