private void LevelActivated(Scene sceneFrom, Scene sceneTo) { string sceneName = sceneTo.name; if (_loadingChar) { TimeSpan timeSpan = TimeSpan.FromSeconds(PlayerData.instance.playTime); string text = string.Format("{0:00}.{1:00}", Math.Floor(timeSpan.TotalHours), timeSpan.Minutes); int profileID = PlayerData.instance.profileID; //string saveFilename = GameManager.instance.GetSaveFilename(profileID); //DateTime lastWriteTime = File.GetLastWriteTime(Application.persistentDataPath + saveFilename); Console.AddLine("New savegame loaded. Profile playtime " + text + " Completion: " + PlayerData.instance.completionPercentage + " Save slot: " + profileID + " Game Version: " + PlayerData.instance.version);// + " Last Written: " + lastWriteTime); _loadingChar = false; } if (GM.IsGameplayScene()) { _loadTime = Time.realtimeSinceStartup; Console.AddLine("New scene loaded: " + sceneName); EnemiesPanel.Reset(); PlayerDeathWatcher.Reset(); BossHandler.LookForBoss(sceneName); } }
public static void ToggleEnemyPanel() { DebugMod.settings.EnemiesPanelVisible = !DebugMod.settings.EnemiesPanelVisible; if (DebugMod.settings.EnemiesPanelVisible) { EnemiesPanel.RefreshEnemyList(); } }
private void LoadCharacter(int saveId) { Console.Reset(); EnemiesPanel.Reset(); DreamGate.Reset(); playerInvincible = false; infiniteHP = false; infiniteSoul = false; noclip = false; _loadingChar = true; }
public static void ToggleAllPanels() { bool active = !(DebugMod.settings.HelpPanelVisible || DebugMod.settings.InfoPanelVisible || DebugMod.settings.EnemiesPanelVisible || DebugMod.settings.TopMenuVisible || DebugMod.settings.ConsoleVisible); DebugMod.settings.TopMenuVisible = active; DebugMod.settings.InfoPanelVisible = active; DebugMod.settings.EnemiesPanelVisible = active; DebugMod.settings.ConsoleVisible = active; DebugMod.settings.HelpPanelVisible = active; if (DebugMod.settings.EnemiesPanelVisible) { EnemiesPanel.RefreshEnemyList(); } }
public void BuildMenus() { LoadResources(); canvas = new GameObject(); canvas.AddComponent <Canvas>().renderMode = RenderMode.ScreenSpaceOverlay; CanvasScaler scaler = canvas.AddComponent <CanvasScaler>(); scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; scaler.referenceResolution = new Vector2(1920f, 1080f); canvas.AddComponent <GraphicRaycaster>(); InfoPanel.BuildMenu(canvas); TopMenu.BuildMenu(canvas); EnemiesPanel.BuildMenu(canvas); Console.BuildMenu(canvas); KeyBindPanel.BuildMenu(canvas); DontDestroyOnLoad(canvas); }
public void Update() { InfoPanel.Update(); TopMenu.Update(); EnemiesPanel.Update(); Console.Update(); KeyBindPanel.Update(); if (DebugMod.GetSceneName() != "Menu_Title") { //Handle keybinds foreach (KeyValuePair <string, int> bind in DebugMod.settings.binds) { if (DebugMod.bindMethods.ContainsKey(bind.Key)) { if ((KeyCode)bind.Value == KeyCode.None) { foreach (KeyCode kc in Enum.GetValues(typeof(KeyCode))) { if (Input.GetKeyDown(kc)) { if (KeyBindPanel.keyWarning != kc) { foreach (KeyValuePair <string, int> kvp in DebugMod.settings.binds) { if (kvp.Value == (int)kc) { Console.AddLine(kc.ToString() + " already bound to " + kvp.Key + ", press again to confirm"); KeyBindPanel.keyWarning = kc; } } if (KeyBindPanel.keyWarning == kc) { break; } } KeyBindPanel.keyWarning = KeyCode.None; DebugMod.settings.binds[bind.Key] = (int)kc; KeyBindPanel.UpdateHelpText(); break; } } } else if (Input.GetKeyDown((KeyCode)bind.Value)) { try { ((MethodInfo)DebugMod.bindMethods[bind.Key].Second).Invoke(null, null); } catch (Exception e) { DebugMod.instance.LogError("Error running keybind method " + bind.Key + ":\n" + e.ToString()); } } } else { DebugMod.instance.LogWarn("Bind found without matching method, removing from binds: " + bind.Key); DebugMod.settings.binds.Remove(bind.Key); } } if (DebugMod.infiniteSoul && PlayerData.instance.MPCharge < PlayerData.instance.maxMP && PlayerData.instance.health > 0 && !HeroController.instance.cState.dead && GameManager.instance.IsGameplayScene()) { PlayerData.instance.MPCharge = PlayerData.instance.maxMP; } if (DebugMod.playerInvincible && PlayerData.instance != null) { PlayerData.instance.isInvincible = true; } if (DebugMod.noclip) { if (DebugMod.IH.inputActions.left.IsPressed) { DebugMod.noclipPos = new Vector3(DebugMod.noclipPos.x - Time.deltaTime * 20f, DebugMod.noclipPos.y, DebugMod.noclipPos.z); } if (DebugMod.IH.inputActions.right.IsPressed) { DebugMod.noclipPos = new Vector3(DebugMod.noclipPos.x + Time.deltaTime * 20f, DebugMod.noclipPos.y, DebugMod.noclipPos.z); } if (DebugMod.IH.inputActions.up.IsPressed) { DebugMod.noclipPos = new Vector3(DebugMod.noclipPos.x, DebugMod.noclipPos.y + Time.deltaTime * 20f, DebugMod.noclipPos.z); } if (DebugMod.IH.inputActions.down.IsPressed) { DebugMod.noclipPos = new Vector3(DebugMod.noclipPos.x, DebugMod.noclipPos.y - Time.deltaTime * 20f, DebugMod.noclipPos.z); } if (HeroController.instance.transitionState.ToString() == "WAITING_TO_TRANSITION") { DebugMod.RefKnight.transform.position = DebugMod.noclipPos; } else { DebugMod.noclipPos = DebugMod.RefKnight.transform.position; } } if (DebugMod.IH.inputActions.pause.WasPressed && DebugMod.GM.IsGamePaused()) { UIManager.instance.TogglePauseGame(); } if (DebugMod.cameraFollow) { BindableFunctions.cameraGameplayScene.SetValue(DebugMod.RefCamera, false); DebugMod.RefCamera.SnapTo(DebugMod.RefKnight.transform.position.x, DebugMod.RefKnight.transform.position.y); } if (PlayerDeathWatcher.PlayerDied()) { PlayerDeathWatcher.LogDeathDetails(); } if (PlayerData.instance.hazardRespawnLocation != hazardLocation) { hazardLocation = PlayerData.instance.hazardRespawnLocation; Console.AddLine("Hazard Respawn location updated: " + hazardLocation.ToString()); if (DebugMod.settings.EnemiesPanelVisible) { EnemiesPanel.EnemyUpdate(200f); } } if (!string.IsNullOrEmpty(respawnSceneWatch) && respawnSceneWatch != PlayerData.instance.respawnScene) { respawnSceneWatch = PlayerData.instance.respawnScene; Console.AddLine(string.Concat(new string[] { "Save Respawn updated, new scene: ", PlayerData.instance.respawnScene.ToString(), ", Map Zone: ", GameManager.instance.GetCurrentMapZone(), ", Respawn Marker: ", PlayerData.instance.respawnMarkerName.ToString() })); } } }
public static void EnemyScan() { EnemiesPanel.EnemyUpdate(200f); Console.AddLine("Refreshing collider data..."); }
public static void Update() { if (panel == null) { return; } if (DebugMod.GM.IsNonGameplayScene()) { if (panel.active) { panel.SetActive(false, true); } return; } if (DebugMod.settings.EnemiesPanelVisible && !panel.active) { panel.SetActive(true, false); } else if (!DebugMod.settings.EnemiesPanelVisible && panel.active) { panel.SetActive(false, true); } if (DebugMod.settings.EnemiesPanelVisible && UIManager.instance.uiState == UIState.PLAYING && (panel.GetPanel("Pause").active || !panel.GetPanel("Play").active)) { panel.GetPanel("Pause").SetActive(false, true); panel.GetPanel("Play").SetActive(true, false); } else if (DebugMod.settings.EnemiesPanelVisible && UIManager.instance.uiState == UIState.PAUSED && (!panel.GetPanel("Pause").active || panel.GetPanel("Play").active)) { panel.GetPanel("Pause").SetActive(true, false); panel.GetPanel("Play").SetActive(false, true); } if (!panel.active && enemyPool.Count > 0) { Reset(); } if (panel.active) { EnemiesPanel.CheckForAutoUpdate(); string enemyNames = ""; string enemyHP = ""; int enemyCount = 0; for (int i = 0; i < enemyPool.Count; i++) { EnemyData dat = enemyPool[i]; GameObject obj = dat.gameObject; if (obj == null || !obj.activeSelf) { if (obj == null) { dat.hpBar.Destroy(); dat.hitbox.Destroy(); enemyPool.RemoveAt(i); i--; } else { dat.hpBar.SetPosition(new Vector2(-1000f, -1000f)); } } else { int hp = dat.FSM.FsmVariables.GetFsmInt("HP").Value; if (hp != dat.HP) { dat.SetHP(hp); if (hpBars) { Texture2D tex = new Texture2D(120, 40); for (int x = 0; x < 120; x++) { for (int y = 0; y < 40; y++) { if (x < 3 || x > 116 || y < 3 || y > 36) { tex.SetPixel(x, y, Color.black); } else { if ((float)hp / (float)dat.maxHP >= (x - 2f) / 117f) { tex.SetPixel(x, y, Color.red); } else { tex.SetPixel(x, y, new Color(255f, 255f, 255f, 0f)); } } } } tex.Apply(); dat.hpBar.UpdateBackground(tex, new Rect(0, 0, 120, 40)); } } if (hitboxes) { if ((dat.Spr as tk2dSprite).boxCollider2D != null) { BoxCollider2D boxCollider2D = (dat.Spr as tk2dSprite).boxCollider2D; Bounds bounds2 = boxCollider2D.bounds; float width = Math.Abs(bounds2.max.x - bounds2.min.x); float height = Math.Abs(bounds2.max.y - bounds2.min.y); Vector2 position = Camera.main.WorldToScreenPoint(boxCollider2D.transform.position + new Vector3(boxCollider2D.offset.x, boxCollider2D.offset.y, 0f)); Vector2 size = Camera.main.WorldToScreenPoint(boxCollider2D.transform.position + new Vector3(width, height, 0)); size -= position; Quaternion rot = boxCollider2D.transform.rotation; rot.eulerAngles = new Vector3(Mathf.Round(rot.eulerAngles.x / 90) * 90, Mathf.Round(rot.eulerAngles.y / 90) * 90, Mathf.Round(rot.eulerAngles.z / 90) * 90); Vector2 pivot = Camera.main.WorldToScreenPoint(boxCollider2D.transform.position); Vector2 pointA = Camera.main.WorldToScreenPoint((Vector2)boxCollider2D.transform.position + boxCollider2D.offset); pointA.x -= size.x / 2f; pointA.y -= size.y / 2f; Vector2 pointB = pointA + size; pointA = (Vector2)(rot * (pointA - pivot)) + pivot; pointB = (Vector2)(rot * (pointB - pivot)) + pivot; position = new Vector2(pointA.x <pointB.x?pointA.x : pointB.x, pointA.y> pointB.y ? pointA.y : pointB.y); size = new Vector2(Math.Abs(pointA.x - pointB.x), Math.Abs(pointA.y - pointB.y)); size.x *= 1920f / Screen.width; size.y *= 1080f / Screen.height; position.x *= 1920f / Screen.width; position.y *= 1080f / Screen.height; position.y = 1080f - position.y; dat.hitbox.SetPosition(position); dat.hitbox.ResizeBG(size); } if (!dat.hitbox.active) { dat.hitbox.SetActive(true, true); } } if (hpBars) { Vector2 enemyPos = Camera.main.WorldToScreenPoint(obj.transform.position); enemyPos.x *= 1920f / Screen.width; enemyPos.y *= 1080f / Screen.height; enemyPos.y = 1080f - enemyPos.y; Bounds bounds = (dat.Spr as tk2dSprite).GetBounds(); enemyPos.y -= (Camera.main.WorldToScreenPoint(bounds.max).y *(1080f / Screen.height) - Camera.main.WorldToScreenPoint(bounds.min).y *(1080f / Screen.height)) / 2f; enemyPos.x -= 60; dat.hpBar.SetPosition(enemyPos); dat.hpBar.GetText("HP").UpdateText(dat.FSM.FsmVariables.GetFsmInt("HP").Value + "/" + dat.maxHP); if (!dat.hpBar.active) { dat.hpBar.SetActive(true, true); } } if (!hpBars && dat.hpBar.active) { dat.hpBar.SetActive(false, true); } if (!hitboxes && dat.hitbox.active) { dat.hitbox.SetActive(false, true); } if (++enemyCount <= 14) { enemyNames += obj.name + "\n"; enemyHP += dat.FSM.FsmVariables.GetFsmInt("HP").Value + "/" + dat.maxHP + "\n"; } } } if (panel.GetPanel("Pause").active) { for (int i = 1; i <= 14; i++) { if (i <= enemyCount) { panel.GetPanel("Pause").GetButton("Del" + i).SetActive(true); panel.GetPanel("Pause").GetButton("Clone" + i).SetActive(true); panel.GetPanel("Pause").GetButton("Inf" + i).SetActive(true); } else { panel.GetPanel("Pause").GetButton("Del" + i).SetActive(false); panel.GetPanel("Pause").GetButton("Clone" + i).SetActive(false); panel.GetPanel("Pause").GetButton("Inf" + i).SetActive(false); } } panel.GetPanel("Pause").GetButton("Collision").SetTextColor(hitboxes ? new Color(244f / 255f, 127f / 255f, 32f / 255f) : Color.white); panel.GetPanel("Pause").GetButton("HP Bars").SetTextColor(hpBars ? new Color(244f / 255f, 127f / 255f, 32f / 255f) : Color.white); panel.GetPanel("Pause").GetButton("Auto").SetTextColor(autoUpdate ? new Color(244f / 255f, 127f / 255f, 32f / 255f) : Color.white); } if (enemyCount > 14) { enemyNames += "And " + (enemyCount - 14) + " more"; } panel.GetText("Enemy Names").UpdateText(enemyNames); panel.GetText("Enemy HP").UpdateText(enemyHP); } }