コード例 #1
0
    public Track PlaceTrack(Track trackPrefab, Vector2Int coordinates)
    {
        Track oldtrack = TrackAt(coordinates);

        if (oldtrack)
        {
            if (oldtrack.type == TrackType.End)
            {
                oldtrack.transform.position = new Vector3(coordinates.x + 1, coordinates.y, 0);
            }
            else
            {
                Destroy(oldtrack.gameObject);
            }
        }

        Track newTrack = Instantiate(trackPrefab, transform);

        newTrack.transform.position = new Vector3(coordinates.x, coordinates.y, 0);

        trainManager.GhostifyActiveAndIdleTrains();

        return(newTrack);
    }