IEnumerator PlayerDeathSequence() { MomentumManager.ResetMomentum(); float fadeOutCompleteTime = Time.time + playerDeathFadeScreenTimer; while (Time.time < fadeOutCompleteTime) { float timeRemaining = fadeOutCompleteTime - Time.time; float percentageComplete = timeRemaining / playerDeathFadeScreenTimer; Color fadeColor = FadeScreen.color; fadeColor.a = Mathf.Lerp(1f, 0f, percentageComplete); FadeScreen.color = fadeColor; yield return(null); } Color finalFadeColor = FadeScreen.color; finalFadeColor.a = 1f; FadeScreen.color = finalFadeColor; MuteAllEmitters(); GlobalEventEmitter.OnGameStateEvent(GlobalConstants.GameStateEvents.PlayerDied); UnmuteAllEmitters(); playerTransform.position = currentlyActiveLevel.SpawnPoint.position; yield return(new WaitForSeconds(3f)); float fadeBackTimer = playerDeathFadeScreenTimer / 2f; float fadeBackCompleteTime = Time.time + fadeBackTimer; // TODO: move this to dedicated scene-change logic SceneManager.LoadScene(SceneManager.GetActiveScene().name); GlobalEventEmitter.OnGameStateEvent(GlobalConstants.GameStateEvents.NewSceneLoaded); EntityEmitter playerEntityEmitter = Player.GetComponent <EntityEmitter>(); playerEntityEmitter.isMuted = false; playerEntityEmitter.EmitEvent(EntityEvents.Respawning); while (Time.time < fadeBackCompleteTime) { float timeRemaining = fadeBackCompleteTime - Time.time; float percentageComplete = timeRemaining / fadeBackTimer; Color fadeColor = FadeScreen.color; fadeColor.a = Mathf.Lerp(0f, 1f, percentageComplete); FadeScreen.color = fadeColor; yield return(null); } }
void UpdateAbilityMomentumCounters(MomentumData newMomentumData) { HardwareType[] allEquippedActiveHardware = InventoryController.GetEquippedActiveHardware(); for (int i = 0; i < abilityMomentumCounters.Length; i++) { HardwareType activeHardwareType = allEquippedActiveHardware[i]; if (activeHardwareType != HardwareType.None) { int newMomentumValue = MomentumManager.GetMomentumPointsByHardwareType(activeHardwareType); if (newMomentumValue != displayedMomentumValues[i]) { Color flashColor = newMomentumValue > displayedMomentumValues[i] ? momentumIncreasedFlashColor : momentumDecreasedFlashColor; Image momentumCounterImage = abilityMomentumCounters[i].GetComponent <Image>(); Sprite counterSprite = Resources.Load <Sprite>(MOMENTUM_COUNTER_PATH + newMomentumValue.ToString()); momentumCounterImage.sprite = counterSprite; StartCoroutine(FlashAbilityMomentumCounter(momentumCounterImage, flashColor)); displayedMomentumValues[i] = newMomentumValue; } } } }
IEnumerator HandleDamage() { float recoveredTime = Time.time + recoveryTime; while (Time.time < recoveredTime) { yield return(null); } if (isPlayer) { MomentumManager.RemoveLastMomentumPoint(); } if (!isDead) { // Once entity has recovered, disable physics and resume action. for (int i = 0; i < renderersCount; i++) { renderers[i].material = defaultMaterials[i]; } entityInformation.EntityRigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ; } yield break; }
void TryToAssignMomentumPoint(int abilityIndex) { HardwareType equippedHardwareType = InventoryController.GetEquippedActiveHardware()[abilityIndex]; if (equippedHardwareType != HardwareType.None) { MomentumManager.AssignMomentumPointToHardware(equippedHardwareType); } }
private void Awake() { i = this; library = FindObjectOfType <Library>(); momentumManager = FindObjectOfType <MomentumManager>(); levelManager = FindObjectOfType <LevelManager>(); ballManager = FindObjectOfType <BallManager>(); enemySpawner = FindObjectOfType <EnemySpawner>(); soundManager = FindObjectOfType <SoundManager>(); comboManager = FindObjectOfType <ComboManager>(); ControlAllPlayers(); }
private void UpdateStackAmount() { if (currentStackAmount < maxStackAmount) { float fillQuantity = (float)currentStackAmount / (float)maxStackAmount; float dashRecoverySpeedMultiplier = Mathf.Lerp(minStackRecoverySpeedMultiplier, maxStackRecoverySpeedMultiplier, dashRecoverySpeedCurve.Evaluate(fillQuantity)); currentStackCooldown += Time.deltaTime * MomentumManager.GetValue(MomentumManager.datas.dashRecoverSpeedMultiplier) * dashRecoverySpeedMultiplier; if (currentStackCooldown >= defaultStackRecoveryDuration) { currentStackCooldown = 0; currentStackAmount += 1; FeedbackManager.SendFeedback("event.DashStackIncreased", linkedPawn); } } }
public float GetSpeedCoef() { float i_speedCoef = 1; foreach (SpeedCoef i_coef in speedCoefs) { i_speedCoef *= i_coef.speedCoef; } if (isPlayer) { i_speedCoef *= MomentumManager.GetValue(MomentumManager.datas.playerSpeedMultiplier); } else { i_speedCoef *= MomentumManager.GetValue(MomentumManager.datas.enemySpeedMultiplier); } return(i_speedCoef); }
public IEnumerator Vibrate_C(PlayerIndex _playerIndex, float _duration, VibrationForce _force, AnimationCurve _forceCurve, float _settingsVibrationModificator) { float i_momentumMultiplier; #if !UNITY_EDITOR i_momentumMultiplier = MomentumManager.GetValue(MomentumManager.datas.vibrationMultiplier); #endif #if UNITY_EDITOR i_momentumMultiplier = 1f; #endif for (float i = 0; i < _duration; i += Time.deltaTime) { float forceCurveMultiplier = (_forceCurve.Evaluate(i / _duration)) * _settingsVibrationModificator; switch (_force) { case VibrationForce.VeryLight: GamePad.SetVibration(_playerIndex, 0.1f * i_momentumMultiplier * forceCurveMultiplier, 0.1f * i_momentumMultiplier * forceCurveMultiplier); break; case VibrationForce.Light: GamePad.SetVibration(_playerIndex, 0.2f * i_momentumMultiplier * forceCurveMultiplier, 0.2f * i_momentumMultiplier * forceCurveMultiplier); break; case VibrationForce.Medium: GamePad.SetVibration(_playerIndex, 0.3f * i_momentumMultiplier * forceCurveMultiplier, 0.3f * i_momentumMultiplier * forceCurveMultiplier); break; case VibrationForce.Heavy: GamePad.SetVibration(_playerIndex, 0.4f * i_momentumMultiplier * forceCurveMultiplier, 0.4f * i_momentumMultiplier * forceCurveMultiplier); break; case VibrationForce.VeryHeavy: GamePad.SetVibration(_playerIndex, 0.5f * i_momentumMultiplier * forceCurveMultiplier, 0.5f * i_momentumMultiplier * forceCurveMultiplier); break; } yield return(new WaitForEndOfFrame()); } GamePad.SetVibration(_playerIndex, 0f, 0f); DestroyImmediate(this.gameObject); }
public void OnHit(BallBehaviour _ball, Vector3 _impactVector, PawnController _thrower, float _damages, DamageSource _source, Vector3 _bumpModificators = default(Vector3)) { if (_ball != null) { if (_ball.isGhostBall) { return; } } if ((_source == DamageSource.Ball | _source == DamageSource.Dunk) & !shutDown) { if (MomentumManager.GetMomentum() >= puzzleData.nbMomentumNeededToLink) { if (fX_Linked != null) { Destroy(fX_Linked); } if (fX_LinkEnd != null) { Destroy(fX_LinkEnd); } fX_Linked = FeedbackManager.SendFeedback("event.PuzzleLinkActivated", this, transform.position, _impactVector, _impactVector).GetVFX(); if (fX_Activation == null) { fX_Activation = FeedbackManager.SendFeedback("event.PuzzleLinkActivation", this, transform.position, _impactVector, _impactVector).GetVFX(); } MomentumManager.DecreaseMomentum(puzzleData.nbMomentumLooseWhenLink); chargingTime = nbSecondsLinkMaintained; isActivated = true; myAnim.SetBool("Awaken", true); myAnim.SetBool("IsActivated", true); ActivateLinkedObjects(); } } }
private void Update() { _virtualCamera = GetVirtualCamera(); if (_virtualCamera == null) { return; } currentShake = CameraShaker.currentShake; CameraShaker.UpdateShakes(); if (currentShake != null) { float i_momentumMultiplier = MomentumManager.GetValue(MomentumManager.datas.screenShakeMultiplier); float i_curveMultiplier = currentShake.intensityCurve.Evaluate(1f - (currentShake.durationLeft / currentShake.duration)); _perlin.m_AmplitudeGain = currentShake.intensity * i_momentumMultiplier * i_curveMultiplier; _perlin.m_FrequencyGain = currentShake.frequency * i_curveMultiplier; } else { _perlin.m_AmplitudeGain = 0; _perlin.m_FrequencyGain = 0; } }
public virtual void Damage(float _amount, bool enableInvincibilityFrame = false) { if (!CanDamage()) { return; } if (enableInvincibilityFrame) { SetInvincible(); } FeedbackManager.SendFeedback(eventOnBeingHit, this, transform.position, transform.up, transform.up); currentHealth -= _amount; if (currentHealth <= 0) { Kill(); } if (isPlayer) { MomentumManager.DecreaseMomentum(MomentumManager.datas.momentumLossOnDamage); } }
private void UpdateBallPosition() { switch (ballInformations.state) { case BallState.Flying: ballInformations.timeFlying += Time.deltaTime; if (ballInformations.isTeleguided) { PassController i_currentPassController = GetCurrentThrower().GetComponent <PassController>(); if (i_currentPassController != null) { ballInformations.direction = (i_currentPassController.GetTarget().GetCenterPosition() - transform.position).normalized; } } else if (ballInformations.curve != null) { PassController i_currentPassController = GetCurrentThrower().GetComponent <PassController>(); List <Vector3> i_pathCoordinates = i_currentPassController.GetCurvedPathCoordinates(startPosition, i_currentPassController.GetTarget(), ballInformations.initialLookDirection, out float d); float i_curveLength; if (i_currentPassController == null) { return; } ConvertCoordinatesToCurve(i_pathCoordinates, out curveX, out curveY, out curveZ, out i_curveLength); ballInformations.maxDistance = i_curveLength; float i_positionOnCurve = ballInformations.distanceTravelled / ballInformations.maxDistance; if (ballInformations.thrower.isPlayer) { LockManager.LockTargetsInPath(i_pathCoordinates, i_positionOnCurve); if (i_positionOnCurve >= 0.95f) { ChangeState(BallState.Grounded); LockManager.UnlockAll(); } } Vector3 i_nextPosition = new Vector3(curveX.Evaluate(i_positionOnCurve + 0.1f), curveY.Evaluate(i_positionOnCurve + 0.1f), curveZ.Evaluate(i_positionOnCurve + 0.1f)); ballInformations.direction = i_nextPosition - transform.position; } if (ballInformations.moveSpeed <= 0) { ballInformations.curve = null; ChangeState(BallState.Grounded); } else { //Ball is going to it's destination, checking for collisions RaycastHit[] i_hitColliders = Physics.RaycastAll(transform.position, ballInformations.direction, ballInformations.moveSpeed * Time.deltaTime); foreach (RaycastHit raycast in i_hitColliders) { /*EnemyShield i_selfRef = raycast.collider.GetComponentInParent<EnemyShield>(); * if (i_selfRef != null) * { * if (i_selfRef.shield.transform.InverseTransformPoint(transform.position).z > 0.0) * { * FeedbackManager.SendFeedback("event.ShieldHitByBall", this); * Vector3 i_newDirection = Vector3.Reflect(ballInformations.direction, i_selfRef.shield.transform.forward); * Bounce(i_newDirection, 1); * } * }*/ IHitable i_potentialHitableObjectFound = raycast.collider.GetComponent <IHitable>(); if (i_potentialHitableObjectFound != null && !hitGameObjects.Contains(i_potentialHitableObjectFound) && !isGhostBall) { hitGameObjects.Add(i_potentialHitableObjectFound); i_potentialHitableObjectFound.OnHit(this, ballInformations.direction * ballInformations.moveSpeed, ballInformations.thrower, GetCurrentDamages(), DamageSource.Ball); SlowTimeScale(); } if (raycast.collider.isTrigger || raycast.collider.gameObject.layer != LayerMask.NameToLayer("Environment")) { break; } FeedbackManager.SendFeedback("event.WallHitByBall", raycast.transform, raycast.point, ballInformations.direction, raycast.normal); if (!ballInformations.canHitWalls) { return; } if (ballInformations.bounceCount < ballInformations.ballDatas.maxBounces && ballInformations.canBounce) //Ball can bounce: Bounce { Analytics.CustomEvent("BallBounce", new Dictionary <string, object> { { "Zone", GameManager.GetCurrentZoneName() }, }); Vector3 i_hitNormal = raycast.normal; i_hitNormal.y = 0; Vector3 i_newDirection = Vector3.Reflect(ballInformations.direction, i_hitNormal); i_newDirection.y = -ballInformations.direction.y; Bounce(i_newDirection, ballInformations.ballDatas.speedMultiplierOnBounce); return; } else //Ball can't bounce: Stop { ChangeState(BallState.Grounded); MomentumManager.DecreaseMomentum(MomentumManager.datas.momentumLossWhenBallHitTheGround); return; } } } transform.position += ballInformations.direction.normalized * ballInformations.moveSpeed * Time.deltaTime * MomentumManager.GetValue(MomentumManager.datas.ballSpeedMultiplier) * GetCurrentSpeedModifier(); ballInformations.distanceTravelled += ballInformations.moveSpeed * Time.deltaTime * MomentumManager.GetValue(MomentumManager.datas.ballSpeedMultiplier) * GetCurrentSpeedModifier(); if (ballInformations.curve == null && !ballInformations.isTeleguided && ballInformations.distanceTravelled >= ballInformations.maxDistance) { ChangeState(BallState.Grounded); } break; } }
void Awake() { m_playerAttack = GameComponents.Player.GetComponent <PlayerAttack>(); m_momentumManager = GameComponents.Player.GetComponent <MomentumManager>(); }
public void OnAssignMomentumButtonClick(int buttonIndex) { HardwareType equippedHardwareType = InventoryController.GetEquippedActiveHardware()[buttonIndex]; MomentumManager.AssignMomentumPointToHardware(equippedHardwareType); }
public void OnHit(BallBehaviour _ball, Vector3 _impactVector, PawnController _thrower, float _damages, DamageSource _source, Vector3 _bumpModificators = default(Vector3)) { FXManager.InstantiateFX(puzzleData.charging, Vector3.up * 2, true, Vector3.forward, Vector3.one * 3, transform); MomentumManager.IncreaseMomentum(puzzleData.nbMomentumChargedByCharger); EnergyManager.IncreaseEnergy(chargeAmount); }
public void Awake() { instance = this; currentMomentum = 0; wantedMomentum = currentMomentum; }