Beispiel #1
0
 /// <summary>
 /// To reuse the vehicle.
 /// Override by SumoBusController so that the gameobject position is not set to the currentStation at reset.
 /// </summary>
 /// <param name="direction"></param>
 public virtual void ResetVehicle(LineDirection direction)
 {
     this.direction     = direction;
     currentStation     = line.GetFirstStop(direction);
     nextStation        = currentStation;
     transform.position = currentStation.transform.position;
     capacity           = line.GetVehicleCapacity();
     InitLists();
     ResetTimer();
 }
Beispiel #2
0
    public static GameObject CreateGameObject(LineController line, LineDirection direction)
    {
        GameObject obj = obj = GameObject.CreatePrimitive(PrimitiveType.Cube);

        obj.transform.localScale *= 0.6f;


        if (line.category == LineCategory.Train)
        {
            var comp = line.gameObject.GetComponent <SpawnerLineController>();
            if (comp != null && comp.modelToSpawn != null)
            {
                obj = Instantiate(comp.modelToSpawn);
            }
        }

        var ctrl = obj.AddComponent <VehicleController>();

        ctrl.id                 = IdCounter++;
        ctrl.line               = line;
        ctrl.direction          = direction;
        ctrl.currentStation     = line.GetFirstStop(direction);
        ctrl.nextStation        = ctrl.currentStation;
        ctrl.transform.position = ctrl.currentStation.transform.position;

        ctrl.capacity = line.GetVehicleCapacity();

        obj.name = "[V]" + line.category.ToString() + ctrl.id;

        obj.GetComponent <Collider>().enabled = false;
        var renderer = obj.GetComponent <MeshRenderer>();

        renderer.shadowCastingMode    = UnityEngine.Rendering.ShadowCastingMode.Off;
        renderer.receiveShadows       = false;
        renderer.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off;
        renderer.useLightProbes       = false;
        renderer.material             = new Material(Shader.Find("Standard"));
        renderer.material.color       = Color.yellow;
        return(obj);
    }