コード例 #1
0
    private TrackSection DeserializeTrackSection()
    {
        var id = reader.ReadUInt32();

        if (id == 0)
        {
            throw new System.Exception("Invalid ID 0 for track section!");
        }
        var pos     = DeserializeVector3();
        var rot     = DeserializeQuaternion();
        var length  = reader.ReadSingle();
        var curve   = reader.ReadSingle();
        var section = new TrackSection()
        {
            UniqueID = id,
            Position = pos,
            Rotation = rot,
            Length   = length,
            Curved   = curve != 0,
            Curve    = curve,
        };

        if (loadedSections.ContainsKey(id))
        {
            throw new System.Exception("Duplicate track id " + id);
        }
        loadedSections[id] = section;
        TrackDatabase.Instance.RegisterTrack(section);
        // TODO: This may be bad
        BasicTrackLayerTool.TryAutoConnect(section);
        return(section);
    }
コード例 #2
0
    public TrackSectionComponent PlaceAndRegisterSection(TrackSection section, bool autoconnect = false)
    {
        TrackDatabase.Instance.RegisterTrack(section);
        var component = PlaceSectionGameObject(section);

        if (autoconnect)
        {
            BasicTrackLayerTool.TryAutoConnect(section);
        }
        return(component);
    }
コード例 #3
0
ファイル: Script.cs プロジェクト: WouterBrookhuis/Rails
 // Use this for initialization
 void Start()
 {
     trackTool = FindObjectOfType <BasicTrackLayerTool>();
     speedText = GameObject.Find("SpeedText").GetComponent <Text>();
 }