public Player(ContentManager content)
 {
     position = new Vector3(0, 0, -250);
     CameraStaticPosition = new Vector3(0, 0, 0);
     this.content = content;
     model = content.Load<Model>(@"models/maincharacter");
     texture = content.Load<Texture2D>(@"models/characterTextureBody");
     controls = new Controller();
     initialLock = true;
     controls.Locked = true;
     shield = 3;
     powerup = 0;
     currentWeapon = new Needle(content);
     oldPos = Vector3.Zero;
     pressedDodgeLeft = false;
     pressedDodgeRight = false;
     isInvincible = false;
     currFireTime = new TimeSpan(currentWeapon.FireTime.Ticks);
     dodgeTime = TimeSpan.FromSeconds(dodgeTimeSeconds);
     betweenDodge = TimeSpan.FromSeconds(betweenDodgeSeconds);
     invincibleTime = TimeSpan.FromSeconds(invincibleTimeSeconds);
     flickerTime = TimeSpan.FromSeconds(flickerTimeSeconds);
     powerUpTime = TimeSpan.FromSeconds(powerupTimeSeconds);
     pressedPowerUpTime = TimeSpan.FromSeconds(pressedPowerUpTimeSeconds);
     playerAVC = new AudioVideoController();
     cameraEnabled = true;
 }
示例#2
0
        public virtual void Update(GameTime gameTime)
        {
            Player p = entities[0] as Player;

            if (p.SwitchedFromShield)
            {
                for (int j = 0; j < entities.Count; j++)
                {
                    if (entities[j] is Shield)
                    {
                        entities.Remove(entities[j]);
                        j = 0;
                    }
                }
                p.SwitchedFromShield = false;
            }
            for (int i = 0; i < entities.Count; i++)
            {
                if (!entities[i].isDead)
                {
                    if (entities[i] is ChargeBall)
                    {
                        ChargeBall cb = entities[i] as ChargeBall;
                        cb.Update(gameTime, p.Position, p.Rotation);
                    }
                    if (entities[i] is Laser)
                    {
                        Laser l = entities[i] as Laser;
                        l.Update(gameTime, p.Position, p.Rotation);
                    }
                    if (entities[i] is Boss)
                    {
                        Boss b = entities[i] as Boss;
                        b.Update(gameTime, p.Position);
                    }
                    if (entities[i] is ClotSide)
                    {
                        ClotSide cs = entities[i] as ClotSide;
                        cs.Update(gameTime, velocity);
                    }
                    if (entities[i] is Infector)
                    {
                        Infector inf = entities[i] as Infector;
                        inf.Update(gameTime, p.Position);
                    }
                    if (entities[i] is TokenPickup)
                    {
                        TokenPickup tp = entities[i] as TokenPickup;
                        tp.Update(gameTime);
                    }
                    if (entities[i] is PlayerWeapon)
                    {
                        PlayerWeapon w = entities[i] as PlayerWeapon;
                        w.Update(gameTime, p.Position, p.Rotation);
                    }
                    if (entities[i] is BotWeapon)
                    {
                        BotWeapon bw = entities[i] as BotWeapon;
                        bw.Update(gameTime, p.Position, p.Rotation);
                    }
                    if (entities[i] is Shield)
                    {
                        Shield s = entities[i] as Shield;
                        s.Update(gameTime, p.Velocity, p.controls.isPlayerFiring());
                    }
                    if (entities[i] is LatchingCell || entities[i] is MeleeBot || entities[i] is MissileBot)
                    {
                        if (entities[i] is LatchingCell)
                        {
                            LatchingCell lc = entities[i] as LatchingCell;
                            lc.Update(gameTime, p.Position);
                        }
                        else if (entities[i] is MeleeBot)
                        {
                            MeleeBot mb = entities[i] as MeleeBot;
                            mb.Update(gameTime, p.Position);
                        }
                        else
                        {
                            MissileBot missBot = entities[i] as MissileBot;
                            missBot.Update(gameTime, p.Position);
                        }
                    }
                    entities[i].Update(gameTime);
                }
                else
                {
                    if (entities[i] is EnemiesAndPlayer)
                    {
                        EnemiesAndPlayer ep = entities[i] as EnemiesAndPlayer;
                        if (ep.killedBy())
                        {
                            p.addScore(ep.Score);
                            p.AddPowerup(15);
                            if (ep is MeleeBot || ep is MissileBot)
                            {
                                if (random.Next(2) == 0)
                                {
                                    Add(new TokenPickup(content, ep.Position));
                                }
                            }
                        }
                    }
                    entities.Remove(entities[i]);
                }
            }
        }
 public void changeWeapon(PlayerWeaponName name)
 {
     if (currentWeapon.Name == name)
     {
         return;
     }
     if (currentWeapon is Shield)
     {
         switchedFromShield = true;
     }
     int currentLevel = currentWeapon.CurrentLevel;
     switch (name)
     {
         case PlayerWeaponName.Needle:
             currentWeapon = new Needle(content);
             break;
         case PlayerWeaponName.Missile:
             currentWeapon = new Missle(content);
             break;
         case PlayerWeaponName.Shield:
             currentWeapon = new Shield(content, new Vector3(position.X - 400, position.Y + 300, position.Z - 12), new Vector3(position.X - 4, position.Y, position.Z + 4));
             Level.Add(new Shield(content, new Vector3(position.X - 4, position.Y, position.Z + 10), new Vector3(position.X - 8, position.Y, position.Z + 10)));
             Level.Add(new Shield(content, new Vector3(position.X + 4, position.Y, position.Z + 10), new Vector3(position.X + 8, position.Y, position.Z + 10)));
             break;
     }
     currentWeapon.CurrentLevel = currentLevel;
 }