Exemplo n.º 1
0
        public override void Initialize(ContentManager content, Vector2 position, Loot theLoot, Wave theWave)
        {
            parachuteRip = (content.Load<SoundEffect>("Music\\Rip.wav")).CreateInstance();
            FlyingTexture = content.Load<Texture2D>("Graphics\\ParachuteEnemy");
            /*
            EnemyDeathTexture = content.Load<Texture2D>("Graphics\\Enemy1Dead");
            FiringTexture = content.Load<Texture2D>("Graphics\\Enemy1Firing");

            EnemyTextureMap = new AnimatedSprite(content.Load<Texture2D>("Graphics\\Enemy1Map"), numMapRows, numMapColumns, animationSpeed);
            speed = E1Speed;
            base.Initialize(content, position, theLoot, theWave);
             * */

            base.Initialize(content, position, theLoot, theWave);

            if (inSky)
            {
                if (position.X < 0)
                {
                    speed *= 2;
                    Position = new Vector2(100, -75);
                }
                else
                {
                    speed *= 2;
                    Position = new Vector2(650, -75);
                }
            }
        }
Exemplo n.º 2
0
 public override void Initialize(ContentManager content, Vector2 position, Loot theLoot, Wave theWave)
 {
     EnemyDeathTexture = content.Load<Texture2D>("Graphics\\Enemy1Dead");
     FiringTexture = content.Load<Texture2D>("Graphics\\Enemy1Firing");
     EnemyTextureMap = new AnimatedSprite(content.Load<Texture2D>("Graphics\\Enemy1Map"), numMapRows, numMapColumns, animationSpeed);
     speed = E1Speed;
     regions = enemyRegions;
     damages = enemyDamages;
     sounds = enemySounds;
     health = enemyHealth;
     base.Initialize(content, position, theLoot, theWave);
 }
Exemplo n.º 3
0
 public override void Initialize(ContentManager content, Vector2 position, Loot theLoot, Wave theWave)
 {
     dogBiteSound = (content.Load<SoundEffect>("Music\\DogBite.wav")).CreateInstance();
     EnemyDeathTexture = content.Load<Texture2D>("Graphics\\DogDead");
     FiringTexture = content.Load<Texture2D>("Graphics\\DogBite");
     EnemyTextureMap = new AnimatedSprite(content.Load<Texture2D>("Graphics\\DogMap"), numMapRows, numMapColumns, animationSpeed);
     speed = E1Speed;
     regions = enemyRegions;
     damages = enemyDamages;
     sounds = enemySounds;
     health = enemyHealth;
     base.Initialize(content, position, theLoot, theWave);
     firingAnimationRate = firinganimationRate;
     isLooted = true; //Dogs can't be looted
     Position.Y += heightOffset;
 }
Exemplo n.º 4
0
 public void Update(int command, GameTime gameTime, Wave wave)
 {
     if (!scavengers[activeScavenger].Alive && activeScavenger < scavengers.Count - 1)
     {
         scavengers[activeScavenger].Active = false;
         activeScavenger++;
         scavengers[activeScavenger].Active = true;
         //Don't use last scavenger's commands at death
         command = -1;
         MainGame.resetScavengeCommand();
     }
     for (int i = 0; i < scavengers.Count; i++)
     {
         if (i == activeScavenger)
         {
             scavengers[i].Update(command, gameTime, wave, this);
         }
         else
         {
             scavengers[i].Update(-1, gameTime, wave, this);
         }
     }
 }
Exemplo n.º 5
0
        public void Update(MouseState currentMouseState, Weapon weapon, GameTime gameTime, Wave wave, Scavenger scavenger,
            GraphicsDevice graphicsDevice)
        {
            if (waveManager.State != 0)
            {
                if (State == 0) //Moving this check after this block creates cool redirect mechanic
                {
                    aimingAngle = -100;
                    float aimX = weapon.waveManager.getWave().layout.weaponGunpoint.X
                        + weapon.waveManager.getWave().layout.crosshairAdjustX;
                    float aimY = weapon.waveManager.getWave().layout.weaponGunpoint.Y
                        + weapon.waveManager.getWave().layout.crosshairAdjustY;

                    if (MainGame.currentGamepadState.IsConnected)
                    {
                        aimingVector.X = MainGame.currentGamepadState.ThumbSticks.Left.X;
                        aimingVector.Y = -1 * MainGame.currentGamepadState.ThumbSticks.Left.Y;
                        aimingVector.Normalize();

                        aimingAngle = (float)Math.Atan2(aimingVector.Y, aimingVector.X);
                        if (!waveManager.getWave().layout.checkAimingVector(aimingVector))
                        {
                            aimingAngle = -100;
                        }
                    }
                    else
                    {
                        if (aimingAngle == -100)
                        {
                            aimingVector.X = currentMouseState.X - aimX;
                            aimingVector.Y = currentMouseState.Y - aimY;
                            aimingVector.Normalize();

                            aimingAngle = (float)Math.Atan2(aimingVector.Y, aimingVector.X);
                            if (!waveManager.getWave().layout.checkAimingVector(aimingVector))
                            {
                                aimingAngle = -100;
                            }
                        }
                    }

                    //If not firing, listen for aiming click
                    //If clicked, place crosshair in front of gun
                    //and switch to aiming state,
                    //recording aiming vector
                    //Also confirm that vector is going in logical direction
                    if (currentMouseState.RightButton == ButtonState.Pressed
                         || (MainGame.currentGamepadState.Buttons.LeftShoulder == ButtonState.Pressed))
                     // || (MainGame.currentGamepadState.Triggers.Left >= MainGame.triggerThreshold)) //is what we want
                    {

                        if (waveManager.getWave().layout.checkAimingVector(aimingVector)
                            && weapon.reloadOver(gameTime) && !(weapon.clipSupply == 0 && weapon.ammoSupply == 0))
                        {
                            aimingTimestamp = gameTime.TotalGameTime;
                            Position.X = aimX;
                            Position.Y = aimY;
                            State = 1;
                        }
                    }

                }
                else
                {
                    //If aiming, listen for firing click
                    //If the aiming button is released, place it back offscreen
                    //switch to not firing state
                    //Otherwise, move crosshair along aiming vector
                    //and if there is a firing clip, determine hit
                    //and ammo changes or reload need

                    if (currentMouseState.RightButton == ButtonState.Released
                         && !(MainGame.currentGamepadState.Buttons.LeftShoulder == ButtonState.Pressed))
                        //&& !(MainGame.currentGamepadState.Triggers.Left >= MainGame.triggerThreshold)) //is what we want
                    {
                        resetPosition();
                        State = 0;
                    }
                    else
                    {
                        //Need to take firing cooldown/reload into consideration

                        if (currentMouseState.LeftButton == ButtonState.Pressed
                            || MainGame.currentGamepadState.Triggers.Right >= MainGame.triggerThreshold) //implied state==1
                        {
                            weapon.playShot(gameTime);
                            if (weapon.isFireable(gameTime))
                            {
                                //Update game world here and inform weapon to draw
                                //shot, but can't draw yet
                                //Make scavengers in trench safe, but not others
                                if (wave.isHit(Position) || (scavenger.action != 0 && scavenger.isHit(Position)))
                                {
                                    weapon.ShotPoint.X = Position.X + Width / 2;
                                    weapon.ShotPoint.Y = Position.Y + Height / 2;
                                }
                                else
                                {
                                    weapon.ShotPoint.X = weapon.waveManager.getWave().layout.weaponGunpoint.X + aimingVector.X * graphicsDevice.Viewport.Width;
                                    weapon.ShotPoint.Y = weapon.waveManager.getWave().layout.weaponGunpoint.Y + aimingVector.Y * graphicsDevice.Viewport.Width;
                                }
                                weapon.startShotCooldown(gameTime);
                            }
                        }

                        float velocity = weapon.GetCrosshairVelocity((gameTime.TotalGameTime.Subtract(aimingTimestamp)).TotalMilliseconds);
                        Position.X = aimingVector.X * velocity + Position.X;
                        Position.Y = aimingVector.Y * velocity + Position.Y;
                    }

                }
            }
        }
Exemplo n.º 6
0
 public virtual void Initialize(ContentManager content, Vector2 position, Loot theLoot, Wave theWave)
 {
     Position = position;
     Alive = true;
     isFiring = false;
     firingAnimationRate = firinganimationrate;
     beginFiringTime = 0;
     loot = new List<Loot>();
     loot.Add(theLoot);
     isLooted = false;
     toShoot = Vector2.Zero;
     wave = theWave;
 }
Exemplo n.º 7
0
 public override void Initialize(ContentManager content, Vector2 position, Loot theLoot, Wave theWave)
 {
     base.Initialize(content, position, theLoot, theWave);
     Alive = false;
     Position = new Vector2(position.X/2, position.Y);
 }
Exemplo n.º 8
0
        public void Update(int command, GameTime gameTime, Wave wave, ScavengerManager manager)
        {
            Vector2 scavengerSpawn = scavengerManager.waveManager.getWave().layout.scavengerSpawnPosition;
            Vector2 scavengerIdle = scavengerManager.waveManager.getWave().layout.getScavengerTrenchPlacement(positionNumber);
            if (Alive)
            {
                if (action == 0) //Idling
                {
                    //If command is to go, then put in scavenging spawn point
                    if (command == 1)
                    {
                        Position = scavengerSpawn;
                        action = 1;
                        movingTowardsTrench = false;
                    }
                }
                else if (action == 1) //Going out
                {
                    //If command is to come back, turn around
                    if (command == 0)
                    {
                        if (scavengerManager.waveManager.getWave().layout.pather.atTrenchEntrance(Position, Width, Height))
                        {
                            Position = scavengerIdle;
                            action = 0;
                        }
                        else
                        {
                            Position = scavengerManager.waveManager.getWave().layout.pather.Move(Position, true, speed);
                            movingTowardsTrench = true;
                            action = 2;
                        }
                    }
                    else //else scavenge
                    {
                        List<Scavenger> lootableScavengers = manager.getScavengableScavengers();
                        //If no lootable things, just move forward
                        if (wave.enemiesOnScreen.Count + lootableScavengers.Count == 0)
                        {
                            Position = scavengerManager.waveManager.getWave().layout.pather.Move(Position, false, speed);
                            movingTowardsTrench = false;
                        }
                        else
                        {
                            //Look for nearest unlooted body
                            Enemy closestEnemy = null;
                            float closestDistance = float.MaxValue;
                            for (int i = 0; i < wave.enemiesOnScreen.Count; i++)
                            {
                                if (!wave.enemiesOnScreen[i].Alive && !wave.enemiesOnScreen[i].isLooted)
                                {
                                    float enemyDistance = Vector2.Distance(Position, wave.enemiesOnScreen[i].Position);
                                    if (enemyDistance < closestDistance)
                                    {
                                        closestEnemy = wave.enemiesOnScreen[i];
                                        closestDistance = enemyDistance;
                                    }
                                }
                            }
                            Scavenger closestScavenger = null;
                            float closestScavengerDistance = float.MaxValue;
                            for (int i = 0; i < lootableScavengers.Count; i++)
                            {
                                float scavengerDistance = Vector2.Distance(Position, lootableScavengers[i].Position);
                                if (scavengerDistance < closestScavengerDistance)
                                {
                                    closestScavenger = lootableScavengers[i];
                                    closestScavengerDistance = scavengerDistance;
                                }
                            }
                            Vector2 enemyPosition = Vector2.Zero;
                            int enemyWidth = 0;
                            int enemyHeight = 0;

                            bool isScavenger = false;

                            if ((closestEnemy == null && closestScavenger != null)
                                || (closestEnemy != null && closestScavenger != null && closestScavengerDistance <= closestDistance))
                            {
                                enemyPosition = closestScavenger.Position;
                                enemyWidth = closestScavenger.Width;
                                enemyHeight = closestScavenger.Height;
                                isScavenger = true;
                            }
                            else if ((closestEnemy != null && closestScavenger == null)
                                || (closestEnemy != null && closestScavenger != null && closestScavengerDistance > closestDistance))
                            {
                                enemyPosition = closestEnemy.Position;
                                enemyWidth = closestEnemy.Width;
                                enemyHeight = closestEnemy.Height;
                                isScavenger = false;
                            }

                            if (enemyWidth != 0 && enemyHeight != 0) //&& enemyPosition not Vector.Zero?
                            {
                                //If it is close enough to scavenge, do so
                                if (scavengerManager.waveManager.getWave().layout.pather.intersectsWith(Position, Width, Height, enemyPosition, enemyWidth, enemyHeight))
                                {
                                    if (isScavenger)
                                    {
                                        closestScavenger.isLooted = true;
                                        lootToLoot = new List<Loot>();
                                        lootToLoot.AddRange(closestScavenger.scavengedLoot);
                                    }
                                    else
                                    {
                                        closestEnemy.isLooted = true;
                                        lootToLoot = new List<Loot>();
                                        lootToLoot.AddRange(closestEnemy.loot);
                                    }
                                    action = 3;
                                    whenScavengeBegan = gameTime.TotalGameTime.TotalMilliseconds;
                                    actionToReturnTo = 1;
                                }
                                else //else move towards it
                                {
                                    //Old: (enemyL > myL), assumes unidirectional
                                    //New: Just move forward
                                    Position = scavengerManager.waveManager.getWave().layout.pather.Move(Position, false, speed);
                                    movingTowardsTrench = false;
                                }
                            }
                            else //Shouldn't happen
                            {
                                Position = scavengerManager.waveManager.getWave().layout.pather.Move(Position, false, speed);
                                movingTowardsTrench = false;
                            }
                        }
                    }
                }
                else if (action == 2) //Coming back
                {
                    if (command == 1)
                    {
                        Position = scavengerManager.waveManager.getWave().layout.pather.Move(Position, false, speed);
                        movingTowardsTrench = false;
                        action = 1;
                    }
                    else
                    {
                        if (scavengerManager.waveManager.getWave().layout.pather.atTrenchEntrance(Position, Width, Height))
                        {
                            Position = scavengerIdle;
                            action = 0;
                            MainGame.scavengerAddToSupply(this);
                        }
                        else
                        {
                            Position = scavengerManager.waveManager.getWave().layout.pather.Move(Position, true, speed);
                            movingTowardsTrench = true;
                        }
                    }
                }
                else //Scavenging from body
                {
                    if (whenScavengeBegan != 0 && gameTime.TotalGameTime.TotalMilliseconds - whenScavengeBegan > timeToScavenge)
                    {
                        action = actionToReturnTo;
                        scavengedLoot.AddRange(lootToLoot);
                        lootToLoot.Clear();
                    }
                    else
                    {
                        if (command == 0) actionToReturnTo = 2;
                        else if (command == 1) actionToReturnTo = 1;
                    }
                }
            }
        }