當前位置: 首頁>>代碼示例>>C#>>正文


C# Point.Move方法代碼示例

本文整理匯總了C#中System.Point.Move方法的典型用法代碼示例。如果您正苦於以下問題:C# Point.Move方法的具體用法?C# Point.Move怎麽用?C# Point.Move使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Point的用法示例。


在下文中一共展示了Point.Move方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetNextPoint

 public Point GetNextPoint()
 {
     Point head = pList.Last();
     Point nextPoint = new Point(head);
     nextPoint.Move(1, direction);
     return nextPoint;
 }
開發者ID:DmitryOst,項目名稱:Snake_Csh,代碼行數:7,代碼來源:Snake.cs

示例2: Snake

        public Snake(Point tail, int lenght, Direction _direction)
        {
            direction = _direction;
            pList = new List<Point>();

            for (int i = 0; i < lenght; i++ )
            {
                Point p = new Point(tail);
                p.Move(i, direction);
                pList.Add(p);
            }
        }
開發者ID:DmitryOst,項目名稱:Snake_Csh,代碼行數:12,代碼來源:Snake.cs

示例3: Main

        public static void Main(string[] args)
        {
            var point = new Point(1, 2);
            var point2 = point.Clone() as Point;
            point.Move(2, 3);
            point.Print();
            point2.Print();

            var personWithChildren = new PersonWithChildren("John", "Doe");
            Console.WriteLine(personWithChildren.Name);
            personWithChildren.Children.Add(new PersonWithChildren("John", "Little"));
            Console.WriteLine(personWithChildren["John Little"].Name);
        }
開發者ID:NikolayIT,項目名稱:CSharp-Tips-and-Tricks,代碼行數:13,代碼來源:Program.cs

示例4: CheckVictory

        /// <summary>
        /// Checks if one of the players won
        /// </summary>
        /// <returns>playerId if someone won, -1 if no one did</returns>
        public string CheckVictory(int x, int y, int z)
        {
            /*
             * Basic winner finding algo:
             *  1. generate all posible direction vectors ([-1,-1,-1], [-1,-1,0] ... )
             *  2. move from current position in vector direction while its posible, getting point A
             *  3. move from current position in reverse vector direction while posible, getting point B
             *  4. if distance between A and B is field size, we've got the winner!
             *
             */
            var who = Field[x, y, z];
            if (who == 0) return null;
            var ways = new[] { -1, 0, 1 };
            foreach (var wx in ways)
            {
                foreach (var wy in ways)
                {
                    foreach (var wz in ways)
                    {
                        if (wx == 0 && wy == 0 && wz == 0)
                            continue;

                        Point pa = new Point(x, y, z);

                        Point pb = new Point(x, y, z);

                        Point newA;
                        while ((newA = pa.Move(wx, wy, wz, _fieldSize)) != null
                               && Field[newA.X, newA.Y, newA.Z] == who)
                        {
                            pa = newA;
                        }

                        Point newB;
                        while ((newB = pb.Move(-wx, -wy, -wz, _fieldSize)) != null
                               && Field[newB.X, newB.Y, newB.Z] == who)
                        {
                            pb = newB;
                        }

                        if (pa.Distance(pb) == _fieldSize)
                        {
                            return Players[who - 1];
                        }

                    }
                }
            }
            return null;
        }
開發者ID:pakrym,項目名稱:tripplet,代碼行數:54,代碼來源:Game.cs

示例5: GetPriority

 private int GetPriority(RobotMap map, Point p, int rotation)
 {
     if (!map.Explored(p)) return 5;
     var t = map[p];
     if (t == MapTileResult.Goal) return 10000000;
     if (t == MapTileResult.Wall || t == MapTileResult.Robot) return 0;
     if (t == MapTileResult.ClosedDoor) return 0;
     var count = 1;
     if (!map.Explored(p.Move(rotation + 3))) count++;
     if (!map.Explored(p.Move(rotation))) count++;
     if (!map.Explored(p.Move(rotation + 1))) count++;
     return count;
 }
開發者ID:exyi,項目名稱:LtpRobot,代碼行數:13,代碼來源:DfsControler.cs


注:本文中的System.Point.Move方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。