Example #1
0
        public void useWarthog(Perso perso, Vehicule vehicule, Controles controles)
        {
            perso.image            = TexturesGame.itemTab[2];
            perso.vitesseMax       = 10;
            perso.currentItem.name = "Hornet";

            if (controles.StayRight())
            {
                Physics.MoveRight(perso);
                Physics.MoveRight(perso);
                Physics.MoveRight(perso);
            }
            else if (controles.StayLeft())
            {
                Physics.MoveLeft(perso);
                Physics.MoveLeft(perso);
                Physics.MoveLeft(perso);
            }
            else
            {
                Physics.Deccelarate(perso);
            }

            if (controles.StayUp() && perso.speed.Y >= -10)
            {
                perso.speed.Y = (-1f + perso.speed.Y) - 1.2f;
            }

            if (controles.StayDown() && !controles.Up() && perso.speed.Y >= -20)
            {
                perso.speed.Y = -1f;
                //if(Perso.speed.X<0)
            }
        }
Example #2
0
        public void useBanshee(Perso Perso, Vehicule vehicule, Controles controles)
        {
            Perso.image                 = TexturesGame.itemTab[1];
            Perso.vitesseMax            = 15;
            Perso.currentWeapon.isOnMap = false;
            //Perso.currentWeapon = Perso.currentItem.VehicleGun[0];
            Perso.currentItem.name = "Banshee";

            if (controles.StayRight())
            {
                Perso.speed.X = 9;
            }
            else if (controles.StayLeft())
            {
                Perso.speed.X = -9;
            }
            else
            {
                if (Perso.direction == Direction.left)
                {
                    Perso.speed.X = -3;
                }
                if (Perso.direction == Direction.right)
                {
                    Perso.speed.X = 3;
                }
            }

            if (controles.StayUp() && Perso.speed.Y >= -10)
            {
                Perso.speed.Y = (-1f + Perso.speed.Y) - 1.2f;
            }

            if (controles.StayDown() && !controles.Up() && Perso.speed.Y >= -20)
            {
                Perso.speed.Y = -0.8f;
                //if(Perso.speed.X<0)
            }
            if (controles.Action())
            {
                int i = Perso.currentItem.VehicleGun.IndexOf(Perso.currentWeapon);
                if (Perso.currentItem.VehicleGun.Count <= i + 1)
                {
                    Perso.currentWeapon = Perso.currentItem.VehicleGun[0];
                }
                else
                {
                    Perso.currentWeapon = Perso.currentItem.VehicleGun[i + 1];
                }
            }
        }
Example #3
0
        public void useHornet(Perso Perso, Vehicule vehicule, Controles controles)
        {
            Perso.currentWeapon.isOnMap = false;
            Perso.image            = TexturesGame.itemTab[0];
            Perso.vitesseMax       = 20;
            Perso.currentItem.name = "Hornet";
            for (int i = 0; i < Perso.objetTouched.Count; i++)
            {
                if (Perso.objetTouched[i].GetType() == typeof(Enemy))
                {
                    //Enemy eny =(Enemy)Perso.objetTouched[i];
                    //  ((Enemy)(Perso.objetTouched[i])).pV = 0;
                }
            }
            if (controles.StayRight())
            {
                Perso.speed.X = 13;
            }
            else if (controles.StayLeft())
            {
                Perso.speed.X = -13;
            }
            else
            {
                Physics.Deccelarate(Perso);
            }

            if (controles.StayUp() && Perso.speed.Y >= -10)
            {
                Perso.speed.Y = (-1f + Perso.speed.Y) - 1.2f;
            }

            if (controles.StayDown() && !controles.Up() && Perso.speed.Y >= -20)
            {
                Perso.speed.Y = -1f;
                //if(Perso.speed.X<0)
            }
            if (controles.Action())
            {
                int i = Perso.currentItem.VehicleGun.IndexOf(Perso.currentWeapon);
                if (Perso.currentItem.VehicleGun.Count <= i + 1)
                {
                    Perso.currentWeapon = Perso.currentItem.VehicleGun[0];
                }
                else
                {
                    Perso.currentWeapon = Perso.currentItem.VehicleGun[i + 1];
                }
            }
        }
Example #4
0
        private static void KeyEvents(Player player, Map map, Controles controles, Sound sound)
        {
            #region Deplacements

            if (controles.StayRight() && !player.usingVehicle)
            {
                Physics.MoveRight(player);
            }
            else if (controles.StayLeft() && !player.usingVehicle)
            {
                Physics.MoveLeft(player);
            }
            else
            {
                Physics.Deccelarate(player);
            }

            if (controles.Up() && player.usingVehicle == false)
            {
                Physics.Jump(player);
            }

            if (player.climb && controles.StayUp() && player.usingVehicle == false)
            {
                Physics.Climb(player);
            }
            if (player.usingVehicle)
            {
                useVehicle(player, (Vehicule)player.currentItem, controles);
                // ControleVehicle(player, player.currentItem, controles);
            }

            #endregion Deplacements

            if (controles.Score())
            {
                player.scoreKey = true;
            }
            else
            {
                player.scoreKey = false;
            }
            if (controles.Reload() && player.currentWeapon.weaponType != cadenceType.none)
            {
                player.Reload();
                if (player.currentWeapon.name == "ShotGun")
                {
                    sound.Play(SoundsName.arme);
                }
                else
                {
                    sound.Play(SoundsName.reload);
                }
            }

            if ((controles.Drop() && (player.nearitem.Count > 0)) && player.usingVehicle == false)
            {
                for (int i = 0; i < player.nearitem.Count; i++)
                {
                    if (player.nearitem[i].type == objectType.vehicule)
                    {
                        player.pVMax      += 400;
                        player.pV          = player.pVMax;
                        player.currentItem = player.nearitem[i];

                        useVehicle(player, (Vehicule)player.nearitem[i], controles);
                        player.currentWeapon = player.currentItem.VehicleGun[0];
                    }
                    player.nearitem.Clear();
                }
            }

            if (controles.Lacher() && (player.currentItem != null))
            {
                if (player.currentItem.type == objectType.vehicule)
                {
                    Vehicule currentvehicule = (Vehicule)player.currentItem;
                    currentvehicule.quitVehicule(player, currentvehicule);
                }
                player.currentWeapon.isOnMap = true;
            }
        }