コード例 #1
0
 public void JiggleInHouse()
 {
     if (Location.Y > HomeLocation.Y)
     {
         CurrentTarget = HomeLocation.Add(0, -0.5m);
         NextDirection = Direction.Up;
     }
     else
     {
         CurrentTarget = HomeLocation.Add(0, 0.5m);
         NextDirection = Direction.Down;
     }
 }
コード例 #2
0
 public BigCloudSprite(Texture2D texture, Vector2 pos) : base(texture)
 {
     //add the location
     Location.Add(new Vector2(100, 50));
     Location.Add(new Vector2(300, 50));
     Location.Add(new Vector2(500, 50));
 }
コード例 #3
0
ファイル: PacMan.cs プロジェクト: pgillett/PacManArcade
 public void KeepInBounds(decimal x, decimal y)
 {
     if (Location.IsOutOfBounds(x, y, out var dx, out var dy))
     {
         Location = Location.Add(dx, dy);
     }
 }
コード例 #4
0
        private void MoveChar_Click(object sender, EventArgs e)
        {
            Location CL = Client.CC.CHR.LoadLocation();

            CL.Add(2.5F, 2.5F, Client.CC.CHR.GetVar("WalkMode") == 2 ? 2.5F : 0);
            Client.CC.CHR.Move(CL);
        }
コード例 #5
0
        public Location GetChaseTarget(PacMan pacMan, Location blinky)
        {
            var pacCell = pacMan.Location.Cell;

            blinky = blinky.Cell;
            switch (Colour)
            {
            case GhostColour.Red:
                return(pacCell);

            case GhostColour.Pink:
                return(pacCell
                       .Move(pacMan.Direction)
                       .Move(pacMan.Direction)
                       .Move(pacMan.Direction)
                       .Move(pacMan.Direction));

            case GhostColour.Cyan:
                var newCell = pacCell
                              .Move(pacMan.Direction)
                              .Move(pacMan.Direction);
                var dx = newCell.X - blinky.X;
                var dy = newCell.Y - blinky.Y;
                return(blinky.Add(2 * dx, 2 * dy));

            case GhostColour.Orange:
                return(Location.Cell.DistanceTo(pacCell) < 64
                        ? ScatterTarget
                        : pacCell);

            default:
                return(Location.Cell);
            }
        }
コード例 #6
0
ファイル: DragDropPanel.cs プロジェクト: Mikholap/UUM32
 private void splitContainer1_Panel1_MouseMove(object sender, MouseEventArgs e)
 {
     if (mouseDown && DragDropEnable)
     {
         Location = Location.Add(new Point(e.X, e.Y).Substract(offestPosition));
     }
 }
コード例 #7
0
        public bool SaveEntertainment()
        {
            string newid         = string.Empty;
            bool   success       = false;
            Group  entertainment = new Group()
            {
                name   = _entertainmentModel.Name,
                @class = "TV",
                lights = ListLights.Select(x => x.Light.Id).ToList(),
                type   = "Entertainment"
            };

            success = _bridge.CreateObject(entertainment);

            if (success)
            {
                Location loc = new Location();
                newid = _bridge.LastCommandMessages.LastSuccess.value;
                foreach (EntertainmentLight el in ListLights)
                {
                    loc.Add(el.Light.Id, el.Location);
                }

                success = success && _bridge.SetEntertrainementLightLocation(newid, loc);
            }


            return(success);
        }
コード例 #8
0
ファイル: ChessBoard.cs プロジェクト: AndrewPool/Chess
 private void SetMovementWithVectors(Location[] vectors, Location fromLoc)
 {
     for (int i = 0; i < vectors.Length; i++)
     {
         Location checkLoc = fromLoc.Add(vectors[i]);
         while (checkLoc.IsValid())
         {
             if (board[checkLoc.row, checkLoc.column].isEmpty)
             {
                 SetMovement(fromLoc, checkLoc);
                 checkLoc = checkLoc.Add(vectors[i]);
             }
             else if (board[checkLoc.row, checkLoc.column].unit.player == board[fromLoc.row, fromLoc.column].unit.player)
             {
                 SetGuardMovement(fromLoc, checkLoc);
                 break;
             }
             else//is not friendly
             {
                 SetMovement(fromLoc, checkLoc);
                 break;
             }
         }
     }
 }
コード例 #9
0
 public BigHillSprite(Texture2D texture, Vector2 pos) : base(texture)
 {
     //add the location
     //Location.Add(new Vector2(150, Sprint1Main.Game.GraphicsDevice.Viewport.Height - texture.Height));
     //Location.Add(new Vector2(250, Sprint1Main.Game.GraphicsDevice.Viewport.Height - texture.Height));
     Location.Add(pos);
 }
コード例 #10
0
 public SmallBushSprite(Texture2D texture, Vector2 pos) : base(texture)
 {
     //add the location
     Location.Add(new Vector2(550, Sprint1Main.Game.GraphicsDevice.Viewport.Height - texture.Height));
     Location.Add(new Vector2(450, Sprint1Main.Game.GraphicsDevice.Viewport.Height - texture.Height));
     Location.Add(new Vector2(500, Sprint1Main.Game.GraphicsDevice.Viewport.Height - texture.Height));
 }
コード例 #11
0
 public SmallCloudSprite(Texture2D texture, Vector2 pos) : base(texture)
 {
     //add the location
     //Location.Add(new Vector2(200, 50));
     //Location.Add(new Vector2(400, 50));
     //Location.Add(new Vector2(600, 50));
     Location.Add(pos);
 }
コード例 #12
0
 public void KeepInBounds(decimal width, decimal height)
 {
     if (Location.IsOutOfBounds(width, height, out var dx, out var dy))
     {
         Location      = Location.Add(dx, dy);
         NextTarget    = NextTarget.Add(dx, dy);
         CurrentTarget = CurrentTarget.Add(dx, dy);
     }
 }
コード例 #13
0
        public void Initialize(Location location, Random random, int[] args, bool isLoading)
        {
            var obj = Builder.Build(PositionExpression.Generate(location, random));

            if (!isLoading || obj.IsStatic)
            {
                location.Add(obj);
            }
        }
コード例 #14
0
        public void Initialize(Location location, Random random, int[] args, bool isLoading)
        {
            GameObject.Position = PositionExpression.Generate(location, random);

            if (!isLoading || GameObject.IsStatic)
            {
                location.Add(GameObject);
            }
        }
コード例 #15
0
        private Point GetRandomDirection(IWorld readonlyWorld)
        {
            var directions = new[] { new Point(1, 0), new Point(-1, 0), new Point(0, 1), new Point(0, -1) }
            .Where(d => !readonlyWorld.GetObjectsAt(Location.Add(d)).Any())
            .Concat(new[] { new Point(0, 0), })
            .ToList();

            return(directions[random.Next(directions.Count)]);
        }
コード例 #16
0
        public void Translate(Vector3D offset)
        {
            if (isReadOnly)
            {
                throw new InvalidOperationException("This map cannot be modified because it is read-only");
            }

            Location = Location.Add(offset);
        }
コード例 #17
0
        public IEnumerable <IMove> GetAvailableMovesFrom(Board board, MovesLog movesLog, Location from)
        {
            var pawn = board.GetPieceAt <Pawn>(from);

            return(GetPossibleMoveDirections(pawn, from)
                   .Select(d => from.Add(d))
                   .TakeWhile(l => !board.ContainsPieceAt(l))
                   .Select(l => CreateMove(from, l)));
        }
コード例 #18
0
ファイル: JunkbotActor.cs プロジェクト: rozniak/Junkbot
        private void Animation_SpecialFrameEntered(object sender, EventArgs e)
        {
            // Each tile is 15x18
            int dx = FacingDirection == FacingDirection.Left ? -1 : 1;

            // Check if we should turn around now
            //
            System.Drawing.Rectangle checkBounds = new System.Drawing.Rectangle(
                Location.Add(new Point(dx * GridSize.Width, 0)),
                new Size(1, 3)
                );

            if (!Scene.CheckGridRegionFree(checkBounds))
            {
                Location = Location.Add(new Point(dx, 0));

                SetWalkingDirection(FacingDirection == FacingDirection.Left ? FacingDirection.Right : FacingDirection.Left);
                return;
            }

            // Space is free, now check whether we need an elevation change, prioritize upwards changes
            //
            System.Drawing.Rectangle floorUpCheckBounds = new System.Drawing.Rectangle(
                Location.Add(new Point(dx, GridSize.Height - 1)),
                new Size(1, 1)
                );

            if (!Scene.CheckGridRegionFree(floorUpCheckBounds))
            {
                // Elevate up
                //
                Location = Location.Add(new Point(dx, -1));
                return;
            }

            // Now check downwards
            //
            System.Drawing.Rectangle floorMissingCheckBounds = new System.Drawing.Rectangle(
                Location.Add(new Point(dx, GridSize.Height)),
                new Size(1, 1)
                );

            System.Drawing.Rectangle floorDownCheckBounds = new System.Drawing.Rectangle(
                Location.Add(new Point(dx, GridSize.Height + 1)),
                new Size(1, 1)
                );

            if (Scene.CheckGridRegionFree(floorMissingCheckBounds) && !Scene.CheckGridRegionFree(floorDownCheckBounds))
            {
                // Lower junkbot
                //
                Location = Location.Add(new Point(dx, 1));
                return;
            }

            Location = Location.Add(new Point(dx, 0));
        }
コード例 #19
0
        public void Load(SegmentEntities entities, XElement element, Version version)
        {
            foreach (var spawnElement in element.Elements("spawn"))
            {
                var type    = spawnElement.Attribute("type");
                var spawner = default(Spawner);

                if (type != null)
                {
                    switch ((string)type)
                    {
                    case "LocationSpawner": spawner = new LocationSpawner(spawnElement); break;

                    case "RegionSpawner": spawner = new RegionSpawner(spawnElement); break;
                    }
                }

                if (spawner != null)
                {
                    foreach (var entryElement in spawnElement.Elements("entry"))
                    {
                        var entry = new SpawnEntry(entryElement);

                        var entity     = default(Entity);
                        var entityName = (string)entryElement.Attribute("entity");

                        if (!String.IsNullOrEmpty(entityName))
                        {
                            entity = entities.FirstOrDefault(
                                e => String.Equals(e.Name,
                                                   entityName, StringComparison.Ordinal));
                        }

                        entry.Entity = entity;

                        if (entry.Entity != null)
                        {
                            spawner.Entries.Add(entry);
                        }
                        else
                        {
                            throw new Exception($"Unable to load spawn entry '{entityName}'.");
                        }
                    }

                    if (spawner is LocationSpawner locationSpawner)
                    {
                        Location.Add(locationSpawner);
                    }
                    else if (spawner is RegionSpawner regionSpawner)
                    {
                        Region.Add(regionSpawner);
                    }
                }
            }
        }
コード例 #20
0
        private IEnumerable <IMove> GetRegularTakeMoves(Board board, Location from)
        {
            var piece = board.GetPieceAt <Pawn>(from);

            return(piece
                   .TakeDirections
                   .Select(d => from.Add(d))
                   .Where(l => board.IsPieceOfColorAt(l, piece.Color.GetOpposite()))
                   .Select(l => CreateMove(from, l)));
        }
コード例 #21
0
        private IEnumerable <Location> GetAvailableMoveLocations(Board board, Location from)
        {
            var piece = board.GetPieceAt(from);

            return(piece
                   .MoveDirections
                   .Select(d => from.Add(d))
                   .Where(board.IsWithinBoard)
                   .Where(l => !board.IsPieceOfColorAt(l, piece.Color)));
        }
コード例 #22
0
 public SmallHillSprite(Texture2D texture, Vector2 pos) : base(texture)
 {
     //Location = new ArrayList
     //{
     //add the location
     //new Vector2(50, Sprint1Main.Game.GraphicsDevice.Viewport.Height - texture.Height),
     //new Vector2(100, Sprint1Main.Game.GraphicsDevice.Viewport.Height - texture.Height)
     //};
     Location.Add(pos);
 }
コード例 #23
0
 public override void Act(IWorld world)
 {
     if (world.Cursor == Location)
     {
         world.RemoveObject(this);
     }
     else
     {
         var destination = GetDirection(world);
         Destination = Location.Add(destination);
     }
 }
コード例 #24
0
        public void UpdatePosition(Rectangle rectangle)
        {
            Velocity.Add(Acceleration);
            Velocity.Limit(MaxSpeed);
            Location.Add(Velocity);


            //CheckEdges(rectangle.Width, rectangle.Height, rectangle.Left, rectangle.Top);

            UpdateRectangle();
            Acceleration.Multiply(0);
        }
コード例 #25
0
ファイル: LastPosition.cs プロジェクト: ZeroByter/SkillZ-2019
        /// <summary>
        /// Returns GetInterceptLocation, but adds an offset incase we want to account for 'attackRange' or something. Also returns timeToImpact
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        /// <param name="offset"></param>
        /// <returns></returns>
        public static Location GetInterceptLocation(GameObject source, GameObject target, int offset, out int timeToImpact)
        {
            Location interceptLocation = GetInterceptLocation(source, target, out timeToImpact);

            if (interceptLocation == target.GetLocation())
            {
                return(interceptLocation);
            }
            else
            {
                return(interceptLocation.Add((GetDirection(target) * offset).GetIntLocation()));
            }
        }
コード例 #26
0
ファイル: Air.cs プロジェクト: oxy0723/M4ple-Editor
        /// <summary>
        /// 真上向きAirのGraphicsPathを返します
        /// </summary>
        /// <returns></returns>
        protected virtual GraphicsPath GetAirPath(Point drawLocation)
        {
            GraphicsPath graphicsPath = new GraphicsPath();
            PointF       baseLocation = Location.Add(-drawLocation.X, -drawLocation.Y);
            PointF       topCenter    = baseLocation.AddX(Width / 2f).AddY(borderWidth).Add(drawOffset);
            PointF       topRight     = topCenter.AddX(Width / 2f - (Size - 1) * widthRatio).AddY(airHeight - airLineHeight - borderWidth);
            PointF       topLeft      = topCenter.AddX(-(Width / 2f - (Size - 1) * widthRatio)).AddY(airHeight - airLineHeight - borderWidth);
            PointF       bottomCenter = topCenter.AddY(airLineHeight - borderWidth);
            PointF       bottomRight  = topRight.AddY(airLineHeight - borderWidth);
            PointF       bottomLeft   = topLeft.AddY(airLineHeight - borderWidth);

            graphicsPath.AddLines(new PointF[] { topCenter, topRight, bottomRight, bottomCenter, bottomLeft, topLeft });
            graphicsPath.CloseFigure();
            return(graphicsPath);
        }
コード例 #27
0
        private static IEnumerable <Location> GetAvailablesMovesInDirection(Board board, Location from, Location direction)
        {
            var piece = board.GetPieceAt(from);

            var location = from.Add(direction);

            var isBlockedByOtherPiece = false;

            while (board.IsWithinBoard(location) &&
                   !board.IsPieceOfColorAt(location, piece.Color) &&
                   !isBlockedByOtherPiece)
            {
                yield return(location);

                isBlockedByOtherPiece = board.ContainsPieceAt(location);
                location = location.Add(direction);
            }
        }
コード例 #28
0
        private IEnumerable <IMove> GetPassingPawnTakeMoves(Board board, MovesLog movesLog, Location from)
        {
            if (!PassingPawnCanBeTaken(board, movesLog, from))
            {
                return(NoMoves);
            }

            var lastMove = movesLog.LastMove.Move;
            var opponentMovingDirection = Math.Sign((lastMove.To - lastMove.From).Row);
            var passedLocationByPawn    = lastMove.To.AddRows(-opponentMovingDirection);

            var pawn          = board.GetPieceAt <Pawn>(from);
            var takeLocations = pawn.TakeDirections.Select(d => from.Add(d));

            return(takeLocations
                   .Where(l => l == passedLocationByPawn)
                   .Select(l => new PassedPawnTakeMove(from, l)));
        }
コード例 #29
0
ファイル: Particle.cs プロジェクト: PhelixSky/Game_of_Dust
        /// <summary>
        /// Обновление сил, скоростей и координат
        /// </summary>
        public virtual void Update(Sandbox sb, float dt)
        {
            var PrevLocation = Location;

            //приращение скорости
            Velocity = Velocity.Add(Acceleration, dt * dt);
            //приращение координаты
            Location = Location.Add(Velocity);
            //мы ударились о другую частицу?
            var cell = sb[X, Y];

            if (cell != null && cell != this)
            {
                //остаемся на месте, обрабатываем столкновение
                Location = PrevLocation;
                OnCollision(sb, cell);
            }
        }
コード例 #30
0
ファイル: AddRoom.cs プロジェクト: dmmnjaws/DAD-2019-2020
        public override object Execute()
        {
            int      capacity;
            string   location_name, room_name;
            Location location;
            Room     room;

            location_name = split_command[1];
            capacity      = Int32.Parse(split_command[2]);
            room_name     = split_command[3];

            room     = new Room(room_name, capacity);
            location = new Location(location_name);
            location.Add(room);

            base.server_library.AddLocation(location);

            return(null);
        }