Пример #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            NumOfPlayers = LoadSetting( "Players", 2 );
            CurrentID = -NumOfPlayers;
            WaitMillisecs = LoadSetting( "EndingDelay", 3000 );
            FreezeMillisecs = LoadSetting( "FreezeTime", 1000 );
            SpawnMillisecs = LoadSetting( "PickupTime", 5000 );
            PickupLifetime = LoadSetting( "PickupLifeTime", 10000 );

            LoadSetting( "BlastRadius", 10.0F );

            KeySet p1keys = LoadSetting( "Player1Keys", new KeySet( Keys.Up, Keys.Down, Keys.Left, Keys.Right, Keys.Z, Keys.X ) );
            KeySet p2keys = LoadSetting( "Player2Keys", new KeySet( Keys.W, Keys.S, Keys.A, Keys.D, Keys.Q, Keys.E ) );
            KeySet p3keys = LoadSetting( "Player3Keys", new KeySet( Keys.T, Keys.G, Keys.F, Keys.H, Keys.V, Keys.B ) );
            KeySet p4keys = LoadSetting( "Player4Keys", new KeySet( Keys.NumPad5, Keys.NumPad2, Keys.NumPad1, Keys.NumPad3, Keys.NumPad7, Keys.NumPad8 ) );

            Colors p1Color = LoadSetting( "Player1Color", Colors.Green );
            Colors p2Color = LoadSetting( "Player2Color", Colors.Purple );
            Colors p3Color = LoadSetting( "Player3Color", Colors.Blue );
            Colors p4Color = LoadSetting( "Player4Color", Colors.Orange );

            bool p1AI = LoadSetting( "Player1AI", false );
            bool p2AI = LoadSetting( "Player2AI", false );
            bool p3AI = LoadSetting( "Player3AI", false );
            bool p4AI = LoadSetting( "Player4AI", false );

            int ProjectileTime = LoadSetting( "ProjectileTime", 10000 );
            int ProjectileSpeed = LoadSetting( "ProjectileSpeed", 10 );
            int ControllerTime = LoadSetting( "ControllerTime", 10000 );
            int FenceTime = LoadSetting( "FenceTime", 10000 );
            int TankSpeed = LoadSetting( "TankSpeed", 5 );
            int BulletLifeTime = LoadPositiveSetting( "BulletLifeTime", ProjectileTime );

            float TankScale = LoadSetting( "TankScale", 2F );

            defaultBullet = new Bullet( LoadPositiveSetting( "BulletSpeed", ProjectileSpeed ), Tank.blank, TimeSpan.Zero, BulletLifeTime );

            int FenceLimit = LoadSetting( "FenceLimit", 10 );
            int ProjectileLimit = LoadSetting( "ProjectileLimit", 3 );

            LoadSetting( "ShockwaveRadius", 200.0F );

            LoadSetting( "SuddenDeathTime", 10000 );

            // Shows mouse
            IsMouseVisible = true;

            MasterControllers = new HashSet<GameController>();
            ScheduledTasks = new HashSet<Tuple<TimeSpan, int, Action>>();
            Entities = new HashSet<GameEntity>();

            // Player 1
            p1 = new Tank( "Player 1", new Vector2( 50, 50 ), 45, p1keys, p1Color, TankSpeed, defaultBullet, ProjectileLimit, FenceLimit, FenceTime, TankScale, p1AI, PlayerIndex.One );
            Entities.Add( p1 );

            // Player 2
            p2 = new Tank( "Player 2", new Vector2( ScreenWidth - 50, ScreenHeight - 50 ), 225, p2keys, p2Color, TankSpeed, defaultBullet, ProjectileLimit, FenceLimit, FenceTime, TankScale, p2AI, PlayerIndex.Two );
            Entities.Add( p2 );

            if ( NumOfPlayers >= 3 )
            {
                Entities.Add( new Tank( "Player 3", new Vector2( ScreenWidth - 50, 50 ), 135, p3keys, p3Color, TankSpeed, defaultBullet, ProjectileLimit, FenceLimit, FenceTime, TankScale, p3AI, PlayerIndex.Three ) );
            }

            if ( NumOfPlayers >= 4 )
            {
                Entities.Add( new Tank( "Player 4", new Vector2( 50, ScreenHeight - 50 ), 315, p4keys, p4Color, TankSpeed, defaultBullet, ProjectileLimit, FenceLimit, FenceTime, TankScale, p4AI, PlayerIndex.Four ) );
            }

            foreach ( GameEntity entity in Entities )
            {
                entity.Initialize( this );
            }

            AvailableProjectiles = new Projectile[]
            {
                new HomingBullet( LoadPositiveSetting( "HomingBulletSpeed", ProjectileSpeed ), LoadPositiveSetting( "HomingBulletTurnSpeed", 5 ), TimeSpan.Zero, LoadPositiveSetting( "HomingBulletNoticeTime", 1000 ), LoadPositiveSetting( "HomingBulletTime", ProjectileTime ) ),
                new Missile( LoadPositiveSetting( "MissileSpeed", ProjectileSpeed ) ),
                new Lazer( LoadPositiveSetting( "LazerTime", ProjectileTime ), LoadPositiveSetting( "LazerSpeed", 100 ), LoadPositiveSetting( "LazerTrail", 200 ) ),
                new Rider( LoadPositiveSetting( "RiderSpeed", ProjectileSpeed ), LoadPositiveSetting( "RiderTime", ProjectileTime ),LoadSetting("RiderDeath").ToLower() == "true", LoadPositiveSetting( "RiderTwist", 1 ) ),
            };

            AvailableControllers = new TankController[]
            {
                new Ghost( LoadPositiveSetting( "GhostTime", ControllerTime ) ),
                new Deflector(),
                new SpeedBoost(LoadPositiveSetting( "SpeedBoostTime", ControllerTime ), LoadSetting( "SpeedBoostFactor", 2F ) ),
                new Minimize( LoadPositiveSetting( "MinimizeTime", ControllerTime ) ),
                new Switcher(),
                new ForceField( LoadPositiveSetting( "ForceFieldTime", ControllerTime ) ),
                new Tripler( LoadPositiveSetting( "TriplerTime", ControllerTime ) ),
                new ExtraLife(),
                new Shockwave(),
                new Roulette(),
                new MindController( LoadPositiveSetting( "MindControlTime", ControllerTime ) ),
                new IronDome( LoadPositiveSetting( "IronDomeTime", ControllerTime ), LoadPositiveSetting( "IronLifeTime", 2000 ), LoadPositiveSetting( "IronSpeed", 10 ), LoadPositiveSetting( "IronRadius", 200 ), LoadPositiveSetting( "IronProbability", 90 ) ),
                new Disabler( LoadPositiveSetting( "MaxDisablerSpeed", 50 ) ),
                new Minigun( LoadPositiveSetting( "MinigunTime", ControllerTime ), LoadPositiveSetting( "MinigunSpeed", 500 ) ),
                new Ring( LoadPositiveSetting( "RingRadius", 50 ) ),
                new Shuffler(),
                new Hypnotizer( LoadPositiveSetting( "HypnotizerTime", ControllerTime ), LoadPositiveSetting( "HypnoRadius", 200 ) ),
                new Aimbot(),
                new Dodger( LoadPositiveSetting( "DodgerTime", ControllerTime ) ),
            };

            AvailableConEnts = new ControllerEntity[]
            {
                new Portal( LoadPositiveSetting( "PortalTime", ControllerTime ) ),
                new BlackHole(),
                //new Concealer( LoadPositiveSetting( "ConcealerTime", ControllerTime ) ),
            };

            SuddenDeaths = new GameController[]
            {
                //new ShrinkyDeath(),
                new Orbit( LoadSetting( "OrbitBaseSpeed", 20F ), LoadSetting( "OrbitMaxSpeed", 60F ), LoadSetting( "OrbitMinSpeed", 1F ), LoadSetting( "OrbitAccleration", -0.5F ), LoadSetting( "OrbitSpiralFactor", 19F ) ),
            };

            QueueSuddenDeath();

            base.Initialize();
        }
Пример #2
0
 /// <summary>
 /// Called whenever the tank gets hit by a bullet.
 /// </summary>
 /// <param name="hitter">The projectile that hit the tank.</param>
 /// <returns>true if the tank should die, otherwise false.</returns>
 public abstract bool ProjectileHit( Projectile hitter, TimeSpan gameTime );
Пример #3
0
 /// <summary>
 /// Called when the tank wants to shoot a bullet.
 /// </summary>
 /// <param name="gameTime">The current game time.</param>
 public virtual bool Shoot( TimeSpan gameTime, Projectile shot )
 {
     return false;
 }
Пример #4
0
 /// <summary>
 /// Shoots the pending bullet if either the controller allows, or force is true.
 /// </summary>
 /// <param name="gameTime">The current game time.</param>
 /// <param name="force">True if the tank must shoot, otherwise false.</param>
 public void Shoot( TimeSpan gameTime, bool force = false )
 {
     if ( NumberOfProjectiles >= ProjectileLimit && ProjectileLimit > 0 )
         return;
     nextProjectile.Angle = Angle;
     nextProjectile.Position = PositionShift( 20 * Scale );
     NumberOfProjectiles++;
     nextProjectile.Initialize( Game, gameTime, this );
     if ( force || Controller == null || !Controller.Shoot( gameTime, nextProjectile ) )
     {
         Game.QueueEntity( nextProjectile );
     }
     nextProjectile = OriginalProjectile;
     shootSound.Play();
 }
Пример #5
0
 public ProjectilePickup( Projectile carrier, int lifeTime )
     : base(lifeTime)
 {
     Carrier = carrier;
 }
Пример #6
0
 /// <summary>
 /// Resets the tank to the original form.
 /// </summary>
 /// <param name="proj">Whether or not to reset the projectile.</param>
 public void Reset( bool proj = true )
 {
     Position = originalPosition;
     Angle = originalAngle;
     Scale = originalScale;
     Texture = originalTexture;
     Speed = originalSpeed;
     isTextureAMap = true;
     if ( proj )
     {
         nextProjectile = OriginalProjectile.Clone();
     }
     IsAlive = true;
     NumberOfProjectiles = 0;
     NumberOfFences = 0;
     RemoveTankController();
     Keys = OriginalKeys.Clone();
     Controllers = new HashSet<GameController>();
 }
Пример #7
0
 /// <summary>
 /// Called when a projectile hits the tank.
 /// </summary>
 /// <param name="Hitter">The projectile that hit the tank.</param>
 /// <returns>True if the tank was killed, otherwise false.</returns>
 public bool ProjectileHit( Projectile Hitter, TimeSpan gameTime )
 {
     if ( Controller == null || Controller.ProjectileHit( Hitter, gameTime ) )
     {
         IsAlive = false;
         hitSound.Play();
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #8
0
 /// <summary>
 /// Called when the tank should pick up a ProjectilePickup.
 /// </summary>
 /// <param name="proj">The projectile pickup.</param>
 /// <returns>True if the projectile was picked up - otherwise false.</returns>
 public bool PickupProjectile( ProjectilePickup proj )
 {
     if ( nextProjectile.GetType() == OriginalProjectile.GetType() && ( Controller == null || Controller.PickupProjectile( proj ) ) )
     {
         nextProjectile = proj.Carrier.Clone();
         powerUpSound.Play();
         return true;
     }
     return false;
 }
Пример #9
0
 public override void Initialize( TanksDrop game )
 {
     originalProjectile.Initialize( game );
     nextProjectile = OriginalProjectile;
     prevPadState = GamePad.GetState( index );
     base.Initialize( game );
 }
Пример #10
0
 public Tank( string name, Vector2 startPosition, float startAngle, KeySet keys, Colors color, float speed, Projectile originalProjectile, int BulletLimit, int FenceLimit, int FenceTime, float Scale, bool AI, PlayerIndex index )
 {
     this.Name = name;
     this.Speed = speed;
     this.originalSpeed = speed;
     this.originalPosition = startPosition;
     this.originalAngle = startAngle;
     this.Keys = keys;
     this.OriginalKeys = keys;
     this.TankColor = color;
     this.OriginalColor = color;
     this.Origin = new Vector2( 16, 16 );
     this.originalProjectile = originalProjectile;
     this.ProjectileLimit = BulletLimit;
     this.FenceLimit = FenceLimit;
     this.originalScale = Scale;
     this.Scale = Scale;
     this.FenceLifeTime = FenceTime;
     this.TurnSpeed = 5;
     this.AI = AI;
     this.r = new Random( 10 );
     this.index = index;
     Reset( false );
 }