Exemplo n.º 1
0
        //pg. 236
        #region Collision Detection
        private static void checkShotWallImpacts(Sprite shot)
        {
            if (shot.Expired)
            {
                return;
            }

            if (TileMap.IsWallTile(
                    TileMap.GetSquareAtPixel(shot.WorldCenter)))
            {
                shot.Expired = true;

                if (shot.Frame == 0)
                {
                    EffectsManager.AddSparksEffect(
                        shot.WorldCenter,
                        shot.Velocity);
                }
                else
                {
                    createLargeExplosion(shot.WorldCenter);
                    //pg. 282
                    checkRocketSplashDamage(shot.WorldCenter);
                }
            }
        }
Exemplo n.º 2
0
        //pg. 268
        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++;
            }
        }
Exemplo n.º 3
0
        private Vector2 getNewTargetSquare()
        {
            List <Vector2> path = PathFinder.FindPath(
                TileMap.GetSquareAtPixel(EnemyBase.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));
            }
        }