Exemplo n.º 1
0
        public void AddNewThreatsToTracks(int currentTurn)
        {
            PhaseStarting(this, new PhaseEventArgs {
                PhaseHeader = ResolutionPhase.AddNewThreats.GetDescription()
            });

            var newExternalThreats = ExternalThreats.Where(threat => threat.TimeAppears == currentTurn).ToList();

            foreach (var newThreat in newExternalThreats)
            {
                newThreat.AttackedSittingDuck += (sender, args) => { ThreatAttackedShip(sender, args); };
                newThreat.PlaceOnTrack(ExternalTracks[newThreat.CurrentZone]);
                EventMaster.LogEvent(string.Format(CultureInfo.CurrentCulture, "{0} Appeared", newThreat.DisplayName));
            }

            var newInternalThreats = InternalThreats.Where(threat => threat.TimeAppears == currentTurn).ToList();

            foreach (var newThreat in newInternalThreats)
            {
                newThreat.AttackedSittingDuck += (sender, args) => { ThreatAttackedShip(sender, args); };
                newThreat.PlaceOnTrack(InternalTrack);
                EventMaster.LogEvent(string.Format(CultureInfo.CurrentCulture, "{0} Appeared", newThreat.DisplayName));
            }

            if (!newExternalThreats.Any() && !newInternalThreats.Any())
            {
                EventMaster.LogEvent("No New Threats Appear.");
            }
        }
Exemplo n.º 2
0
        public void ActivateThreats()
        {
            if (InternalThreats.Count < 1 && ExternalThreats.Count < 1)
            {
                return;
            }


            ThreatDie threatDie = new ThreatDie();
            string    message   = $"Rolling the threat die. {SoundFx.Dice}The result is {threatDie.Value}. ";

            _eventManager.Trigger("AppendMessage", new DefaultEvent(message));
            var threatsToActivate = InternalThreats.Where(t => !t.IsDisabled && t.ActivationList.Contains(threatDie.Value)).ToList <Threat>();

            threatsToActivate.AddRange(ExternalThreats.Where(t => !t.IsDisabled && t.ActivationList.Contains(threatDie.Value)).OrderByDescending(t => t.Health).ToList <Threat>());


            // if no threats, check if we have mercenary
            if (threatsToActivate.Count < 1)
            {
                var mercenary = ExternalThreats.FirstOrDefault(t => t is MercenaryThreat && !t.IsDisabled);
                if (mercenary != null)
                {
                    threatsToActivate.Add(mercenary);
                }
            }
            // check if Scout needs to be added to the list
            if (threatsToActivate.Count > 0)
            {
                var scout = ExternalThreats.FirstOrDefault(t => t is ScoutingShipThreat && !t.IsDisabled);
                if (scout != null)
                {
                    threatsToActivate.Add(scout);
                }
            }


            if (threatsToActivate.Count < 1)
            {
                message = "No threats were activated on this roll. ";
                _eventManager.Trigger("AppendMessage", new DefaultEvent(message));
            }

            foreach (var item in threatsToActivate)
            {
                item.Activate(_eventManager);
            }

            // if cloaked threats activated, we run this method again
            if (_rollThreatDieAgain)
            {
                _rollThreatDieAgain = false;
                ActivateThreats();
            }
        }
Exemplo n.º 3
0
        public Threat GetActiveThreat(string id)
        {
            Threat threat = ExternalThreats.FirstOrDefault(t => t.Id == id) as Threat;

            if (threat == null)
            {
                // no active external threat with that id, let's check internal threats
                threat = InternalThreats.FirstOrDefault(t => t.Id == id) as Threat;
            }
            return(threat);
        }
Exemplo n.º 4
0
 public void AddExternalThreat(ExternalThreat newThreat, int timeAppears, ZoneLocation zoneLocation)
 {
     newThreat.SetInitialPlacement(timeAppears, zoneLocation);
     newThreat.PlaceOnTrack(ExternalTracks[zoneLocation]);
     newThreat.AttackedSittingDuck += (sender, args) => { ThreatAttackedShip(sender, args); };
     foreach (var threat in externalThreatStatusEffects.Concat(singleTurnExternalThreatStatusEffects))
     {
         newThreat.SetThreatStatus(threat, true);
     }
     ExternalThreats.Add(newThreat);
 }
Exemplo n.º 5
0
        public void RemoveCrewFromMission(RemoveCrewFromMissionEvent e)
        {
            // search external threats first
            var threat = (Threat)ExternalThreats.FirstOrDefault(t => t.Name == e.ThreatName);

            if (threat == null)
            {
                threat = InternalThreats.FirstOrDefault(t => t.Name == e.ThreatName);
            }

            threat.AwayMissions.First(a => a.IsAssigned && a.Type == e.Type).IsAssigned = false;
            string message = $"{e.Type} crew was removed from the {e.ThreatName} mission. ";

            _eventManager.Trigger("AppendMessage", new DefaultEvent(message));
        }
Exemplo n.º 6
0
        public Threat DrawThreat()
        {
            // check if deck is empty
            if (ThreatDeck.Count < 1)
            {
                return(null);
            }

            var threat = ThreatDeck.Dequeue();

            if (threat is ExternalThreat et)
            {
                ExternalThreats.Add(et);
            }
            else if (threat is InternalThreat it)
            {
                InternalThreats.Add(it);
            }

            threat.OnSpawn(_eventManager);
            return(threat);
        }
Exemplo n.º 7
0
        public void InitializeEvents(EventManager eventManager)
        {
            _eventManager = eventManager;
            // create events
            _eventManager.On("ScannerDrawThreatCard", (e) =>
            {
                // scanners detected a threat, draw a card
                if (ThreatDeck.Count < 1)
                {
                    // if threat deck is empty deal 1 damage to the player ship
                    var damageEvent = new DamageShipEvent(string.Empty, 1, $"We have three locked threats in our scanners, but the threat deck is empty. An unknown entity opened fire");
                    eventManager.Trigger("DamageShip", damageEvent);
                    return;
                }
                _eventManager.Trigger("AppendMessage", new DefaultEvent("Our scanners are detecting a new threat. "));
                DrawThreat();
            });
            _eventManager.On("DiscardThreat", (e) =>
            {
                var threat = ((DefaultThreatEvent)e).Threat;
                threat.OnDestroy(_eventManager);
                _eventManager.Trigger("MissionCleanup", (DefaultThreatEvent)e);
                if (threat is InternalThreat it)
                {
                    InternalThreats.Remove(it);
                }
                else if (threat is ExternalThreat et)
                {
                    ExternalThreats.Remove(et);
                }
            });

            _eventManager.On("CloakedThreatsActivated", (e) => _rollThreatDieAgain = true);

            _eventManager.On("RemoveCrewFromMission", (e) => RemoveCrewFromMission((RemoveCrewFromMissionEvent)e));
            _eventManager.On("TimeWarpActivated", (e) => HealExternalThreats());
        }
Exemplo n.º 8
0
 public void ResetThreats()
 {
     // fire this before the player turn starts, used to remove any effects that disappear at the end of enemey's turn
     ExternalThreats.ForEach(t => t.IsDisabled = false);
     InternalThreats.ForEach(t => t.IsDisabled = false);
 }