public RocketRunner(IDeactivateableTargetKnower knower, IPilot engineControl, IDetonator detonator, FuelTank tank)
 {
     _pilot        = engineControl;
     _detonator    = detonator;
     _targetKnower = knower;
     _tank         = tank;
 }
예제 #2
0
        public string EngageMachine(string selectedPilotName, string selectedMachineName)
        {
            IPilot pilot = pilots.FirstOrDefault(p => p.Name == selectedPilotName);

            if (pilot is null)
            {
                return(string.Format(OutputMessages.PilotNotFound, selectedPilotName));
            }

            IMachine machine = machines.FirstOrDefault(m => m.Name == selectedMachineName);

            if (machine is null)
            {
                return(string.Format(OutputMessages.MachineNotFound, selectedMachineName));
            }

            if (machine.Pilot != null)
            {
                return(string.Format(OutputMessages.MachineHasPilotAlready, selectedMachineName));
            }

            machine.Pilot = pilot;

            return(string.Format(OutputMessages.MachineEngaged, selectedPilotName, selectedMachineName));
        }
예제 #3
0
        public string EngageMachine(string selectedPilotName, string selectedMachineName)
        {
            IPilot pilot = this.pilots
                           .FirstOrDefault(x => x.Name == selectedPilotName);

            if (pilot == null)
            {
                return(string.Format(OutputMessages.PilotNotFound,
                                     selectedPilotName));
            }

            IMachine machine = this.machines
                               .FirstOrDefault(x => x.Name == selectedMachineName);

            if (machine == null)
            {
                return(string.Format(OutputMessages.MachineNotFound,
                                     selectedMachineName));
            }

            if (machine.Pilot != null)
            {
                return(string.Format(OutputMessages.MachineHasPilotAlready,
                                     selectedMachineName));
            }

            pilot.AddMachine(machine);
            machine.Pilot = pilot;

            return(string.Format(OutputMessages.MachineEngaged,
                                 selectedPilotName,
                                 selectedMachineName));
        }
예제 #4
0
        public string EngageMachine(string selectedPilotName, string selectedMachineName)
        {
            IMachine machine = machines.FirstOrDefault(m => m.Name == selectedMachineName);
            IPilot   pilot   = pilots.FirstOrDefault(p => p.Name == selectedPilotName);

            if (!pilots.Any(p => p.Name == selectedPilotName))
            {
                return(string.Format(OutputMessages.PilotNotFound, selectedPilotName));
            }
            else if (!machines.Any(m => m.Name == selectedMachineName))
            {
                return(string.Format(OutputMessages.MachineNotFound, selectedMachineName));
            }
            else if (machines.First(m => m.Name == selectedMachineName).Pilot != null)
            {
                return(string.Format(OutputMessages.MachineHasPilotAlready, selectedMachineName));
            }
            else if (machines.First(m => m.Name == selectedMachineName).Pilot is null)
            {
                machine.Pilot = pilot;
                pilot.AddMachine(machine);
                return(string.Format(OutputMessages.MachineEngaged, selectedPilotName, selectedMachineName));
            }

            return(null);
        }
예제 #5
0
 public void RemovePilot(IPilot pilot)
 {
     if (pilots.Contains(pilot))
     {
         pilots.Remove(pilot);
     }
 }
예제 #6
0
        public string EngageMachine(string selectedPilotName, string selectedMachineName)
        {
            if (this.pilots.FirstOrDefault(p => p.Name == selectedPilotName) == null)
            {
                return(string.Format(OutputMessages.PilotNotFound, selectedPilotName));
            }

            if (this.machines.FirstOrDefault(m => m.Name == selectedMachineName) == null)
            {
                return(string.Format(OutputMessages.MachineNotFound, selectedMachineName));
            }

            IPilot   pilot   = this.pilots.FirstOrDefault(p => p.Name == selectedPilotName);
            IMachine machine = this.machines.FirstOrDefault(m => m.Name == selectedMachineName);

            if (machine.Pilot != null)
            {
                return(string.Format(OutputMessages.MachineHasPilotAlready, machine.Name));
            }

            machine.Pilot = pilot;
            pilot.AddMachine(machine);

            return(string.Format(OutputMessages.MachineEngaged, pilot.Name, machine.Name));
        }
예제 #7
0
        async Task IServer.Access(int accessCount, IPilot pilot, Game game)
        {
            reshuffledDuringAccess = false;
            var accessDepth = 0;

            for (var accessesLeft = accessCount; accessesLeft > 0; accessesLeft--)
            {
                if (accessDepth > Zone.Cards.Count)
                {
                    break;
                }
                var nextCard = Zone.Cards[accessDepth];
                // TODO show top of R&D and cards in root
                // TODO2: should draw facedown
                // TODO3: nice if we could display the pile, not just the top+root
                var cardToAccess = await pilot.ChooseACard().Declare("Which card to access now?", new List <Card> {
                    nextCard
                }, game);

                accessDepth++;
                await new AccessCard(cardToAccess, game).AwaitEnd(); // TODO show the already seen on the side, maintaining proper order CR: 7.2.1.b
                if (reshuffledDuringAccess)                          // CR: 7.2.1.c
                {
                    accessDepth            = 0;
                    reshuffledDuringAccess = false;
                }
            }
        }
        public string EngageMachine(string selectedPilotName, string selectedMachineName)
        {
            IPilot pilot = this.pilots
                           .FirstOrDefault(p => p.Name == selectedPilotName);

            if (pilot == null)
            {
                return($"Pilot {selectedPilotName} could not be found");
            }

            IMachine machine = this.machines
                               .FirstOrDefault(m => m.Name == selectedMachineName);

            if (machine == null)
            {
                return($"Machine {selectedMachineName} could not be found");
            }

            if (machine.Pilot != null)
            {
                return($"Machine {selectedMachineName} is already occupied");
            }

            pilot.AddMachine(machine);
            machine.Pilot = pilot;

            return($"Pilot {selectedPilotName} engaged machine {selectedMachineName}");
        }
    // Use this for initialization
    void Start()
    {
        _rigidbody = GetComponent <Rigidbody>();

        var initialAngularDrag = _rigidbody.angularDrag;
        var torqueApplier      = new MultiTorquerTorqueAplier(_rigidbody, TorqueMultiplier, initialAngularDrag);

        _pilot = new RocketPilot(torqueApplier, _rigidbody, Engines, StartDelay)
        {
            LocationAimWeighting             = LocationAimWeighting,
            TurningStartDelay                = TurningStartDelay,
            VectorArrow                      = VectorArrow,
            TimeThresholdForMaximumEvasion   = TimeThresholdForMaximumEvasion,
            TimeThresholdForMediumEvasion    = TimeThresholdForMediumEvasion,
            TimeThresholdForMinimalEvasion   = TimeThresholdForMinimalEvasion,
            EvasionModeTime                  = EvasionModeTime,
            MinimumFriendlyDetectionDistance = MinimumFriendlyDetectionDistance
        };

        var exploder = new ShrapnelExploder(_rigidbody, Shrapnel, ExplosionEffect, ShrapnelCount)
        {
            EnemyTags             = TargetChoosingMechanism.EnemyTagKnower.KnownEnemyTags,
            TagShrapnel           = TagShrapnel,
            SetEnemyTagOnShrapnel = SetEnemyTagOnShrapnel,
            ShrapnelSpeed         = ShrapnelSpeed
        };

        _detonator = new ProximityApproachDetonator(exploder, _rigidbody, TimeToTargetForDetonation, ShrapnelSpeed);

        _runner = new RocketRunner(TargetChoosingMechanism, _pilot, _detonator, Tank)
        {
            name = transform.name
        };
    }
예제 #10
0
        public string EngageMachine(string selectedPilotName, string selectedMachineName)
        {
            IPilot pilot = (Pilot)this.pilots
                           .FirstOrDefault(p => p.Name == selectedPilotName && p.GetType().Name == "Pilot");
            IMachine machine = (BaseMachine)this.machines.FirstOrDefault(m => m.Name == selectedMachineName);

            if (pilot == null)
            {
                return(string.Format(OutputMessages.PilotNotFound, selectedPilotName));
            }
            else if (machine == null)
            {
                return(string.Format(OutputMessages.MachineNotFound, selectedMachineName));
            }
            else if (machine.Pilot != null)
            {
                return(string.Format(OutputMessages.MachineHasPilotAlready, selectedMachineName));
            }
            else
            {
                machine.Pilot = pilot;
                pilot.AddMachine(machine);
                return(string.Format(OutputMessages.MachineEngaged, selectedPilotName, selectedMachineName));
            }
        }
예제 #11
0
        public string EngageMachine(string selectedPilotName, string selectedMachineName)
        {
            IPilot pilotToFind   = this.pilots.FirstOrDefault(p => p.Name == selectedPilotName);
            bool   isPilotExists = pilotToFind != null;

            IMachine machineToFind   = this.machines.FirstOrDefault(m => m.Name == selectedMachineName);
            bool     isMachineExists = machineToFind != null;

            bool isMachineFree = machineToFind?.Pilot == null;

            if (!isPilotExists)
            {
                return(string.Format(OutputMessages.PilotNotFound, selectedPilotName));
            }

            if (!isMachineExists)
            {
                return(string.Format(OutputMessages.MachineNotFound, selectedMachineName));
            }

            if (!isMachineFree)
            {
                return(string.Format(OutputMessages.MachineHasPilotAlready, selectedMachineName));
            }

            machineToFind.Pilot = pilotToFind;
            return(string.Format(OutputMessages.MachineEngaged, pilotToFind.Name, machineToFind.Name));
        }
예제 #12
0
        public string EngageMachine(string selectedPilotName, string selectedMachineName)
        {
            StringBuilder sb = new StringBuilder();

            IPilot   pilot   = pilots.FirstOrDefault(p => p.Name == selectedPilotName);
            IMachine machine = machines.FirstOrDefault(m => m.Name == selectedMachineName);

            if (pilot == null)
            {
                sb.AppendLine($"{string.Format(OutputMessages.PilotNotFound, selectedPilotName) }");
            }
            else if (machine == null)
            {
                sb.AppendLine($"{string.Format(OutputMessages.MachineNotFound, selectedMachineName) }");
            }
            else if (machine != null)
            {
                //IPilot machinePilot = machine.Pilot;
                if (machine.Pilot != null)
                {
                    sb.AppendLine($"{string.Format(OutputMessages.MachineHasPilotAlready, machine.Name)}");
                }
                else if (machine.Pilot == null)
                {
                    pilot.AddMachine(machine);
                    machine.Pilot = pilot;
                    sb.AppendLine($"{string.Format(OutputMessages.MachineEngaged, pilot.Name, machine.Name)}");
                }
            }



            return(sb.ToString().TrimEnd());
        }
 public UpgradeSelector(IPilot pilot, IUpgradeSlot slot, IEnumerable <IUpgrade> uniquesTaken)
 {
     Pilot         = pilot;
     Slot          = slot;
     UniquesTaken  = uniquesTaken;
     SlotsAvaiable = pilot.Upgrades.Where(x => x.Upgrade.Name == "" && x.UpgradeType.Equals(slot.UpgradeType)).Count();
 }
예제 #14
0
        public string EngageMachine(string selectedPilotName, string selectedMachineName)
        {
            IMachine machine = this.machines.FirstOrDefault(x => x.Name == selectedMachineName && x.Pilot == null);
            string   result  = string.Empty;

            IPilot pilot = this.pilots.FirstOrDefault(x => x.Name == selectedPilotName);

            if (pilot == null)
            {
                result = $"Pilot {selectedPilotName} could not be found";
            }
            else if (machine == null)
            {
                result = $"Machine {selectedMachineName} could not be found";
            }
            else if (machine.Pilot != null)
            {
                result = $"Machine {selectedMachineName} is already occupied";
            }
            else
            {
                machine.Pilot = pilot;
                pilot.AddMachine(machine);
                result = $"Pilot {selectedPilotName} engaged machine {selectedMachineName}";
            }

            return(result);
        }
예제 #15
0
        public string EngageMachine(string selectedPilotName, string selectedMachineName)
        {
            IPilot   pilot   = null;
            IMachine machine = null;

            if (!pilots.ContainsKey(selectedPilotName))
            {
                return(string.Format(OutputMessages.PilotNotFound, selectedPilotName));
            }

            pilot = pilots[selectedPilotName];

            if (!machines.ContainsKey(selectedMachineName))
            {
                return(string.Format(OutputMessages.MachineNotFound, selectedMachineName));
            }

            machine = machines[selectedMachineName];

            if (machine.Pilot != null)
            {
                return(string.Format(OutputMessages.MachineHasPilotAlready, selectedMachineName));
            }

            pilot.AddMachine(machine);
            machine.Pilot = pilot;

            return(string.Format(OutputMessages.MachineEngaged, selectedPilotName, selectedMachineName));
        }
예제 #16
0
        public string EngageMachine(string selectedPilotName, string selectedMachineName)
        {
            IPilot foundPilot = this.pilots
                                .FirstOrDefault(p => p.Name == selectedPilotName);

            IMachine foundMachine = this.machines
                                    .FirstOrDefault(p => p.Name == selectedMachineName);

            if (foundPilot == null)
            {
                return(string.Format(OutputMessages.PilotNotFound, selectedPilotName));
            }

            if (foundMachine == null)
            {
                return(string.Format(OutputMessages.MachineNotFound, selectedMachineName));
            }

            if (foundMachine.Pilot != null)
            {
                return(string.Format(OutputMessages.MachineHasPilotAlready, foundMachine.Name));
            }
            else
            {
                foundPilot.AddMachine(foundMachine);
                foundMachine.Pilot = foundPilot;

                return(string.Format(OutputMessages.MachineEngaged, foundPilot.Name, foundMachine.Name));
            }
        }
예제 #17
0
        public string PilotReport(string pilotReporting)
        {
            IPilot pilot = this.pilots
                           .FirstOrDefault(p => p.Name == pilotReporting);

            return(pilot.Report());
        }
예제 #18
0
 public SpaceshipRunner(ITargetDetector detector, ITargetPicker picker, IPilot pilot, IKnowsCurrentTarget knower)
 {
     _detector = detector;
     _picker   = picker;
     _pilot    = pilot;
     _knower   = knower;
 }
        public string EngageMachine(string selectedPilotName, string selectedMachineName)
        {
            if (!IsThatPilotExist(selectedPilotName))
            {
                return(String.Format(
                           OutputMessages.PilotNotFound,
                           selectedPilotName));
            }

            if (!IsThatMachineExist(selectedMachineName))
            {
                return(String.Format(
                           OutputMessages.MachineNotFound,
                           selectedPilotName));
            }

            IPilot   pilot   = this.pilots[selectedPilotName];
            IMachine machine = this.machines[selectedMachineName];

            if (machine.Pilot != null)
            {
                return(String.Format(
                           OutputMessages.MachineHasPilotAlready,
                           selectedMachineName));
            }

            pilot.AddMachine(machine);
            machine.Pilot = pilot;

            return(String.Format(OutputMessages.MachineEngaged, selectedPilotName, selectedMachineName));
        }
예제 #20
0
        public string EngageMachine(string selectedPilotName, string selectedMachineName)
        {
            if (this.pilots.ContainsKey(selectedPilotName) == false)
            {
                return($"Pilot {selectedPilotName} could not be found");
            }

            if (this.machines.ContainsKey(selectedMachineName) == false)
            {
                return($"Machine {selectedMachineName} could not be found");
            }

            //dont know what machine not occupied means
            //one more if statement

            IPilot   pilot   = this.pilots[selectedPilotName];
            IMachine machine = this.machines[selectedMachineName];

            if (machine.Pilot != null)
            {
                return($"Machine {selectedMachineName} is already occupied");
            }

            pilot.AddMachine(machine);
            machine.Pilot = pilot;

            return($"Pilot {selectedPilotName} engaged machine {selectedMachineName}");
        }
예제 #21
0
 public PilotViewModel(IPilot pilot)
 {
     Pilot = pilot;
     Pilot.PropertyChanged += (sender, e) =>
     {
         RaisePropertyChanged(nameof(Upgrades));
     };
 }
예제 #22
0
        public string PilotReport(string pilotReporting)
        {
            IPilot pilot = this.pilots
                           .Where(x => x.Name == pilotReporting)
                           .FirstOrDefault();

            return(pilot.Report());
        }
예제 #23
0
 public RocketRunner(ITargetDetector targetDetector, ITargetPicker targetPicker, IPilot engineControl, IDetonator detonator, IKnowsCurrentTarget knower)
 {
     _targetDetector = targetDetector;
     _targetPicker   = targetPicker;
     _pilot          = engineControl;
     _detonator      = detonator;
     _knower         = knower;
 }
예제 #24
0
 protected Machine(string name, double attackPoints, double defensePoints)
 {
     this.Name = name;
     this.pilot = null;
     this.AttackPoints = attackPoints;
     this.DefensePoints = defensePoints;
     this.targets = new List<string>();
 }
예제 #25
0
 public Machine(string name, double healthpoints, double attackPoints, double defencePoints, IPilot pilot = null)
 {
     this.Name = name;
     this.HealthPoints = healthpoints;
     this.attackPoints = attackPoints;
     this.defencePoints = defencePoints;
     this.targets = new List<string>();
 }
예제 #26
0
파일: Tank.cs 프로젝트: GoranGit/CSharp-OOP
 public Tank(string name, IPilot pilot, double attackPoints, double defencePoints)
     : base(name, pilot, attackPoints, defencePoints)
 {
     this.AttackPoints  -= 40;
     this.DefensePoints += 30;
     this.DefenseMode    = true;
     this.HealthPoints   = 100;
 }
예제 #27
0
 public Machine(string name, IPilot pilot, double attackPoints, double defencePoints)
 {
     this.Name          = name;
     this.Pilot         = pilot;
     this.targets       = new List <string>();
     this.AttackPoints  = attackPoints;
     this.DefensePoints = defencePoints;
 }
예제 #28
0
 public bool Equals(IPilot other)
 {
     return(Name == other.Name &&
            ShipName == other.ShipName &&
            other.Upgrades.All(Upgrades.Contains) &&
            other.Upgrades.Count == Upgrades.Count &&
            other.UpgradesCost == UpgradesCost);
 }
예제 #29
0
 protected Machine(string name, double attackPoints, double defensePoints)
 {
     this.Name          = name;
     this.pilot         = null;
     this.AttackPoints  = attackPoints;
     this.DefensePoints = defensePoints;
     this.targets       = new List <string>();
 }
예제 #30
0
 public Machine(string name, IPilot pilot, double healthPoints, double attackPoints, double defensePoints)
 {
     this.Name = name;
     this.pilot = pilot;
     this.HealthPoints = healthPoints;
     this.attackPoints = attackPoints;
     this.defensePoints = defensePoints;
 }
예제 #31
0
        //private List<string> targets;

        public BaseMachine(string name, double attackPoints, double defensePoints, double healthPoints)
        {
            this.Name          = name;
            this.AttackPoints  = attackPoints;
            this.DefensePoints = defensePoints;
            this.HealthPoints  = healthPoints;
            this.pilot         = null;
            this.Targets       = new List <string>();
        }
예제 #32
0
 //Constructor with all fields
 public Machine(string machineName, IPilot pilot, double healthPoints, double attackPoints, double defensePoints, IList <string> targets)
 {
     this.Name          = machineName;
     this.Pilot         = pilot;
     this.HealthPoints  = healthPoints;
     this.attackPoints  = attackPoints;
     this.defensePoints = defensePoints;
     this.targets       = targets;
 }
예제 #33
0
        public async Task NavigateToPilotDetailsAsync(IPilot pilot)
        {
            if (!SquadronViewModel.Squadron.AddPilot(pilot))
            {
                return;
            }

            await NavigationService.NavigateAsync(typeof(SquadronBuilder));
        }
예제 #34
0
 public Mashine(string name, IPilot pilot, double healthPoint, 
     double attckPoints, double defensePoints,IList<string>targets)
 {
     this.Name = name;
     this.Pilot = pilot;
     this.HealthPoints = healthPoint;
     this.AttackPoints = attckPoints;
     this.DefensePoints = defensePoints;
     this.Targets = targets;
 }
예제 #35
0
 public void JoinRace(IPilot pilot)
 {
     if (!_pilots.Contains(pilot))
         _pilots.Add(pilot);
 }
예제 #36
0
 public Fighter(string name, double attackPoints, double defensePoints, bool stealthMode, IPilot pilot = null)
     : base(name, 200, attackPoints, defensePoints, pilot)
 {
         this.stealthMode = stealthMode;
 }
예제 #37
0
 public Tank(string name, IPilot pilot, double healthPoints, double attackPoints, double defensePoints)
     : base(name, pilot, 100, attackPoints - DefModeAttPoints, defensePoints + DefModeDefPoints)
 {
 }
예제 #38
0
 public Fighter(string name, IPilot pilot, double healthPoints, double attackPoints, double defensePoints, bool stealthMode)
     : base(name, null, 200, attackPoints, defensePoints)
 {
     this.stealthMode = stealthMode;
 }
예제 #39
0
 public Tank(string name, double attackPoints, double defencePoints, IPilot pilot = null)
     : base(name, 100, attackPoints, defencePoints, pilot = null)
 {
     ToggleDefenseMode();
 }
예제 #40
0
 public Fighter(string name, IPilot pilot, double healthPoint,
     double attckPoints, double defensePoints, IList<string> targets)
 {
 }
예제 #41
0
 public void LeaveRace(IPilot pilot)
 {
     if (_pilots.Contains(pilot))
         _pilots.Remove(pilot);
 }