コード例 #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.");
            }
        }
コード例 #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();
            }
        }