Beispiel #1
0
    public override void _Ready()
    {
        this.Connect("input_event", this, nameof(clickedOnEmptyTile));

        index = int.Parse(Name.Substring("Tile".Length));
        foreach (ClickableItem item in GetNode("Items").GetChildren())
        {
            registerListener(item);

            var depotMaybe = item as DepotTemplate;
            if (depotMaybe != null)
            {
                this.depot = depotMaybe;
            }
        }
        randomizeGround();
    }
Beispiel #2
0
    private void initPaths()
    {
        // go through all tiles
        foreach (Tile tile in tiles)
        {
            // for those who has depot
            if (tile.hasDepot)
            {
                DepotTemplate depot          = tile.depot;
                var           color          = depot.color;
                PathElement   newPathElement = new PathElement(tile.index, depot);

                // create new Path or get existing one, based on color
                Path path;
                var  hasPath = paths.TryGetValue(color, out path);
                if (!hasPath)
                {
                    path = new Path(color);
                    paths.Add(color, path);
                }

                // write depot to the path
                if (depot.depotType == DepotType.START)
                {
                    path.startDepot = newPathElement;
                }
                else if (depot.depotType == DepotType.END)
                {
                    path.endDepot = newPathElement;
                }
                else
                {
                    throw new Exception(String.Format("I don't know this depot type '{0}'.", depot.depotType));
                }
            }
        }

        foreach (Path path in paths.Values)
        {
            path.pathCompleteEvent += pathCompleteChanged;
        }

        printPaths();
    }