Beispiel #1
0
        /// <summary>
        /// Checks if the intro for this jet is over
        /// </summary>
        private void checkIfIntroIsOver()
        {
            if (_isIntroOver)
            {
                _myBehaviorState = TwinJetBehaviouralState.FIGHT;

                onEntry();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates a shiny new jet
        /// </summary>
        /// <param name="id">the factory id on the underside of this jet</param>
        /// <param name="content">The content manager to use</param>
        /// <param name="newPosition">The position to spawn the jet</param>
        public TwinJet(uint id, ContentManager content, Vector2 newPosition)
            : base(id)
        {
            //Setting the health
            this.Health = FullHealth;

            //Setting alive to 'true'
            _isAlive = true;

            //Initializing the states
            _myVisualState   = TwinJetVisualState.HEALTHY;
            _myBehaviorState = TwinJetBehaviouralState.INTRO;
            _myFireState     = TwinJetFireState.STAGE1;
            _myGunState      = GunState.REST;
            _oldGunState     = GunState.LEFT;

            //Initializing rotation
            _myRotation = 0;

            //Setting the flight pattern to null
            _myPattern = null;

            //Setting position and velocity
            _position = newPosition;
            _velocity = Vector2.Zero;

            //Marking the intro as still occurring
            _isIntroOver = false;

            //Setup firerates
            _timerGunFireRate     = 0;
            _timerMissileFireRate = 0;

            //Bring in the spritesheet
            _spriteSheet = content.Load <Texture2D>("Spritesheets/newshi.shp.000000");

            //Setting up Sprite Bounds for the jet and gun
            _spriteBounds[(int)TwinJetVisualState.HEALTHY]      = new Rectangle(98, 143, 93, 80);
            _spriteBounds[(int)TwinJetVisualState.DAMAGED]      = new Rectangle(2, 143, 93, 53);
            _spriteBounds[(int)TwinJetVisualState.GUNDESTROYED] = new Rectangle(2, 143, 93, 53);
            _spriteBounds[(int)TwinJetVisualState.EXPLODING]    = Rectangle.Empty;
            _spriteBounds[(int)TwinJetVisualState.DEAD]         = Rectangle.Empty;

            _spriteGunBounds[(int)GunState.LEFT]      = new Rectangle(62, 196, 21, 21);
            _spriteGunBounds[(int)GunState.REST]      = new Rectangle(38, 196, 21, 20);
            _spriteGunBounds[(int)GunState.RIGHT]     = new Rectangle(14, 196, 21, 21);
            _spriteGunBounds[(int)GunState.DESTROYED] = new Rectangle(38, 196, 21, 11);

            //Calls the on entry method to initialize some things
            onEntry();
        }
Beispiel #3
0
        /// <summary>
        /// Called when the overall state of this jet is changed
        /// </summary>
        private void onEntry()
        {
            //Mostly setting variables to appropriate values
            //or calling some helper functions
            switch (_myVisualState)
            {
            case TwinJetVisualState.HEALTHY:

                _myMaxSpeed        = MaxHealthySpeed;
                _myGunFireRate     = HealthyGunFireRate;
                _myMissileFireRate = HealthyMissileFireRate;
                _myFireState       = TwinJetFireState.STAGE1;

                break;

            case TwinJetVisualState.DAMAGED:

                _myMaxSpeed        = MaxDamagedSpeed;
                _myGunFireRate     = DamagedGunFireRate;
                _myMissileFireRate = DamagedMissileFireRate;
                _myFireState       = TwinJetFireState.STAGE2;

                break;

            case TwinJetVisualState.GUNDESTROYED:

                _myMaxSpeed        = MaxGunLostSpeed;
                _myGunFireRate     = GunLostGunFireRate;
                _myMissileFireRate = GunLostMissileFireRate;
                _myFireState       = TwinJetFireState.STAGE3;
                _myGunState        = GunState.DESTROYED;

                break;

            case TwinJetVisualState.EXPLODING:
                _myBehaviorState = TwinJetBehaviouralState.PAUSED;
                break;
            }

            switch (_myBehaviorState)
            {
            case TwinJetBehaviouralState.FIGHT:
                _myPattern.SetToNearestNode(CenterPosition);
                break;
            }
        }
        /// <summary>
        /// Called when the overall state of this jet is changed
        /// </summary>
        private void onEntry()
        {
            //Mostly setting variables to appropriate values
            //or calling some helper functions
            switch (_myVisualState)
            {
                case TwinJetVisualState.HEALTHY:

                    _myMaxSpeed = MaxHealthySpeed;
                    _myGunFireRate = HealthyGunFireRate;
                    _myMissileFireRate = HealthyMissileFireRate;
                    _myFireState = TwinJetFireState.STAGE1;

                    break;

                case TwinJetVisualState.DAMAGED:

                    _myMaxSpeed = MaxDamagedSpeed;
                    _myGunFireRate = DamagedGunFireRate;
                    _myMissileFireRate = DamagedMissileFireRate;
                    _myFireState = TwinJetFireState.STAGE2;

                    break;

                case TwinJetVisualState.GUNDESTROYED:

                    _myMaxSpeed = MaxGunLostSpeed;
                    _myGunFireRate = GunLostGunFireRate;
                    _myMissileFireRate = GunLostMissileFireRate;
                    _myFireState = TwinJetFireState.STAGE3;
                    _myGunState = GunState.DESTROYED;

                    break;

                case TwinJetVisualState.EXPLODING:
                    _myBehaviorState = TwinJetBehaviouralState.PAUSED;
                    break;
            }

            switch (_myBehaviorState)
            {
                case TwinJetBehaviouralState.FIGHT:
                    _myPattern.SetToNearestNode(CenterPosition);
                    break;
            }
        }
        /// <summary>
        /// Checks if the intro for this jet is over
        /// </summary>
        private void checkIfIntroIsOver()
        {
            if (_isIntroOver)
            {
                _myBehaviorState = TwinJetBehaviouralState.FIGHT;

                onEntry();
            }
        }
        /// <summary>
        /// Creates a shiny new jet
        /// </summary>
        /// <param name="id">the factory id on the underside of this jet</param>
        /// <param name="content">The content manager to use</param>
        /// <param name="newPosition">The position to spawn the jet</param>
        public TwinJet(uint id, ContentManager content, Vector2 newPosition)
            : base(id)
        {
            //Setting the health
            this.Health = FullHealth;
            this.Score = 75;

            //Setting alive to 'true'
            _isAlive = true;

            //Initializing the states
            _myVisualState = TwinJetVisualState.HEALTHY;
            _myBehaviorState = TwinJetBehaviouralState.INTRO;
            _myFireState = TwinJetFireState.STAGE1;
            _myGunState = GunState.REST;
            _oldGunState = GunState.LEFT;

            //Initializing rotation
            _myRotation = 0;

            //Setting the flight pattern to null
            _myPattern = null;

            //Setting position and velocity
            _position = newPosition;
            _velocity = Vector2.Zero;

            //Marking the intro as still occurring
            _isIntroOver = false;

            //Setup firerates
            _timerGunFireRate = 0;
            _timerMissileFireRate = 0;

            //Bring in the spritesheet
            _spriteSheet = content.Load<Texture2D>("Spritesheets/newshi.shp.000000");

            //Setting up Sprite Bounds for the jet and gun
            _spriteBounds[(int)TwinJetVisualState.HEALTHY] = new Rectangle(98, 143, 93, 80);
            _spriteBounds[(int)TwinJetVisualState.DAMAGED] = new Rectangle(2, 143, 93, 53);
            _spriteBounds[(int)TwinJetVisualState.GUNDESTROYED] = new Rectangle(2, 143, 93, 53);
            _spriteBounds[(int)TwinJetVisualState.EXPLODING] = Rectangle.Empty;
            _spriteBounds[(int)TwinJetVisualState.DEAD] = Rectangle.Empty;

            _spriteGunBounds[(int)GunState.LEFT] = new Rectangle(62, 196, 21, 21);
            _spriteGunBounds[(int)GunState.REST] = new Rectangle(38, 196, 21, 20);
            _spriteGunBounds[(int)GunState.RIGHT] = new Rectangle(14, 196, 21, 21);
            _spriteGunBounds[(int)GunState.DESTROYED] = new Rectangle(38, 196, 21, 11);

            //Calls the on entry method to initialize some things
            onEntry();
        }