Пример #1
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);

                ComputerTerminal terminal = new ComputerTerminal(activeSprite, disabledSprite, new Vector2(startX, startY));
                float timerOffest = (float)rand.Next(1, 100);
                terminal.LastSpawnCounter = timerOffest / 100f;

                computerTerminals.Add(terminal);
                activeCount++;
            }
        }
Пример #2
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);
                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++;
            }
        }