コード例 #1
0
        private void buttonMove_Click(object sender, EventArgs e)
        {
            MissionVehicle vehicle = this.listBoxVehicles.SelectedItem as MissionVehicle;
            if (vehicle == null)
            {
                LPMessageBox.ShowExclamation("Sélectionnes un véhicule avant de te déplacer !");
                return;
            }

            if (this.listBoxVehicles.Enabled &&
                LPMessageBox.ShowQuestion(string.Format(
                "Es-tu sur de vouloir utiliser '{0}' ?\r\n\r\nTu ne pourras plus changer de véhicule en cours de mission.", vehicle.Name)) != DialogResult.Yes)
                return;

            // As soon as a vehicle has been selected, don't allow user to select a new one after the first move
            this.listBoxVehicles.Enabled = false;

            int number = this.game.GetRandomNumber(vehicle.MinMovePerRound, vehicle.MaxMovePerRound);
            using (FormMoving dlg = new FormMoving(number))
            {
                dlg.ShowDialog(this);

                this.roundLeft--;
                ComputeGain();
                UpdateRoundLeftDisplay();
                UpdateGainDisplay();

                if (this.roundLeft == 0)
                {
                    this.buttonSuccess.Enabled = false;
                    LPMessageBox.ShowExclamation("Tu n'es pas arrivé à temps pour réussir la Mission !");
                }
            }
        }
コード例 #2
0
        private void ShowMove()
        {
            int number = 1;

            if (this.radioButtonVehicle.Checked)
            {
                // Compute move cost
                Vehicle vehicle = this.comboBoxVehicles.SelectedItem as Vehicle;
                if (vehicle == null)
                {
                    this.DialogResult = DialogResult.None;
                    return;
                }
                this.player.StateData.LastMoveUseVehicle = true;
                this.player.StateData.LastMoveVehicleName = vehicle.Name;

                number = this.game.GetRandomNumber(vehicle.MinMovePerRound, vehicle.MaxMovePerRound);
                MotorVehicle motorVehicle = vehicle as MotorVehicle;
                if (motorVehicle != null && motorVehicle.NumberOfMoveLeft < 40)
                {
                    LPMessageBox.ShowWarning("Attention ! Tu n'as plus beaucoup d'essence dans votre véhicule.\r\nIl te reste moins de 40 cases d'autonomie.\r\nVa prochainement à la station service !");
                }

                for (int i = 0; i < number; i++)
                {
                    // Check cost per move and update Player capital
                    if (player.Capital - vehicle.CostPerMove < 0)
                    {
                        if (i == 0)
                            LPMessageBox.ShowExclamation("Impossible de te déplacer !\r\n Tu n'aa plus d'argent pour payer les frais de déplacement.");
                        else
                            LPMessageBox.ShowExclamation("Ton déplacement a été limité !\r\nTu n'as plus assez d'argent pour te déplacer plus.");
                        number = i;
                        break;
                    }

                    player.Capital -= vehicle.CostPerMove;

                    // If the player use a Motor vehicle, checks vehicle tank and update it
                    if (motorVehicle != null)
                    {
                        if (motorVehicle.FuelLevel == -1)
                            motorVehicle.FuelLevel = motorVehicle.TankCapacity;

                        if (motorVehicle.FuelLevel - motorVehicle.ConsumptionPerMove < 0)
                        {
                            if (i == 0)
                                LPMessageBox.ShowExclamation("Impossible de te déplacer !\r\n Tu n'as plus d'essence dans ton véhicule.");
                            else
                                LPMessageBox.ShowExclamation("Ton déplacement a été limité !\r\nTu n'as plus assez d'essence dans ton véhicule.");
                            number = i;
                            break;
                        }

                        motorVehicle.FuelLevel -= motorVehicle.ConsumptionPerMove;
                    }
                }

            }
            else
                this.player.StateData.LastMoveUseVehicle = false;

            if (number > 0)
            {
                using (FormMoving dlg = new FormMoving(number))
                {
                    dlg.ShowDialog(this);
                }
            }
        }