Пример #1
0
    public void ResetStartTime()
    {
        //var maxTimeGap = Time.time - this.starttime;
        //this.starttime = this.starttime + qut.GetRanFloat(maxTimeGap);
        this.starttime = vehicleTrack.GetRandomTrackTime();

        MoveToTracktime();
    }
Пример #2
0
    public void Init(VehicleTrack vehicleTrack, SimpleDf sdf, GameObject vehicleParent, string avatartype, float startime, float avaSecpersecInput)
    {
        this.vehicleTrack = vehicleTrack;
        this.vtm          = vehicleTrack.vtm;
        this.sdf          = sdf;
        this.avaSecpersec = avaSecpersecInput;
        var cnt = Count(avatartype);

        totcnt++;

        avaGo = new GameObject(avatartype + "_" + cnt);
        avaGo.transform.parent = vehicleParent.transform;
        GameObject prefabgo = null;
        var        shift    = Vector3.zero;
        var        angle    = 0;
        var        scale    = 1;

        switch (avatartype)
        {
        case "DumpTruck":
            scale    = 1;
            angle    = 180;
            prefabgo = Resources.Load <GameObject>("obj/DumpTruck_TS1");
            break;

        case "Dozer1":
            scale    = 1;
            angle    = 0;
            shift    = new Vector3(-28.80f, 0, 0);
            prefabgo = Resources.Load <GameObject>("obj/Dozer1");
            break;

        case "Dozer2":
            scale    = 1;
            angle    = 0;
            shift    = new Vector3(-20, 0, 0);
            prefabgo = Resources.Load <GameObject>("obj/Dozer2");
            break;

        case "Minehaul1":
            scale    = 1;
            angle    = 0;
            shift    = new Vector3(0, 0, 0);
            prefabgo = Resources.Load <GameObject>("obj/Minehaul1");
            break;

        case "Shovel1":
            scale    = 1;
            angle    = 0;
            shift    = new Vector3(-10, 0, 0);
            prefabgo = Resources.Load <GameObject>("obj/Shovel1");
            break;

        case "Rover":
            scale    = 1;
            angle    = 0;
            shift    = new Vector3(0, 0, 0);
            prefabgo = Resources.Load <GameObject>("obj/Rover2");
            break;

        case "Sailboat1":
            scale    = 1;
            angle    = 90;
            shift    = new Vector3(0, 0, 0);
            prefabgo = Resources.Load <GameObject>("obj/Sailboat1");
            break;

        case "Sailboat100":
            scale             = 100;
            angle             = 90;
            this.avaSecpersec = avaSecpersec * 100;
            shift             = new Vector3(0, 0, 0);
            prefabgo          = Resources.Load <GameObject>("obj/Sailboat1");
            break;
        }
        switch (vtm.vehicleInitialPlacement)
        {
        case VehicleInitialPlacement.zero:
            this.starttime = avaSecpersec * vehicleTrack.vtm.GetSimulationTime();
            break;

        case VehicleInitialPlacement.random:
            this.starttime = vehicleTrack.GetRandomTrackTime();
            break;
        }
        if (prefabgo == null)
        {
            Debug.LogWarning($"Prefab not loaded for {avatartype}");
            return;
        }
        var       skav3 = prefabgo.transform.localScale * scale;
        Transform t     = UnityEngine.Object.Instantiate <Transform>(prefabgo.transform);

        t.localScale    = skav3;
        t.localRotation = Quaternion.Euler(0, angle, 0);
        t.position      = shift;
        t.SetParent(avaGo.transform, worldPositionStays: false);
        MoveToTracktime();
    }