Exemplo n.º 1
0
        private string GetDirection(string dir1, string dir2)
        {
            string concatenateDirection = dir1 + dir2;

            if (DirectionObject.isDirectionExisting(concatenateDirection))
            {
                return(concatenateDirection);
            }
            else
            {
                return(DIRECTION_NOT_EXISTING);
            }
        }
Exemplo n.º 2
0
        private EventRelativeToUserInformation ApiObjectToEventData(DirectionObject dObj, ApplicationUser usr,
                                                                    Event targetEvent, DirectionModes md)
        {
            var data = new EventRelativeToUserInformation
            {
                User          = usr,
                Event         = targetEvent,
                DirectionMode = md,
                Unit          = "km",
                Distance      = (dObj.routes.Any() ? dObj.routes.FirstOrDefault().legs.FirstOrDefault().distance.value / 1000.0 : 0.0),
                Duration      = (dObj.routes.Any() ? dObj.routes.FirstOrDefault().legs.FirstOrDefault().duration.value / 60 : 0),
                MapLink       = _apiHelper.GenerateMapLink(usr.Address, targetEvent.Address, md)
            };

            return(data);
        }
Exemplo n.º 3
0
        protected override void OnFixedUpdate()
        {
            base.OnFixedUpdate();


            ray = new Ray(StartingPosition, DirectionObject.GetDirection());

            Debug.DrawRay(StartingPosition, DirectionObject.GetDirection().normalized *maxDistance, Color.magenta);

            var lineRenderer = GetLineRenderer("0");

            lineRenderer.SetPosition(0, StartingPosition);

            if (Physics.SphereCast(ray, Radius, out hit, maxDistance))
            {
                Vector3 hitPoint = Vector3.MoveTowards(hit.point, hit.point + hit.normal, radius);

                if (Projection != null)
                {
                    Projection.transform.position = hitPoint;
                }

                if (hit.collider.tag.Equals(Tags.Wall.GetStringValue()))
                {
                    RemoveAllLineRendererExceptFirst();

                    lineRenderer = GetLineRenderer("0");
                    lineRenderer.SetPosition(1, hitPoint);
                }
                else
                {
                    for (int i = 0; i <= reflectionCount; i++)
                    {
                        if (Physics.SphereCast(ray, radius, out hit, maxDistance))
                        {
                            hitPoint    = Vector3.MoveTowards(hit.point, hit.point + hit.normal, radius);
                            inDirection = Vector3.Reflect(ray.direction, hit.normal);

                            if (i == reflectionCount)
                            {
                                lineRenderer = GetLineRenderer(i.ToString());


                                if (lineRenderer != null)
                                {
                                    if (Vector3.Distance(lineRenderer.GetPosition(0), hit.point) < maxReflectDistance)
                                    {
                                        lineRenderer.SetPosition(1, hitPoint);
                                    }

                                    break;
                                }
                            }


                            ray = new Ray(hitPoint, inDirection);

                            Debug.DrawRay(hit.point, hit.normal * 3, Color.blue);
                            Debug.DrawRay(hitPoint, inDirection.normalized * maxReflectDistance, Color.green);


                            if (GetLineRenderer((i + 1).ToString()) == null)
                            {
                                CreateLineRenderer((i + 1).ToString(), lineRendererContainerGO);
                            }

                            lineRenderer = GetLineRenderer((i + 1).ToString());

                            lineRenderer.SetPosition(0, hitPoint);
                            lineRenderer.SetPosition(1, hitPoint + inDirection.normalized * maxReflectDistance);

                            lineRenderer = GetLineRenderer(i.ToString());
                            lineRenderer.SetPosition(1, hitPoint);
                        }
                        else
                        {
                            lineRenderer = GetLineRenderer((i + 1).ToString());

                            if (lineRenderer != null)
                            {
                                Object.Destroy(lineRenderer.gameObject);
                            }
                        }
                    }
                }
            }
        }