public static IEnumerator RestartBattleCoroutine(BattleHud battleHud) { // Get managers from battleHud private fields CombatManager combatManager = Traverse.Create(battleHud).Field("combatManager").GetValue <CombatManager>(); GameStateManager gameStateManager = Traverse.Create(combatManager).Field("gameStateManager").GetValue <GameStateManager>(); SaveManager saveManager = Traverse.Create(combatManager).Field("saveManager").GetValue <SaveManager>(); ScreenManager screenManager = Traverse.Create(battleHud).Field("screenManager").GetValue <ScreenManager>(); CardManager cardManager = Traverse.Create(battleHud).Field("cardManager").GetValue <CardManager>(); CardStatistics cardStatistics = Traverse.Create(cardManager).Field("cardStatistics").GetValue <CardStatistics>(); // Get the current type of run that you're playing RunType runType = Traverse.Create(saveManager).Field("activeRunType").GetValue <RunType>(); string sharecode = Traverse.Create(saveManager).Field("activeSharecode").GetValue <string>(); // Return to the main menu // Note: Copied from PauseDialog.ReturnToMainMenu() gameStateManager.LeaveGame(); screenManager.ReturnToMainMenu(); cardStatistics.ResetAllStats(); // Wait until the main menu is loaded yield return(new WaitUntil(() => SceneManager.GetActiveScene().name == "main_menu" && SceneManager.GetActiveScene().isLoaded)); yield return(null); yield return(null); yield return(null); // Resume your battle from the main menu gameStateManager.ContinueRun(runType, sharecode); }
public PlayBattleState(BattleSceneController BattleSceneControllerRef) : base(BattleSceneControllerRef) { BattleSystem.Get().OnTimerFinished += SetNextState; BattleSystem.Get().SetPlayBattleState(); BattleHud.Get().SetPlayBattleState(); }
public InitialBattleState(BattleSceneController BattleSceneControllerRef) : base(BattleSceneControllerRef) { BattleHud.Get().SetInitialBattleState(); BattleSystem.Get().SetInitialBattleState(); BattleSceneControllerCached.BattleState = new MainBattleState(BattleSceneControllerCached); }
private void Start() { BattleSystem.Get().OnBattleFinished += OnBattleFinished; BattleView.Initialize(); BattleHud.Get().Initialize(); BattleState = new InitialBattleState(this); }
public MainBattleState(BattleSceneController BattleSceneControllerRef) : base(BattleSceneControllerRef) { BattleHud.Get().OnPlayBattleButtonEvent += SetPlayState; WindowManager.OnDiscardWindowOpened += SetDiscardState; BattleSystem.Get().SetMainBattleState(); BattleSceneControllerRef.BattleView.SetBattleCardsControlStrategy(); }
IEnumerator DealDamage(int dam, BattleHud hud, int hp) { float delay = 1f / dam; for (int i = 0; i < dam; i++) { yield return(new WaitForSeconds(delay)); //this causes the hp bar to drain over time hp--; enemyHud.setHP(hp); } }
//--------------------------------------------------------------------- // Create the restart battle button //--------------------------------------------------------------------- /// <summary> /// Copy the "end turn" button and modify it to be the "restart battle" button. /// </summary> public static void Create(BattleHud battleHud) { // Don't create button if we're doing a hell rush if (Traverse.Create(Traverse.Create(battleHud).Field("combatManager").GetValue <CombatManager>()).Field("saveManager").GetValue <SaveManager>().IsBattleMode()) { return; } // Get BattleHud private fields EndTurnUI endTurnButton = Traverse.Create(battleHud).Field("endTurnButton").GetValue <EndTurnUI>(); EnergyUI energyUI = Traverse.Create(battleHud).Field("energyUI").GetValue <EnergyUI>(); CardPileCountUI deckUI = Traverse.Create(battleHud).Field("deckUI").GetValue <CardPileCountUI>(); // Copy end turn game object GameObject buttonRoot = GameObject.Instantiate(endTurnButton.gameObject, energyUI.transform.parent) as GameObject; buttonRoot.name = "RestartBattleButton"; // Delete unwanted game objects and components DeleteUnwanted(buttonRoot); // Set position to in the corner next to the ember RectTransform transRoot = buttonRoot.transform as RectTransform; RectTransform transEmber = energyUI.transform as RectTransform; transRoot.anchorMin = transEmber.anchorMin; transRoot.anchorMax = transEmber.anchorMax; transRoot.anchoredPosition = transEmber.anchoredPosition; transRoot.sizeDelta = transEmber.sizeDelta; buttonRoot.transform.position = new Vector3( Mathf.LerpUnclamped(deckUI.transform.position.x, energyUI.transform.position.x, 1.75f), Mathf.LerpUnclamped(deckUI.transform.position.y, energyUI.transform.position.y, -0.1f), buttonRoot.transform.position.z); // Make it a bit smaller than the "End Turn" button buttonRoot.transform.localScale = new Vector3(.6f, .6f, buttonRoot.transform.localScale.z); // Clear shortcut key so "End Turn" keyboard shortcut doesn't trigger restart battle GameUISelectableButton restartBattleButton = buttonRoot.GetComponent <GameUISelectableButton>(); Traverse.Create(restartBattleButton).Field("inputType").SetValue((int)InputManager.Controls.NONE); // Set button text to "Restart Battle" TextMeshProUGUI textMeshPro = buttonRoot.GetComponentInChildren <TextMeshProUGUI>(); textMeshPro.text = "Restart Battle"; // Add RestartBattleButton to handle the button click restartBattleButton.gameObject.AddComponent <RestartBattleButton>(); }
private void OnEnable() { Note = transform.parent.Find("Note").gameObject; playerHUD = transform.parent.Find("BattleUI").Find("PlayerHealth").GetComponent <BattleHud>(); enemyHUD = transform.parent.Find("BattleUI").Find("EnemyHealth").GetComponent <BattleHud>(); PlayerShadow = playerHUD.transform.Find("PlayerShadow"); EnemyShadow = enemyHUD.transform.Find("EnemyShadow"); nameText = playerHUD.gameObject.transform.Find("Name").GetComponent <Text>(); turnText = transform.parent.Find("Turn").GetComponent <Text>(); BackButton = Note.transform.Find("Back").GetComponent <Button>(); BackButton.onClick.AddListener(OnBackButton); levelScript = transform.parent.parent.parent.gameObject.GetComponent <Level>(); state = BattleState.START; StartCoroutine(SetupBattle()); Note.SetActive(false); }
// Use this for initialization void Awake() { characterControl = GameObject .Find("Player1") .GetComponent <CharacterControl>(); characterControl.MyFolderInBattle = this; battleHud = GameObject .Find("HUD") .GetComponent <BattleHud>(); gamestate = GameObject .Find("Gamestate") .GetComponent <Gamestate>(); inUseChips = new string[4]; LoadCurrentEquippedFolder(); RandomizeFolder(); //SetSelectionScreenChips(); }
public void RegenerateBoard() { List <CardWrapper> alliedCards = null; alliedCards = BoardCached.AlliedTimeline?.RemoveCardsFromTimeline(); BoardCached.RegenerateTimelinesAndTimerView(); if (alliedCards != null) { foreach (CardWrapper card in alliedCards) { if (!BoardCached.AlliedTimeline.TryAddCard(card)) { HandCached.AddCard(card); } } } BattleHud.Get().UpdateStatuses(GetStatusPosition(BoardCached.AlliedTimeline), GetStatusPosition(BoardCached.EnemyTimeline)); }
public void Start() { hud = gameObject.GetComponentInChildren <BattleHud>(); }
public LoseBattleState(BattleSceneController BattleSceneControllerRef) : base(BattleSceneControllerRef) { BattleSystem.Get().StopBattleTimer(); BattleHud.Get().OpenWindow <LoseWindow>(); }
private void UnsubscribeAll() { BattleHud.Get().OnPlayBattleButtonEvent -= SetPlayState; WindowManager.OnDiscardWindowOpened -= SetDiscardState; }
private void SetupHud() { battleHud = battleHudObject.GetComponent <BattleHud>(); battleHud.Initialise(partyUnits); }
private void Start() { _battleHud = GetComponentInParent <BattleHud>(); _restartBattleButton = GetComponent <GameUISelectableButton>(); UISignals.GameUITriggered.AddListener(OnGameUITriggered); }
// When the BattleHud starts, create game objects under it that make up the "restart battle" button private static void Postfix(BattleHud __instance) { RestartBattleButton.Create(__instance); }
//setters public void SetHud(BattleHud hud) { battleHud = hud; }
/// <summary> /// Initializes GameObjects containing HUD elements /// </summary> void InitializeHudObjects() { battleHud = GameObject.Find("HUD").GetComponent <BattleHud>(); battleCardSelection = GameObject.Find("HUD").GetComponent <BattleCardSelection>(); }