void StartRetreatJumpTranslation() { _currentJumpState = PlayerSpriteJumpState.Retreating; _timeElapsed = 0; //StartJumpAnimation(_activeSpriteScript); }
public void PrepForBattle(bool bIsPVP, float StartingHealth, int wVictoriesNeededToWin, int wCurrentVictores) { _bIsPVP = bIsPVP; RefreshHealth(StartingHealth, StartingHealth); if (_bIsPVP) { PVESpritePanel.SetActive(true); PVPSpritePanel.SetActive(false); } else { PVESpritePanel.SetActive(false); PVPSpritePanel.SetActive(true); } if (wVictoriesNeededToWin <= 1) { //If the party only needs one victory to win, then we don't need to keep count of victories for (int i = 1; i <= 4; i++) { GetVictorySprite(i).SetActive(false); } } else { //We only support up to 3 victories per player. Because we're lazy coders for (int i = 1; i <= 4; i++) { if (i <= wVictoriesNeededToWin) { //Show this sprite GetVictorySprite(i).SetActive(true); //Tell it whether to make it bright or make it boring. if (i <= wCurrentVictores) { //The party has already won this many games. Make it shine! GetVictorySprite(i).GetComponent <Renderer>().material = SpriteActiveMaterial; } else { //The party has yet to win this many games. Make it dull. GetVictorySprite(i).GetComponent <Renderer>().material = SpriteSubdueMaterial; } } else { //Hide this sprite. It's more than we need. GetVictorySprite(i).SetActive(false); } } } _currentJumpState = PlayerSpriteJumpState.None; //Reset jumper positions ResetAllJumpPositions(); }
void StopJumpTranslation() { _timeElapsed = 0; _currentJumpState = PlayerSpriteJumpState.None; EndJumpAnimation(_activeSpriteScript); //SendPressNotification(); }
void StartPressingTranslation() { _timeElapsed = 0; _currentJumpState = PlayerSpriteJumpState.Pressing; //EndJumpAnimation(_activeSpriteScript); SendPressNotification(); }
void StartAttackJumpTranslation(PlayerSprite player) { StartJumpAnimation(_activeSpriteScript); Transform playerSpriteTransform = GetPlayerSpriteTransform(player); if (playerSpriteTransform != null) { _activePlayerSpriteStartPosition = GetStartPosition(player); _currentJumpState = PlayerSpriteJumpState.Attacking; _timeElapsed = 0; } }
Vector3 GetJumpingSpritePositon(PlayerSpriteJumpState jumpState, float timeElapsed, float jumpDuration, Vector3 currentStartPosition, Vector3 buttonPosition) { if (jumpState == PlayerSpriteJumpState.None) { //Don't do anything. No jump is happening. This should never even be called. return(currentStartPosition); } else if (jumpState == PlayerSpriteJumpState.Pressing) { //He's standing on the button for just a split second. //Just have him hold the standing point. return(buttonPosition); } else { if (timeElapsed > jumpDuration) { timeElapsed = jumpDuration; } //Jumping, either towards or away. Render the current position. Vector3 startPoint; Vector3 endPoint; if (jumpState == PlayerSpriteJumpState.Attacking) { startPoint = currentStartPosition; endPoint = buttonPosition; } else { startPoint = buttonPosition; endPoint = currentStartPosition; } float x = startPoint.x + (((endPoint.x - startPoint.x) / jumpDuration) * timeElapsed); float y = startPoint.y + (((endPoint.y - startPoint.y) / jumpDuration) * timeElapsed); float z = startPoint.z; //Y bonus parabola float ybonus = 1 - ((4 / (jumpDuration * jumpDuration)) * Mathf.Pow((timeElapsed - (jumpDuration / 2)), 2)); ybonus *= JumpYMultiplier; return(new Vector3(x, y + ybonus, z)); } }
// Use this for initialization void Awake() { _healthBar = gameObject.GetComponentInChildren <HealthBar>(true); _audioSource = GetComponent <AudioSource>(); //If we have to add multiple text boxes then we will need this script to sort through them and select the proper textbox Text[] textBoxes = gameObject.GetComponentsInChildren <Text>(true); if (textBoxes != null) { foreach (Text text in textBoxes) { if (text.gameObject.name == "PlayerHealthText") { _healthText = text; break; } } } PVPSprite[] pvpSprites = gameObject.GetComponentsInChildren <PVPSprite>(true); if (pvpSprites != null) { foreach (PVPSprite x in pvpSprites) { if (x.gameObject.name == "PVP1") { _pvp1 = x; } else if (x.gameObject.name == "PVP2") { _pvp2 = x; } } } _activeSpriteScript = null; _currentJumpState = PlayerSpriteJumpState.None; SetJumpStartPositions(); _characterSpriteEndPosition = new Vector3(ButtonX, ButtonY, 1); }