Ejemplo n.º 1
0
        public MovingSpike(Level level, Vector2 position, bool createdByEvent, bool vertical, bool goRight)
        {
            this.level = level;
            this.position = position;
            this.createdByEvent = createdByEvent;
            this.vertical = vertical;
            this.goRight = goRight;
            continueMoving = true;

            if (vertical)
            {
                if (goRight)
                    RotationAngle = MathHelper.ToRadians(180);
                else
                    RotationAngle = 0;
            }
            else
            {
                if (goRight)
                    RotationAngle = MathHelper.ToRadians(90);
                else
                    RotationAngle = MathHelper.ToRadians(-90);
            }
            LoadContent();
        }
Ejemplo n.º 2
0
Archivo: Gem.cs Proyecto: bmh10/RedMan
        // Constructs a new gem.
        public Gem(Level level, Vector2 position)
        {
            this.level = level;
            this.basePosition = position;

            LoadContent();
        }
Ejemplo n.º 3
0
 // Constructs a new falling platform.
 public FallingPlatform(Level level, Vector2 pos)
 {
     this.level = level;
     this.position = pos;
     this.originalPosition = pos;
     tileXpos = (int)(this.originalPosition.X / Tile.Width);
     tileYpos = (int)(this.originalPosition.Y / Tile.Height);
     LoadContent();
 }
Ejemplo n.º 4
0
 public Elevator(Level level, Vector2 position, bool goUp)
 {
     this.level = level;
     this.position = new Vector2(position.X + Tile.Width / 2, position.Y + Tile.Height);
     this.initialPosition = this.position;
     this.goUp = goUp;
     this.airTime = 0.0f;
     continueLifting = true;
     LoadContent();
 }
Ejemplo n.º 5
0
 public Turret(Level level, Vector2 position, bool createdByEvent, Enemy enemy, bool multiDirectionalFire)
 {
     this.enemy = enemy;
     this.level = level;
     //this.position = position;
     this.position = new Vector2(position.X + Tile.Width / 2, position.Y + Tile.Height);
     this.initialPosition = position;
     this.createdByEvent = createdByEvent;
     this.multiDirectionalFire = multiDirectionalFire;
     this.timeSinceShot = 50;
     level.Turrets.Add(this);
     LoadContent();
 }
Ejemplo n.º 6
0
        // Constructs a new moving platform.
        public MovingPlatform(Level level, Vector2 position, bool createdByEvent, bool verticalMotion, bool horizontalOrientation)
        {
            this.level = level;
            this.position = position;
            this.createdByEvent = createdByEvent;
            MovingPlatform.currMoveSpeed = PlatformSpeed;
            this.moveVertical = verticalMotion;
            this.horizontalOrientation = horizontalOrientation;

            if (horizontalOrientation)
                RotationAngle = 0;
            else
                RotationAngle = MathHelper.ToRadians(90);

            LoadContent();
        }
Ejemplo n.º 7
0
        public Laser(Level level, int x, int y, bool createdByEvent, bool vertical, bool flashing, RotationDirection rotationDir)
        {
            this.level = level;
            this.position = RectangleExtensions.GetBottomCenter(level.GetBounds(x, y));
            this.tileCoords = new Vector2(x, y);
            this.createdByEvent = createdByEvent;
            this.vertical = vertical;
            this.flashing = flashing;
            this.rotationDir = rotationDir;
            // If not flashing laser is always on
            if (!flashing)
                laserOn = true;
            // Rotate tile to use as either horizontal or vertical (so only need to store one image file)
            if (vertical)
                rotationAngle = 0;
            else
            {
                rotationAngle = MathHelper.ToRadians(90);
            }

            LoadContent();
        }
Ejemplo n.º 8
0
        // Constructors a new player.
        public Player(Level level, Vector2 position)
        {
            this.level = level;
            this.showStats = true;
            this.inSudo3D = level.inSudo3D();

            hasGun = false;

            this.carRaceMode = level.inCarRaceMode();
            if (carRaceMode)
            {
                inVehicle = true;
                currVehicle = Vehicle.Car;
                inAutomaticVehicle = true;
                automaticVehicleRight = true;
                automaticVehicleSpeed = NormalVehicleSpeed;
            }

            this.automaticRun = level.inRunningMode();
            if (automaticRun)
            {
                automaticRunRight = true;
                automaticRunSpeed = NormalRunSpeed;
                this.playerHealth = playerMaxHealth;
            }

            sniperMode = level.inSniperMode();
            if (level.LevelIndex == 10)
                AssignAutomaticJumpPoints();
            LoadContent();

            Reset(position);
        }
Ejemplo n.º 9
0
Archivo: Game.cs Proyecto: bmh10/RedMan
        private void LoadNextLevel()
        {
            // Move to the next level
            levelIndex = (levelIndex + 1) % numberOfLevels;

            //Level.LoadFromSubLevel = false; --> might need to put this back in

            // Unloads the content for the current level before loading the next one.
            if (level != null)
                level.Dispose();

            // Load the level.
            string levelPath = string.Format("Content/Levels/{0}.txt", levelIndex);

            using (Stream fileStream = TitleContainer.OpenStream(levelPath))
                level = new Level(Services, fileStream, levelIndex);

            LoadCrossHair();

            // Credit typewriter for last level
            if (levelIndex == 13)
                typewriter = new Typewriter(this);
        }
Ejemplo n.º 10
0
Archivo: Game.cs Proyecto: bmh10/RedMan
        // Loads main world level and puts player outside level just completed (or exited)
        public void LoadMainWorld()
        {
            // Unloads the content for the current level before loading the next one.
            if (level != null)
                level.Dispose();

            // Load the level.
            levelIndex = -1;
            string levelPath = "Content/Levels/" + levelIndex.ToString() + ".txt";

            using (Stream fileStream = TitleContainer.OpenStream(levelPath))
                level = new Level(Services, fileStream, levelIndex);
        }
Ejemplo n.º 11
0
Archivo: Game.cs Proyecto: bmh10/RedMan
        // Loads a specified level
        public void LoadLevel(int index)
        {
            // Unloads the content for the current level before loading the next one.
            if (level != null)
                level.Dispose();

            if (index < -1)
                ReloadCurrentLevel();
            else
            {
                levelIndex = index;
                string levelPath = "Content/Levels/" + levelIndex.ToString() + ".txt";

                using (Stream fileStream = TitleContainer.OpenStream(levelPath))
                    level = new Level(Services, fileStream, levelIndex);
            }
            Level.LoadMainWorldFromLevel = true;
            LoadCrossHair();

            // Credit typewriter for last level
            if (index == 13)
                typewriter = new Typewriter(this);
        }
Ejemplo n.º 12
0
        public void Update(GameTime gameTime, Level level)
        {
            HandleCollisions();

                if (continueLifting)
                {

                    if (airTime == 0.0f)
                        Game.PlaySound(elevateSound);
                    airTime++;

                    if (goUp)
                        initialVelocity = -MoveSpeed;
                    else
                        initialVelocity = MoveSpeed;

                    Position = new Vector2((float)Math.Round(Position.X), (float)Math.Round(Position.Y + initialVelocity));

                    level.Player.Position = new Vector2((float)Math.Round(Position.X), (float)Math.Round(Position.Y + initialVelocity)); // velocity* elapsed;
                }
                else
                {
                    Position = new Vector2((float)Math.Round(initialPosition.X), (float)Math.Round(initialPosition.Y));
                    airTime = 0;
                    continueLifting = true;
                }
        }
Ejemplo n.º 13
0
        // Constructs a new Enemy.
        public Enemy(Level level, Vector2 position, string spriteSet, bool createdByEvent)
        {
            this.level = level;
            this.position = position;
            this.startPosition = position;
            this.monsterType = spriteSet;
            this.createdByEvent = createdByEvent;
            this.currMoveSpeed = EnemySpeed;
            this.bouncingBullets = false;
            this.fireVertical = false;
            this.multiDirectoinalFiring = false;
            this.enemyTurrets = new Turret[2];

            SetupEnemy();

            LoadContent(spriteSet);

            // For bosses other continously firing enemies make turrets to act as their guns
            if (isBoss)
            {
                    Vector2 turretOffset = new Vector2(BoundingRectangle.X + BoundingRectangle.Width / 2, BoundingRectangle.Y + BoundingRectangle.Height / 2);

                    // Water boss - fires 2 parallel guns
                    if (monsterType == "Boss1")
                    {
                        Vector2 upperGun = new Vector2(BoundingRectangle.X + BoundingRectangle.Width / 2, BoundingRectangle.Y + BoundingRectangle.Height * 0.25f);
                        Vector2 lowerGun = new Vector2(BoundingRectangle.X + BoundingRectangle.Width / 2, BoundingRectangle.Y + BoundingRectangle.Height * 0.75f);
                        enemyTurrets[0] = new Turret(level, upperGun, false, this, false);
                        enemyTurrets[1] = new Turret(level, lowerGun, false, this, false);
                    }

                    // Space boss - fires bouncing bullets
                    else if (monsterType == "Boss2")
                    {
                        this.bouncingBullets = true;
                        enemyTurrets[0] = new Turret(level, turretOffset, false, this, false);
                    }

                    // Witch boss - fires upwards
                    else if (monsterType == "Boss3")
                    {
                        this.fireVertical = true;
                        enemyTurrets[0] = new Turret(level, turretOffset, false, this, false);
                    }

                    // Angel boss
                    else if (monsterType == "Boss4")
                    {
                        enemyTurrets[0] = new Turret(level, turretOffset, false, this, true);
                    }

                    // Devil boss
                    else if (monsterType == "Boss5" || monsterType == "Boss5R")
                    {
                        switch (level12bossCount)
                        {
                            case 0:
                                this.bouncingBullets = true;
                                enemyTurrets[0] = new Turret(level, turretOffset, false, this, false);
                                break;
                            case 1:
                                //this.bouncingBullets = false;
                                this.fireVertical = true;
                                enemyTurrets[0] = new Turret(level, turretOffset, false, this, true);
                                break;
                            case 2:
                                this.bouncingBullets = true;
                                Vector2 upperGun = new Vector2(BoundingRectangle.X + BoundingRectangle.Width / 2, BoundingRectangle.Y + BoundingRectangle.Height * 0.25f);
                                Vector2 lowerGun = new Vector2(BoundingRectangle.X + BoundingRectangle.Width / 2, BoundingRectangle.Y + BoundingRectangle.Height * 0.75f);
                                enemyTurrets[0] = new Turret(level, upperGun, false, this, true);
                                enemyTurrets[1] = new Turret(level, lowerGun, false, this, false);
                                break;

                        }
                    }

                    // Multidirecitional firing enemies
                    else if (multiDirectoinalFiring)
                    {
                        enemyTurrets[0] = new Turret(level, turretOffset, false, this, true);
                    }

                }
        }
Ejemplo n.º 14
0
Archivo: Info.cs Proyecto: bmh10/RedMan
 public Info(Level level, Vector2 position)
 {
     this.level = level;
     this.position = position;
 }
Ejemplo n.º 15
0
        // For creating player bullets, turret bullets or continously firing enemies (implemented as turrets)
        public Bullet(Level level, Vector2 position, GameTime gameTime, Turret turret)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            float MoveVelocity = MoveAcceleration * elapsed * AirDragFactor;
            this.level = level;
            this.position = position;
            this.initialPosition = position;
            this.turret = turret;
            this.removeBullet = false;
            this.airTime = 0.0f;
            this.explodeTimer = 0.0f;

            this.playerBullet = (turret == null);
            if (level.LevelIndex == 9)
                LoadContent();

            animationPlayer.PlayAnimation(blankAnimation);

            if (playerBullet)
            {
                // This bullet is from a player

                // Set range and bullet velocity depending on weapon
                if (level.Player.powerBulletCount > 0)
                {
                    powerBullet = true;
                    MoveVelocity *= powerBulletVelocity;
                    range = powerBulletRange;
                }
                else
                {
                    if (level.Player.inVehicle)
                    {
                        switch (level.Player.currVehicle)
                        {
                            case Vehicle.Submarine:
                                MoveVelocity *= submarineGunVelocity;
                                range = harpoonRange;
                                break;
                            case Vehicle.Spaceship:
                                MoveVelocity *= spaceBlasterVelocity;
                                range = spaceBlasterRange;
                                break;
                            case Vehicle.Snowmobile:
                                MoveVelocity *= spaceBlasterVelocity;
                                range = spaceBlasterRange;
                                break;
                            case Vehicle.Car:
                                MoveVelocity *= multiDirectionalVelocity;
                                range = multiDirectionalRange;
                                break;
                            default:
                                MoveVelocity *= uziVelocity;
                                range = pistolRange;
                                break;
                        }
                    }

                    else
                    {
                        switch (Level.Player.currGun)
                        {
                            case Gun.Pistol:
                                MoveVelocity *= pistolVelocity;
                                range = pistolRange;
                                break;
                            case Gun.Uzi:
                                MoveVelocity *= uziVelocity;
                                range = uziRange;
                                break;
                            case Gun.Sniper:
                                MoveVelocity *= sniperVelocity;
                                range = sniperRange;
                                break;
                            case Gun.Harpoon:
                                if (level.Player.inVehicle)
                                    MoveVelocity *= submarineGunVelocity;
                                else
                                    MoveVelocity *= harpoonVelocity;
                                range = harpoonRange;
                                break;
                            case Gun.SpaceBlaster:
                                MoveVelocity *= spaceBlasterVelocity;
                                range = spaceBlasterRange;
                                break;
                            case Gun.Multidirectional:
                                MoveVelocity *= multiDirectionalVelocity;
                                range = multiDirectionalRange;
                                break;
                            default:
                                range = pistolRange;
                                break;
                        }
                    }
                }

                //// If there is horizontal movement or no vertical movement fire horizontally
                //if (level.Player.Velocity.X == 0 || level.Player.vertMovement == 0)
                //{
                if (level.Player.shootWithMouse)
                {
                    if (level.Player.sniperMode)
                    {
                        animationPlayer.PlayAnimation(sniperShotAnimation);
                        initialVelocityX = 0;
                        initialVelocityY = 0;

                        // Update stats
                        shotsFired++;
                    }
                    else
                    {
                        Vector2 vector = level.Player.bulletVector;
                        initialVelocityX = vector.X * MoveVelocity;
                        initialVelocityY = vector.Y * MoveVelocity;
                    }
                }

                // Drop power bullets (like bombs in level 6)
                else if (DropBomb)
                {
                    initialVelocityX = 0;
                    initialVelocityY = MoveVelocity;
                }
                else
                {
                    if (level.Player.FacingRight)
                        initialVelocityX = MoveVelocity;
                    else
                        initialVelocityX = -MoveVelocity;

                    // In sudo 3D levels can also fire up or down when moving in those directions
                    if (level.inSudo3D())
                    {
                        if (level.Player.vertMovement != 0 && level.Player.Velocity.X == 0)
                        {
                            initialVelocityX = 0;
                            bulletRotation = MathHelper.ToRadians(90);

                            if (level.Player.vertMovement > 0)
                                initialVelocityY = MoveVelocity;
                            else if (level.Player.vertMovement < 0)
                                initialVelocityY = -MoveVelocity;
                        }
                    }
                }
            }

            else
            {
                // This bullet is from a turret/enemy
                // Set range for turret
                range = turretRange;
                MoveVelocity *= turretVelocity;

                // Set direction to fire
                if (turret.multiDirectionalFire)
                {
                    // Find top-left camera position
                    int left = (int)Math.Floor(level.cameraPosition.X);
                    int top = (int)Math.Floor(level.cameraPosition.Y);
                    turret.turretVector = level.Player.Position - turret.Position;

                    // Normalize movement vector
                    if (turret.turretVector != Vector2.Zero)
                        turret.turretVector.Normalize();
                    Vector2 vector = this.turret.turretVector;
                    initialVelocityX = vector.X * MoveVelocity;
                    initialVelocityY = vector.Y * MoveVelocity;
                }
                else if (turret.currFiringDireciton == TurretFiringDirection.Right)
                    initialVelocityX = MoveVelocity;
                else
                    initialVelocityX = -MoveVelocity;

                // If bullet is from enemy and fires bouncing bullets or vertical bullets
                if (turret.enemy != null)
                {
                    if (turret.enemy.bouncingBullets)
                    {
                        bouncable = true;
                        if (turret.enemy.Velocity.Y < 0)
                            initialVelocityY = -MoveVelocity;
                        else
                            initialVelocityY = MoveVelocity;
                    }
                    else if (turret.enemy.fireVertical)
                    {
                        initialVelocityX = 0;
                        initialVelocityY = -MoveVelocity;
                        bulletRotation = MathHelper.ToRadians(270);
                    }
                }
            }

            LoadContent();
        }
Ejemplo n.º 16
0
        // For creating single enemy bullets (which are not continous like turrets)
        public Bullet(Level level, Vector2 position, GameTime gameTime, Enemy enemy)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            float MoveVelocity = MoveAcceleration * elapsed * AirDragFactor;
            this.level = level;
            this.position = position;
            this.enemy = enemy;
            this.initialPosition = position;
            this.removeBullet = false;
            this.airTime = 0.0f;
            this.explodeTimer = 0.0f;

            this.playerBullet = false;

            // Set range and velocity
            range = enemyShotRange;
            MoveVelocity *= enemyShotVelocity;

            if (enemy.direction == FaceDirection.Right)
                initialVelocityX = MoveVelocity;
            else
                initialVelocityX = -MoveVelocity;

            LoadContent();
        }