IEnumerator PlayEmergeAnimation() { PersistentGameManager.EnterCutscene(head.position - (head.up * 20f)); yield return(new WaitForSeconds(4.0f)); Animator headAnimator = head.GetComponent <Animator>(); headAnimator.speed /= 3; headAnimator.enabled = true; while (headAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime < 1) { yield return(null); } Destroy(headAnimator); //yield return new WaitForSeconds(2.0f); enabled = true; GetComponentInChildren <OsmiumHead>().enabled = true; PersistentGameManager.ExitCutscene(); }
public void LoadMazeLevel(List <string> arguments) { if (MazeLevelGameplayManager.Instance == null) { if (PersistentGameManager.CurrentSceneType == SceneType.Overworld) { Logger.Warning("We are currently in the overworld scene. Switching scenes."); PersistentGameManager.SetLastMazeLevelName("default"); PersistentGameManager.SetCurrentSceneName("default"); PhotonNetwork.LoadLevel("Maze"); // TODO this loads the default maze, should load specific maze } else { Logger.Error("Cannot find MazeLevelManager. Returning."); } return; } MazeLevelData mazeLevelData; if (arguments.Count < 2) { PersistentGameManager.SetLastMazeLevelName("default"); PersistentGameManager.SetCurrentSceneName("default"); mazeLevelData = MazeLevelLoader.LoadMazeLevelData(PersistentGameManager.CurrentSceneName); MazeLevelLoader.LoadMazeLevel(mazeLevelData); return; //string message = "The command '<color=" + ConsoleConfiguration.HighlightColour + ">load maze</color>' needs an additional argument with the name of the maze level"; //Logger.Warning(message); //message += "\nThe Currently available levels are: \n"; //message = MazeLevelLoader.GetAllMazeLevelNamesForPrint(message); //throw new NotEnoughArgumentsConsoleException(message); } string mazeName = arguments[1]; mazeLevelData = MazeLevelLoader.LoadMazeLevelData(mazeName); if (mazeLevelData == null && Console.Instance.ConsoleState != ConsoleState.Closed) { string printLine = "<color=" + ConsoleConfiguration.HighlightColour + ">" + arguments[1] + "</color> is not a known maze level and cannot be loaded.\n\n"; printLine += "The Currently available levels are: \n"; printLine = MazeLevelLoader.GetAllMazeLevelNamesForPrint(printLine); Console.Instance.PrintToReportText(printLine); } PersistentGameManager.SetLastMazeLevelName(mazeName); PersistentGameManager.SetCurrentSceneName(mazeName); mazeLevelData = MazeLevelLoader.LoadMazeLevelData(PersistentGameManager.CurrentSceneName); MazeLevelLoader.LoadMazeLevel(mazeLevelData); }
public void LoadMazeEditor() { PersistentGameManager.SceneLoadOrigin = SceneLoadOrigin.Editor; string mazeName = "default"; PersistentGameManager.SetLastMazeLevelName(mazeName); PersistentGameManager.SetCurrentSceneName(mazeName); PhotonNetwork.LoadLevel("Maze"); }
public void UpdateBarForHeal(int totalHealed) { PersistentGameManager PGMngr = FindObjectOfType <PersistentGameManager>(); float HPRatio = ((float)my.currentHP + totalHealed) / my.MaxHP; Color nextColor = (HPRatio > midRatio ? PGMngr.HighHealthColor : (HPRatio > lowRatio ? PGMngr.MidHealthColor : PGMngr.LowHealthColor)); for (int i = my.currentHP + totalHealed - 1; i >= 0; --i) { healthPieces[i].Fill(nextColor); } }
public void DeselectAllAndTerminate() { foreach (SelectionIndicator curr in AllInRange) { curr.transform.parent = null; curr.StartCoroutine(PersistentGameManager.FadeOutAndDestroy(curr.gameObject, 1)); } AllInRange.Clear(); StartCoroutine(PersistentGameManager.FadeOutAndDestroy(gameObject, 2)); }
// Use this for initialization void Start () { if (theGameManager == null) { theGameManager = this; DontDestroyOnLoad(theGameManager); } else { DestroyImmediate(this); return; } }
private void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
public void LoadOverworldEditor() { PersistentGameManager.SceneLoadOrigin = SceneLoadOrigin.Editor; if (PersistentGameManager.OverworldName == "") { PersistentGameManager.SetOverworldName("overworld"); } PersistentGameManager.SetLastMazeLevelName(PersistentGameManager.CurrentSceneName); PersistentGameManager.SetCurrentSceneName(PersistentGameManager.OverworldName); PhotonNetwork.LoadLevel("Overworld"); }
void Start() { PersistentGameManager = GameObject.FindWithTag("PersistentGameManager").GetComponent <PersistentGameManager>(); Button = GetComponent <Button>(); if (gameObject.name == "Options" || gameObject.name == "Rules" || gameObject.name == "BlockInfo") { Button.onClick.AddListener(delegate { ButtonHandler(gameObject.name); }); //Button.onClick.AddListener(delegate { PersistentGameManager.Instance.SaveLevelState(gameObject.name); }); } else if (gameObject.name == "Return") { Button.onClick.AddListener(PersistentGameManager.Instance.LoadLevelState); } }
// Start is called before the first frame update void Start() { pgm = GameObject.Find("PersistentGameManager").GetComponent <PersistentGameManager>(); iMenu = GameObject.FindObjectOfType <InventoryMenu>(); //Add onClick listener to each item name = "Index " + cardIndex + " button"; GetComponent <Button>().onClick.AddListener(() => { Debug.Log(name + ": Remove from Deck at index: " + (cardIndex) + " title: " + GetComponentInChildren <Text>().text); pgm.playerData.cardInventory.Add(pgm.playerData.currrentDeck[cardIndex]); pgm.playerData.currrentDeck.RemoveAt(cardIndex); iMenu.UpdateDeckListUI(); iMenu.UpdateInventoryListUI(); }); }
public void initialize() { if (instance == null) { instance = this; } else { Destroy(gameObject); } DontDestroyOnLoad(instance); DontDestroyOnLoad(loadingScreen); playerData = new SaveData(); playerData.playerData = new PlayerData(); if (!SerializationManager.DoesFileExist("save")) { playerData.ResetPlayerData(false); SaveGame(); } LoadSave(); LoadClickerData(); Advertisement.Initialize(AdConfig.monetizeProjectID, Debug.isDebugBuild); int minutes = (int)System.DateTime.UtcNow.Subtract(playerData.playerData.lastDate.date).TotalMinutes; for (int i = 0; i < minutes; i++) { UpdateStats(); } InvokeRepeating("UpdateStats", 60f, 60f * 1f); InvokeRepeating("ClickerTick", 0.0f, 1.0f / GlobalConfig.incrementsPerSecond); InvokeRepeating("DepleteStardom", 15f, 15f * 1f); PersistentGameManager.instance.playerData.playerData.coinz += minutes * 60f * CoinzPerSecond(false); PersistentGameManager.instance.audioManager.ToggleMusicVolume(PlayerPrefs.GetInt("musicEnabled") == 1); PersistentGameManager.instance.audioManager.ToggleSoundFXVolume(PlayerPrefs.GetInt("soundEnabled") == 1); currentScene = (int)SceneManager.GetActiveScene().buildIndex; LoadButtonSounds(); GetSceneMusic(); SceneManager.sceneLoaded += OnSceneLoaded; }
public void LoadOverworld(string overworldName = "default") { if (GameRules.GamePlayerType == GamePlayerType.SinglePlayer || GameRules.GamePlayerType == GamePlayerType.SplitScreenMultiplayer) { PersistentGameManager.SetLastMazeLevelName(PersistentGameManager.CurrentSceneName); PersistentGameManager.SetCurrentSceneName(overworldName); IEnumerator loadLevelCoroutine = LoadOverworldCoroutine("Overworld"); StartCoroutine(loadLevelCoroutine); } else { LoadOverworldEvent loadOverworldEvent = new LoadOverworldEvent(); loadOverworldEvent.SendLoadOverworldEvent(overworldName); } }
public void Launch() { if (GameRules.GameMode == GameMode.Campaign) { PersistentGameManager.SetOverworldName("overworld"); PersistentGameManager.SetCurrentSceneName(PersistentGameManager.OverworldName); PhotonNetwork.LoadLevel("Overworld"); } else { PersistentGameManager.SetLastMazeLevelName("default"); PersistentGameManager.SetCurrentSceneName("default"); PhotonNetwork.LoadLevel("Maze"); } }
void Awake() { //Debug.Log("scene count: " + SceneManager.sceneCountInBuildSettings); //Debug.Log(Application.persistentDataPath); if (manager == null) { DontDestroyOnLoad(this); manager = this; } else if (manager != this) { Destroy(gameObject); } levelLoaded_ = false; Load(); }
public void UpdateBarForDamage(int totalDamage) { PersistentGameManager PGMngr = FindObjectOfType <PersistentGameManager>(); float HPRatio = ((float)my.currentHP - totalDamage) / my.MaxHP; Color nextColor = (HPRatio > midRatio ? PGMngr.HighHealthColor : (HPRatio > lowRatio ? PGMngr.MidHealthColor : PGMngr.LowHealthColor)); for (int i = my.currentHP - 1; i >= 0; --i) { if (totalDamage > 0) { healthPieces[i].Drain(); --totalDamage; } else { healthPieces[i].Fill(nextColor); } } }
// Start is called before the first frame update void Start() { pgm = GameObject.Find("PersistentGameManager").GetComponent <PersistentGameManager>(); items = new List <GameObject>(); for (int i = 0; i < pgm.playerData.currrentDeck.Count; i++) { int value = itemIndex + 1; // Create new item var item = Instantiate(itemTemplate); items.Add(item); item.transform.SetParent(content.transform); //Config list item position item.transform.localPosition = Vector3.zero; item.transform.localScale = Vector3.one; //Add samle text to button's text item.GetComponentInChildren <Text>().text = pgm.playerData.currrentDeck[i].cardTitle; item.GetComponent <DeckListButton>().cardIndex = itemIndex; itemIndex++; } cardsInDeckText.text = "Cards in Deck: " + items.Count + "/20"; for (int i = 0; i < 10; i++) { if (i + (currentCardPage * 10) < pgm.playerData.cardInventory.Count) { CardUIObjects[i].GetComponent <BasicCard>().gameObject.SetActive(true); CardUIObjects[i].GetComponent <BasicCard>().SetCardData(pgm.playerData.cardInventory[i + (currentCardPage * 10)]); CardUIObjects[i].GetComponent <BasicCard>().SetupUI(); } else { CardUIObjects[i].GetComponent <BasicCard>().gameObject.SetActive(false); } } }
public void CalculateScores() { Logger.Log(Logger.Score, "Finished counting score."); ICharacterManager characterManager = GameManager.Instance.CharacterManager; if (characterManager == null) { return; } if (characterManager.GetPlayers <MazePlayerCharacter>().Count == 1) { PlayerMazeScores.Add(PlayerNumber.Player1, new PlayerMazeScore()); } else { PlayerMazeScores.Add(PlayerNumber.Player1, new PlayerMazeScore()); PlayerMazeScores.Add(PlayerNumber.Player2, new PlayerMazeScore()); } CountTileMarkerScores(); CountEnemyEncountersScores(); CountFirstFinishedBonus(); Dictionary <PlayerNumber, PlayerMazeScore> tempPlayerScores = new Dictionary <PlayerNumber, PlayerMazeScore>(); foreach (KeyValuePair <PlayerNumber, PlayerMazeScore> item in PlayerMazeScores) { int mazeTotal = item.Value.CountMazeTotal(); PlayerMazeScore playerMazeScore = item.Value; playerMazeScore.MazeScore = mazeTotal; tempPlayerScores.Add(item.Key, playerMazeScore); PersistentGameManager.UpdatePlayerOveralScoresWithMazeScore(item.Key, playerMazeScore.MazeScore); } PlayerMazeScores = tempPlayerScores; }
public void PerformMazeLevelEntryAction(string mazeName) { // Player does not meet entry requirements? Return; if (GameRules.GamePlayerType == GamePlayerType.SinglePlayer) { PersistentGameManager.SetCurrentSceneName(mazeName); OverworldGameplayManager.Instance.LoadMaze(); } else if (GameRules.GamePlayerType == GamePlayerType.SplitScreenMultiplayer) { PersistentGameManager.SetCurrentSceneName(mazeName); OverworldGameplayManager.Instance.LoadMaze(); } else { PersistentGameManager.SetCurrentSceneName(mazeName); PlayerSendsMazeLevelInvitationEvent playerSendsMazeLevelInvitationEvent = new PlayerSendsMazeLevelInvitationEvent(); playerSendsMazeLevelInvitationEvent.SendPlayerSendsMazeLevelInvitationEvent(PhotonView.Owner.NickName, mazeName); string otherPlayerName = ""; if (PlayerNumber == PlayerNumber.Player1) { otherPlayerName = GameManager.Instance.CharacterManager.GetPlayerCharacter <PlayerCharacter>(PlayerNumber.Player2).PhotonView.Owner.NickName; } else if (PlayerNumber == PlayerNumber.Player2) { otherPlayerName = GameManager.Instance.CharacterManager.GetPlayerCharacter <PlayerCharacter>(PlayerNumber.Player1).PhotonView.Owner.NickName; } else { Logger.Warning($"Unknown player number {PlayerNumber}"); } OverworldMainScreenOverlayCanvas.Instance.ShowPlayerMessagePanel($"We are waiting for {otherPlayerName} to accept our invitation..."); MazeLevelInvitation.PendingInvitation = true; } }
public void OnEvent(EventData photonEvent) { byte eventCode = photonEvent.Code; if (eventCode == LoadNextMazeLevelEvent.LoadNextMazeLevelEventCode) { object[] data = (object[])photonEvent.CustomData; string mazeName = (string)data[0]; PersistentGameManager.SetCurrentSceneName(mazeName); Logger.Log("received event to load maze"); IEnumerator loadLevelCoroutine = LoadLevelCoroutine("Maze"); StartCoroutine(loadLevelCoroutine); } else if (eventCode == PlayerSendsMazeLevelInvitationEvent.PlayerSendsMazeLevelInvitationEventCode) { object[] data = (object[])photonEvent.CustomData; string invitorName = (string)data[0]; string mazeName = (string)data[1]; Logger.Log($"received event for invitation from {invitorName}"); MazeLevelInvitation.PendingInvitation = true; OverworldMainScreenOverlayCanvas.Instance.ShowMazeInvitation(invitorName, mazeName); } else if (eventCode == PlayerRejectsMazeLevelInvitationEvent.PlayerRejectsMazeLevelInvitationEventCode) { object[] data = (object[])photonEvent.CustomData; string rejectorName = (string)data[0]; string mazeName = (string)data[1]; Logger.Log($"received event that {rejectorName} rejected the invitation"); OverworldMainScreenOverlayCanvas.Instance.ShowMazeInvitationRejection(rejectorName, mazeName); } }
public void TakeDamage(int damageAmount, ElementType hitElement) { PersistentGameManager pgMngr = FindObjectOfType <PersistentGameManager>(); // Modify damageAmount by resistance (via persistentgamemanager?) damageAmount = PersistentGameManager.CalculateDamage(Element, hitElement, damageAmount); EntityHUD myHud = GetComponentInChildren <EntityHUD>(); if (damageAmount > 0) { if (currentHP <= 0) { return; } GetComponentInChildren <HPBar>().UpdateBarForDamage(Mathf.Clamp(damageAmount, 0, currentHP)); if (shakeStrength <= 0) { StartCoroutine(ShowGotDamaged()); } else { shakeStrength = startShakeStrength; } // Display damaged text DamageText dmgText = ((GameObject)Instantiate(pgMngr.DamagedText, myHud.transform.GetChild(0).position + Vector3.up, pgMngr.DamagedText.transform.rotation)).GetComponent <DamageText>(); dmgText.elementType = hitElement; dmgText.damageAmount = damageAmount; } else if (damageAmount < 0) { if (currentHP < MaxHP) { GetComponentInChildren <HPBar>().UpdateBarForHeal(Mathf.Clamp(-damageAmount, 0, MaxHP - currentHP)); // Display healed text DamageText healText = ((GameObject)Instantiate(pgMngr.HealedText, myHud.transform.GetChild(0).position + Vector3.up, pgMngr.HealedText.transform.rotation)).GetComponent <DamageText>(); healText.elementType = hitElement; healText.damageAmount = -damageAmount; } } else { // Do Blocked // Display blocked text DamageText blockText = ((GameObject)Instantiate(pgMngr.BlockedText, myHud.transform.GetChild(0).position + Vector3.up, pgMngr.BlockedText.transform.rotation)).GetComponent <DamageText>(); blockText.elementType = hitElement; return; } currentHP = Mathf.Clamp(currentHP - damageAmount, 0, MaxHP); if (currentHP <= 0) { if (!hasDeathThrown && !InParty && Random.value < spareableChance) { ++currentHP; // DO THE DERP StartCoroutine(BecomeSpareable()); hasDeathThrown = true; } else { Die(); } } }
void Start () { m_pPersistentGameManager = FindObjectOfType<PersistentGameManager>(); // Now we have all the information we need from other scenes. m_fGameTimeRemaining = m_fGameTime; }
public void Start() { switch (PersistentGameManager.CurrentSceneType) { case SceneType.Overworld: Logger.Log("instantiate overworld sprites, tiles and characters"); if (PersistentGameManager.SceneLoadOrigin == SceneLoadOrigin.Gameplay) { if (PersistentGameManager.OverworldName == "") { PersistentGameManager.SetOverworldName("overworld"); } string overworldName = PersistentGameManager.OverworldName; Logger.Log($"We will load the maze '{overworldName}'"); OverworldData startUpOverworldData = OverworldLoader.LoadOverworldData(overworldName); if (startUpOverworldData == null) { Logger.Error("Could not find the default overworld for startup"); } OverworldLoader.LoadOverworld(startUpOverworldData); if (OverworldGameplayManager.Instance.Overworld == null) { Logger.Log(Logger.Initialisation, "No overworld loaded on startup. Returning"); return; } } // We loaded a overworld scene through the editor. Set up an empty grid for in the editor else { Logger.Log("create empty grid"); EditorCanvasUI.Instance.OverworldModificationPanel.GenerateTiles(); } break; case SceneType.Maze: // We loaded a maze scene through the game. Set up the maze level if (PersistentGameManager.SceneLoadOrigin == SceneLoadOrigin.Gameplay) { if (PersistentGameManager.CurrentSceneName == "") { PersistentGameManager.SetCurrentSceneName("default"); } string mazeName = PersistentGameManager.CurrentSceneName; PersistentGameManager.SetLastMazeLevelName(mazeName); Logger.Log($"We will load the maze '{mazeName}'"); MazeLevelData startUpMazeLevelData = MazeLevelLoader.LoadMazeLevelData(mazeName); if (startUpMazeLevelData == null) { Logger.Error($"Could not find the level {mazeName} for startup. Will load defult level instead."); mazeName = "default"; startUpMazeLevelData = MazeLevelLoader.LoadMazeLevelData(mazeName); } MazeLevelLoader.LoadMazeLevel(startUpMazeLevelData); if (CurrentGameLevel == null) { Logger.Log(Logger.Initialisation, "No level loaded on startup. Returning"); return; } if (CurrentGameLevel.PlayerCharacterSpawnpoints.Count == 0) { return; } PlayableLevelNames = MazeLevelLoader.GetAllPlayableLevelNames(); } // We loaded a maze scene through the editor. Set up an empty grid for in the editor else { Logger.Log("create empty grid"); EditorCanvasUI.Instance.MazeModificationPanel.GenerateTiles(); } break; default: Logger.Error($"Scenetype {PersistentGameManager.CurrentSceneType} is not implemented yet"); break; } }
public void OnEvent(EventData photonEvent) { byte eventCode = photonEvent.Code; if (eventCode == PlayerMarksTileEvent.PlayerMarksTileEventCode) { object[] data = (object[])photonEvent.CustomData; GridLocation tileLocation = new GridLocation((int)data[0], (int)data[1]); PlayerNumber playerNumber = (PlayerNumber)data[2]; InGameMazeTile tile = Level.TilesByLocation[tileLocation] as InGameMazeTile; MazeTilePath mazeTilePath = (MazeTilePath)tile.GetBackgrounds().FirstOrDefault(background => background is MazeTilePath); if (mazeTilePath == null) { return; } PlayerMark playerMark = new PlayerMark(mazeTilePath.ConnectionScore); HandlePlayerMarkerSprite(tile, playerNumber, playerMark); HandlePlayerTileMarkerEnds(tile); HandleNumberOfUnmarkedTiles(); tile.ResetPlayerMarkEndsRenderer(); tile.TriggerTransformations(); } else if (eventCode == LoadNextMazeLevelEvent.LoadNextMazeLevelEventCode) { object[] data = (object[])photonEvent.CustomData; string pickedLevel = (string)data[0]; MazeLevelData mazeLevelData = MazeLevelLoader.LoadMazeLevelData(pickedLevel); if (mazeLevelData == null) { Logger.Error($"Could not load maze level data for the randomly picked maze level {pickedLevel}"); } PersistentGameManager.SetCurrentSceneName(pickedLevel); IEnumerator loadLevelCoroutine = LoadOverworldCoroutine("Overworld"); StartCoroutine(loadLevelCoroutine); } else if (eventCode == LoadOverworldEvent.LoadOverworldEventCode) { object[] data = (object[])photonEvent.CustomData; string overworldName = (string)data[0]; PersistentGameManager.SetLastMazeLevelName(PersistentGameManager.CurrentSceneName); PersistentGameManager.SetCurrentSceneName(PersistentGameManager.OverworldName); IEnumerator loadLevelCoroutine = LoadOverworldCoroutine("Overworld"); StartCoroutine(loadLevelCoroutine); } else if (eventCode == PlayerCollidesWithMusicInstrumentCaseEvent.PlayerCollidesWithMusicInstrumentCaseEventCode) { object[] data = (object[])photonEvent.CustomData; GridLocation tileLocation = new GridLocation((int)data[0], (int)data[1]); PlayerNumber playerNumber = (PlayerNumber)data[2]; InGameMazeTile tile = Level.TilesByLocation[tileLocation] as InGameMazeTile; MusicInstrumentCase musicInstrumentCase = (MusicInstrumentCase)tile.GetAttributes().FirstOrDefault(attribute => attribute is MusicInstrumentCase); if (musicInstrumentCase == null) { Logger.Error("Could not find musicInstrumentCase"); } MazePlayerCharacter player = GameManager.Instance.CharacterManager.GetPlayers <MazePlayerCharacter>()[playerNumber]; musicInstrumentCase.PlayerCollisionOnTile(player); } else if (eventCode == EnemyCollidesWithMusicInstrumentCaseEvent.EnemyCollidesWithMusicInstrumentCaseEventCode) { object[] data = (object[])photonEvent.CustomData; GridLocation tileLocation = new GridLocation((int)data[0], (int)data[1]); int enemyId = (int)data[2]; InGameMazeTile tile = Level.TilesByLocation[tileLocation] as InGameMazeTile; MusicInstrumentCase musicInstrumentCase = (MusicInstrumentCase)tile.GetAttributes().FirstOrDefault(attribute => attribute is MusicInstrumentCase); if (musicInstrumentCase == null) { Logger.Error("Could not find musicInstrumentCase"); } MazeCharacterManager characterManager = GameManager.Instance.CharacterManager as MazeCharacterManager; EnemyCharacter enemyCharacter = characterManager.Enemies.FirstOrDefault(enemy => enemy.PhotonView.ViewID == enemyId); if (enemyCharacter == null) { Logger.Error("Could not find enemy character"); } musicInstrumentCase.EnemyCollisinOnTile(enemyCharacter); } }