static ThreatManager() { if (instance == null) { instance = new ThreatManager(); } }
private void Awake() { prefabManager = GetComponent <PrefabManager>(); menuManager = GetComponent <MenuManager>(); sceneLoader = GetComponent <SceneLoader>(); charactersCommon = GetComponent <CharactersCommon>(); spawnCharacter = GetComponent <SpawnCharacter>(); pauseManager = GetComponent <PauseManager>(); levelMessageManager = GetComponent <LevelMessageManager>(); tutorialMessageManager = GetComponent <TutorialMessageManager>(); menuMessageManager = GetComponent <MenuMessageManager>(); threatManager = GetComponent <ThreatManager>(); timeEventManager = GetComponent <TimeEventManager>(); timeManager = GetComponent <TimeManager>(); cameraManager = GetComponent <CameraManager>(); notebookManager = GetComponent <NotebookManager>(); dialogBoxManager = GetComponent <DialogBoxManager>(); tutorialDialogBoxManager = GetComponent <TutorialDialogBoxManager>(); idCardManager = GetComponent <IdCardManager>(); gameDataManager = GetComponent <GameDataManager>(); threatChartManager = GetComponent <ThreatChartManager>(); logManager = GetComponent <LogManager>(); userActionManager = GetComponent <UserActionManager>(); if (SceneManager.GetActiveScene().buildIndex == StaticDb.menuSceneIndex || SceneManager.GetActiveScene().buildIndex == StaticDb.loginSceneIndex) { return; } regularPathfinder = GameObject.Find("PathFinderRegular").GetComponent <Pathfinding>(); strictedPathfinder = GameObject.Find("PathFinderRestricted").GetComponent <Pathfinding>(); }
/// <summary> /// Select the best target (in <targetType> order) satisfying <predicate> from the threat list. /// If <offset> is nonzero, the first <offset> entries in <targetType> order (or MAXTHREAT order, if <targetType> is RANDOM) are skipped. /// </summary> public Unit SelectTarget(SelectAggroTarget targetType, uint offset, ISelector selector) { ThreatManager mgr = GetThreatManager(); // shortcut: if we ignore the first <offset> elements, and there are at most <offset> elements, then we ignore ALL elements if (mgr.GetThreatListSize() <= offset) { return(null); } List <Unit> targetList = SelectTargetList((uint)mgr.GetThreatListSize(), targetType, offset, selector); // maybe nothing fulfills the predicate if (targetList.Empty()) { return(null); } switch (targetType) { case SelectAggroTarget.MaxThreat: case SelectAggroTarget.MinThreat: case SelectAggroTarget.MaxDistance: case SelectAggroTarget.MinDistance: return(targetList[0]); case SelectAggroTarget.Random: return(targetList.SelectRandom()); default: return(null); } }
private void LoadData(string jsonData) { var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }; Game gameObject = JsonConvert.DeserializeObject <Game>(jsonData, settings); InitializeEventManager(); if (gameObject.Ship != null) { Ship = gameObject.Ship; Ship.InitializeEvents(_eventManager); } if (gameObject.ThreatManager != null) { ThreatManager = gameObject.ThreatManager; ThreatManager.InitializeEvents(_eventManager); } RepromptMessage = gameObject.RepromptMessage; RepeatMessage = gameObject.RepeatMessage; GameState = gameObject.GameState; LastGameState = gameObject.LastGameState; IsGameInProgress = gameObject.IsGameInProgress; RuleSelector = gameObject.RuleSelector; }
public void CreateNewGame(int difficulty) { InitializeEventManager(); IsGameInProgress = true; Message = $"Starting a new game. {SoundFx.Beeping} We have traced the distress call coordinates. Prepare to warp. {SoundFx.Warp} Captain, it looks like we warped into a trap! We need to survive until all external threats are destroyed! "; Ship = new HalcyonShip(); Ship.InitializeEvents(_eventManager); ThreatManager = new ThreatManager(); ThreatManager.InitializeEvents(_eventManager); Ship.InitializeShip(); ThreatManager.Initialize(difficulty); Message += $"Rolling the crew dice. {SoundFx.Dice} "; Ship.RollCrewDice(); GameState = GameState.PlayerTurn; Message += $"We have {Ship.GetAvailableCrewAsString()}. "; Message += Ship.ScannerCount > 0 ? $"Number of locked threats in our scanners is {Ship.ScannerCount}. " : ""; Message += ThreatManager.InternalThreats.Count > 0 ? $"Number of active internal threats is {ThreatManager.InternalThreats.Count}. {ThreatManager.GetThreatsAsString(true, false)}. " : ""; Message += ThreatManager.ExternalThreats.Count > 0 ? $"Number of active external threats is {ThreatManager.ExternalThreats.Count}. {ThreatManager.GetThreatsAsString(false, true)}. " : ""; Message += ThreatManager.ExternalThreats.Count + ThreatManager.InternalThreats.Count < 1 ? "There are no active threats at the moment. " : ""; Message += "What are your orders, captain? "; RepeatMessage = Message; RepromptMessage = $"Awaiting your orders, captain. "; SaveData(); }
public ThreatReference(ThreatManager mgr, Unit victim) { _owner = mgr._owner as Creature; _mgr = mgr; _victim = victim; Online = OnlineState.Offline; }
public MainWindow() { InitializeComponent(); ThreatManager = new ThreatManager(this); ThreatManager.InitThreats(); ComboBox_pages.SelectionChanged += (o, a) => { ResetPage(); }; Button_refresh.Click += (o, a) => { ThreatManager.RefreshDatabase(); }; Button_right.Click += (o, a) => { ShiftRight(); UpdatePage(); }; Button_left.Click += (o, a) => { ShiftLeft(); UpdatePage(); }; Button_help.Click += (o, a) => { MessageBox.Show("Двойной клик по угрозе для просмотра её полной информации"); }; Button_left.IsEnabled = false; Button_right.IsEnabled = false; Button_exit.Click += (o, a) => Application.Current.Shutdown(); }
public ThreatReference(ThreatManager mgr, Unit victim) { _owner = mgr._owner as Creature; _mgr = mgr; _victim = victim; Online = ShouldBeSuppressed() ? OnlineState.Suppressed : OnlineState.Online; }
public ThreatReference(ThreatManager mgr, Unit victim, float amount) { _owner = mgr._owner; _mgr = mgr; _victim = victim; _baseAmount = amount; _online = SelectOnlineState(); }
/// <summary> /// Select the best (up to) <num> targets (in <targetType> order) satisfying <predicate> from the threat list and stores them in <targetList> (which is cleared first). /// If <offset> is nonzero, the first <offset> entries in <targetType> order (or MAXTHREAT order, if <targetType> is RANDOM) are skipped. /// </summary> public List <Unit> SelectTargetList(uint num, SelectAggroTarget targetType, uint offset, ISelector selector) { var targetList = new List <Unit>(); ThreatManager mgr = GetThreatManager(); // shortcut: we're gonna ignore the first <offset> elements, and there's at most <offset> elements, so we ignore them all - nothing to do here if (mgr.GetThreatListSize() <= offset) { return(targetList); } if (targetType == SelectAggroTarget.MaxDistance || targetType == SelectAggroTarget.MinDistance) { foreach (HostileReference refe in mgr.GetThreatList()) { if (!refe.IsOnline()) { continue; } targetList.Add(refe.GetTarget()); } } else { Unit currentVictim = mgr.GetCurrentVictim(); if (currentVictim != null) { targetList.Add(currentVictim); } foreach (HostileReference refe in mgr.GetThreatList()) { if (!refe.IsOnline()) { continue; } Unit thisTarget = refe.GetTarget(); if (thisTarget != currentVictim) { targetList.Add(thisTarget); } } } // shortcut: the list isn't gonna get any larger if (targetList.Count <= offset) { targetList.Clear(); return(targetList); } // right now, list is unsorted for DISTANCE types - re-sort by MAXDISTANCE if (targetType == SelectAggroTarget.MaxDistance || targetType == SelectAggroTarget.MinDistance) { SortByDistance(targetList, targetType == SelectAggroTarget.MinDistance); } // now the list is MAX sorted, reverse for MIN types if (targetType == SelectAggroTarget.MinThreat) { targetList.Reverse(); } // ignore the first <offset> elements while (offset != 0) { targetList.RemoveAt(0); --offset; } // then finally filter by predicate targetList.RemoveAll(target => { return(!selector.Check(target)); }); if (targetList.Count <= num) { return(targetList); } if (targetType == SelectAggroTarget.Random) { targetList = targetList.SelectRandom(num).ToList(); } else { targetList.Resize(num); } return(targetList); }
private void Start() { threatManager = gameObject.GetComponent <ThreatManager>(); }
// Use this for initialization void Start() { GameManager.Instance.LevelManager = this; ThreatManager = GetComponent <ThreatManager>(); }
void Start() { threatPlayers = ThreatManager.Instance; agent = GetComponent <NavMeshAgent>(); }
public int CompareTo(ThreatReference other) { return(ThreatManager.CompareReferencesLT(this, other, 1.0f) ? 1 : -1); }
public void EndTurn() { // check if we won if (IsVictorious()) { GameOver(); SaveData(); return; } // check if we need to return crew from a mission if (Ship.AvailableCrewCount + Ship.ReturningCrewCount < 1 && Ship.MissionCrewCount > 0) { Message = "You need to return a crew member from a mission because we won't have any available crew for the next turn. Say return crew from a mission to do that. "; return; } Ship.EndTurn(); GameState = GameState.PlayerTurn; if (ThreatManager.ThreatDeck.Count > 0) { ThreatManager.DrawThreat(); } ThreatManager.ActivateThreats(); // reset threats when their turn is over ThreatManager.ResetThreats(); // check if we are dead if (IsShipDestroyed()) { GameOver(); SaveData(); return; } // check if we won, some threats can kill themselves when activating if (IsVictorious()) { GameOver(); SaveData(); return; } // check if we're out of crew to roll if (AreCrewIncapacitated()) { RepeatMessage = $"I am sorry, captain. All of our crew is incapacitated. {SoundFx.GameOver}Game over. To start a new game, say new game. "; Message += RepeatMessage; RepromptMessage = "Game over. To play again, say new game. "; GameOver(); SaveData(); return; } Message += $"Rolling the crew dice. {SoundFx.Dice} "; Ship.RollCrewDice(); // check if ship is destroyed, this can happen if threat deck is empty and we rolled three scanners that deals damage if (IsShipDestroyed()) { GameOver(); SaveData(); return; } Message += $"We have {Ship.GetAvailableCrewAsString()}. "; Message += Ship.ScannerCount > 0 ? $"Number of locked threats in our scanners is {Ship.ScannerCount}. " : ""; Message += ThreatManager.InternalThreats.Count > 0 ? $"Number of active internal threats is {ThreatManager.InternalThreats.Count}. {ThreatManager.GetThreatsAsString(true,false)}. " : ""; Message += ThreatManager.ExternalThreats.Count > 0 ? $"Number of active external threats is {ThreatManager.ExternalThreats.Count}. {ThreatManager.GetThreatsAsString(false, true)}. " : ""; Message += ThreatManager.ExternalThreats.Count + ThreatManager.InternalThreats.Count < 1 ? "There are no active threats at the moment. " : ""; Message += "What are your orders, captain? "; RepeatMessage = Message; RepromptMessage = "What are your orders, captain? "; SaveData(); }