Ejemplo n.º 1
1
        public static void Init(Control control, Control container, Direction direction)
        {
            bool Dragging = false;
            Point DragStart = Point.Empty;

            control.MouseDown += delegate(object sender, MouseEventArgs e)
            {
                Dragging = true;
                DragStart = new Point(e.X, e.Y);
                control.Capture = true;

            };
            control.MouseUp += delegate(object sender, MouseEventArgs e)
            {
                Dragging = false;
                control.Capture = false;

            };
            control.MouseMove += delegate(object sender, MouseEventArgs e)
            {
                if (Dragging)
                {
                    if (direction != Direction.Vertical)
                        container.Left = Math.Max(0, e.X + container.Left - DragStart.X);
                    if (direction != Direction.Horizontal)
                        container.Top = Math.Max(0, e.Y + container.Top - DragStart.Y);
                }
            };
        }
Ejemplo n.º 2
0
        public void MoveScreen(Direction dd)
        {
            using (var w = Window.ForegroundWindow())
            {
                var currentScreenRect = w.ScreenRect();
                var hw = currentScreenRect.Width / 2;
                var hh = currentScreenRect.Height / 2;
                var nextPoint = currentScreenRect.Location;
                switch (dd)
                {
                    case Direction.Left:
                        nextPoint.Offset(-1, hh);
                        break;
                    case Direction.Up:
                        nextPoint.Offset(hw, -1);
                        break;
                    case Direction.Right:
                        nextPoint.Offset(currentScreenRect.Width + 1, hh);
                        break;
                    case Direction.Down:
                        nextPoint.Offset(hw, currentScreenRect.Height + 1);
                        break;
                }

                var newScreen = Screen.FromPoint(nextPoint);

                var newOffset = RepositionPoint(w.NormalRectangle.Location, currentScreenRect.Location, newScreen.WorkingArea.Location);

                w.MoveTo(newOffset);
            }
        }
Ejemplo n.º 3
0
 public void ThrowsArgumentOutOfRangeException_WhenShipIsOutOfBoard(byte x, byte y, Direction direction)
 {
     Assert.Throws<ArgumentOutOfRangeException>(() =>
     {
         board.Add(new Battleship(x, y, direction));
     });
 }
Ejemplo n.º 4
0
		public override bool OnMoveInto( Mobile m, Direction d, Point3D newLocation, Point3D oldLocation )
		{
			if ( m.AccessLevel > AccessLevel.Player || Contains( oldLocation ) )
				return true;

            // do they have enough faction to enter?
            XmlMobFactions a = (XmlMobFactions)XmlAttach.FindAttachment(m, typeof(XmlMobFactions));
            
            if(a == null) return false;
            
            int fac = a.GetFactionLevel(m_FactionType);
            
            if(fac < FactionLevel)
            {
                // throttle message display
                if(DateTime.Now - m_lastmsg > TimeSpan.FromSeconds(1))
                {
                    m.SendMessage("Your {0} faction is too low to enter here", FactionType);
                    m_lastmsg = DateTime.Now;
                }
                return false;
            }

			return true;
		}
Ejemplo n.º 5
0
 public Rotation(Direction d, float xr, float yr, float zr)
 {
     this.dir  = d;
     this.xRot = xr;
     this.yRot = yr;
     this.zRot = zr;
 }
        private bool Move(Direction direction)
        {
            if (Editor.WebEditor.Host == null)
                return false;

            var point = _textView.BufferGraph.MapDownToInsertionPoint(_textView.Caret.Position.BufferPosition, PointTrackingMode.Positive, ts => ts.ContentType.IsOfType(Editor.CssContentTypeDefinition.CssContentType));
            if (point == null)
                return false;

            var tree = CssEditorDocument.FromTextBuffer(point.Value.Snapshot.TextBuffer);
            ParseItem item = tree.StyleSheet.ItemBeforePosition(point.Value.Position);
            if (item == null)
                return false;

            NumericalValue unit = item.FindType<NumericalValue>();
            if (unit != null)
            {
                return HandleUnits(direction, unit, point.Value.Snapshot);
            }

            HexColorValue hex = item.FindType<HexColorValue>();
            if (hex != null)
            {
                return HandleHex(direction, hex, point.Value.Snapshot);
            }

            return false;
        }
Ejemplo n.º 7
0
        public static Direction OppositeDirection(Direction from)
        {
            switch (from)
            {
                case Direction.Northwest:
                    return Direction.Southeast;
                case Direction.North:
                    return Direction.South;
                case Direction.Northeast:
                    return Direction.Southwest;

                case Direction.East:
                    return Direction.West;
                case Direction.West:
                    return Direction.East;

                case Direction.Southeast:
                    return Direction.Northwest;
                case Direction.South:
                    return Direction.North;
                case Direction.Southwest:
                    return Direction.Northeast;

                case Direction.Up:
                    return Direction.Down;
                case Direction.Down:
                    return Direction.Up;
            }
            return Direction.Here;
        }
 public static void BuildRenderer(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction, Vector3 ModelSize, Vector3 ConnMeshSizeX, Vector3 ConnMeshSizeY, Vector3 ConnMeshSizeZ, Direction[] Dir)
 {
     MakeStickFace(chunk, pos, meshData, direction, false, ModelSize);
     Debug.Log(Dir.Length);
     if (Dir.Length > 0)
         MakeFenceFace(chunk, pos, meshData, direction, false, ModelSize, ConnMeshSizeX, ConnMeshSizeY, ConnMeshSizeZ, Dir);
 }
Ejemplo n.º 9
0
 public void DrawMouse(Position position, Direction direction)
 {
     MousePosition = position;
     MouseDirection = direction;
     PrepareMouse();
     Invalidate();
 }
Ejemplo n.º 10
0
 public static Point ConvertDirectionToDestinationPoint(Point initial, Direction direction)
 {
     Point destPoint;
     switch (direction)
     {
         case Direction.North:
             destPoint = new Point(initial.X, initial.Y - 1);
             break;
         case Direction.South:
             destPoint = new Point(initial.X, initial.Y + 1);
             break;
         case Direction.West:
             destPoint = new Point(initial.X - 1, initial.Y);
             break;
         case Direction.East:
             destPoint = new Point(initial.X + 1, initial.Y);
             break;
         case Direction.Northeast:
             destPoint = new Point(initial.X + 1, initial.Y - 1);
             break;
         case Direction.Northwest:
             destPoint = new Point(initial.X - 1, initial.Y - 1);
             break;
         case Direction.Southeast:
             destPoint = new Point(initial.X + 1, initial.Y + 1);
             break;
         case Direction.Southwest:
             destPoint = new Point(initial.X - 1, initial.Y + 1);
             break;
         default:
             throw new ArgumentException("ConvertDirectionToDestinationPoint - Invalid Direction");
     }
     return destPoint;
 }
		public Alert ExitAlertCreate(Bar exitBar, Position position, double stopOrLimitPrice, string signalName,
			Direction direction, MarketLimitStop exitMarketLimitStop) {

			this.checkThrowEntryBarIsValid(exitBar);
			this.checkThrowPositionToCloseIsValid(position);

			double priceScriptOrStreaming = stopOrLimitPrice;
			OrderSpreadSide orderSpreadSide = OrderSpreadSide.Unknown;
			if (exitMarketLimitStop == MarketLimitStop.Market) {
				priceScriptOrStreaming = this.getStreamingPriceForMarketOrder(exitMarketLimitStop, direction, out orderSpreadSide);
			}

			PositionLongShort longShortFromDirection = MarketConverter.LongShortFromDirection(direction);
			double exitPriceScript = exitBar.ParentBars.SymbolInfo.RoundAlertPriceToPriceLevel(
				priceScriptOrStreaming, true, longShortFromDirection, exitMarketLimitStop);

			Alert alert = new Alert(exitBar, position.Shares, exitPriceScript, signalName,
				direction, exitMarketLimitStop, orderSpreadSide,
				//this.executor.Script,
				this.executor.Strategy);
			alert.AbsorbFromExecutor(executor);
			alert.PositionAffected = position;
			// moved to CallbackAlertFilled - we can exit by TP or SL - and position has no clue which Alert was filled!!!
			//position.ExitCopyFromAlert(alert);
			alert.PositionAffected.ExitAlertAttach(alert);

			return alert;
		}
Ejemplo n.º 12
0
        /// <summary>
        /// Removes the specified number of characters in the position defined by startIndex and endIndex.
        /// </summary>
        /// <param name="startIndex">Where to start removing characters. Base 0.</param>
        /// <param name="direction">Which direction the removal of characters goes.</param>
        /// <param name="nrOfCharacters">The number of characters to remove. 0 to make it until the end/beginning.</param>
        /// <param name="textFound">The text at which to stop removing characters. Null or empty to not search for text to stop.</param>
        /// <param name="applyTo">Whether the removal of characters applies only to the filename or only to the extension or both.
        ///                       In order to apply to both, two separate commands need to be issued.</param>
        public CommandRemoveByPosition(int startIndex, Direction direction, int nrOfCharacters, string textFound = "", CommandApplyTo applyTo = CommandApplyTo.Filename)
        {
            if (IsUntilBeginningOrEnd())
                description = string.Format("Remove characters starting at {0} until {1}",
                    startIndex,
                    direction == Direction.Forward ? "the end" : "the beginning");
            else
                description = string.Format("Remove {0} character{1} {2} starting at {3}",
                    nrOfCharacters,
                    nrOfCharacters == 1 ? "" : "s",
                    direction == Direction.Forward ? "forwards" : "backwards",
                    startIndex);

            if (!string.IsNullOrEmpty(textFound))
            {
                description += string.Format(" or the text \"{0}\" is found, whichever comes first", textFound);
            }

            description += string.Format(" applying to {0}",
                applyTo == CommandApplyTo.Filename ? "the filename" : "the extension");

            this.startIndex = startIndex;
            this.nrOfCharacters = nrOfCharacters;
            this.direction = direction;
            this.textFound = textFound;
            this.applyTo = applyTo;
        }
		private object ConvertIdentifier(
			object value,
			Item item,
			Direction direction,
			Guid providerId,
			string itemType)
		{
			if (value != null && !string.IsNullOrWhiteSpace(value.ToString()))
			{
				if (direction == Direction.Packaging)
				{
					var guid = Dependencies.ConvertIdentifier(value.ToString(), IdentifierReplaceDirection.FromNodeIdToGuid);

					// add dependency for the item
					var name = string.Concat(itemType, " from picker");
					var dependency = new Dependency(name, guid, providerId);
					item.Dependencies.Add(dependency);

					return guid;
				}
				else if (direction == Direction.Extracting)
				{
					return Dependencies.ConvertIdentifier(value.ToString(), IdentifierReplaceDirection.FromGuidToNodeId);
				}
			}

			return value;
		}
		public Alert EntryAlertCreate(Bar entryBar, double stopOrLimitPrice, string entrySignalName,
			Direction direction, MarketLimitStop entryMarketLimitStop) {

			this.checkThrowEntryBarIsValid(entryBar);

			double priceScriptOrStreaming = stopOrLimitPrice;
			OrderSpreadSide orderSpreadSide = OrderSpreadSide.Unknown;
			if (entryMarketLimitStop == MarketLimitStop.Market) {
				priceScriptOrStreaming = this.getStreamingPriceForMarketOrder(entryMarketLimitStop, direction, out orderSpreadSide);
			}

			PositionLongShort longShortFromDirection = MarketConverter.LongShortFromDirection(direction);
			// ALREADY_ALIGNED_AFTER GetAlignedBidOrAskForTidalOrCrossMarketFromStreaming
			double entryPriceScript = entryBar.ParentBars.SymbolInfo.RoundAlertPriceToPriceLevel(
				priceScriptOrStreaming, true, longShortFromDirection, entryMarketLimitStop);

			double shares = this.executor.PositionSizeCalculate(entryBar, entryPriceScript);

			Alert alert = new Alert(entryBar, shares, entryPriceScript, entrySignalName,
				direction, entryMarketLimitStop, orderSpreadSide,
				//this.executor.Script,
				this.executor.Strategy);
			alert.AbsorbFromExecutor(executor);

			return alert;
		}
Ejemplo n.º 15
0
 public void Attack(Direction direction, Random random)
 {
     foreach (Enemy enemy in Enemies)
     {
         enemy.Move(random);
     }
 }
        public ControlPage()
        {
            this.InitializeComponent();

            turn = Turn.none;
            direction = Direction.none;

            accelerometer = App.accelerometer;
            bluetooth = App.bluetooth;
            arduino = App.arduino;

            if( accelerometer == null || bluetooth == null || arduino == null )
            {
                Frame.Navigate( typeof( MainPage ) );
                return;
            }

            startButton.IsEnabled = true;
            stopButton.IsEnabled = true;
            disconnectButton.IsEnabled = true;

            bluetooth.ConnectionLost += Bluetooth_ConnectionLost;

            keepScreenOnRequest = new DisplayRequest();
            keepScreenOnRequest.RequestActive();

            App.arduino.pinMode( LR_DIRECTION_CONTROL_PIN, PinMode.OUTPUT );
            App.arduino.pinMode( FB_DIRECTION_CONTROL_PIN, PinMode.OUTPUT );
            App.arduino.pinMode( LR_MOTOR_CONTROL_PIN, PinMode.PWM );
            App.arduino.pinMode( FB_MOTOR_CONTROL_PIN, PinMode.PWM );

            App.arduino.pinMode(HEARTBEAT_LED_PIN, PinMode.OUTPUT);
        }
    private void CheckDiagonal(BoardMeta boardMeta, int row, int column, Direction direction, PlayerId playerId)
    {
        int nextRow = DirectionUtil.getNextRow (row, direction);
        int nextColumn = DirectionUtil.getNextColumn (column, direction);

        TileMeta tileMeta = boardMeta.getTile (nextRow, nextColumn);
        if (tileMeta != null) {
            PieceMeta pieceMeta = tileMeta.pieceMeta;

            if (pieceMeta != null) {
                if(pieceMeta.playerId == playerId){
                    // protect
                    tileMeta.protectList.Add(new MoveMeta(direction, 1));
                }
                else{
                    // active threat and move
                    tileMeta.moveList.Add(new MoveMeta(direction, 1));
                    tileMeta.activeThreatList.Add(new MoveMeta(direction, 1));
                }

            } else {
                // passive threat
                tileMeta.passiveThreatList.Add(new MoveMeta(direction, 1));
            }
        }
    }
Ejemplo n.º 18
0
 public DynamicObject(Position topLeft, char[,] texture, int speed, Direction direction)
     : base(topLeft, texture)
 {
     this.Speed = speed;
     this.state = this.Speed;
     this.ObjDirection = direction;
 }
Ejemplo n.º 19
0
 public Line(Vector2 newStart, Vector2 newEnd, Color colour, Direction newDir)
 {
     start = newStart;
     end = newEnd;
     drawColour = colour;
     myDir = newDir;
 }
Ejemplo n.º 20
0
        public void addAuto(Auto auto, Direction afkomst)
        {
            Direction[] choose = new Direction[3];

            switch (afkomst) {
                case Direction.NORTH:
                    choose[0] = Direction.SOUTH;
                    choose[1] = Direction.EAST;
                    choose[2] = Direction.WEST;
                    break;
                case Direction.SOUTH:
                    choose[0] = Direction.NORTH;
                    choose[1] = Direction.EAST;
                    choose[2] = Direction.WEST;
                    break;
                case Direction.EAST:
                    choose[0] = Direction.NORTH;
                    choose[1] = Direction.SOUTH;
                    choose[2] = Direction.WEST;
                    break;
                case Direction.WEST:
                    choose[0] = Direction.NORTH;
                    choose[1] = Direction.SOUTH;
                    choose[2] = Direction.EAST;
                    break;
            }

            auto.kiesRichting(choose);

            getWachtrij(afkomst, auto.Richting).Add(auto);
        }
Ejemplo n.º 21
0
 public Line(Vector2 newStart, Vector2 newEnd, Color colour)
 {
     start = newStart;
     end = newEnd;
     drawColour = colour;
     myDir = Direction.Forwards;
 }
Ejemplo n.º 22
0
    void OnTriggerEnter2D(Collider2D other)
    {
        Tile tile = other.GetComponent<Tile>();
        if (tile != null)
        {
            Position = tile.Position;
            ProcessMovement();

            if (tile.gameObject == GameManager.gameManager.TeleporterLeft.gameObject && Direction == Direction.None)
            {
                Vector3 tempPos = GameManager.gameManager.TeleporterRight.transform.position;
                tile.GetComponent<AudioSource>().Play();
                tempPos.z = transform.position.z;
                transform.position = tempPos;
                Direction = Direction.Left;
            }
            if (tile.gameObject == GameManager.gameManager.TeleporterRight.gameObject && Direction == Direction.None)
            {
                Vector3 tempPos = GameManager.gameManager.TeleporterLeft.transform.position;
                tile.GetComponent<AudioSource>().Play();
                tempPos.z = transform.position.z;
                transform.position = tempPos;
                Direction = Direction.Right;
            }
        }
    }
Ejemplo n.º 23
0
        public void ChangeDirection(Direction value)
        {
            Direction opposite = Direction.Left;
            switch (value)
            {
                case Direction.Up:
                    opposite = Direction.Down;
                    break;
                case Direction.Down:
                    opposite = Direction.Up;
                    break;
                case Direction.Left:
                    opposite = Direction.Right;
                    break;
                case Direction.Right:
                    opposite = Direction.Left;
                    break;
            }

            // must not move snake backwards except when it is only snake head
            if (opposite != _currentDirection || SnakeBody.Count == 1)
            {
                _currentDirection = value;
            }
        }
Ejemplo n.º 24
0
        //! Convert Map.Direction to LookDirection.
        public static LookDirection Convert(Direction Dir)
        {
            LookDirection direction = LookDirection.EAST;

            switch(Dir)
            {
                case he.Direction.EAST:
                    direction = LookDirection.EAST;
                    break;
                case he.Direction.NORTH:
                    direction = LookDirection.NORTH;
                    break;
                case he.Direction.NORTH_EAST:
                    direction = LookDirection.NORTHEAST;
                    break;
                case he.Direction.NORTH_WEST:
                    direction = LookDirection.NORTHWEST;
                    break;
                case he.Direction.SOUTH:
                    direction = LookDirection.SOUTH;
                    break;
                case he.Direction.SOUTH_EAST:
                    direction = LookDirection.SOUTHEAST;
                    break;
                case he.Direction.SOUTH_WEST:
                    direction = LookDirection.SOUTHWEST;
                    break;
                case he.Direction.WEST:
                    direction = LookDirection.WEST;
                    break;
            }

            return direction;
        }
Ejemplo n.º 25
0
        public Coords NeighborInDirection(Direction dir)
        {
            switch (dir)
            {
                case (Direction.Northeast):
                    return new Coords(this.Type, this.X + 1, this.Y - 1);
                case (Direction.East):
                    return new Coords(this.Type, this.X + 1, this.Y);
                case (Direction.Southeast):
                    return new Coords(this.Type, this.X + 1, this.Y + 1);
                case (Direction.South):
                    return new Coords(this.Type, this.X, this.Y + 1);
                case (Direction.Southwest):
                    return new Coords(this.Type, this.X - 1, this.Y + 1);
                case (Direction.West):
                    return new Coords(this.Type, this.X - 1, this.Y);
                case (Direction.Northwest):
                    return new Coords(this.Type, this.X - 1, this.Y - 1);
                case (Direction.North):
                    return new Coords(this.Type, this.X, this.Y - 1);
            }

            // This code should be unreachable. Added because compiler wants it.
            return this;
        }
        public Direction GetNextMove(IGameBoard board, bool lastMoveResult)
        {
            if (lastMoveResult)
                return currentDirection;

            switch (currentDirection)
            {
                case Direction.Up:
                    currentDirection = Direction.Left;
                    break;

                case Direction.Left:
                    currentDirection = Direction.Down;
                    break;

                case Direction.Down:
                    currentDirection =  Direction.Right;
                    break;

                case Direction.Right:
                    currentDirection =  Direction.Up;
                    break;

                default:
                    throw new Exception("TILT - Cannot get here, what happened?");
            }

            return currentDirection;
        }
Ejemplo n.º 27
0
        public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation)
        {
            if (m.Player && Factions.Sigil.ExistsOn(m))
            {
                m.SendMessage(0x22, "You are holding a sigil and cannot enter this zone.");
                return false;
            }

            PlayerMobile pm = m as PlayerMobile;

            if (pm == null && m is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)m;

                if (bc.Summoned)
                    pm = bc.SummonMaster as PlayerMobile;
            }

            if (pm != null && pm.DuelContext != null && pm.DuelContext.StartedBeginCountdown)
                return true;

            if (DuelContext.CheckCombat(m))
            {
                m.SendMessage(0x22, "You have recently been in combat and cannot enter this zone.");
                return false;
            }

            return base.OnMoveInto(m, d, newLocation, oldLocation);
        }
    public bool CheckCollisionDirection(Direction direction)
    {
        bool directionResult = false;

        float extraSize = 0.025f;

        float ownerHalfWidth = gameObject.rigidbody2D.renderer.bounds.size.x / 2 + extraSize;
        float ownerHalfHeight = gameObject.rigidbody2D.renderer.bounds.size.y / 2 + extraSize;

        switch(direction)
        {
            case Direction.UP:
                directionResult = CheckRayTrace(Vector2.up, ownerHalfHeight);
                break;
            case Direction.DOWN:
                directionResult = CheckRayTrace(-Vector2.up, ownerHalfHeight);
                break;
            case Direction.LEFT:
                directionResult = CheckRayTrace(-Vector2.right, ownerHalfWidth);
                break;
            case Direction.RIGHT:
                directionResult = CheckRayTrace(Vector2.right, ownerHalfWidth);
                break;
        }
        return directionResult;
    }
Ejemplo n.º 29
0
 public void SafeMoveTo(Direction direction)
 {
     if (direction == Direction.NORTH)
     {
         SwapTo(X, Y - 1, Z, true);
     }
     else if (direction == Direction.EAST)
     {
         SwapTo(X + 1, Y, Z, true);
     }
     else if (direction == Direction.SOUTH)
     {
         SwapTo(X, Y + 1, Z, true);
     }
     else if (direction == Direction.WEST)
     {
         SwapTo(X - 1, Y, Z, true);
     }
     else if (direction == Direction.NORTHEAST)
     {
         SwapTo(X + 1, Y - 1, Z, true);
     }
     else if (direction == Direction.SOUTHEAST)
     {
         SwapTo(X + 1, Y + 1, Z, true);
     }
     else if (direction == Direction.NORTHWEST)
     {
         SwapTo(X - 1, Y - 1, Z, true);
     }
     else if (direction == Direction.SOUTHWEST)
     {
         SwapTo(X - 1, Y + 1, Z, true);
     }
 }
Ejemplo n.º 30
0
 /// <summary>
 /// 上/下/左/右居中
 /// </summary>
 /// <param name="bound"></param>
 /// <param name="size"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static Rectangle NearCenter(this Rectangle bound, Size size, Direction type)
 {
     var _bound = bound;
     switch (type)
     {
         case Direction.Left:
             _bound.Inflate(0, (size.Height - bound.Height) / 2);
             _bound.Width = size.Width;
             break;
         case Direction.Up:
             _bound.Inflate((size.Width - bound.Width) / 2, 0);
             _bound.Height = size.Height;
             break;
         case Direction.Right:
             _bound.Inflate(0, (size.Height - bound.Height) / 2);
             _bound.X = bound.Right - size.Width;
             _bound.Width = size.Width;
             break;
         case Direction.Bottom:
             _bound.Inflate((size.Width - bound.Width) / 2, 0);
             _bound.Y = bound.Bottom - size.Height;
             _bound.Height = size.Height;
             break;
         default:
             break;
     }
     _bound.Intersect(bound);
     return _bound;
 }
Ejemplo n.º 31
0
        public Direction[] GetFloorTriangleSlopeDirections()
        {
            const float CriticalSlantYComponent = 0.8f;

            var normals = GetFloorTriangleNormals();

            // Initialize slope directions as unslidable by default (EntireFace means unslidable in our case).

            Direction[] slopeDirections = new Direction[2] {
                Direction.None, Direction.None
            };

            if (Floor.HasSlope)
            {
                for (int i = 0; i < (Floor.IsQuad ? 1 : 2); i++)           // If floor is quad, we don't solve second triangle
                {
                    if (Math.Abs(normals[i].Y) <= CriticalSlantYComponent) // Triangle is slidable
                    {
                        bool angleNotDefined = true;
                        var  angle           = (float)(Math.Atan2(normals[i].X, normals[i].Z) * (180 / Math.PI));
                        angle = angle < 0 ? angle + 360.0f : angle;

                        // Note about 45, 135, 225 and 315 degree steps:
                        // Core Design has used override instead of rounding for triangular slopes angled under
                        // 45-degree stride, to produce either east or west-oriented slide.

                        while (angleNotDefined)
                        {
                            switch ((int)angle)
                            {
                            case 0:
                            case 360:
                                slopeDirections[i] = Direction.PositiveZ;
                                angleNotDefined    = false;
                                break;

                            case 45:
                            case 90:
                            case 135:
                                slopeDirections[i] = Direction.PositiveX;
                                angleNotDefined    = false;
                                break;

                            case 180:
                                slopeDirections[i] = Direction.NegativeZ;
                                angleNotDefined    = false;
                                break;

                            case 225:
                            case 270:
                            case 315:
                                slopeDirections[i] = Direction.NegativeX;
                                angleNotDefined    = false;
                                break;

                            default:
                                angle = (int)Math.Round(angle / 90.0f, MidpointRounding.AwayFromZero) * 90;
                                break;
                            }
                        }
                    }
                }

                // We swap triangle directions for XpZn and XnZp cases, because in these cases
                // triangle indices are inverted.
                // For other cases, we move slide direction triangle to proper one accordingly to
                // step slant value encoded in corner heights.

                if (Floor.DiagonalSplit != DiagonalSplit.None)
                {
                    switch (Floor.DiagonalSplit)
                    {
                    case DiagonalSplit.XpZn:
                        slopeDirections[1] = slopeDirections[0];
                        slopeDirections[0] = Direction.None;
                        break;

                    case DiagonalSplit.XnZp:
                        if (!Floor.IsQuad)
                        {
                            slopeDirections[0] = slopeDirections[1];
                            slopeDirections[1] = Direction.None;
                        }
                        break;

                    case DiagonalSplit.XnZn:
                        if (Floor.IsQuad)
                        {
                            slopeDirections[1] = slopeDirections[0];
                            slopeDirections[0] = Direction.None;
                        }
                        else
                        {
                            slopeDirections[0] = Direction.None;
                        }
                        break;

                    case DiagonalSplit.XpZp:
                        if (!Floor.IsQuad)
                        {
                            slopeDirections[1] = Direction.None;
                        }
                        break;
                    }
                }
            }

            return(slopeDirections);
        }
Ejemplo n.º 32
0
		protected virtual bool ExcludePoint(Point3D p, int range, Direction fromCenter)
		{
			return LOSCheck && !Map.LineOfSight(p, Start);
		}
Ejemplo n.º 33
0
 public void SetRequiredDirection(Direction direction)
 {
     requiredDirection = Game.GetDirectionNumber(direction);
 }
Ejemplo n.º 34
0
 void SwipeHandler(Vector2 swipe)
 {
     swipeDirection = GetDirection(swipe);
 }
Ejemplo n.º 35
0
 void DragHandler(Vector2 swipe)
 {
     dragDirection = GetDirection(swipe);
 }
Ejemplo n.º 36
0
 public static void Walk(GameClient Client, Direction dir)
 {
     BeginWalk(Client, dir);
     EndWalk(Client, dir);
 }
Ejemplo n.º 37
0
 //Note for this one we just always use checkDirection.LINE here, you can extend it if you like!
 public InARowEffect(TriggeredEffect e, int n)
 {
     onTriggerEffect = e;
     rowLength       = n;
     checkDirection  = Direction.LINE;
 }
Ejemplo n.º 38
0
        public static void TargetTileRelative(object obj, int distance, bool reverse = false)
        {
            int serial = AliasCommands.ResolveSerial(obj);

            if (serial == 0)
            {
                UOC.SystemMessage(Strings.Invalid_or_unknown_object_id);
                return;
            }

            Entity entity = Engine.Mobiles.GetMobile(serial);

            if (entity == null)
            {
                UOC.SystemMessage(Strings.Mobile_not_found___);
                return;
            }

            int x = entity.X;
            int y = entity.Y;

            int offsetX = 0;
            int offsetY = 0;

            // TODO
            Direction direction = (Direction)((int)entity.Direction & ~0x80);

            switch (direction)
            {
            case Direction.North:
                offsetY = -1;
                break;

            case Direction.Northeast:
                offsetY = -1;
                offsetX = 1;
                break;

            case Direction.East:
                offsetX = 1;
                break;

            case Direction.Southeast:
                offsetX = 1;
                offsetY = 1;
                break;

            case Direction.South:
                offsetY = 1;
                break;

            case Direction.Southwest:
                offsetY = 1;
                offsetX = -1;
                break;

            case Direction.West:
                offsetX = -1;
                break;

            case Direction.Northwest:
                offsetX = -1;
                offsetY = -1;
                break;

            case Direction.Invalid:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            int totalOffsetX = offsetX * distance;
            int totalOffsetY = offsetY * distance;

            if (reverse)
            {
                totalOffsetX = -totalOffsetX;
                totalOffsetY = -totalOffsetY;
            }

            int destinationX = x + totalOffsetX;
            int destinationY = y + totalOffsetY;

            Engine.SendPacketToServer(new Target(TargetTypeEnum.Tile, -1, TargetFlags.None, 0, destinationX,
                                                 destinationY, entity.Z, 0, true));
        }
Ejemplo n.º 39
0
 /// <summary>
 /// Janky hack for keeping the player from moving into an area
 /// </summary>
 /// <param name="position"></param>
 /// <param name="direction">Where this blocker is relative to the screen</param>
 public DirectionalBlocker(Vector2 position, Direction direction) : base(position)
 {
     this.direction = direction;
 }
Ejemplo n.º 40
0
		/// <summary>
		/// Return value is true if the player was able to move false when the player couldn't move, such as trying to move into a wall.
		/// </summary>
		/// <param name="direction"></param>
		/// <returns></returns>
		public bool MovePlayer (Direction direction)
		{
			int x = game.Player.X;
			int y = game.Player.Y;

			switch (direction) {
			case Direction.Up:
				{
					y = game.Player.Y + 1;
					break;
				}
			case Direction.Down:
				{
					y = game.Player.Y - 1;
					break;
				}
			case Direction.Left:
				{
					x = game.Player.X - 1;
					break;
				}
			case Direction.Right:
				{
					x = game.Player.X + 1;
					break;
				}
			case Direction.UpLeft:
				{
					x = game.Player.X - 1;
					y = game.Player.Y + 1;
					break;
				}
			case Direction.UpRight:
				{
					x = game.Player.X + 1;
					y = game.Player.Y + 1;
					break;
				}
			case Direction.DownLeft:
				{
					x = game.Player.X - 1;
					y = game.Player.Y - 1;
					break;
				}
			case Direction.DownRight:
				{
					x = game.Player.X + 1;
					y = game.Player.Y - 1;
					break;
				}
			default:
				{
					return false;
				}
			}

			if (game.World.SetActorPosition (game.Player, x, y)) {
				return true;
			}

			Monster monster = game.World.GetMonsterAt (x, y);

			if (monster != null) {
				Attack (game.Player, monster);
				return true;
			}

			return false;
		}
Ejemplo n.º 41
0
        public static BiDictionary <Opcode, int> GetOpcodeDictionary(ClientVersionBuild build, Direction direction)
        {
            switch (GetOpcodeDefiningBuild(build))
            {
            case ClientVersionBuild.V3_3_5a_12340:
                return(Opcodes_3_3_5.Opcodes(direction));

            case ClientVersionBuild.V4_0_3_13329:
                return(Opcodes_4_0_3.Opcodes(direction));

            case ClientVersionBuild.V4_0_6_13596:
                return(Opcodes_4_0_6.Opcodes(direction));

            case ClientVersionBuild.V4_1_0_13914:
                return(Opcodes_4_1_0.Opcodes(direction));

            case ClientVersionBuild.V4_2_0_14333:
                return(Opcodes_4_2_0.Opcodes(direction));

            case ClientVersionBuild.V4_2_2_14545:
                return(Opcodes_4_2_2.Opcodes(direction));

            case ClientVersionBuild.V4_3_0_15005:
                return(Opcodes_4_3_0.Opcodes(direction));

            case ClientVersionBuild.V4_3_2_15211:
                return(Opcodes_4_3_2.Opcodes(direction));

            case ClientVersionBuild.V4_3_3_15354:
                return(Opcodes_4_3_3.Opcodes(direction));

            case ClientVersionBuild.V4_3_4_15595:
                return(Opcodes_4_3_4.Opcodes(direction));

            case ClientVersionBuild.V5_0_4_16016:
                return(Opcodes_5_0_4.Opcodes(direction));

            case ClientVersionBuild.V5_0_5_16048:
                return(Opcodes_5_0_5.Opcodes(direction));

            case ClientVersionBuild.V5_1_0_16309:
                return(Opcodes_5_1_0.Opcodes(direction));

            case ClientVersionBuild.V5_2_0_16650:
                return(Opcodes_5_2_0.Opcodes(direction));

            case ClientVersionBuild.V5_3_0_16981:
                return(Opcodes_5_3_0.Opcodes(direction));

            case ClientVersionBuild.V5_4_0_17359:
                return(Opcodes_5_4_0.Opcodes(direction));

            case ClientVersionBuild.V5_4_1_17538:
                return(Opcodes_5_4_1.Opcodes(direction));

            case ClientVersionBuild.V5_4_2_17658:
                return(Opcodes_5_4_2.Opcodes(direction));

            case ClientVersionBuild.V5_4_7_17898:
                return(Opcodes_5_4_7.Opcodes(direction));

            case ClientVersionBuild.V5_4_8_18291:
                return(Opcodes_5_4_8.Opcodes(direction));

            case ClientVersionBuild.V6_0_2_19033:
                return(Opcodes_6_0_2.Opcodes(direction));

            case ClientVersionBuild.V6_0_3_19103:
                return(Opcodes_6_0_3.Opcodes(direction));

            case ClientVersionBuild.V6_1_0_19678:
                return(Opcodes_6_1_0.Opcodes(direction));

            case ClientVersionBuild.V6_1_2_19802:
                return(Opcodes_6_1_2.Opcodes(direction));

            case ClientVersionBuild.V6_2_0_20173:
                return(Opcodes_6_2_0.Opcodes(direction));

            case ClientVersionBuild.V6_2_2_20444:
                return(Opcodes_6_2_2.Opcodes(direction));

            case ClientVersionBuild.V6_2_3_20726:
                return(Opcodes_6_2_3.Opcodes(direction));

            case ClientVersionBuild.V6_2_4_21315:
                return(Opcodes_6_2_4.Opcodes(direction));

            case ClientVersionBuild.V7_0_3_22248:
                return(Opcodes_7_0_3.Opcodes(direction));

            case ClientVersionBuild.V7_1_0_22900:
                return(Opcodes_7_1_0.Opcodes(direction));

            case ClientVersionBuild.V7_1_5_23360:
                return(Opcodes_7_1_5.Opcodes(direction));

            case ClientVersionBuild.V7_2_0_23706:
                return(Opcodes_7_2_0.Opcodes(direction));

            case ClientVersionBuild.V7_2_5_24330:
                return(Opcodes_7_2_5.Opcodes(direction));

            case ClientVersionBuild.V7_3_0_24920:
                return(Opcodes_7_3_0.Opcodes(direction));

            case ClientVersionBuild.V7_3_2_25383:
                return(Opcodes_7_3_2.Opcodes(direction));

            case ClientVersionBuild.V7_3_5_25848:
                return(Opcodes_7_3_5.Opcodes(direction));

            case ClientVersionBuild.V8_0_1_27101:
                return(Opcodes_8_0_1.Opcodes(direction));

            case ClientVersionBuild.V8_1_0_28724:
                return(Opcodes_8_1_0.Opcodes(direction));

            case ClientVersionBuild.V8_1_5_29683:
                return(Opcodes_8_1_5.Opcodes(direction));

            case ClientVersionBuild.V8_2_0_30898:
                return(Opcodes_8_2_0.Opcodes(direction));

            case ClientVersionBuild.V8_2_5_31921:
                return(Opcodes_8_2_5.Opcodes(direction));

            case ClientVersionBuild.V8_3_0_33062:
                return(Opcodes_8_3_0.Opcodes(direction));

            case ClientVersionBuild.V8_3_7_35249:
                return(Opcodes_8_3_7.Opcodes(direction));

            case ClientVersionBuild.V9_0_1_36216:
                return(Opcodes_9_0_1.Opcodes(direction));

            case ClientVersionBuild.V9_0_2_36639:
                return(Opcodes_9_0_2.Opcodes(direction));

            case ClientVersionBuild.V1_13_2_31446:
                return(Opcodes_1_13_2.Opcodes(direction));

            case ClientVersionBuild.V1_13_4_33598:
                return(Opcodes_1_13_4.Opcodes(direction));

            case ClientVersionBuild.v1_13_5_34713:
                return(Opcodes_1_13_5.Opcodes(direction));

            case ClientVersionBuild.V1_13_6_36714:
                return(Opcodes_1_13_6.Opcodes(direction));

            default:
                return(Opcodes_3_3_5.Opcodes(direction));
            }
        }
 public ClampedScrollbar(Direction direction)
     : base(direction)
 {
 }
Ejemplo n.º 43
0
 public static OrderBy Create(string field, Direction direction)
 {
     return(new OrderBy(direction.ToFriendlyString(), field));
 }
Ejemplo n.º 44
0
 public IAsyncEnumerable <IReadOnlyCollection <RestMessage> > GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch, RequestOptions options = null)
 => ChannelHelper.GetMessagesAsync(this, Discord, fromMessage.Id, dir, limit, options);
Ejemplo n.º 45
0
 internal Bullet(int x, int y, int width, int height, Direction direction)
     : base(x, y, width, height)
 {
     this.Direction = direction;
 }
Ejemplo n.º 46
0
 public PrimaryKeyColumnRef(SecondaryIndexInfo parent, ColumnInfo column, Direction direction)
     : base(parent, column, direction)
 {
 }
 protected override ScrollbarContainer CreateScrollbar(Direction direction) => new ClampedScrollbar(direction);
Ejemplo n.º 48
0
 public virtual Port InstantiatePort(Orientation orientation, Direction direction, Port.Capacity capacity, Type type)
 {
     return(Port.Create <Edge>(orientation, direction, capacity, type));
 }
Ejemplo n.º 49
0
 public MagicRequest(Type type, Direction direction)
 {
     this.type      = type;
     this.direction = direction;
 }
Ejemplo n.º 50
0
 /// <summary>
 /// Record that the ship is now deployed.
 /// </summary>
 /// <param name="direction"></param>
 /// <param name="row"></param>
 /// <param name="col"></param>
 internal void Deployed(Direction direction, int row, int col)
 {
     _row       = row;
     _col       = col;
     _direction = direction;
 }
Ejemplo n.º 51
0
 IAsyncEnumerable <IReadOnlyCollection <IMessage> > IMessageChannel.GetMessagesAsync(IMessage fromMessage, Direction dir, int limit, CacheMode mode, RequestOptions options)
 {
     if (mode == CacheMode.AllowDownload)
     {
         return(GetMessagesAsync(fromMessage, dir, limit, options));
     }
     else
     {
         return(AsyncEnumerable.Empty <IReadOnlyCollection <IMessage> >());
     }
 }