当前位置: 首页>>代码示例>>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;未经允许,请勿转载。