Example #1
0
        private void Update(EvaluationContext context)
        {
            var pointArray = PointArray.GetValue(context);

            if (pointArray == null || pointArray.Length == 0)
            {
                Length.Value = 0;
                Log.Warning("Invalid input for PointsToBuffer");
                return;
            }

            Length.Value = pointArray.Length;

            var resourceManager = ResourceManager.Instance();

            if (_bufferData.Length != pointArray.Length)
            {
                _bufferData = new T3.Core.DataTypes.Point[pointArray.Length];
            }


            for (int index = 0; index < pointArray.Length; index++)
            {
                _bufferData[index] = pointArray[index];
            }

            var stride = 32;

            _bufferWithViews.Buffer = _buffer;
            resourceManager.SetupStructuredBuffer(_bufferData, stride * pointArray.Length, stride, ref _buffer);
            resourceManager.CreateStructuredBufferSrv(_buffer, ref _bufferWithViews.Srv);
            resourceManager.CreateStructuredBufferUav(_buffer, UnorderedAccessViewBufferFlags.None, ref _bufferWithViews.Uav);
            OutBuffer.Value = _bufferWithViews;
        }
Example #2
0
 public MapUI(GameRunUI ui) : base(ui)
 {
     tilesLastSeen    = new PointArray <TileType>(GameUniverse.MapWidth, GameUniverse.MapHeight);
     featuresLastSeen = new PointArray <FeatureType>(GameUniverse.MapWidth, GameUniverse.MapHeight);
     trapsLastSeen    = new Dictionary <Point, TrapType>();
     itemsLastSeen    = new Dictionary <Point, ItemType>();
 }
Example #3
0
        private void buttonArr_Click(object sender, EventArgs e)
        {
            if ((!radioButton1.Checked) && (!radioButton2.Checked))
            {
                MessageBox.Show("请选择方向并确认");
                return;
            }

            int RowNum    = Convert.ToInt32(numericUpDown10.Value);
            int ColumnNum = Convert.ToInt32(numericUpDown11.Value);

            pLeftUp.X = Convert.ToSingle(numericUpDown1.Value);
            pLeftUp.Y = Convert.ToSingle(numericUpDown2.Value);
            pLeftUp.Z = Convert.ToSingle(numericUpDown3.Value);


            pRightUp.X = Convert.ToSingle(numericUpDown4.Value);
            pRightUp.Y = Convert.ToSingle(numericUpDown5.Value);
            pRightUp.Z = Convert.ToSingle(numericUpDown6.Value);

            pRightDwon.X = Convert.ToSingle(numericUpDown7.Value);
            pRightDwon.Y = Convert.ToSingle(numericUpDown8.Value);
            pRightDwon.Z = Convert.ToSingle(numericUpDown9.Value);

            int dripDirection = radioButton1.Checked ? 0 : 1;

            ftemp.LoadStickData(PointArray.MatrixArrayList(pLeftUp, pRightUp, pRightDwon, RowNum, ColumnNum, dripDirection), _id);
            MessageBox.Show("阵列成功");
        }
Example #4
0
    void InitHouses(string filename)
    {
        using (StreamReader sr = new StreamReader(filename)) {
            //парсинг конфига точек
            String line = "{\"Points\":" + sr.ReadToEnd() + "}";
            points = JsonUtility.FromJson <PointArray> (line);
        }
        //построение точек на карте
        int i = 1;

        foreach (var item in points.Points)
        {
            //point
            GameObject house = GameObject.Instantiate(this.house) as GameObject;
            house.name = "House" + i;
            house.transform.localPosition = new Vector3((item.X * 0.001f), (item.Y * 0.001f), -0.001f);
            house.transform.Rotate(new Vector3(-90, 0, 0));
            house.transform.localScale = new Vector3(0.0060f, 0.0060f, 0.0060f);
            house.transform.SetParent(marker.transform);


            house.AddComponent <BoxCollider>();
            BoxCollider boxColl = house.GetComponent <BoxCollider>();
            boxColl.size = new Vector3(10, 10, 10);
            house.AddComponent <ShowGoods>();



            house.layer = LayerMask.NameToLayer("AR foreground");
            SetLayerRecursively(house, house.layer);

            //constructor/sort
            if (item.Constructor)
            {
                GameObject constructor = GameObject.Instantiate(this.constructor) as GameObject;
                constructor.transform.localPosition = new Vector3((item.X * 0.001f), (item.Y * 0.001f), -0.0095f * 4.3f);
                constructor.transform.Rotate(new Vector3(-90, 0, 0));
                constructor.transform.localScale = new Vector3(24 * 0.001f, 24 * 0.001f, 24 * 0.001f);
                constructor.transform.SetParent(house.transform);


                constructor.layer = LayerMask.NameToLayer("AR foreground");
                SetLayerRecursively(constructor, constructor.layer);
            }
            if (item.Sorter)
            {
                GameObject sorter = GameObject.Instantiate(this.sorter) as GameObject;
                sorter.transform.localPosition = new Vector3((item.X * 0.001f), (item.Y * 0.001f), -0.0095f * 4.3f);
                sorter.transform.Rotate(new Vector3(-90, 0, 0));
                sorter.transform.localScale = new Vector3(24 * 0.001f, 24 * 0.001f, 24 * 0.001f);
                sorter.transform.SetParent(house.transform);


                sorter.layer = LayerMask.NameToLayer("AR foreground");
                SetLayerRecursively(sorter, sorter.layer);
            }
            i++;
        }
    }
Example #5
0
        public PointArray GetRange(int index, int count)
        {
            var range = new PointArray(count);

            for (int i = index + count - 1; i > index - 1; i--)
            {
                range.AddPoint(new Vector3(x[i].value, y[i].value, z[i].value));
            }
            return(range);
        }
Example #6
0
        public void PointArray1()
        {
            PointArray arr = new PointArray(3);

            arr[0] = new Point(1, 1);
            arr[1] = new Point(2, 2);
            arr[2] = new Point(3, 3);
            double actual = arr.FindShortestDistance();

            Assert.AreEqual(Math.Sqrt(2), actual);
        }
Example #7
0
 /// <summary>
 /// 记录绘制的点
 /// </summary>
 private void RememberPoint()
 {
     if (Operation == ScreenUnLockOperationType.Remember)
     {
         PointArray.Clear();
         foreach (var item in currentPointArray)
         {
             PointArray.Add(item);
         }
     }
 }
Example #8
0
        public static AnnotationPolyline Create(Rect rect, PointArray vertices)
        {
            PDFDict dict1 = Library.CreateDict();

            dict1["Subtype"] = Library.CreateName("Polyline");
            AnnotationPolyline polyline1 = (Resources.Get(dict1, typeof(AnnotationPolyline)) as AnnotationPolyline);

            polyline1.Rect     = rect;
            polyline1.Vertices = vertices;
            Library.CreateIndirect(dict1);
            return(polyline1);
        }
Example #9
0
        public float ZDataMin()
        {
            float zmin = 0;

            for (int i = 0; i < PointArray.GetLength(0); i++)
            {
                for (int j = 0; j < PointArray.GetLength(1); j++)
                {
                    zmin = Math.Min(zmin, PointArray[i, j].Z);
                }
            }
            return(zmin);
        }
Example #10
0
        public float ZDataMax()
        {
            float zmax = 0;

            for (int i = 0; i < PointArray.GetLength(0); i++)
            {
                for (int j = 0; j < PointArray.GetLength(1); j++)
                {
                    zmax = Math.Max(zmax, PointArray[i, j].Z);
                }
            }
            return(zmax);
        }
Example #11
0
        public GeneticTspEngine(PointArray nodePositions)
        {
            this.nodePositions = nodePositions;
            this.population = new List<Solution>();

            this.PopulationSize = 100;
            this.MutationProbability = 0.02;
            this.EliteFactor = 0.05;
            this.NNProbability = 0.02;

            this.CurrentGeneration = 0;

            this.random = new Random();
        }
Example #12
0
        public Edge FindInCompleteGraph(PointArray nodes)
        {
            this.nodes = nodes;

            TaskLogger.Text = string.Format("Computing shortest edge in graph with {0} parallel threads...", threads.Length);
            TaskLogger.Progress = 0.0;

            this.ClearThreadData();
            this.SplitDomain();

            for (int i = 0; i < threads.Length; i++)
                threads[i] = new Thread(ScanSubdomain);

            this.ExecuteThreads();

            return this.AggregateThreadResults();
        }
Example #13
0
        protected Coordinate[] ToCoordinates()
        {
            List <Coordinate> coordinates = new List <Coordinate>();

            if (PointArray != null)
            {
                coordinates = PointArray.Select(o => o.ToCoordinate()).ToList();
            }
            else
            {
                if (SegmentArray != null)
                {
                    for (int i = 0; i < SegmentArray.Length; ++i)
                    {
                        coordinates.AddRange(SegmentArray[i].ToCommonCoordinates(i == SegmentArray.Length - 1));
                    }
                }
            }

            return(coordinates.ToArray());
        }
        /// <summary>
        /// This test verify that we correctly handle unique point arrays where every point in every array belong to the same tile on the space filling curve.
        /// We verify this by asserting that we always get exactly one hit on an exact match and that the value is what we expect.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustHandlePointArraysWithinSameTile() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException, org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustHandlePointArraysWithinSameTile()
        {
            // given
            // Many random points that all are close enough to each other to belong to the same tile on the space filling curve.
            int        nbrOfValues = 10000;
            PointValue origin      = Values.pointValue(WGS84, 0.0, 0.0);
            long?      derivedValueForCenterPoint = _curve.derivedValueFor(origin.Coordinate());

            double[] centerPoint      = _curve.centerPointFor(derivedValueForCenterPoint.Value);
            double   xWidthMultiplier = _curve.getTileWidth(0, _curve.MaxLevel) / 2;
            double   yWidthMultiplier = _curve.getTileWidth(1, _curve.MaxLevel) / 2;

            IList <Value> pointArrays = new List <Value>();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = new java.util.ArrayList<>();
            IList <IndexEntryUpdate <object> > updates = new List <IndexEntryUpdate <object> >();

            for (int i = 0; i < nbrOfValues; i++)
            {
                int          arrayLength = _random.Next(5) + 1;
                PointValue[] pointValues = new PointValue[arrayLength];
                for (int j = 0; j < arrayLength; j++)
                {
                    double     x     = (_random.NextDouble() * 2 - 1) * xWidthMultiplier;
                    double     y     = (_random.NextDouble() * 2 - 1) * yWidthMultiplier;
                    PointValue value = Values.pointValue(WGS84, centerPoint[0] + x, centerPoint[1] + y);

                    AssertDerivedValue(derivedValueForCenterPoint, value);
                    pointValues[j] = value;
                }
                PointArray array = Values.pointArray(pointValues);
                pointArrays.Add(array);
                updates.Add(IndexEntryUpdate.add(i, _descriptor, array));
            }

            ProcessAll(updates);

            // then
            ExactMatchOnAllValues(pointArrays);
        }
Example #15
0
        private List <Point> GetPathToNearbyReachable(Point potentialDestination, DijkstraMap playerMovementMap, ref PointArray <bool> knownReachable, ref DijkstraMap distanceToKnownReachable)
        {
            Point destination = potentialDestination;

            // First, figure out whether the destination cell is known-reachable:
            if (knownReachable == null)
            {
                knownReachable = FloodFill.ScanToArray(Player.Position, CellIsKnownPassable);
            }
            PointArray <bool> knownReachable2 = knownReachable;            // Can't use a ref parameter inside a lambda, but using a 2nd variable works.

            if (!knownReachable[destination])
            {
                // If not, then find the nearest known reachable spaces:
                if (distanceToKnownReachable == null)
                {
                    distanceToKnownReachable = new DijkstraMap(point => 1)
                    {
                        IsSource = point => knownReachable2[point]
                    };
                    distanceToKnownReachable.Scan();
                }
                if (distanceToKnownReachable[destination] > 1)                                                                       // If distance is 1, then we can reach it anyway
                {
                    destination = destination.EnumeratePointsAtChebyshevDistance(distanceToKnownReachable[destination], true, false) // We know the distance already, so check only those cells...
                                  .Where(nearby => nearby.ExistsBetweenMapEdges() && knownReachable2[nearby])                        // ...make sure only reachable ones are considered...
                                  .WhereLeast(nearby => destination.GetHalfStepMetricDistance(nearby))                               // ...get the nearest ones to the targeted point...
                                  .WhereLeast(nearby => Player.Position.GetHalfStepMetricDistance(nearby))[0];                       // ...and finally get whichever one of those is closest to the player.
                }
            }
            if (destination == Player.Position)
            {
                return(new List <Point>());
            }
            List <Point> path = playerMovementMap.GetDownhillPath(destination, preferCardinalDirections: true, includePathSource: true, includePathDestination: false, ignorePathSourceCost: true);

            path.Reverse();
            return(path);
        }
Example #16
0
    private void Start()
    {
        mainHealth = GetComponent <Health>();
        if (!buildOnStart)
        {
            // keyFrameLength = initialSections * 4;
            lastPosition = transform.position;
            return;
        }
        body     = GameObject.Instantiate(bodyParentPrefab, Vector3.zero, Quaternion.identity).transform;
        sections = BuildSnake(initialSections);
        var turrets = GetComponent <TurretSystemComponent>();

        turrets.turretParent = body;

        keyFrameLength = initialSections * 4;
        points         = new PointArray(keyFrameLength);

        for (int i = 0; i < keyFrameLength; i++)
        {
            points.AddPoint(lastPosition);
        }
        SetKeys();
    }
Example #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void comparePointArraysMustOnlyReturnZeroForEqualArrays()
        internal virtual void ComparePointArraysMustOnlyReturnZeroForEqualArrays()
        {
            PointArray firstArray = _random.randomValues().nextPointArray();

            PointValue[] sourcePointValues = firstArray.AsObjectCopy();
            PointArray   equalArray        = Values.pointArray(sourcePointValues);

            PointValue[] centerPointValues = new PointValue[sourcePointValues.Length];
            for (int i = 0; i < sourcePointValues.Length; i++)
            {
                PointValue sourcePointValue     = sourcePointValues[i];
                CoordinateReferenceSystem crs   = sourcePointValue.CoordinateReferenceSystem;
                SpaceFillingCurve         curve = _noSpecificIndexSettings.forCrs(crs, false);
                long?spaceFillingCurveValue     = curve.DerivedValueFor(sourcePointValue.Coordinate());
                centerPointValues[i] = Values.pointValue(crs, curve.CenterPointFor(spaceFillingCurveValue.Value));
            }
            PointArray centerArray = Values.pointArray(centerPointValues);

            GenericKey firstKey = NewKeyState();

            firstKey.WriteValue(firstArray, NEUTRAL);
            GenericKey equalKey = NewKeyState();

            equalKey.WriteValue(equalArray, NEUTRAL);
            GenericKey centerKey = NewKeyState();

            centerKey.WriteValue(centerArray, NEUTRAL);
            GenericKey noCoordsKey = NewKeyState();

            noCoordsKey.WriteValue(equalArray, NEUTRAL);
            GeometryType.NoCoordinates = noCoordsKey;

            assertEquals(0, firstKey.CompareValueTo(equalKey), "expected keys to be equal");
            assertEquals(firstArray.compareToSequence(centerArray, AnyValues.COMPARATOR) != 0, firstKey.CompareValueTo(centerKey) != 0, "expected keys to be equal if and only if source points are equal");
            assertEquals(0, firstKey.CompareValueTo(noCoordsKey), "expected keys to be equal");
        }
Example #18
0
 public static                Point[] operator -(Point Point, Point[] PointArray)
 {
     return(PointArray.Select(point => Point - point).ToArray());
 }
Example #19
0
        public static                Point[] operator +(Point Point, Point[] PointArray)
        {
            IEnumerable <Point> points = PointArray.Select(point => Point + point);

            return(points.ToArray());
        }
        private void buttonArr_Click(object sender, EventArgs e)
        {
            if ((!radioButton1.Checked) && (!radioButton2.Checked))
            {
                MessageBox.Show("请选择方向并确认");
                return;
            }

            int Num = Convert.ToInt32(numericUpDown10.Value);

            int dripDirection = radioButton1.Checked ? 0 : 1;//点胶方式

            pLeftUp.X = Convert.ToSingle(numericUpDown1.Value);
            pLeftUp.Y = Convert.ToSingle(numericUpDown2.Value);
            pLeftUp.Z = Convert.ToSingle(numericUpDown3.Value);


            pRightUp.X = Convert.ToSingle(numericUpDown4.Value);
            pRightUp.Y = Convert.ToSingle(numericUpDown5.Value);
            pRightUp.Z = Convert.ToSingle(numericUpDown6.Value);

            pRightDwon.X = Convert.ToSingle(numericUpDown7.Value);
            pRightDwon.Y = Convert.ToSingle(numericUpDown8.Value);
            pRightDwon.Z = Convert.ToSingle(numericUpDown9.Value);

            List <PointF3> List;

            if (dripDirection == 0)
            {
                List = PointArray.MatrixArrayList(pLeftUp, pRightUp, pRightDwon, Num, 2, dripDirection);
            }
            else
            {
                List = PointArray.MatrixArrayList(pLeftUp, pRightUp, pRightDwon, 2, Num, dripDirection);
            }

            if (List.Count < 2)
            {
                return;
            }

            //DripLine = new List<DripLineDef>();

            for (int i = 1; i < List.Count; i++)
            {
                //DripLineDef def = new DripLineDef();
                PointF4 f4 = new PointF4();

                f4.X = List[i - 1].X;
                f4.Y = List[i - 1].Y;
                f4.Z = List[i - 1].Z;

                //def.Point.Add(f4);

                PointF4 point = new PointF4();

                point.X = List[i].X;
                point.Y = List[i].Y;
                point.Z = List[i].Z;

                //def.Point.Add(point);

                //DripLine.Add(def);
            }
        }
Example #21
0
 public override void RemovePoint(Point pos)
 {
     (Figure as Polygon).Points.Remove(pos);
     PointArray.Remove(pos);
 }
Example #22
0
        static void ParseData()
        {
            TaskLogger.TaskName = "Parsing";
            TaskLogger.Text = "Reading and parsing input file...";
            TaskLogger.HideProgress();

            var reader = new StreamReader(InputFileName);
            var count = int.Parse(reader.ReadLine());

            cities = new PointArray(count);
            for (int i = 0; i < count; i++)
            {
                var coords = reader.ReadLine().Split(',');

                var x = int.Parse(coords[1]);
                var y = int.Parse(coords[2]);

                cities[i] = new Point() { X = x, Y = y };
            }

            TaskLogger.ShowProgress();
        }
Example #23
0
        public void PrintDijkstraTest(PointArray <int> dm2)
        {
            PointArray <int> dm = new PointArray <int>(dm2.Width, dm2.Height);

            Screen.HoldUpdates();
            int min = int.MaxValue;

            for (int i = 0; i < GameUniverse.MapHeight; ++i)
            {
                for (int j = 0; j < GameUniverse.MapWidth; ++j)
                {
                    dm[j, i] = dm2[j, i];
                    if (dm[j, i] != DijkstraMap.Blocked && dm[j, i] < min)
                    {
                        min = dm[j, i];
                    }
                }
            }
            if (min != 0)
            {
                for (int i = 0; i < GameUniverse.MapHeight; ++i)
                {
                    for (int j = 0; j < GameUniverse.MapWidth; ++j)
                    {
                        if (dm[j, i] != DijkstraMap.Blocked && dm[j, i] != DijkstraMap.Unexplored)
                        {
                            dm[j, i] -= min;
                        }
                    }
                }
            }
            for (int i = 0; i < GameUniverse.MapHeight; ++i)
            {
                for (int j = 0; j < GameUniverse.MapWidth; ++j)
                {
                    int   num     = dm[j, i];
                    char  ch      = '#';
                    Color bgColor = Color.Gray;
                    Color color   = Color.Black;
                    if (num != DijkstraMap.Unexplored && num != DijkstraMap.Blocked)
                    {
                        bgColor = Color.Black;
                        if (num < 10)
                        {
                            color = Color.Yellow;
                            ch    = num.ToString()[0];
                        }
                        else
                        {
                            if (num < 36)
                            {
                                color = Color.Red;
                                ch    = (char)((num - 10) + 'a');
                            }
                            else if (num < 62)
                            {
                                color = Color.Magenta;
                                ch    = (char)((num - 36) + 'A');
                            }
                            else
                            {
                                color = Color.Blue;
                                ch    = '+';
                            }
                        }
                    }
                    Screen.Write(GameUniverse.MapHeight - 1 - i + MapUI.RowOffset, j + MapUI.ColOffset, ch, color, bgColor);
                }
            }
            Screen.ResumeUpdates();
            Input.ReadKey();
        }
Example #24
0
 public void AddPoint(PointArray polyLine)
 {
     points.Add(polyLine);
 }
Example #25
0
 public void SetPoints(PointArray points)
 {
     this.points = points;
 }
Example #26
0
 public TwoOptimizer(PointArray nodes)
 {
     this.nodes = nodes;
 }
Example #27
0
        public void LookMode(PlayerTurnEvent e, bool startInTravelMode = false, TravelDestinationPriority travelPriority = TravelDestinationPriority.Explore)
        {
            bool         travelMode         = startInTravelMode;
            List <Point> travelDestinations = GetTravelDestinations(travelPriority);            //todo, start this as null or not?
            DijkstraMap  playerMovementMap  = new DijkstraMap(point => (!Map.Seen[point] || !TileDefinition.IsPassable(TileTypeAt(point)))? -1 : 10);

            playerMovementMap.Scan(Player.Position);
            PointArray <bool> knownReachable           = null;
            DijkstraMap       distanceToKnownReachable = null;
            int   travelIndex = 0;
            Point p           = travelDestinations[0];

            while (true)
            {
                Screen.HoldUpdates();
                Screen.Clear(MessageBuffer.RowOffset, ColOffset, 4, MapDisplayWidth);
                Screen.Clear(GameRunUI.EnviromentalDescriptionRow, ColOffset, 1, MapDisplayWidth);
                Screen.Clear(GameRunUI.CommandListRow, ColOffset, 1, MapDisplayWidth);
                GameRunUI.DrawGameUI(
                    sidebar: DrawOption.Normal,
                    messages: DrawOption.DoNotDraw,
                    environmentalDesc: DrawOption.DoNotDraw,
                    commands: DrawOption.DoNotDraw
                    );
                string moveCursorMsg = travelMode? "Travel mode -- Move cursor to choose destination." : "Move cursor to look around.";
                Screen.Write(MessageBuffer.RowOffset, ColOffset, moveCursorMsg);
                Screen.Write(MessageBuffer.RowOffset + 2, ColOffset, "[Tab] to cycle between interesting targets          [m]ore details");
                Screen.Write(MessageBuffer.RowOffset + 2, ColOffset + 1, "Tab", Color.Cyan);
                Screen.Write(MessageBuffer.RowOffset + 2, ColOffset + 53, 'm', Color.Cyan);
                if (travelMode)
                {
                    Screen.Write(MessageBuffer.RowOffset + 3, ColOffset, "[x] to confirm destination           [Space] to cancel travel mode");
                    Screen.Write(MessageBuffer.RowOffset + 3, ColOffset + 1, 'x', Color.Cyan);
                    Screen.Write(MessageBuffer.RowOffset + 3, ColOffset + 38, "Space", Color.Cyan);
                }
                else
                {
                    Screen.Write(MessageBuffer.RowOffset + 3, ColOffset, "[x] to enter travel mode");
                    Screen.Write(MessageBuffer.RowOffset + 3, ColOffset + 1, 'x', Color.Cyan);
                }
                Highlight highlight;
                if (travelMode)
                {
                    List <Point> path = GetPathToNearbyReachable(p, playerMovementMap, ref knownReachable, ref distanceToKnownReachable);
                    highlight = new Highlight(MapHighlightType.Path)
                    {
                        Source      = Player.Position,
                        Destination = p,
                        LineOrPath  = path
                    };
                }
                else
                {
                    highlight = new Highlight(MapHighlightType.SinglePoint)
                    {
                        Destination = p
                    };
                }
                MapRenderer.UpdateAllSettings(p, highlight);
                MapRenderer.DrawMap(e);
                bool   hasLOS          = e.CellsVisibleThisTurn[p];
                bool   seen            = Map.Seen[p];
                string lookDescription = hasLOS? GetDescriptionAtCell(p)
                                        : seen?GetLastKnownDescriptionAtCell(p)
                                             : "";

                if (lookDescription.Length > MapDisplayWidth)
                {
                    int splitIdx = 0;
                    for (int idx = MapDisplayWidth - 1; idx >= 0; --idx)
                    {
                        if (lookDescription[idx] == ' ')
                        {
                            splitIdx = idx;
                            break;
                        }
                    }
                    int firstLineRow = Option.IsSet(BoolOptionType.MessagesAtBottom)? GameRunUI.CommandListRow
                                                : GameRunUI.EnviromentalDescriptionRow; // Start printing at whichever is higher onscreen
                    string firstLine  = lookDescription.Substring(0, splitIdx);
                    string secondLine = lookDescription.Substring(splitIdx + 1);        // Remove the space
                    if (secondLine.Length > MapDisplayWidth)
                    {
                        firstLine = hasLOS? "You see many things here."
                                                        : "You remember seeing many things here."; //todo, what should this say?
                        secondLine = "(Press 'm' for more details)";
                        //secondLine = "(Use the '[m]ore details' command for the full list)"; todo...any better options?
                    }
                    Screen.Write(firstLineRow, ColOffset, firstLine, Color.Green);
                    Screen.Write(firstLineRow + 1, ColOffset, secondLine, Color.Green);
                }
                else
                {
                    Screen.Write(GameRunUI.EnviromentalDescriptionRow, ColOffset, lookDescription, Color.Green);
                }
                Screen.ResumeUpdates();
                bool needsRedraw = false;
                while (!needsRedraw)
                {
                    ConsoleKeyInfo key   = Input.ReadKey();
                    bool           shift = (key.Modifiers & ConsoleModifiers.Shift) == ConsoleModifiers.Shift;
                    switch (key.Key)
                    {
                    case ConsoleKey.Tab:
                        if (shift)
                        {
                            travelIndex--;
                        }
                        else
                        {
                            travelIndex++;
                        }
                        if (travelIndex < 0)
                        {
                            travelIndex = travelDestinations.Count - 1;
                        }
                        else if (travelIndex >= travelDestinations.Count)
                        {
                            travelIndex = 0;
                        }
                        p           = travelDestinations[travelIndex];
                        needsRedraw = true;
                        break;

                    case ConsoleKey.Escape:
                        return;                                 // Done

                    case ConsoleKey.Spacebar:
                        if (travelMode)
                        {
                            travelMode  = false;
                            needsRedraw = true;
                        }
                        else
                        {
                            return;
                        }
                        break;

                    case ConsoleKey.Enter:
                        if (travelMode)
                        {
                            goto case ConsoleKey.X;                                            // Allow Enter to confirm travel destination, or cancel look mode.
                        }
                        else
                        {
                            goto case ConsoleKey.Escape;
                        }

                    case ConsoleKey.X:
                        if (travelMode)
                        {
                            List <Point> path = GetPathToNearbyReachable(p, playerMovementMap, ref knownReachable, ref distanceToKnownReachable);
                            if (path.Count > 0)
                            {
                                GameEventHandler.Path          = path;
                                GameEventHandler.NextPathIndex = 0;
                            }
                            //if(false) GameEventHandler.Autoexplore = true; //todo, option here
                            return;
                        }
                        else
                        {
                            travelMode  = true;
                            needsRedraw = true;
                        }
                        break;

                    case ConsoleKey.NumPad8:
                        p           = p.PointInDir(Dir8.N, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad6:
                        p           = p.PointInDir(Dir8.E, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad4:
                        p           = p.PointInDir(Dir8.W, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad2:
                        p           = p.PointInDir(Dir8.S, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad9:
                        p           = p.PointInDir(Dir8.NE, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad3:
                        p           = p.PointInDir(Dir8.SE, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad1:
                        p           = p.PointInDir(Dir8.SW, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad7:
                        p           = p.PointInDir(Dir8.NW, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    default:
                        break;
                    }
                    if (!p.ExistsOnMap())
                    {
                        int newX, newY;
                        if (p.X < 0)
                        {
                            newX = 0;
                        }
                        else if (p.X >= GameUniverse.MapWidth)
                        {
                            newX = GameUniverse.MapWidth - 1;
                        }
                        else
                        {
                            newX = p.X;
                        }
                        if (p.Y < 0)
                        {
                            newY = 0;
                        }
                        else if (p.Y >= GameUniverse.MapHeight)
                        {
                            newY = GameUniverse.MapHeight - 1;
                        }
                        else
                        {
                            newY = p.Y;
                        }
                        p = new Point(newX, newY);
                    }
                }
            }
        }
Example #28
0
 public NNTourFinder(PointArray nodes)
 {
     this.nodes = nodes;
     this.random = new Random();
 }
Example #29
0
 public override void AddPoint(Point pos)
 {
     (Figure as Polygon).Points.Add(pos);
     PointArray.Add(pos);
 }
Example #30
0
 internal Solution(PointArray nodesPosition, IntegerPermutation permutation)
     : base(permutation)
 {
     this.nodePositions = nodesPosition;
 }
Example #31
0
 public new IMultiPoint ToCommon()
 {
     return(new NetTopologySuite.Geometries.MultiPoint(PointArray.Select(o => ((PointN)o).ToCommon()).ToArray()));
 }