public void DialogueEventInsideBattle(DialogueBattleClass dialogueData) { dialogueAnimator = dialogueContainer.GetComponent <Animator>(); dialogueContainer.SetActive(true); if (!dialogueInitialization) { startTime = Time.time; endAnimCheck = dialogueContainer.GetComponent <CheckForAnimationFinish>(); dialogueInitialization = true; } if (trackDialogue < dialogueData.allDialogueForEvent.Length) { switch (dialogueData.allDialogueForEvent[trackDialogue].animationIntroTrigger) { case (DialogueAnimatorChoice.AnimateInFromLeft): if (trackDialogue == 0) { dialogueAnimator.SetBool("EnterLeft", true); } else if (dialogueData.allDialogueForEvent[trackDialogue - 1].animationIntroTrigger == DialogueAnimatorChoice.AnimateInFromRight) { dialogueAnimator.SetBool("EnterRight", false); dialogueAnimator.SetBool("ExitLeft", false); dialogueAnimator.SetBool("ExitRight", true); dialogueAnimator.SetBool("EnterLeft", true); } break; case (DialogueAnimatorChoice.AnimateInFromRight): if (trackDialogue == 0) { dialogueAnimator.SetBool("EnterRight", true); } else if (dialogueData.allDialogueForEvent[trackDialogue - 1].animationIntroTrigger == DialogueAnimatorChoice.AnimateInFromLeft) { dialogueAnimator.SetBool("EnterRight", true); dialogueAnimator.SetBool("ExitLeft", true); dialogueAnimator.SetBool("ExitRight", false); dialogueAnimator.SetBool("EnterLeft", false); } break; } if (trackDialogue == 0) { speakerName.text = dialogueData.allDialogueForEvent[trackDialogue].speakerName; timeStamp.text = dialogueData.allDialogueForEvent[trackDialogue].timestamp; bodyText.text = dialogueData.allDialogueForEvent[trackDialogue].textToSay; dialogueData.allDialogueForEvent[trackDialogue].characterImage.SetActive(true); endAnimCheck.moveIsFinished = false; } else { if (endAnimCheck.moveIsFinished) { speakerName.text = dialogueData.allDialogueForEvent[trackDialogue].speakerName; timeStamp.text = dialogueData.allDialogueForEvent[trackDialogue].timestamp; bodyText.text = dialogueData.allDialogueForEvent[trackDialogue].textToSay; dialogueData.allDialogueForEvent[trackDialogue - 1].characterImage.SetActive(false); dialogueData.allDialogueForEvent[trackDialogue].characterImage.SetActive(true); endAnimCheck.moveIsFinished = false; } } if (Input.GetKeyDown("space")) { trackDialogue++; } /*else if (Time.time - startTime >= dialogueData.allDialogueForEvent[trackDialogue].timeToSay) * { * startTime = Time.time; * trackDialogue++; * }*/ } else { switch (dialogueData.allDialogueForEvent[trackDialogue - 1].animationIntroTrigger) { case (DialogueAnimatorChoice.AnimateInFromLeft): dialogueAnimator.SetBool("ExitLeft", true); break; case (DialogueAnimatorChoice.AnimateInFromRight): dialogueAnimator.SetBool("ExitRight", true); break; } if (endAnimCheck.moveIsFinished) { endAnimCheck.moveIsFinished = false; dialogueAnimator.SetBool("EnterRight", false); dialogueAnimator.SetBool("ExitLeft", false); dialogueAnimator.SetBool("ExitRight", false); dialogueAnimator.SetBool("EnterLeft", false); dialogueData.allDialogueForEvent[trackDialogue - 1].characterImage.SetActive(false); dialogueContainer.SetActive(false); trackDialogue = 0; dialogueInitialization = false; battleSystem.dialogueConditionIsMet = false; dialogueData.thisEventIsDone = true; //gameLoop.dialogueInstance = null; //gameLoop.isDialogue = false; //gameLoop.isRunning = true; } } }
public void battleUpdate() { battleConditions = gameLoop.battleEncounterInstance.gameObject.GetComponents <DialogueBattleClass>(); foreach (DialogueBattleClass eventParams in battleConditions) { switch (eventParams.condition) { case (DialogueBattleConditions.BattleBeginning): if (beginningInitIsOver && !eventParams.thisEventIsDone) { dialogueConditionIsMet = true; chosenDialogueEvent = eventParams; } break; case (DialogueBattleConditions.OnTurnX): if (eventParams.turnForDialogue == turnTracker && !eventParams.thisEventIsDone) { dialogueConditionIsMet = true; chosenDialogueEvent = eventParams; } break; case (DialogueBattleConditions.EnemyHealthIs): break; case (DialogueBattleConditions.PlayerHealthIs): break; case (DialogueBattleConditions.EndBattle): break; } } if (!dialogueConditionIsMet) { if (currentState == BattleStates.INTRO) { if (!firstPassPosition) { playerStartTravelTime = Time.time; playerTravelDistance = Vector3.Distance(playerPrefab.transform.parent.position, gameLoop.battleEncounterInstance.playerPosition.position); firstPassPosition = true; containerBackInOriginalPosition = false; } float distCovered = (Time.time - playerStartTravelTime) * playerTravelSpeed; float fracTraveled = distCovered / playerTravelDistance; playerPrefab.transform.parent.position = Vector3.Lerp(playerPrefab.transform.parent.position, gameLoop.battleEncounterInstance.playerPosition.position, fracTraveled); if (playerPrefab.transform.parent.position == gameLoop.battleEncounterInstance.playerPosition.position) { currentState = BattleStates.START; beginningInitIsOver = true; camMovementScript.enabled = !camMovementScript.enabled; firstPassPosition = false; } } else if (currentState == BattleStates.START) { moveNamesHolder.SetActive(true); Move01Text.text = participantList[currentHero].Move01Name; Move02Text.text = participantList[currentHero].Move02Name; UltimateText.text = participantList[currentHero].UltimateName; if (Input.GetButtonDown("a") && participantList[currentHero].proceedNext == false) { useMove01 = true; } else if (Input.GetButtonDown("s") && participantList[currentHero].proceedNext == false) { useMove02 = true; } else if (Input.GetButtonDown("d") && participantList[currentHero].proceedNext == false) { if (participantList[currentHero].UltimateLimitRequirement <= limitBreakCollection.limitBreakCurrent) { limitBreakCollection.limitBreakCurrent -= participantList[currentHero].UltimateLimitRequirement; Transform limitBarHolder = playerPrefab.transform.parent.Find("Canvas/LimitBreakBar"); Image limitBar = limitBarHolder.gameObject.GetComponent <Image>(); limitBar.fillAmount = (float)gameManager.GetComponent <LimitBreakCollection>().limitBreakCurrent / (float)gameManager.GetComponent <LimitBreakCollection>().limitBreakMax; useUltimate = true; } else { Debug.Log(participantList[currentHero].UltimateLimitRequirement + " ::: " + limitBreakCollection.limitBreakCurrent); moveNamesHolder.GetComponent <Animator>().SetTrigger("fire"); } } } switch (currentState) { case (BattleStates.INTRO): // Handle taking hero from running state to battle state. // Intro main character animation. introActions(); break; case (BattleStates.START): // Load in party members. // Party member intro animations. // Load in enemies. // Enemy intro animations. // Load in UI. // Order turn priorities. // Check who has turn priority and proceed to proper state. startActions(); break; case (BattleStates.PLAYERCHOICE): // Prompt player to choose a move within time limit. // Move should handle 'mini game.' Call move in player class. // Move to PLAYERANIMATE. break; case (BattleStates.PLAYERANIMATE): // Call player animation for move. // Call actual mini game for move from player. // Move to action summary. break; case (BattleStates.PLAYERACTIONSUMMARY): // Calculate damage done. // Apply damage done. // Play damage taken animations. // Check if enemy has taken lethal damage. // Move to appropriate state (win/player choice/enemy choice). break; case (BattleStates.ENEMYCHOICE): // Select ability to use. Maybe some abilities can be dodged / negated? // Move to enemy animate. break; case (BattleStates.ENEMYANIMATE): // Animate enemy. // Player mini game. // Move to action summary. break; case (BattleStates.ENEMYACTIONSUMMARY): // Calculate damage done. // Apply damage done. // Play damage taken animations. // Check if any player has taken lethal damage. // Move to appropriate state. (lose/player choice/enemy choice) break; case (BattleStates.LOSE): // Tell player they've lost. Animation? YOU DIED // Revert back to last checkpoint. loseActions(); break; case (BattleStates.WIN): // Winning animations. // Deload party animations. Move player back to center at same time. // Change from battle state controllers to running controller. winActions(); break; } // Actions allowable to dodge abilities. IE: Jumping and position shifting //if (participantList[currentHero].isEnemy) // Jump if (baseRunner.canJump && Input.GetButtonDown("Jump") && participantList[currentHero].isEnemy && currentState != BattleStates.WIN) { baseRunner.dynamicJumpImpulse = baseRunner.initialJumpImpulse; baseRunner.currentTimeToHoldJump = Time.time; baseRunner.triggerJump = true; baseRunner.letGoOfSpace = false; baseRunner.trackJump++; if (baseRunner.trackJump == 1) { baseRunner.runner.SetBool("Grounded Running", false); baseRunner.runner.SetTrigger("Jump"); } else if (baseRunner.trackJump == 2) { baseRunner.runner.SetTrigger("DoubleJump"); } } if (Input.GetKeyUp("space") && participantList[currentHero].isEnemy) { baseRunner.letGoOfSpace = true; baseRunner.fallVelocityDecay = 0; baseRunner.dynamicJumpImpulse = 0; baseRunner.triggerJump = false; } // Double jump. if (baseRunner.trackJump == baseRunner.numberOfJumps) { baseRunner.canJump = false; baseRunner.trackJump = 0; } // Stuff when returning to ground. if (baseRunner.grounded) { if (baseRunner.runner.GetBool("Grounded Running") == false) { baseRunner.runner.SetTrigger("FireEvent"); baseRunner.runner.SetBool("Grounded Running", true); } baseRunner.isFalling = false; baseRunner.fallVelocityDecay = 0; } // Right dash if (participantList[currentHero].isEnemy && currentState != BattleStates.WIN && currentState != BattleStates.LOSE) { if (Input.GetKeyDown("right") && dashPositionTracker < 1) { dashPositionTracker++; playerContainerObject.transform.position = new Vector3(playerContainerObject.transform.position.x + 2.0f, playerContainerObject.transform.position.y, playerContainerObject.transform.position.z); } if (Input.GetKeyDown("left") && dashPositionTracker > -1) { dashPositionTracker--; playerContainerObject.transform.position = new Vector3(playerContainerObject.transform.position.x - 2.0f, playerContainerObject.transform.position.y, playerContainerObject.transform.position.z); } } } // dialogue condition is met here vvv else { dialogueManager.DialogueEventInsideBattle(chosenDialogueEvent); } }