示例#1
0
        public virtual List <Bullet> Shoot(ShipUpdateInfo info)
        {
            //list to accumulate bullets from each weapon on the ship
            List <Bullet> toReturn = new List <Bullet>();

            //Check the fire method to see if we should fire
            if (!fireMethod.Fire(info))
            {
                return(toReturn);
            }

            foreach (Weapon w in weapons)
            {
                //make sure not an empty port
                if (w == null)
                {
                    continue;
                }

                //copy fixed bullets to return list and clear temp bullet
                toReturn.AddRange(w.Fire(info));
            }

            return(toReturn);
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            //Get the direction from the player (controller)
            Vector2 direction = player.input.ShipMoveDirNormal();

            //Check is the player is trying to move
            //Since update (GameObject) will try and move the ship
            //if player is not trying to move we flag it false
            if (direction.X == 0 && direction.Y == 0)
            {
                obj.moving = false;
            }
            else
            {
                obj.moving = true;             //re-flag true in case set to false

                direction.Normalize();         //just in case....
                obj.SetRotation(direction);

                //Since SetRotation() above, also turns the "face" direction
                //we need to correct this for the human players whose ships
                //always face directly upwards on the screen
                obj.SetFaceDir(VecUtil.GetNormUP());
            }
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            int time = info.gameTime.ElapsedGameTime.Milliseconds;

            elapsed -= time;

            angle = (double)time * rotateSpeed * sign;

            if (elapsed <= 0)    //time to change direction
            {
                sign   *= -1;    //flip sign
                elapsed = clock; //reset clock
            }
            if (obj.position.Y > (info.viewport.Top + 500))
            {
                dir.X += (float)0.002 * info.gameTime.ElapsedGameTime.Milliseconds * sign;

                obj.SetRotation(dir);
                obj.speed = 0.35;

                if (dir.X > sign)
                {
                    dir.X = 1;
                    return;
                }
                return;
            }

            obj.Rotate((float)angle);
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            if (done)   //performance reasons
                return;

            done = true;
            obj.SetRotation(dir);
        }
        public bool Fire(ShipUpdateInfo info)
        {
            //check if player is trying to fire
            if (player.input.ShipFirePrimary())
            {
                return(true);
            }

            return(false);
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            if (done)   //performance reasons
            {
                return;
            }

            done = true;
            obj.SetRotation(dir);
        }
        public bool Fire(ShipUpdateInfo info)
        {
            //charge up the weapon
            charge -= info.gameTime.ElapsedGameTime.Milliseconds;

            if (charge <= 0)    //ready to fire
            {
                charge = chargeTime;    //cooldown time
                return true;
            }

            return false;
        }
示例#8
0
        public bool Fire(ShipUpdateInfo info)
        {
            //charge up the weapon
            charge -= info.gameTime.ElapsedGameTime.Milliseconds;

            if (charge <= 0)         //ready to fire
            {
                charge = chargeTime; //cooldown time
                return(true);
            }

            return(false);
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            if (done)
            {
                return;
            }

            if (obj.position.X > (info.viewport.Left + 100) &&
                obj.position.X < (info.viewport.Right - 100))
            {
                done = true;
                obj.SetRotation(VecUtil.GetNormDown());
            }
        }
示例#10
0
        public override List <Bullet> Shoot(ShipUpdateInfo info)
        {
            List <Bullet> toReturn = new List <Bullet>();

            //Sub ship bullets
            foreach (Ship s in subShips)
            {
                toReturn.AddRange(s.Shoot(info));
            }

            //main boss bullets
            toReturn.AddRange(base.Shoot(info));

            return(toReturn);
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            int time = info.gameTime.ElapsedGameTime.Milliseconds;

            elapsed -= time;

            angle = (double)time * rotateSpeed * sign;

            if (elapsed <= 0)    //time to change direction
            {
                sign   *= -1;    //flip sign
                elapsed = clock; //reset clock
            }

            obj.Rotate((float)angle);
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            if (obj.position.Y > (info.viewport.Top + Y_trigger))
            {
                dir.X += (float)0.002 * info.gameTime.ElapsedGameTime.Milliseconds * sign;

                obj.SetRotation(dir);
                obj.speed = speed;

                if (dir.X > sign)
                {
                    dir.X = 1;
                    return;
                }
            }
        }
示例#13
0
        public void Aim(Ship ship, int port, ShipUpdateInfo info)
        {
            //get player ship position
            Vector2 dif = PROP.players[0].ship.position;

            //get weapon position
            Vector2 wepPos = ship.GetWeaponPosition(port);

            //subtract to get Change vector
            dif.X -= wepPos.X;
            dif.Y -= wepPos.Y;

            dif.Normalize();    //normalize for direciton

            ship.SetWeaponRotation(port, dif);
        }
示例#14
0
        public virtual void Update(ShipUpdateInfo info, bool UseMoveMethod)
        {
            if (UseMoveMethod)
            {
                //rotate the ship according to moveMethod
                moveMethod.Move(this, info);
            }

            //move the ship on screen
            base.Update(info.gameTime);

            //fix weapon position overlay on ship
            AdjustWeaponPos();

            //aim weapons according to aimMethod
            for (int i = 0; i < weapons.Length; i++)
            {
                if (weapons[i] == null)
                {
                    continue;
                }

                weapons[i].aimMethod.Aim(this, i, info);
            }

            //Update weapons to recharge them
            foreach (Weapon w in weapons)
            {
                if (w != null)
                {
                    w.Update(info.gameTime);
                }
            }


            //constantly
            if (hitColorCtr <= 0) //no longer flashing as hit
            {
                base.tint   = Color.White;
                hitColorCtr = 0;
            }
            else //Still flashing as hit
            {
                hitColorCtr -= info.gameTime.ElapsedGameTime.Milliseconds;
                base.tint    = hitColor;
            }
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            timer.Update(info.gameTime);

            switch (timer.Current)
            {
            case Timer2.TimerNum.First:
                obj.SetRotation(VecUtil.GetNormLeft());
                break;

            case Timer2.TimerNum.Second:
                obj.SetRotation(VecUtil.GetNormRight());
                break;
            }

            obj.SetFaceDir(VecUtil.GetNormDown());
        }
        public bool Fire(ShipUpdateInfo info)
        {
            counter -= info.gameTime.ElapsedGameTime.Milliseconds;

            if (counter <= 0)
            {
                fireInt = (fireInt == 0) ? 1 : 0;   //flip the counter
                counter = intervals[fireInt];       //reset couter with appropriate time interval
            }

            if (fireInt == 0)
            {
                return(true);
            }

            return(false);
        }
示例#17
0
        //Fire the weapon (or at least ATTEMPT to fire)
        public List<Bullet> Fire(ShipUpdateInfo info)
        {
            //The list of bullets we return to the ship
            List<Bullet> toReturn = new List<Bullet>();

            ////If we can't shoot yet, return empty list
            //if (!canFire)
            //    return toReturn;

            ////So... I guess we can shoot afterall
            //canFire = false;    //flag false untill done recharging
            //recharge = (int)((float)fireSpeed / (float)level);

            if (fireMethod.Fire(info))
                toReturn.AddRange(firePattern.GetBullets(this));

            return toReturn;
        }
示例#18
0
        //Unload the level
        //clear all data for memory management reasons
        public virtual void Unload()
        {
            state = GameState.Unloaded;

            slider = null;
            SUI    = null;

            if (loaded)
            {
                enemyShips.Clear();
                enemyBullets.Clear();
            }

            foreach (Player p in PROP.players)
            {
                p.bullets.Clear();
            }
        }
示例#19
0
        //The main loading of the level
        //Child classes (the actuall level objects)
        //should call this base method first to Init the basic stuff
        public virtual void Load(Textures.TextureName levelBackground)
        {
            loaded = true;

            border = new GameObject(Textures.TextureName.LevelBorder);
            border.LoadContent();
            border.CenterIn(bounds);

            slider = new LevelSlider(levelBackground, bounds);
            slider.Load();

            //Items
            itemMan = new ItemManager(ref slider);


            //Init data structures
            enemyShips   = new List <Ship>();
            enemyBullets = new List <Bullet>();
            items        = new List <Item>();


            //Link the UpdateInfo to appropriate data
            SUI          = new ShipUpdateInfo();
            SUI.viewport = bounds;
            SUI.npcs     = enemyShips;
            SUI.slider   = this.slider;


            //Position the player ships
            foreach (Player p in PROP.players)
            {
                if (p.ControllerIndex == PlayerIndex.Two)
                {
                    p.ship.MoveTo(GetPlayerInitPos());
                    p.ship.position.X += 60;
                }
                else
                {
                    p.ship.MoveTo(GetPlayerInitPos());
                }
            }
        }
示例#20
0
        //Fire the weapon (or at least ATTEMPT to fire)
        public List <Bullet> Fire(ShipUpdateInfo info)
        {
            //The list of bullets we return to the ship
            List <Bullet> toReturn = new List <Bullet>();

            ////If we can't shoot yet, return empty list
            //if (!canFire)
            //    return toReturn;

            ////So... I guess we can shoot afterall
            //canFire = false;    //flag false untill done recharging
            //recharge = (int)((float)fireSpeed / (float)level);

            if (fireMethod.Fire(info))
            {
                toReturn.AddRange(firePattern.GetBullets(this));
            }

            return(toReturn);
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            switch (state)
            {
            case status.linearDown:
                if (obj.position.Y > (info.viewport.Center.Y + 100))
                {
                    state = status.upTurn;
                }

                break;

            case status.linearUp:
                break;

            case status.upTurn:

                if (turnRad > 180)
                {
                    obj.SetRotation(new Vector2(-1, -1));
                    state = status.linearUp;
                }


                turnRad += (float)0.2 * info.gameTime.ElapsedGameTime.Milliseconds;
                obj.SetRotation(MathHelper.ToRadians(turnRad));
                obj.speed = 0.3;



                break;

            case status.downTurn:

                break;

            case status.End:

                break;
            }
        }
示例#22
0
        public override void Update(ShipUpdateInfo info)
        {
            if (!sleep)     //do nothing while sleeping
            {
                if (moving) //while moving, fix subShip positions manually
                {
                    //Override the boss move method
                    base.SetRotation(VecUtil.GetNormDown());
                    CenterInHoriz(info.viewport);

                    //move boss down at a fixed rate
                    float speed = 0.05f;
                    speed *= (float)info.gameTime.ElapsedGameTime.Milliseconds;
                    Vector2 v = new Vector2(0, speed);
                    base.Offset(v);

                    AdjustWeaponPos();

                    //base.Update(info, false);

                    //Override subship movement
                    FixSubShipPositions();
                }
                else  //once stopped moving allow sub ships to move themselves
                {
                    hp.MoveTopLeftTo(new Vector2(info.viewport.Left + 150f, info.viewport.Top + 30));
                    hp.SetHealth(this.health);

                    //Allow all the subShips to move
                    foreach (Ship s in subShips)
                    {
                        s.Update(info);
                    }

                    //Allow main boss ship to move according ot its move method
                    base.Update(info);
                }
            }
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            timer.Update(info.gameTime);

            switch (timer.Current)
            {
                case Timer2.TimerNum.First:
                    obj.SetRotation(VecUtil.GetNormLeft());
                    break;

                case Timer2.TimerNum.Second:
                    obj.SetRotation(VecUtil.GetNormRight());
                    break;
            }

            obj.SetFaceDir(VecUtil.GetNormDown());
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            if (done)
                return;

            if (obj.position.X > (info.viewport.Left + 100) &&
                obj.position.X < (info.viewport.Right - 100))
            {
                done = true;
                obj.SetRotation(VecUtil.GetNormDown());
            }
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            if (obj.position.Y > (info.viewport.Top + Y_trigger))
            {

                dir.X += (float)0.002 * info.gameTime.ElapsedGameTime.Milliseconds * sign;

                obj.SetRotation(dir);
                obj.speed = speed;

                if (dir.X > sign)
                {
                    dir.X = 1;
                    return;

                }
            }
        }
示例#26
0
        public override List<Bullet> Shoot(ShipUpdateInfo info)
        {
            List<Bullet> toReturn = new List<Bullet>();

            //Sub ship bullets
            foreach (Ship s in subShips)
                toReturn.AddRange(s.Shoot(info));

            //main boss bullets
            toReturn.AddRange(base.Shoot(info));

            return toReturn;
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            int time = info.gameTime.ElapsedGameTime.Milliseconds;
            elapsed -= time;

            angle = (double)time * rotateSpeed * sign;

            if (elapsed <= 0)   //time to change direction
            {
                sign *= -1;         //flip sign
                elapsed = clock;    //reset clock
            }
            if (obj.position.Y > (info.viewport.Top + 500))
            {

                dir.X += (float)0.002 * info.gameTime.ElapsedGameTime.Milliseconds * sign;

                obj.SetRotation(dir);
                obj.speed = 0.35;

                if (dir.X > sign)
                {
                    dir.X = 1;
                    return;
                }
                return;
            }

            obj.Rotate((float)angle);
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            //Get the direction from the player (controller)
            Vector2 direction = player.input.ShipMoveDirNormal();

            //Check is the player is trying to move
            //Since update (GameObject) will try and move the ship
            //if player is not trying to move we flag it false
            if (direction.X == 0 && direction.Y == 0)
                obj.moving = false;
            else
            {
                obj.moving = true;             //re-flag true in case set to false

                direction.Normalize();          //just in case....
                obj.SetRotation(direction);

                //Since SetRotation() above, also turns the "face" direction
                //we need to correct this for the human players whose ships
                //always face directly upwards on the screen
                obj.SetFaceDir(VecUtil.GetNormUP());
            }
        }
示例#29
0
 public virtual void Update(ShipUpdateInfo info)
 {
     Update(info, true);
 }
 public bool Fire(ShipUpdateInfo info)
 {
     return(true);    //always try and fire
 }
示例#31
0
        public virtual List<Bullet> Shoot(ShipUpdateInfo info)
        {
            //list to accumulate bullets from each weapon on the ship
            List<Bullet> toReturn = new List<Bullet>();

            //Check the fire method to see if we should fire
            if (!fireMethod.Fire(info))
                return toReturn;

            foreach (Weapon w in weapons)
            {
                //make sure not an empty port
                if (w == null)
                    continue;

                //copy fixed bullets to return list and clear temp bullet
                toReturn.AddRange(w.Fire(info));
            }

            return toReturn;
        }
示例#32
0
        public virtual void Update(ShipUpdateInfo info, bool UseMoveMethod)
        {
            if (UseMoveMethod)
            {
                //rotate the ship according to moveMethod
                moveMethod.Move(this, info);
            }

            //move the ship on screen
            base.Update(info.gameTime);

            //fix weapon position overlay on ship
            AdjustWeaponPos();

            //aim weapons according to aimMethod
            for (int i = 0; i < weapons.Length; i++)
            {
                if (weapons[i] == null)
                    continue;

                weapons[i].aimMethod.Aim(this, i, info);
            }

            //Update weapons to recharge them
            foreach (Weapon w in weapons)
                if (w != null)
                    w.Update(info.gameTime);

            //constantly
            if (hitColorCtr <= 0) //no longer flashing as hit
            {
                base.tint = Color.White;
                hitColorCtr = 0;
            }
            else //Still flashing as hit
            {
                hitColorCtr -= info.gameTime.ElapsedGameTime.Milliseconds;
                base.tint = hitColor;
            }
        }
示例#33
0
 public virtual void Update(ShipUpdateInfo info)
 {
     Update(info, true);
 }
示例#34
0
        public override void Update(ShipUpdateInfo info)
        {
            if (!sleep) //do nothing while sleeping
            {
                if (moving) //while moving, fix subShip positions manually
                {

                    //Override the boss move method
                    base.SetRotation(VecUtil.GetNormDown());
                    CenterInHoriz(info.viewport);

                    //move boss down at a fixed rate
                    float speed = 0.05f;
                    speed *= (float)info.gameTime.ElapsedGameTime.Milliseconds;
                    Vector2 v = new Vector2(0, speed);
                    base.Offset(v);

                    AdjustWeaponPos();

                    //base.Update(info, false);

                    //Override subship movement
                    FixSubShipPositions();
                }
                else  //once stopped moving allow sub ships to move themselves
                {
                    hp.MoveTopLeftTo(new Vector2(info.viewport.Left + 150f, info.viewport.Top + 30));
                    hp.SetHealth(this.health);

                    //Allow all the subShips to move
                    foreach (Ship s in subShips)
                        s.Update(info);

                    //Allow main boss ship to move according ot its move method
                    base.Update(info);
                }
            }
        }
示例#35
0
        //Unload the level
        //clear all data for memory management reasons
        public virtual void Unload()
        {
            state = GameState.Unloaded;

            slider = null;
            SUI = null;

            if (loaded)
            {
                enemyShips.Clear();
                enemyBullets.Clear();
            }

            foreach (Player p in PROP.players)
                p.bullets.Clear();
        }
 public void Move(GameObject obj, ShipUpdateInfo info)
 {
     //don't need to change anything
 }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            switch (state)
            {
                case status.linearDown:
                    if (obj.position.Y > (info.viewport.Center.Y + 100))
                        state = status.upTurn;

                    break;

                case status.linearUp:
                    break;

                case status.upTurn:

                    if (turnRad > 180)
                    {
                        obj.SetRotation(new Vector2(-1,-1) );
                        state = status.linearUp;
                    }

                    turnRad += (float)0.2*info.gameTime.ElapsedGameTime.Milliseconds;
                    obj.SetRotation(MathHelper.ToRadians(turnRad) );
                    obj.speed = 0.3;

                    break;

                case status.downTurn:

                    break;

                case status.End:

                    break;

            }
        }
示例#38
0
        public void Aim(Ship ship, int port, ShipUpdateInfo info)
        {
            //get player ship position
            Vector2 dif = PROP.players[0].ship.position;

            //get weapon position
            Vector2 wepPos = ship.GetWeaponPosition(port);

            //subtract to get Change vector
            dif.X -= wepPos.X;
            dif.Y -= wepPos.Y;

            dif.Normalize();    //normalize for direciton

            ship.SetWeaponRotation(port, dif);
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            int time = info.gameTime.ElapsedGameTime.Milliseconds;
            elapsed -= time;

            angle = (double)time * rotateSpeed * sign;

            if (elapsed <= 0)   //time to change direction
            {
                sign *= -1;         //flip sign
                elapsed = clock;    //reset clock
            }

            obj.Rotate((float)angle);
        }
示例#40
0
 public void Aim(Ship ship, int port, ShipUpdateInfo info)
 {
     ship.SetWeaponRotation(port, ship.rotation);
 }
 public void Move(GameObject obj, ShipUpdateInfo info)
 {
     obj.moving = false;
 }
示例#42
0
 public void Aim(Ship ship, int port, ShipUpdateInfo info)
 {
     ship.SetWeaponRotation(port, dir);
 }
示例#43
0
        //The main loading of the level
        //Child classes (the actuall level objects)
        //should call this base method first to Init the basic stuff
        public virtual void Load(Textures.TextureName levelBackground)
        {
            loaded = true;

            border = new GameObject(Textures.TextureName.LevelBorder);
            border.LoadContent();
            border.CenterIn(bounds);

            slider = new LevelSlider(levelBackground, bounds);
            slider.Load();

            //Items
            itemMan = new ItemManager(ref slider);

            //Init data structures
            enemyShips = new List<Ship>();
            enemyBullets = new List<Bullet>();
            items = new List<Item>();

            //Link the UpdateInfo to appropriate data
            SUI = new ShipUpdateInfo();
            SUI.viewport = bounds;
            SUI.npcs = enemyShips;
            SUI.slider = this.slider;

            //Position the player ships
            foreach (Player p in PROP.players)
            {
                if (p.ControllerIndex == PlayerIndex.Two)
                {
                    p.ship.MoveTo(GetPlayerInitPos());
                    p.ship.position.X += 60;
                }
                else
                    p.ship.MoveTo(GetPlayerInitPos());
            }
        }
 public void Move(GameObject obj, ShipUpdateInfo info)
 {
     obj.moving = false;
 }
 public void Move(GameObject obj, ShipUpdateInfo info)
 {
     //don't need to change anything
 }
示例#46
0
        public void Update(GameTime gameTime, ShipUpdateInfo info)
        {
            moveMethod.Move(this, info);

            base.Update(gameTime);
        }