Esempio n. 1
0
        public IEnumerable <HexCoords> Arc(uint radius, HexFacing begin, HexFacing end)
        {
            HexCoords cursor = this + (begin.ToOffset() * (int)radius);

            // Yielding the initial cursor position is unique to arcs,
            // and is why this code works at radius 0 while rings do not.
            yield return(cursor);

            // We need to track our travel facing.
            // When following a circle, we start at the southwest corner heading north.
            // Southwest to north is rotating CW twice.
            // Any corner you start at, your travel on that side will be CW twice.
            HexRotation turnIntoSide = new HexRotation(2);

            foreach (HexFacing facing in begin.Rotate(2).CompassTurnCW(end.Rotate(1)))
            {
                for (int idx = 0; idx < radius; idx++)
                {
                    cursor += facing;
                    yield return(cursor);
                }
            }
        }