예제 #1
0
    public float PositionDistanceInLevel(Vector2 pos0, Vector2 pos1)
    {
        ViewBounds view0Bounds = ViewBoundsByID(0);
        ViewBounds view5Bounds = ViewBoundsByID(views.Length - 1);

        float pos0DistToLeftTransfer  = Mathf.Abs(pos0.x - view0Bounds.left);
        float pos0DistToRightTransfer = Mathf.Abs(pos0.x - view5Bounds.right);
        float pos0DistToPos1          = Mathf.Abs(pos0.x - pos1.x);
        float distToTransfer          = Mathf.Min(pos0DistToLeftTransfer, pos0DistToRightTransfer);

        float pos1DistToLeftTransfer  = Mathf.Abs(pos1.x - view0Bounds.left);
        float pos1DistToRightTransfer = Mathf.Abs(pos1.x - view5Bounds.right);

        float distViaPos0Left  = pos0DistToLeftTransfer + pos1DistToRightTransfer;
        float distViaPos0Right = pos0DistToRightTransfer + pos1DistToLeftTransfer;

        if (pos0DistToPos1 <= distViaPos0Left && pos0DistToPos1 <= distViaPos0Right)
        {
            return(Vector2.Distance(pos0, pos1));
        }

        float dX = Mathf.Min(distViaPos0Left, distViaPos0Right);
        float dY = Mathf.Abs(pos0.y - pos1.y);

        Debug.Log("pos1DistToLeftTransfer: " + pos1DistToLeftTransfer);
        Debug.Log("pos1DistToRightTransfer: " + pos1DistToRightTransfer);

        return(new Vector2(dX, dY).magnitude);
    }
예제 #2
0
        protected void SaveViewBounds(ViewBounds bounds, bool writeLocation = true, bool writeSize = true)
        {
            bounds.ThrowIfNull(nameof(bounds));

            bounds.Location  = writeLocation ? View.PersistentBounds.Location : (Point?)null;
            bounds.Size      = writeSize ? View.PersistentBounds.Size : (Size?)null;
            bounds.Maximized = View.Maximized;
        }
예제 #3
0
        void IFormView.RestoreBounds(ViewBounds bounds, bool restoreLocation, bool restoreSize)
        {
            bounds.ThrowIfNull(nameof(bounds));

            if (restoreLocation && bounds.Location != null)
            {
                Location = bounds.Location.Value;
            }
            if (restoreSize && bounds.Size != null)
            {
                Size = bounds.Size.Value;
            }
            WindowState = bounds.Maximized ? FormWindowState.Maximized : FormWindowState.Normal;
        }
예제 #4
0
    public ViewBounds Get()
    {
        ViewBounds retBounds = null;

        if (mStack.Count > 0)
        {
            retBounds = mStack.Pop();
        }
        if (null == retBounds)
        {
            retBounds = CreatViewBounds();
        }
        retBounds.gameObject.SetActive(true);
        return(retBounds);
    }
예제 #5
0
 void Update()
 {
     if (show && enabled && !BSInput.s_MouseOnUI)
     {
         GetCenterVoxel();
         UpdateViewBounds();
     }
     else
     {
         if (null != mViewBounds)
         {
             ViewBoundsMgr.Instance.Recycle(mViewBounds);
             mViewBounds = null;
         }
     }
 }
예제 #6
0
    void UpdateViewBounds()
    {
        if (null == mViewBounds)
        {
            mViewBounds = ViewBoundsMgr.Instance.Get();
        }

        float   minBorder = Mathf.RoundToInt(m_Radius);
        float   maxBorder = -minBorder + Mathf.FloorToInt(m_Radius * 2f);
        Vector3 min       = new Vector3(m_Center.x - minBorder - 0.5f, m_Center.y - 0.5f, m_Center.z - minBorder - 0.5f);
        Vector3 max       = new Vector3(m_Center.x + maxBorder + 0.5f, m_Center.y + m_AddHeight + 0.5f, m_Center.z + maxBorder + 0.5f);

        min -= shrink * Vector3.one;
        max += shrink * Vector3.one;
        mViewBounds.SetSize(max - min);
        mViewBounds.SetPos(min);
        mViewBounds.SetColor(active ? m_ActiveColors.Evaluate(1f) : m_UnActiveColors.Evaluate(1f));
    }
예제 #7
0
    public Vector2 LevelPositionToWorldPosition(Vector2 pos)
    {
        ViewBounds view0Bounds = ViewBoundsByID(0);
        ViewBounds view5Bounds = ViewBoundsByID(views.Length - 1);
        Vector2    newPos      = pos;

        if (pos.x <= view0Bounds.left)
        {
            float xOverflow = view0Bounds.left - pos.x;
            newPos.x = view5Bounds.right - xOverflow;
        }
        else if (pos.x >= view5Bounds.right)
        {
            float xOverflow = pos.x - view5Bounds.right;
            newPos.x = view0Bounds.left + xOverflow;
        }

        return(newPos);
    }
예제 #8
0
 void Update()
 {
     if (showBounds)
     {
         if (null == mViewBounds)
         {
             mViewBounds = ViewBoundsMgr.Instance.Get();
         }
         Bounds bounds = worldBounds;
         mViewBounds.SetPos(bounds.min);
         mViewBounds.SetSize(bounds.size);
         mViewBounds.SetColor(activeState?Color.green:Color.red);
     }
     else
     {
         if (null != mViewBounds)
         {
             ViewBoundsMgr.Instance.Recycle(mViewBounds);
             mViewBounds = null;
         }
     }
 }
예제 #9
0
 public void Recycle(ViewBounds bounds)
 {
     bounds.gameObject.SetActive(false);
     mStack.Push(bounds);
 }
예제 #10
0
        protected override void AddSpecifiedAttributes()
        {
            AddAttribute(PropertyHelper.GetDescription(() => RouteId), RouteId);

            if (RoutingMode != null)
            {
                AddAttribute(RoutingMode);
            }
            if (Waypoints != null)
            {
                foreach (var wp in Waypoints)
                {
                    AddAttribute(wp);
                }
            }
            if (JsonAttributes != null)
            {
                AddAttribute(JsonAttributes);
            }
            if (GeneralizationTolerances != null)
            {
                AddAttribute(GeneralizationTolerances);
            }

            AddAttribute(new JsonRepresentation(JsonAttribute.Include_TypeElement, JsonAttribute.UsePluralNamingForCollections, JsonAttribute.SupressJsonResponseObjectWrapper));

            if (RequestId != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => RequestId), RequestId);
            }
            if (Departure != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Departure), ((DateTime)Departure).ToString("s"));
            }
            if (UnitSystem != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => UnitSystem), EnumHelper.GetDescription(UnitSystem));
            }
            if (ViewBounds != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ViewBounds), ViewBounds.GetAttributeValue());
            }
            if (InstructionFormat != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => InstructionFormat), EnumHelper.GetDescription(InstructionFormat));
            }
            if (Language != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Language), EnumHelper.GetDescription(Language));
            }
            if (JsonCallback != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => JsonCallback), JsonCallback);
            }
            if (Representation != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Representation), EnumHelper.GetDescription(Representation));
            }
            if (RouteAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => RouteAttributes), string.Join(",", RouteAttributes.Select(ra => EnumHelper.GetDescription(ra))));
            }
            if (LegAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => LegAttributes), string.Join(",", LegAttributes.Select(la => EnumHelper.GetDescription(la))));
            }
            if (ManeuverAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ManeuverAttributes), string.Join(",", ManeuverAttributes.Select(ma => EnumHelper.GetDescription(ma))));
            }
            if (LinkAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => LinkAttributes), string.Join(",", LinkAttributes.Select(la => EnumHelper.GetDescription(la))));
            }
            if (ReturnElevation != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ReturnElevation), ReturnElevation.ToString().ToLower());
            }
        }
        protected override void AddSpecifiedAttributes()
        {
            //Add IRequestAttribute types
            AddAttribute(RoutingMode);
            foreach (var wp in Waypoints)
            {
                AddAttribute(wp);
            }
            if (Resolution != null)
            {
                AddAttribute(Resolution);
            }
            if (JsonAttributes != null)
            {
                AddAttribute(JsonAttributes);
            }
            if (GeneralizationTolerances != null)
            {
                AddAttribute(GeneralizationTolerances);
            }
            if (VehicleType != null)
            {
                AddAttribute(VehicleType);
            }
            if (ConsumptionModel != null)
            {
                AddAttribute(ConsumptionModel);
            }
            if (CustomConsumptionDetails != null)
            {
                AddAttribute(CustomConsumptionDetails);
            }

            AddAttribute(new JsonRepresentation(JsonAttribute.Include_TypeElement, JsonAttribute.UsePluralNamingForCollections, JsonAttribute.SupressJsonResponseObjectWrapper));

            //Other parameters
            if (RequestId != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => RequestId), RequestId);
            }
            if (AvoidAreas != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => AvoidAreas), string.Join("!", AvoidAreas.Select(aa => aa.GetAttributeValue()).ToArray()));
            }
            if (AvoidLinks != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => AvoidLinks), string.Join(",", AvoidLinks.Select(al => al.GetAttributeValue()).ToArray()));
            }
            if (AvoidSeasonalClosures != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => AvoidSeasonalClosures), AvoidSeasonalClosures.ToString().ToLower());
            }
            if (AvoidTurns != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => AvoidTurns), string.Join(",", AvoidTurns.Select(at => EnumHelper.GetDescription(at))));
            }
            if (ExcludeZones != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ExcludeZones), string.Join(",", ExcludeZones));
            }
            if (ExcludeCountries != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ExcludeCountries), string.Join(",", ExcludeCountries));
            }
            if (Departure != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Departure), ((DateTime)Departure).ToString("s"));
            }
            if (Arrival != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Arrival), ((DateTime)Arrival).ToString("s"));
            }
            if (Alternatives != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Alternatives), Alternatives.ToString());
            }
            if (UnitSystem != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => UnitSystem), EnumHelper.GetDescription(UnitSystem));
            }
            if (ViewBounds != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ViewBounds), ViewBounds.GetAttributeValue());
            }
            if (InstructionFormat != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => InstructionFormat), EnumHelper.GetDescription(InstructionFormat));
            }
            if (Language != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Language), EnumHelper.GetDescription(Language));
            }
            if (JsonCallback != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => JsonCallback), JsonCallback);
            }
            if (Representation != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Representation), EnumHelper.GetDescription(Representation));
            }
            if (RouteAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => RouteAttributes), string.Join(",", RouteAttributes.Select(ra => EnumHelper.GetDescription(ra))));
            }
            if (LegAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => LegAttributes), string.Join(",", LegAttributes.Select(la => EnumHelper.GetDescription(la))));
            }
            if (ManeuverAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ManeuverAttributes), string.Join(",", ManeuverAttributes.Select(ma => EnumHelper.GetDescription(ma))));
            }
            if (LinkAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => LinkAttributes), string.Join(",", LinkAttributes.Select(la => EnumHelper.GetDescription(la))));
            }
            if (LineAttributes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => LineAttributes), string.Join(",", LineAttributes.Select(la => EnumHelper.GetDescription(la))));
            }

            if (MaxNumberOfChanges != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => MaxNumberOfChanges), MaxNumberOfChanges.ToString());
            }
            if (AvoidTransportTypes != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => AvoidTransportTypes), string.Join(",", AvoidTransportTypes.Select(tt => EnumHelper.GetDescription(tt))));
            }

            if (WalkTimeMultiplier != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => WalkTimeMultiplier), WalkTimeMultiplier.Value.ToString(HereAPISession.Culture));
            }
            if (WalkSpeed != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => WalkSpeed), WalkSpeed.Value.ToString(HereAPISession.Culture));
            }
            if (WalkRadius != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => WalkRadius), WalkRadius.Value.ToString(HereAPISession.Culture));
            }
            if (CombineChange != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => CombineChange), CombineChange.ToString().ToLower());
            }
            if (TruckType != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => TruckType), EnumHelper.GetDescription(TruckType));
            }
            if (TrailersCount != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => TrailersCount), TrailersCount.ToString());
            }

            if (ShippedHazardousGoods != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ShippedHazardousGoods), string.Join(",", ShippedHazardousGoods.Select(sg => EnumHelper.GetDescription(sg))));
            }

            if (LimitedWeight != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => LimitedWeight), LimitedWeight.Value.ToString(HereAPISession.Culture));
            }
            if (WeightPerAxle != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => WeightPerAxle), WeightPerAxle.Value.ToString(HereAPISession.Culture));
            }
            if (Height != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Height), Height.Value.ToString(HereAPISession.Culture));
            }
            if (Width != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Width), Width.Value.ToString(HereAPISession.Culture));
            }
            if (Length != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => Length), Length.Value.ToString(HereAPISession.Culture));
            }

            if (TunnelCategory != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => TunnelCategory), EnumHelper.GetDescription(TunnelCategory));
            }
            if (TruckRestrictionPenalty != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => TruckRestrictionPenalty), EnumHelper.GetDescription(TruckRestrictionPenalty));
            }

            if (ReturnElevation != null)
            {
                AddAttribute(PropertyHelper.GetDescription(() => ReturnElevation), ReturnElevation.ToString().ToLower());
            }
        }