Example #1
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;
            }
        }