Beispiel #1
0
        private void hurtPlayer(Marine player)
        {
            double knockbackFactor = 1.2;

            player.CurrentHP -= alienHurt;
            Parent.ViewPort.Shake(3.0f, 0.8f, 0.95f);
            for (int i = 0; i < player.BloodPerHit; i++)
            {
                new Blood(_Parent, _Geometry.Position, Color.Red, 8.0f, 16.0f, 0.1f, 0.2f, 0.92f, 22);
            }

            //bump em
            Vector2 diff  = Geometry.Position - player.Geometry.Position;
            double  angle = Math.Atan2(diff.Y, diff.X);

            player.Geometry.Position.X = (float)(Geometry.Position.X + ((player.Geometry.CollisionRadius + Geometry.CollisionRadius) * -Math.Cos(angle) * knockbackFactor));
            player.Geometry.Position.Y = (float)(Geometry.Position.Y + ((player.Geometry.CollisionRadius + Geometry.CollisionRadius) * -Math.Sin(angle) * knockbackFactor));
        }
Beispiel #2
0
        private bool FindAliens(Entity ent, object batch, object player, object p3)
        {
            SpriteBatch spriteBatch   = (SpriteBatch)batch;
            Marine      marine        = (Marine)player;
            float       scalingFactor = 0.1f;
            float       dFactor       = 0.05f;

            if (ent as Alien == null)
            {
                return(true);
            }

            Vector2 diff      = ent.Geometry.Position - marine.Geometry.Position;
            Vector2 worldLoc  = Geometry.Position + (dFactor * diff);
            Vector2 pixelLoc  = _Parent.ViewPort.Transform_UnitPosition_To_PixelPosition(worldLoc);
            Vector2 pixelSize = _Parent.ViewPort.Transform_UnitSize_To_PixelSize(ent.Geometry.Size * scalingFactor);

            spriteBatch.Draw(_BlipTex, new Rectangle((int)pixelLoc.X, (int)pixelLoc.Y, (int)pixelSize.X, (int)pixelSize.Y), Color.White);

            return(true);
        }
Beispiel #3
0
        public WorldScreen(ScreenManager manager, String worldMap)
            : base(manager, "World")
        {
            // Load world
            _WorldMap = worldMap;
            FileStream   fs  = File.OpenRead(_WorldMap);
            BinaryReader bin = new BinaryReader(fs);

            TileRows        = bin.ReadInt32();
            TileCols        = bin.ReadInt32();
            Tile.TileWidth  = bin.ReadSingle();
            Tile.TileHeight = bin.ReadSingle();

            for (int row = 0; row < TileRows; row++)
            {
                for (int col = 0; col < TileCols; col++)
                {
                    int index = bin.ReadInt32();
                    Tile.TileGen[index](this, row, col, index);
                }
            }

            bin.Close();
            fs.Close();

            // Create player
            _Player = new Marine(this);
            _Player.Geometry.Position.X = TileCols * Tile.TileWidth / 2;
            _Player.Geometry.Position.Y = TileRows * Tile.TileHeight / 2;

            // Create crosshair
            _Crosshair = new Crosshair(this);

            // Create aliens
            for (int i = 0; i < NumAliens; i++)
            {
                float dist = (float)Application.AppReference.Random.NextDouble() * 300 + 200f;
                Alien.CreateNearbyAlien(this, _Player, dist, _Player);
            }


            // Setup screen behavior
            Depth                = 0.9f;
            _BackBehaviour       = ActionOnBack.ExitApplication;
            _FadeInTime          = 0.0f;
            _FadeOutTime         = 0.0f;
            _Message             = _HelpMessage;
            _MessageFont         = Application.AppReference.Content.Load <SpriteFont>("Font");
            _MessageColour       = Color.White;
            _BackgroundDrawingOn = true;
            //Application.AppReference.DynamicLighting = false;

            // Create loadport
            LoadPort = new LoadPort(this, new Vector2(), new Vector2(1050, 750), 100f);

            //music time
            Random random = new Random();
            int    song   = random.Next(0, 2);

            MediaPlayer.Play(Application.AppReference.Content.Load <Song>("Sounds\\03 - Teardrop"));
            //if (song == 1)
            //    MediaPlayer.Play(Application.AppReference.Content.Load<Song>("Sounds\\leanonme"));
            StartBackgroundThread();
        }
Beispiel #4
0
        protected override void HandleInputActive(Bind bind)
        {
            base.HandleInputActive(bind);

            if (bind.Name.CompareTo("MoveForward") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    _Player.MoveForward = true;
                }
                else
                {
                    _Player.MoveForward = false;
                }
            }
            else if (bind.Name.CompareTo("MoveBack") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    _Player.MoveBack = true;
                }
                else
                {
                    _Player.MoveBack = false;
                }
            }
            else if (bind.Name.CompareTo("StrafeLeft") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    _Player.MoveLeft = true;
                }
                else
                {
                    _Player.MoveLeft = false;
                }
            }
            else if (bind.Name.CompareTo("StrafeRight") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    _Player.MoveRight = true;
                }
                else
                {
                    _Player.MoveRight = false;
                }
            }
            else if (bind.Name.CompareTo("MoveMode") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    _Manager.Input.AbsoluteMovement = !_Manager.Input.AbsoluteMovement;
                }
            }
            else if (bind.Name.CompareTo("FlashLight") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    _Player.FlashLight.Active = !_Player.FlashLight.Active;
                }
            }
            else if (bind.Name.CompareTo("PrimaryFire") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    isFiring = true;
                }
                else
                {
                    isFiring = false;
                }
            }
            else if (bind.Name.CompareTo("SecondaryFire") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    if (_Player.Disposed)
                    {
                        _Player = new Marine(this);
                        _Player.Geometry.Position.X = TileCols * Tile.TileWidth / 2;
                        _Player.Geometry.Position.Y = TileRows * Tile.TileHeight / 2;
                    }
                }
            }
            else if (bind.Name.CompareTo("Reload") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    _Player.Reload();
                }
            }
            else if (bind.Name.CompareTo("NightVision") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    _Player.NightVision.Active = !_Player.NightVision.Active;
                }
            }
            else if (bind.Name.CompareTo("FPS") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    if (_FPSDisplay)
                    {
                        _FPSDisplay = false;
                        _Message    = _HelpMessage;
                    }
                    else
                    {
                        _FPSDisplay = true;
                    }
                }
            }
            else if (bind.Name.CompareTo("Editor") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    Screen gui;
                    _Manager.LookupScreen("GUI", out gui);
                    gui.Remove();
                    Remove();
                    _Manager.AddScreen(new EditorScreen(_Manager));
                    _Manager.AddScreen(new GUIEditor(_Manager));
                }
            }
            else if (bind.Name.CompareTo("Weapon1") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    if (Player.weaponList.Count > 0)
                    {
                        Player.currentWeapon = Player.weaponList[0];
                    }
                }
            }
            else if (bind.Name.CompareTo("Weapon2") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    if (Player.weaponList.Count > 1)
                    {
                        Player.currentWeapon = Player.weaponList[1];
                    }
                }
            }
            else if (bind.Name.CompareTo("Weapon3") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    if (Player.weaponList.Count > 2)
                    {
                        Player.currentWeapon = Player.weaponList[2];
                    }
                }
            }
            else if (bind.Name.CompareTo("Weapon4") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    if (Player.weaponList.Count > 3)
                    {
                        Player.currentWeapon = Player.weaponList[3];
                    }
                }
            }
            else if (bind.Name.CompareTo("Weapon5") == 0)
            {
                if (bind.State == Microsoft.Xna.Framework.Input.KeyState.Down)
                {
                    if (Player.weaponList.Count > 4)
                    {
                        Player.currentWeapon = Player.weaponList[4];
                    }
                }
            }
        }
Beispiel #5
0
 public Weapon(Marine Player)
 {
     this.player = Player;
     _Sound      = Application.AppReference.Content.Load <SoundEffect>("Sounds\\bullet");
 }
Beispiel #6
0
 public AutoHandGun(Marine player)
     : base(player)
 {
 }
Beispiel #7
0
 public MachineGun(Marine player)
     : base(player)
 {
     this.weaponCooldown = 50;
     this.ReloadTime     = 2000;
 }