private bool SimpleMoveExists(Towards towards) { var direction = new Direction(towards); var square = Geometry.ShiftSquare(MainItem.Coordinates, direction); return(Geometry.ValidSquare(square) && !State.Contain(square)); }
public void ChangeSnakeDirect(Towards newDirect) { if (Math.Abs((int)newDirect - (int)_direct) != 2) { _direct = newDirect; } }
public void Move(Towards dir) { block.MoveBlock(); if (dir == Towards.LEFT) { block.MoveLeft(); } if (dir == Towards.RIGHT) { block.MoveRight(); } if (dir == Towards.UP) { block.MoveUp(); } if (dir == Towards.DOWN) { block.MoveDown(); } if (!Intersect()) { block.ChangePos(); } else { block.InitialtPos(); } }
public void Move(Towards dir)//移动方块,返回值 { curBrick.MoveTestMod(); if (dir == Towards.LETF) { curBrick.MoveTestLeft(); } if (dir == Towards.RIGHT) { curBrick.MoveTestRight(); } if (dir == Towards.UP)//呵呵 { curBrick.MoveTestUp(); } if (dir == Towards.DOWN) { curBrick.MoveTestDown(); } if (!Intersect()) { curBrick.ChangePos();//改变位置 } else { curBrick.InitialtPos(); } }
private List <IVector> DirectionAlong(Towards towards, int distanse) { var list = new List <IVector>(); var vector = CreateVector(towards).Multiple(distanse); list.Add(vector); return(list); }
protected override void OnKeyDown(KeyEventArgs e) { if (bLost) { return; } Towards t = snake.SnakeDirect; switch (e.KeyCode) { case Keys.Left: { t = Towards.Left; } break; case Keys.Right: { t = Towards.Right; } break; case Keys.Up: { t = Towards.Up; } break; case Keys.Down: { t = Towards.Down; } break; default: return; } if (path != null) { foreach (SnakePoint p in path) { if (BgArray[p.X, p.Y].Active) { BgArray[p.X, p.Y].Active = false; BgArray[p.X, p.Y].Refresh(); } } } snake.ChangeSnakeDirect(t); if (!MoveAndEat()) { Lost(); } else { RefreshSnake(); } }
private Path SimpleMove(Towards towards) { var list = new Path(MainItem.Coordinates); var direction = new Direction(towards); var square = Geometry.ShiftSquare(MainItem.Coordinates, direction); list.Add(square); return(list); }
private bool TakingExists(Towards towards) { var direction = new Direction(towards); var vector = new Vector(direction); var draught = CreateDraught(vector, MainItem.Clothes.InverseColour()); var square = Geometry.ShiftSquare(MainItem.Coordinates, vector.Multiple(Constants.DISTANCE_FOR_SIMPLE_TAKING)); return(State.Contain(draught) && !Captured.Contain(draught) && Geometry.ValidSquare(square) && !State.Contain(square)); }
private List <IVector> DirectionsAlong(Towards towards) { var list = new List <IVector>(); var vector = CreateVector(towards); for (int i = 1; i < BoardGeometry.DRAUGHT_BOARD_WIDTH; i++) { list.Add(vector.Multiple(i)); } return(list); }
public void Turn(Towards towards) { if (towards == Towards.LEFT) { this.Dir++; } if (towards == Towards.RIGHT) { this.Dir--; } if (this.Dir == Direction.BEGIN) { this.Dir = Direction.END - 1; } if (this.Dir == Direction.END) { this.Dir = Direction.BEGIN + 1; } }
public void Turn(Towards towards) { if (towards == Towards.LEFT) { this.location.direction--; } else if (towards == Towards.RIGHT) { this.location.direction++; } if (this.location.direction == Direction.BEGIN) { this.location.direction = Direction.END - 1; } else if (this.location.direction == Direction.END) { this.location.direction = Direction.BEGIN + 1; } }
private Paths Takings(Towards towards) { var moves = new Paths(); var direction = new Direction(towards); var vector = new Vector(direction); var nextCapturedItem = CreateDraught(vector, MainItem.Clothes.InverseColour()); MoveMainItem(vector.Multiple(Constants.DISTANCE_FOR_SIMPLE_TAKING)); Captured.AddItem(nextCapturedItem); if (TakingExists()) { moves.AddMoves(Takings()); } else { moves.AddPath(new Path(MainItem.Coordinates)); } MoveMainItem(vector.Multiple(-1 * Constants.DISTANCE_FOR_SIMPLE_TAKING)); Captured.DeleteItem(nextCapturedItem); moves.InsertAtBeginning(MainItem.Coordinates); return(moves); }
public Direction(Towards course) { Course = course; }
private static Vector CreateVector(Towards towards) { var direction = new Direction(towards); return(new Vector(direction)); }
public override int GetHashCode() { int hash = 1; if (Price != 0F) { hash ^= Price.GetHashCode(); } if (Date.Length != 0) { hash ^= Date.GetHashCode(); } if (Datetime.Length != 0) { hash ^= Datetime.GetHashCode(); } if (SendingTime.Length != 0) { hash ^= SendingTime.GetHashCode(); } if (TransactTime.Length != 0) { hash ^= TransactTime.GetHashCode(); } if (Amount != 0F) { hash ^= Amount.GetHashCode(); } if (Towards != 0L) { hash ^= Towards.GetHashCode(); } if (Code.Length != 0) { hash ^= Code.GetHashCode(); } if (User.Length != 0) { hash ^= User.GetHashCode(); } if (Strategy.Length != 0) { hash ^= Strategy.GetHashCode(); } if (Type.Length != 0) { hash ^= Type.GetHashCode(); } if (BidModel.Length != 0) { hash ^= BidModel.GetHashCode(); } if (AmountModel.Length != 0) { hash ^= AmountModel.GetHashCode(); } if (OrderId.Length != 0) { hash ^= OrderId.GetHashCode(); } if (TradeId.Length != 0) { hash ^= TradeId.GetHashCode(); } if (Status.Length != 0) { hash ^= Status.GetHashCode(); } return(hash); }
public void ChangeSnakeDirect(Towards newDirect) { if (Math.Abs((int)newDirect - (int)_direct) != 2) { _direct = newDirect; } }