예제 #1
0
        // TODO: Move these to new class? Or abstraction?
        /// <summary>
        /// Checks for movement between two positions, stopping at the first geo wall encountered
        /// TODO: Similar for blade / rocket attacks?
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public Vector3 MoveCheck(Vector3 start, Vector3 end)
        {
            // Convert world pos to geo
            var(geoX, geoY, z) = GetGeoXYZ(start);

            // Get nearest z layer
            z = GetNearestZ(geoX, geoY, z);

            // Get target pos as geo
            var(tGeoX, tGeoY, tz) = GetGeoXYZ(end);

            // Get nearest z layer
            tz = GetNearestZ(tGeoX, tGeoY, tz);

            // TODO: Check for collisions with geoobjects

            var pointIter = new LinePointIterator(geoX, geoY, tGeoX, tGeoY);

            // First point is always available
            pointIter.Next();

            var prevX = pointIter.X();
            var prevY = pointIter.Y();
            var prevZ = z;

            // Check blocks between
            while (pointIter.Next())
            {
                var curX = pointIter.X();
                var curY = pointIter.Y();
                var curZ = GetNearestZ(curX, curY, prevZ);

                // Check for can move
                if (!CheckNearest(curX, curY, curZ))
                {
                    return(new Vector3(GetWorldX(prevX), GetWorldY(prevY), prevZ));
                }

                prevX = curX;
                prevY = curY;
                prevZ = curZ;
            }

            // Skip floor check?

            return(end);
        }
예제 #2
0
        public override void Refine()
        {
            double EPS = 0.5;

            LinePointIterator <LinePointSegmentSpline> iter = new LinePointIterator <LinePointSegmentSpline>(pointList);

            while (iter.Next())
            {
                if (iter.Current.Dist < EPS)
                {
                    RemoveVertex(iter.Current);
                }
            }

            List <SegmentSpline> marked = new List <SegmentSpline>();

            do
            {
                marked.Clear();

                foreach (var seg in segmentList)
                {
                    if (seg.distance > EPS)
                    {
                        marked.Add(seg);
                    }
                }

                foreach (var seg in marked)
                {
                    double tA = (seg.startPoint as LinePointSegmentSpline).t;
                    double tB = (seg.endPoint as LinePointSegmentSpline).t;

                    double t = (tA + tB) / 2.0;

                    LinePointSegmentSpline lcp = (seg.startPoint as LinePointSegmentSpline).spline.CreatePoint(t);
                    AddVertex(lcp, LinePointAdditionMethod.intoSpline);
                }
            }while (marked.Count != 0);
        }