예제 #1
0
 /// <summary>
 /// Constructeur de base 
 /// </summary>
 /// <param name="giveBasicWeapon"></param>
 public EnnemyShip( bool giveBasicWeapon = true)
     : base()
 {
     _activeWeapon = new Weapon(this);
     if(giveBasicWeapon)
     _ia.AddAction(new ActionShoot(this, _activeWeapon, 1000, 3000));
     _value = TypeScore.EnemiShip;
 }
예제 #2
0
        /// <summary>
        /// Ajoute une arme à la liste du ship
        /// </summary>
        /// <param name="weapon"></param>
        public void AddWeapon(Weapons.Weapon weapon)
        {
            bool canAdd = true;

            foreach (Weapons.Weapon currentWeapon in LstWeapons)
            {
                if (weapon.GetType() == currentWeapon.GetType())
                {
                    canAdd = false;
                }
            }

            if (canAdd)
            {
                LstWeapons.Add(weapon);
            }
        }
예제 #3
0
        //pGMng)
        /// <summary>
        /// Constructeur de base 
        /// </summary>
        public Ship()
            : base()
        {
            _lstWeapons = new List<Weapons.Weapon>() { new Weapons.Weapon(this)};
            _activeWeapon = LstWeapons.First();
            //_weapon = new Weapons.Weapon( this);
            _moove = new Moving.MovingDirect(this);
            Shield = new Defense.DefenseBase(this);
            _value = TypeScore.Hit;

            _moove.Friction = 0.01f;
            _rotation = -90;
            changeAngleAccel();
            Sprite = SpriteManager.ShipMainSprite;
            _scale = SpriteManager.scaleRateShip;
            _origin.X = _sprite.Width  / 2;
            _origin.Y = _sprite.Height  / 2;
            MAX_SPEED = 12;
        }
예제 #4
0
        /// <summary>
        /// Constructeur de base
        /// </summary>
        public Ship()
            : base()//pGMng)
        {
            _lstWeapons = new List <Weapons.Weapon>()
            {
                new Weapons.Weapon(this)
            };
            _activeWeapon = LstWeapons.First();
            //_weapon = new Weapons.Weapon( this);
            _moove = new Moving.MovingDirect(this);
            Shield = new Defense.DefenseBase(this);
            _value = TypeScore.Hit;

            _moove.Friction = 0.01f;
            _rotation       = -90;
            changeAngleAccel();
            Sprite    = SpriteManager.ShipMainSprite;
            _scale    = SpriteManager.scaleRateShip;
            _origin.X = _sprite.Width / 2;
            _origin.Y = _sprite.Height / 2;
            MAX_SPEED = 12;
        }
예제 #5
0
 /// <summary>
 /// fais tirer le ship
 /// </summary>
 /// <param name="arme"></param>
 public void Shoot(Weapon arme)
 {
     arme.CheckShoot(ref _lstToAdd);
 }
예제 #6
0
        /// <summary>
        /// Modifier le ship selon les inputs du joueur
        /// </summary>
        /// <param name="keyBoardState"></param>
        /// <param name="mouseState"></param>
        /// <param name="gamePadState"></param>
        public virtual void HandlePlayerInput(KeyboardState keyBoardState, MouseState mouseState, GamePadState gamePadState)
        {
            _shoot = (keyBoardState.IsKeyDown(Keys.Space) || gamePadState.IsButtonDown(Buttons.A));
            _moove.sendInput(new Vector2((keyBoardState.IsKeyDown(Keys.Left) ? -1 : (keyBoardState.IsKeyDown(Keys.Right) ? 1 : gamePadState.ThumbSticks.Left.X)),
                                         (keyBoardState.IsKeyDown(Keys.Down) ? -1 : (keyBoardState.IsKeyDown(Keys.Up) ? 1 : gamePadState.ThumbSticks.Left.Y))), gamePadState.Triggers.Right - gamePadState.Triggers.Left);


            //type d'Arme... pas pratique, doit faire un ifElse mais pas le choix avec le système de inputs présent.
            if (keyBoardState.IsKeyDown(Keys.D1) && LstWeapons.IndexOf(_activeWeapon) != 0)
            {
                _activeWeapon = LstWeapons[0];
            }
            else if (LstWeapons.Count > 1 && keyBoardState.IsKeyDown(Keys.D2) && LstWeapons.IndexOf(_activeWeapon) != 1)
            {
                _activeWeapon = LstWeapons[1];
            }
            else if (LstWeapons.Count > 2 && keyBoardState.IsKeyDown(Keys.D3) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[2];
            }
            else if (LstWeapons.Count > 3 && keyBoardState.IsKeyDown(Keys.D4) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[3];
            }
            else if (LstWeapons.Count > 4 && keyBoardState.IsKeyDown(Keys.D5) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[4];
            }
            else if (LstWeapons.Count > 5 && keyBoardState.IsKeyDown(Keys.D6) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[5];
            }
            else if (LstWeapons.Count > 6 && keyBoardState.IsKeyDown(Keys.D7) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[6];
            }
            else if (LstWeapons.Count > 7 && keyBoardState.IsKeyDown(Keys.D8) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[7];
            }
            else if (LstWeapons.Count > 8 && keyBoardState.IsKeyDown(Keys.D9) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[8];
            }

            // changement d'armes avec x et y pour manette
            if (gamePadState.Buttons.X == ButtonState.Pressed && _oldGamePad.Buttons.X != ButtonState.Pressed)
            {
                _activeWeapon = LstWeapons[(LstWeapons.IndexOf(_activeWeapon) + 1) % LstWeapons.Count];
            }
            else if (gamePadState.Buttons.Y == ButtonState.Pressed && _oldGamePad.Buttons.Y != ButtonState.Pressed)
            {
                if (LstWeapons.IndexOf(_activeWeapon) <= 0)
                {
                    _activeWeapon = LstWeapons[LstWeapons.Count - 1];
                }
                else
                {
                    _activeWeapon = LstWeapons[LstWeapons.IndexOf(_activeWeapon) - 1];
                }
            }
            _oldGamePad = gamePadState;
        }
예제 #7
0
 public ActionShoot(EnnemyShip ship, Weapon arme, int delay = 0, int sleep = 0)
 {
     _time = delay;
     _initialTime = delay;
     _timePaused = sleep;
     _ship = ship;
     _weapon = arme;
     Recursive = true;
 }
예제 #8
0
        protected override List<MovingObject> GetIAs(Ship playerShip)
        {
            EnnemyShip enemyShip;
            ActionFollowPlayer mouvement;
            List<MovingObject> retour = new List<MovingObject>();
            Weapon wep;
            for (int i = 10;i<100 ; i++)
            {
                enemyShip = new EnnemyShip(false);
                enemyShip.Position = new Vector2(10 + i * 30,100);
                enemyShip.Speed = new Vector2(3, 0);
                if (i % 5 != 0)
                {//nous visent au 5 sec, tirent aux 2 sec
                    mouvement = new ActionFollowPlayer(enemyShip, playerShip, Laser.LASER_SPEED, 120, 5000);
                }
                else
                {//suivent toujours
                    mouvement = new ActionFollowPlayer(enemyShip, playerShip, Laser.LASER_SPEED, 120);
                }
                mouvement.Recursive = true;
                wep = new Weapon(enemyShip, 500);

                enemyShip.AddAction(mouvement);
                enemyShip.AddAction(new ActionShoot(enemyShip, new Weapon(enemyShip, 2000), 2000, (int)( 2000)));

                retour.Add(enemyShip);
            }
            //Enemis tourrelles*
            enemyShip = new EnnemyShip(false);
            enemyShip.Position = new Vector2(100, GetHeight()-100);
            enemyShip.Speed = new Vector2(0, 0);
            mouvement = new ActionFollowPlayer(enemyShip, playerShip, Laser.LASER_SPEED, 120);
            mouvement.Recursive = true;
            wep = new ShotGun(enemyShip, 1500);
            enemyShip.AddAction(new ActionShoot(enemyShip, new Weapon(enemyShip), 1000));
            enemyShip.AddAction(mouvement);
            enemyShip.AddAction(new ActionShoot(enemyShip, wep, 5000));
            retour.Add(enemyShip);
            //tourelle 2
            enemyShip = new EnnemyShip(false);
            enemyShip.Position = new Vector2(100, 100);
            enemyShip.Speed = new Vector2(0, 0);
            mouvement = new ActionFollowPlayer(enemyShip, playerShip, Laser.LASER_SPEED, 120);
            mouvement.Recursive = true;
            wep = new ShotGun(enemyShip, 1500);
            enemyShip.AddAction(new ActionShoot(enemyShip, new Weapon(enemyShip), 1000));
            enemyShip.AddAction(mouvement);
            enemyShip.AddAction(new ActionShoot(enemyShip, wep, 5000));
            retour.Add(enemyShip);
            //tourelle 3

            enemyShip = new EnnemyShip(false);
            enemyShip.Position = new Vector2(GetWidth()-100, 100);
            enemyShip.Speed = new Vector2(0, 0);
            mouvement = new ActionFollowPlayer(enemyShip, playerShip, Laser.LASER_SPEED, 120);
            mouvement.Recursive = true;
            wep = new ShotGun(enemyShip, 1500);
            enemyShip.AddAction(mouvement);
            enemyShip.AddAction(new ActionShoot(enemyShip, wep, 5000));
            enemyShip.AddAction(new ActionShoot(enemyShip, new Weapon(enemyShip), 1000));
            retour.Add(enemyShip);
            //tourelle 4
            enemyShip = new EnnemyShip(false);
            enemyShip.Position = new Vector2(GetWidth()-100, GetHeight()-100);
            enemyShip.Speed = new Vector2(0, 0);
            mouvement = new ActionFollowPlayer(enemyShip, playerShip, Laser.LASER_SPEED, 120);
            mouvement.Recursive = true;
            wep = new ShotGun(enemyShip, 1500);
            enemyShip.AddAction(new ActionShoot(enemyShip, new Weapon(enemyShip), 1000));
            enemyShip.AddAction(mouvement);
            enemyShip.AddAction(new ActionShoot(enemyShip, wep, 5000));
            retour.Add(enemyShip);

            return retour;
        }
예제 #9
0
        /// <summary>
        /// Modifier le ship selon les inputs du joueur
        /// </summary>
        /// <param name="keyBoardState"></param>
        /// <param name="mouseState"></param>
        /// <param name="gamePadState"></param>
        public virtual void HandlePlayerInput(KeyboardState keyBoardState, MouseState mouseState, GamePadState gamePadState)
        {
            _shoot = (keyBoardState.IsKeyDown(Keys.Space) || gamePadState.IsButtonDown(Buttons.A));
            _moove.sendInput(new Vector2((keyBoardState.IsKeyDown(Keys.Left) ? -1 : (keyBoardState.IsKeyDown(Keys.Right) ? 1 : gamePadState.ThumbSticks.Left.X)),
                (keyBoardState.IsKeyDown(Keys.Down) ? -1 : (keyBoardState.IsKeyDown(Keys.Up) ? 1 : gamePadState.ThumbSticks.Left.Y))), gamePadState.Triggers.Right- gamePadState.Triggers.Left);

            //type d'Arme... pas pratique, doit faire un ifElse mais pas le choix avec le système de inputs présent.
            if (keyBoardState.IsKeyDown(Keys.D1) && LstWeapons.IndexOf(_activeWeapon) != 0)
            {
                 _activeWeapon = LstWeapons[0];
            }
            else if (LstWeapons.Count > 1 &&  keyBoardState.IsKeyDown(Keys.D2) && LstWeapons.IndexOf(_activeWeapon) != 1)
            {
                _activeWeapon = LstWeapons[1];
            }
            else if (LstWeapons.Count > 2 && keyBoardState.IsKeyDown(Keys.D3) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[2];
            }
            else if (LstWeapons.Count > 3 && keyBoardState.IsKeyDown(Keys.D4) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[3];
            }
            else if (LstWeapons.Count > 4 && keyBoardState.IsKeyDown(Keys.D5) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[4];
            }
            else if (LstWeapons.Count > 5 && keyBoardState.IsKeyDown(Keys.D6) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[5];
            }
            else if (LstWeapons.Count > 6 && keyBoardState.IsKeyDown(Keys.D7) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[6];
            }
            else if (LstWeapons.Count > 7 && keyBoardState.IsKeyDown(Keys.D8) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[7];
            }
            else if (LstWeapons.Count > 8 && keyBoardState.IsKeyDown(Keys.D9) && LstWeapons.IndexOf(_activeWeapon) != 2)
            {
                _activeWeapon = LstWeapons[8];
            }

            // changement d'armes avec x et y pour manette
            if (gamePadState.Buttons.X == ButtonState.Pressed && _oldGamePad.Buttons.X != ButtonState.Pressed)
            {
                _activeWeapon = LstWeapons[(LstWeapons.IndexOf(_activeWeapon) + 1) % LstWeapons.Count];
            }
            else if (gamePadState.Buttons.Y == ButtonState.Pressed && _oldGamePad.Buttons.Y != ButtonState.Pressed)
            {
                if (LstWeapons.IndexOf(_activeWeapon) <= 0)
                {
                    _activeWeapon = LstWeapons[LstWeapons.Count - 1];
                }
                else
                {
                    _activeWeapon = LstWeapons[LstWeapons.IndexOf(_activeWeapon) - 1];
                }
            }
            _oldGamePad = gamePadState;
        }