Exemplo n.º 1
0
    private BoxCollider createCollider(Vector3 position, Vehicle potentialVehicle)
    {
        // WayReference of emergency
        WayReference closestWayReference = NodeIndex.getClosestWayReference(position);

        GameObject colliderGameObject = new GameObject();

        colliderGameObject.name = "EmergencyCollider:" + emergencyId;
        colliderGameObject.transform.rotation = closestWayReference.transform.rotation * Quaternion.Euler(0f, 0f, 90f);
        colliderGameObject.transform.position = Misc.GetProjectedPointOnLine(Misc.NoZ(position), Game.getCameraPosition(closestWayReference.node1), Game.getCameraPosition(closestWayReference.node2));
        BoxCollider collider = colliderGameObject.AddComponent <BoxCollider>();

        collider.size = new Vector3(closestWayReference.transform.localScale.y, 0.1f, 3f);
        return(collider);
    }
Exemplo n.º 2
0
    private List <Pos> getEndPosForVector(Vector3 vector)
    {
        // First check in the end-point register
        foreach (KeyValuePair <long, List <WayReference> > pair in NodeIndex.endPointDriveWayIndex)
        {
            if (Game.getCameraPosition(NodeIndex.getPosById(pair.Key)) == vector)
            {
                return(new List <Pos>()
                {
                    NodeIndex.getPosById(pair.Key)
                });
            }
        }

        // If not found as end-point, get closest WayReference
        WayReference closestWayReference = NodeIndex.getClosestWayReference(vector);

        return(new List <Pos>()
        {
            closestWayReference.node1,
            closestWayReference.node2
        });
    }