Пример #1
0
        private Vector2 getNewTargetSquare()
        {
            List <Vector2> path = PathFinder.FindPath(TileMap.GetSquareAtPixel(EnemySprite.WorldCenter), TileMap.GetSquareAtPixel(Player.BaseSprite.WorldCenter));

            if (path.Count > 1)
            {
                return(new Vector2(path[1].X, path[1].Y));
            }
            else
            {
                return(TileMap.GetSquareAtPixel(Player.BaseSprite.WorldCenter));
            }
        }
        private static void checkShotWallImpacts(Sprite shot)
        {
            if (shot.Expired)
            {
                return;
            }

            if (TileMap.IsWallTile(
                    TileMap.GetSquareAtPixel(shot.WorldCenter)))
            {
                shot.Expired = true;
            }
        }
Пример #3
0
        public static void AddComputerTerminal()
        {
            int startX = rand.Next(2, TileMap.MapWidth - 2);
            int startY = rand.Next(0, TileMap.MapHeight - 2);

            Vector2 tileLocation = new Vector2(startX, startY);

            if ((TerminalInSquare(tileLocation) != null) ||
                (TileMap.IsWallTile(tileLocation)))
            {
                return;
            }

            if (Vector2.Distance(
                    TileMap.GetSquareCenter(startX, startY),
                    Player.BaseSprite.WorldCenter) < minDistanceFromPlayer)
            {
                return;
            }

            List <Vector2> path =
                PathFinder.FindPath(
                    new Vector2(startX, startY),
                    TileMap.GetSquareAtPixel(
                        Player.BaseSprite.WorldCenter));

            if (path != null)
            {
                Rectangle squareRect =
                    TileMap.SquareWorldRectangle(startX, startY);

                Sprite activeSprite = new Sprite(
                    new Vector2(squareRect.X, squareRect.Y),
                    texture,
                    initialActiveFrame,
                    Vector2.Zero);

                for (int x = 1; x < 3; x++)
                {
                    activeSprite.AddFrame(
                        new Rectangle(
                            initialActiveFrame.X + (x *
                                                    initialActiveFrame.Width),
                            initialActiveFrame.Y,
                            initialActiveFrame.Width,
                            initialActiveFrame.Height));
                }
                activeSprite.CollisionRadius = 15;

                Sprite disabledSprite = new Sprite(
                    new Vector2(squareRect.X, squareRect.Y),
                    texture,
                    initialDisabledFrame,
                    Vector2.Zero);

                for (int x = 1; x < 3; x++)
                {
                    disabledSprite.AddFrame(
                        new Rectangle(
                            initialDisabledFrame.X + (x *
                                                      initialDisabledFrame.Width),
                            initialDisabledFrame.Y,
                            initialDisabledFrame.Width,
                            initialDisabledFrame.Height));
                }

                ComputerTerminal terminal = new ComputerTerminal(
                    activeSprite,
                    disabledSprite,
                    new Vector2(startX, startY));

                float timerOffset = (float)rand.Next(1, 100);
                terminal.LastSpawnCounter = timerOffset / 100f;

                computerTerminals.Add(terminal);

                activeCount++;
            }
        }