Exemplo n.º 1
0
        private Vector3 GetMarkerPositionBySlotNew(int slot, bool secondary)
        {
            if (PartyInteractionPointsIsNull() || slot < 0)
            {
                return(base.transform.position);
            }

            if (slot >= 5)
            {
                if (PartyInteractionPoints.Length - 1 < slot)
                {
                    Array.Resize(ref PartyInteractionPoints, slot + 1);
                }

                if (PartyInteractionPoints[slot] == null)
                {
                    PartyInteractionPoints[slot] = new GameObject().transform;
                }
                else
                {
                    return(PartyInteractionPoints[slot].transform.position);
                }

                var neighbor = PartyInteractionPoints[slot - 1] ?? PartyInteractionPoints[0];
                var position = neighbor.transform.position + Vector3.right;
                var rotation = neighbor.transform.rotation;

                PartyInteractionPoints[slot].transform.SetPositionAndRotation(position, rotation);
            }

            if (slot >= PartyInteractionPoints.Length)
            {
                return(base.transform.position);
            }

            if (secondary)
            {
                Vector3    hitPosition = PartyInteractionPoints[slot].position + PartyInteractionPoints[slot].right;
                Vector3    origin      = hitPosition + Vector3.up * 2f;
                RaycastHit result;
                if (GameUtilities.Raycast(origin, Vector3.down, out result, float.PositiveInfinity, LayerUtility.WalkableLayersMask))
                {
                    hitPosition = result.point;
                }

                NavMeshUtility.SamplePosition(hitPosition, out hitPosition, 5f, NavMeshUtility.WalkableAreasMask);
                return(hitPosition);
            }

            return(PartyInteractionPoints[slot].position);
        }
Exemplo n.º 2
0
        private Vector3 GetMarkerPositionBySlotNew(int slot, bool secondary)
        {
            if (WaypointsIsNull() || slot < 0)
            {
                return(base.transform.position);
            }

            if (slot >= 5)
            {
                if (Waypoints.Length - 1 < slot)
                {
                    Array.Resize(ref Waypoints, slot + 1);
                }

                if (Waypoints[slot] == null)
                {
                    Waypoints[slot] = new GameObject();
                }
                else
                {
                    return(Waypoints[slot].transform.position);
                }

                var neighbor = Waypoints[slot - 1] ?? Waypoints[0];
                var position = neighbor.transform.position + Vector3.right;
                var rotation = neighbor.transform.rotation;

                Waypoints[slot].transform.SetPositionAndRotation(position, rotation);
            }

            if (slot >= Waypoints.Length)
            {
                return(base.transform.position);
            }

            if (secondary)
            {
                Vector3    vector = Waypoints[slot].transform.position + Waypoints[slot].transform.right;
                Vector3    origin = vector + Vector3.up * 2f;
                RaycastHit result;
                if (GameUtilities.Raycast(origin, Vector3.down, out result, float.PositiveInfinity, -5))
                {
                    vector = result.point;
                }
                return(vector);
            }

            return(Waypoints[slot].transform.position);
        }