当前位置: 首页>>代码示例>>C#>>正文


C# Coord类代码示例

本文整理汇总了C#中Coord的典型用法代码示例。如果您正苦于以下问题:C# Coord类的具体用法?C# Coord怎么用?C# Coord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Coord类属于命名空间,在下文中一共展示了Coord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SimpleCircle

        public SimpleCircle(Coord center, int radius)
            : base(center, radius)
        {
            pts = new List<Coord>();

            int x0 = center.X;
            int y0 = center.Y;
            int x = radius;
            int y = 0;
            int decisionOver2 = 1 - x;   // Decision criterion divided by 2 evaluated at x=r, y=0

            while (y <= x)
            {
                pts.Add(new Coord(x + x0, y + y0)); // Octant 1
                pts.Add(new Coord(y + x0, x + y0)); // Octant 2
                pts.Add(new Coord(-x + x0, y + y0)); // Octant 4
                pts.Add(new Coord(-y + x0, x + y0)); // Octant 3
                pts.Add(new Coord(-x + x0, -y + y0)); // Octant 5
                pts.Add(new Coord(-y + x0, -x + y0)); // Octant 6
                pts.Add(new Coord(x + x0, -y + y0)); // Octant 7
                pts.Add(new Coord(y + x0, -x + y0)); // Octant 8
                y++;
                if (decisionOver2 <= 0)
                {
                    decisionOver2 += 2 * y + 1;   // Change in decision criterion for y -> y+1
                }
                else
                {
                    x--;
                    decisionOver2 += 2 * (y - x) + 1;   // Change for y -> y+1, x -> x-1
                }
            }
        }        
开发者ID:Fux90,项目名称:GodsWill_ASCIIRPG,代码行数:33,代码来源:Circle.cs

示例2: OnUserJoinedMessage

        public User OnUserJoinedMessage(EMMServerMessage message)
        {
            // make sure user exists in database
            using (EMMDataContext db = Manager.GetContext)
            {
                User user = db.Users.SingleOrDefault(i => i.Username == message.Data["username"]);
                if (user == null)
                {
                    user = CreateDefaultUser(message.Data["username"]);
                }

                // parse their current location from the join message
                Coord position = new Coord(message);
                user.LocX = position.X;
                user.LocY = position.Y;
                user.LocZ = position.Z;
                user.LastSeen = DateTime.Now;
                db.SubmitChanges();

                // save the current location to the tracking table
                TrackUserPosition(user);

                return user;
            }
        }
开发者ID:Cylindric,项目名称:Enigma-MM-old,代码行数:25,代码来源:UserManager.cs

示例3: StraightTrajectory

        public void StraightTrajectory()
        {
            this.board.RemovePinAt(1, 1);

            Coord from = new Coord(0, 1), to = new Coord(2, 1);
            this.AssertBestProbToArrive(from, to, 1);
        }
开发者ID:yngwie74,项目名称:PegGame,代码行数:7,代码来源:WalkerTest.cs

示例4: makeLine

	// Generate a line from one coordinate to another
	// You can ask for it to be totaly walls or totally floor, based on the bool
	// False: Walls
	// True: Floor
	public static void makeLine(Tile[,] map, Coord begin, Coord end, bool applyFloor) {

		// Assert in range
		if( begin.isOOB (map.GetLength(0), map.GetLength (1), Direction.Stop) ||
		    end.isOOB (map.GetLength(0), map.GetLength (1), Direction.Stop) )
			return;
		
		int startX = begin.x;
		int endX = end.x;
		int startY = begin.y;
		int endY = end.y;


		// Find the linear spacing appropriate from point
		// including the endpoint
		int lengthX = Math.Abs( endX - startX );

		var linspace = new List<Double>();
			linspace = LinSpace (startY, endY, lengthX, true).ToList ();

		// Now it's time to actually put our money where our mouth is
		for(int i = startX; i < endX; i++) {
			int j = (int) linspace[i] ;
			map[i,j].property = applyFloor ? TileType.Floor1 : TileType.OuterWall1;
		}

		// Phew! Thought this one was so easy, didn't cha!?

		return;
	}
开发者ID:starrodkirby86,项目名称:Better-Game-App,代码行数:34,代码来源:RoomUtilityFunctions.cs

示例5: Distance

    public int Distance(Coord start, Coord end)
    {
        //		Debug.Log ("Chain Start: " + start.ToString());
        //		Debug.Log ("Chain End: " + end.ToString());

        return GetChain(start,end).Count;
    }
开发者ID:CaveExplorerStudio,项目名称:ProjectDarkZone,代码行数:7,代码来源:Graph.cs

示例6: RenderOverlay

		public override void RenderOverlay(Scene scene)
		{
			// compute the current frame rate
			if (_stopwatch.IsRunning)
			{
				var fps = 1.0 / _stopwatch.Elapsed.TotalSeconds;
				_stopwatch.Reset();
				_fpsAverager.Add(fps);
			}
			else
			{
				_stopwatch.Start();
			}

			// get the last mouse position
			Coord pos;
			if (_lastMouseEvent != null)
				pos = _lastMouseEvent.Pos;
			else
				pos = new Coord();
					
			_label.Body = String.Format("{0:###.#} fps -- {1} ({2} x {3})", 
				_fpsAverager.Compute(), pos, Scene.Width, Scene.Height);
			OnSceneResized(Scene);

			base.RenderOverlay(scene);
		}
开发者ID:erisonliang,项目名称:monoworks,代码行数:27,代码来源:SceneInfoOverlay.cs

示例7: DemoCardContents

		public DemoCardContents() : base(Orientation.Vertical)
		{
			var label = new Label(Name);
			AddChild(label);
			
			UserSize = new Coord(320, 480);
		}
开发者ID:erisonliang,项目名称:monoworks,代码行数:7,代码来源:DemoCardContents.cs

示例8: IsJumpableFrom

 public static bool IsJumpableFrom(Game game, Coord src, Coord toJump)
 {
     Coord diff = new Coord() { Row = toJump.Row - src.Row, Col = toJump.Col - src.Col };
     Coord toLand = new Coord() { Row = src.Row + diff.Row * 2, Col = src.Col + diff.Col * 2 };
     // TODO add out of bounds checking
     return game.GetPieceAt(toLand) == BoardSpaceState.None && game.GetPieceAt(toJump) != BoardSpaceState.None;
 }
开发者ID:NickHeiner,项目名称:chivalry,代码行数:7,代码来源:GameUtils.cs

示例9: CopyTo

 /// <summary>
 /// 拷贝源本到新元素
 /// </summary>
 /// <param name="desPos">目标坐标</param>
 public void CopyTo(Coord desPos)
 {
     if (SouVersion != null)
     {
         MotaWorld.GetInstance().MapManager.CopyNode(SouVersion, desPos);
     }
 }
开发者ID:sleepandeat,项目名称:Program,代码行数:11,代码来源:Edit.cs

示例10: Line

        public Line(Coord ptA, Coord ptB)
        {
            pts = new List<Coord>();

            int x0 = ptA.X;
            int y0 = ptA.Y;
            int x1 = ptB.X;
            int y1 = ptB.Y;

            bool steep = Math.Abs(y1 - y0) > Math.Abs(x1 - x0);
            if (steep) { Utilities.Swap<int>(ref x0, ref y0); Utilities.Swap<int>(ref x1, ref y1); }
            if (x0 > x1) { Utilities.Swap<int>(ref x0, ref x1); Utilities.Swap<int>(ref y0, ref y1); }
            int dX = (x1 - x0), dY = Math.Abs(y1 - y0), err = (dX / 2), ystep = (y0 < y1 ? 1 : -1), y = y0;

            for (int x = x0; x <= x1; ++x)
            {
                pts.Add(steep ? new Coord(y, x) : new Coord(x, y));
                err = err - dY;
                if (err < 0) { y += ystep; err += dX; }
            }

            if (pts.Count > 0 && pts[0] != ptA)
            {
                pts.Reverse();
            }
        }
开发者ID:Fux90,项目名称:GodsWill_ASCIIRPG,代码行数:26,代码来源:Line.cs

示例11: ArrowDirectionOfCoords

        public static BoardSpace.ArrowDirection ArrowDirectionOfCoords(Coord from, Coord to)
        {
            Coord diff = to - from;

            if (diff.Row < 0 && diff.Col == 0)
            {
                return BoardSpace.ArrowDirection.NORTH;
            }
            if (diff.Row < 0 && diff.Col < 0)
            {
                return BoardSpace.ArrowDirection.NORTHWEST;
            }
            if (diff.Row == 0 && diff.Col < 0)
            {
                return BoardSpace.ArrowDirection.WEST;
            }
            if (diff.Row > 0 && diff.Col < 0)
            {
                return BoardSpace.ArrowDirection.SOUTHWEST;
            }
            if (diff.Row > 0 && diff.Col == 0)
            {
                return BoardSpace.ArrowDirection.SOUTH;
            }
            if (diff.Row > 0 && diff.Col > 0)
            {
                return BoardSpace.ArrowDirection.SOUTHEAST;
            }
            if (diff.Row == 0 && diff.Col > 0)
            {
                return BoardSpace.ArrowDirection.EAST;
            }

            return BoardSpace.ArrowDirection.NORTHEAST;
        }
开发者ID:NickHeiner,项目名称:chivalry,代码行数:35,代码来源:GameUtils.cs

示例12: Main

        static void Main(string[] args)
        {
            string delim = new string('-', 50);

            string st1 = "Niki";
            string st2 = "Niki";
            string st3 = st2;
            st3 = "Gosho";
            Console.WriteLine(Object.ReferenceEquals(st3, st2));  // returns false, because for strings assigning new value doesn`t change the value in heap, but creates  new instance, writes the new value there and changes the address of the string to point to the new address with the new value. st2 value is unchanged

            //st3 = Console.ReadLine();

            Console.WriteLine(st3.Equals(st2)); // if we entered "Niki" at the console this will return true, because Equals is overriden for string types to compare by value
            Console.WriteLine(Object.ReferenceEquals(st3, st2)); // this will return false because st3 has different address than st2, although its value is the same it was dynamically (at runtime) assigned, so it was stored in a new address in heap. If it was compile time aassigned, it was going to be at the same address as st2, so this would have returned true

            Console.WriteLine(delim);
            int i1 = 1;
            //int i2 = int.Parse(Console.ReadLine());
            int i2 = 1;
            Console.WriteLine(ReferenceEquals(i1, i2));
            Console.WriteLine(Equals(i1, i2));
            Console.WriteLine(i1 == i2);

            Console.WriteLine(delim);
            Coord c1 = new Coord(1, 2);
            Coord c2 = new Coord(1, 2);

            Console.WriteLine(ReferenceEquals(c1, c2)); // always gives false for value types
            Console.WriteLine(Equals(c1, c2)); // actually compares them
            //Console.WriteLine(c1 == c2); // must be overriden first
        }
开发者ID:tddold,项目名称:TelerikAcademy-5,代码行数:31,代码来源:Program.cs

示例13: Play

        public void Play(Player p, Coord start, Coord end)
        {
            if (CanSelectToPlay(p, start.x, start.y) && board.IsEmpty(end.x, end.y))
            {
                var distance = end - start;
                int travelLength = Math.Abs(distance.x) + Math.Abs(distance.y);

                //Move -> Remove original
                if (travelLength == 2)
                {
                    board[start.x, start.y] = null;
                }

                //Copy (or Move) -> Put token
                PutToken(p, end.x, end.y);
                var offsetCalc = new OffsetCalculator(end.x, end.y);
                for (int i = 0; i < 9; i++)
                {
                    offsetCalc.setDirection(i);
                    offsetCalc.MakeOffset(1);

                    if (board.CanOvertakeToken(p, offsetCalc.ResultX, offsetCalc.ResultY))
                    {
                        PutToken(p, offsetCalc.ResultX, offsetCalc.ResultY);
                    }
                }

                HandlePlayerChange();

                if (SnapshotContainer != null)
                {
                    SnapshotContainer.TakeSnapShot(new TwoPartTurn() { Start = start, End = end, PlayerThatPlayed = p, PlayerToPlay = CurrentPlayer, Board = board.Clone() });
                }
            }
        }
开发者ID:cslecours,项目名称:RevLib,代码行数:35,代码来源:ChineseChessGame.cs

示例14: DeviceRect

 public void DeviceRect(Coord x0, Coord y0, Coord x1, Coord y1)
 {
     int x = (int) Math.Round(Math.Min((double) x0.Value, (double) x1.Value));
     int y = (int) Math.Round(Math.Min((double) x0.Value, (double) x1.Value));
     int w = (int) Math.Round(Math.Min((double) x0.Value, (double) x1.Value));
     int h = (int) Math.Round(Math.Min((double) x0.Value, (double) x1.Value));
 }
开发者ID:Helen1987,项目名称:edu,代码行数:7,代码来源:XWindowImp.cs

示例15: MoveElement

        /// <summary>
        /// 以一定的移动速度创建可移动元素对象
        /// </summary>
        /// <param name="faceIndex">移动对象的图像索引</param>
        /// <param name="pos">可移动对象的初始位置</param>
        /// <param name="name">移动对象名称</param>
        public MoveElement(MotaElement faceIndex, Coord pos, string name)
            : base(faceIndex, pos, TouchMethod.ImmediatelyTouch, true, name)
        {
            this.Speed = GameIni.IniHeroSpeed;

            MoveDirection = Direction.No;
        }
开发者ID:sleepandeat,项目名称:Program,代码行数:13,代码来源:MoveElement.cs


注:本文中的Coord类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。