static QuestSource CreateWarningSource(TrackedEntity player, TrackedEntity grid, long playerId, bool doesPunish) { // note: there's a chance that `player` or `grid` is null var playerName = player?.Name ?? grid?.OwnerName; var playerLag = player?.LagNormal ?? 0; var playerPin = doesPunish ? player?.PinRemainingTime ?? TimeSpan.Zero : TimeSpan.Zero; var gridLag = grid?.LagNormal ?? 0; var gridPin = doesPunish ? grid?.PinRemainingTime ?? TimeSpan.Zero : TimeSpan.Zero; var src = new QuestSource(playerId, playerName, playerLag, playerPin, grid?.Id ?? 0, gridLag, gridPin); return(src); }
private void HandlePlayerInteract() { PlayerController pContr = GameManager.Instance.PlayerAvatar.GetComponent <PlayerController>(); if (pContr) { if (pContr.AcceptsInput) { QuestSource mySource = transform.parent.parent.GetComponent <QuestSource>(); if (mySource.IsPlayerInTrigger() && !_isMenuOpen) { // display menu _isMenuOpen = true; QuestParchmentMenu.SetActive(_isMenuOpen); pContr.AcceptsInput = false; } } } }
private void InitNPCs() { foreach (Quest quest in GameManager.Instance.QuestManager.Quests) { if (quest.Identifier.SourceID != string.Empty) { if (GameManager.Instance.QuestSources == null) { break; } QuestSource source = GameManager.Instance.QuestSources.FindSourceByID(quest.Identifier.SourceID); if (source == null) { Debug.Log("Can't spawn NPC \"" + quest.Identifier.SourceID + "\". No QuestSource with this ID found in the scene."); } else { if (source.needsToBeSpawned) { GameObject spawnedPawn = GameManager.Instance.PawnDataBase.CreatePawn(source.ID, source.Transform.position, source.Transform.rotation, null); // TODO: NPCs must be registered in Tile Manager and ComputeItems called in character initializer if (spawnedPawn.GetComponent <PawnInstance>() != null && spawnedPawn.GetComponent <Keeper>() == null) { if (spawnedPawn.GetComponent <Inventory>() != null && spawnedPawn.GetComponent <Inventory>().PossibleItems != null && spawnedPawn.GetComponent <Inventory>().PossibleItems.Count > 0) { spawnedPawn.GetComponent <Inventory>().ComputeItems(); } } spawnedPawn.transform.SetParent(source.Tile.transform); spawnedPawn.transform.SetAsLastSibling(); spawnedPawn.GetComponent <PawnInstance>().CurrentTile = source.Tile; spawnedPawn.GetComponent <Behaviour.QuestDealer>().QuestToGive = quest; spawnedPawn.GetComponent <Behaviour.QuestDealer>().Init(); InitCharacterUI(spawnedPawn.GetComponent <PawnInstance>()); if (source.Tile.State != TileState.Discovered) { spawnedPawn.SetActive(false); } } else { source.Transform.GetComponent <Behaviour.QuestDealer>().QuestToGive = quest; source.Transform.GetComponent <Behaviour.QuestDealer>().Init(); } } } } foreach (Tile t in TileManager.Instance.Tiles.GetComponentsInChildren <Tile>()) { if (GetComponentsInChildren <Trader>() != null) { for (int i = 0; i < t.transform.childCount; i++) { if (t.transform.GetChild(i).GetComponent <Trader>() != null) { Trader ta = t.transform.GetChild(i).GetComponent <Trader>(); if (ta.GetComponent <Inventory>() != null && ta.GetComponent <Inventory>().PossibleItems != null && ta.GetComponent <Inventory>().PossibleItems.Count > 0) { ta.GetComponent <Inventory>().ComputeItems(); } ta.GetComponent <PawnInstance>().CurrentTile = t; InitCharacterUI(ta.GetComponent <PawnInstance>()); } } } if (GetComponentsInChildren <HintWoman>() != null) { for (int i = 0; i < t.transform.childCount; i++) { if (t.transform.GetChild(i).GetComponent <HintWoman>() != null) { HintWoman ta = t.transform.GetChild(i).GetComponent <HintWoman>(); ta.GetComponent <PawnInstance>().CurrentTile = t; } } } } // TODO this should not be handled like, especially if there is more prisoner in scene GameObject prisoner = GameManager.Instance.PawnDataBase.CreatePawn("ashley", TileManager.Instance.BeginTile.transform.position, Quaternion.identity, null); GlowController.RegisterObject(prisoner.GetComponent <GlowObjectCmd>()); // TODO: Inutile maintenant ? InitCharacterUI(prisoner.GetComponent <PawnInstance>()); GameManager.Instance.PrisonerInstance = prisoner.GetComponent <PawnInstance>(); if (GameManager.Instance.QuestManager.CurrentQuestDeck != null) { switch (GameManager.Instance.QuestManager.CurrentQuestDeck.LevelId) { case "tuto": GameManager.Instance.QuestSources.GetComponent <QuestInitializer_Level1>().InitializeQuests(); break; case "level1": GameManager.Instance.QuestSources.GetComponent <QuestInitializer_Level1>().InitializeQuests(); break; case "level2": GameManager.Instance.QuestSources.GetComponent <QuestInitializer_Level2>().InitializeQuests(); break; case "level3": GameManager.Instance.QuestSources.GetComponent <QuestInitializer_Level3>().InitializeQuests(); break; case "level4": GameManager.Instance.QuestSources.GetComponent <QuestInitializer_Level4>().InitializeQuests(); break; default: break; } //GameManager.Instance.QuestSources.GetComponent<QuestInitializer>().InitializeQuests(); GameManager.Instance.QuestManager.MainQuest.OnQuestComplete += EndGameQuest; } else { Debug.Log("No deck loaded"); } }