public void GoToHands(Transform _handTransform, float _travelDuration, BallDatas _passData) { ballInformations.ballDatas = _passData; ballInformations.curve = null; ChangeState(BallState.Held); ballCoroutine = StartCoroutine(GoToPosition(_handTransform, _travelDuration)); transform.SetParent(_handTransform, true); }
public void CurveShoot(PassController _passController, PawnController _thrower, PawnController _target, BallDatas _passDatas, Vector3 _lookDirection) //Shoot a curve ball to reach a point { if (ballCoroutine != null) { StopCoroutine(ballCoroutine); } startPosition = _passController.GetHandTransform().position; transform.SetParent(null, true); transform.localScale = Vector3.one; ballInformations.thrower = _thrower; ballInformations.moveSpeed = _passDatas.moveSpeed; ballInformations.maxDistance = Mathf.Infinity; ballInformations.ballDatas = _passDatas; ballInformations.bounceCount = 0; ballInformations.canBounce = true; ballInformations.canHitWalls = true; ballInformations.curve = _passController.GetCurvedPathCoordinates(startPosition, _target, _lookDirection, out float d); ballInformations.timeFlying = 0; ballInformations.initialLookDirection = _lookDirection; ballInformations.isTeleguided = false; hitGameObjects.Clear(); ChangeState(BallState.Flying); UpdateColor(); }
public void Shoot(Vector3 _startPosition, Vector3 _direction, PawnController _thrower, BallDatas _passDatas, bool _teleguided) //Shoot the ball toward a direction { if (ballCoroutine != null) { StopCoroutine(ballCoroutine); } transform.SetParent(null, true); transform.localScale = Vector3.one; transform.position = _startPosition; ballInformations.direction = _direction; ballInformations.thrower = _thrower; ballInformations.moveSpeed = _passDatas.moveSpeed; ballInformations.ballDatas = _passDatas; ballInformations.bounceCount = 0; ballInformations.timeFlying = 0; ballInformations.curve = null; ballInformations.canBounce = true; ballInformations.canHitWalls = true; ballInformations.isTeleguided = _teleguided; hitGameObjects.Clear(); ChangeState(BallState.Flying); UpdateColor(); }
public virtual void OnHit(BallBehaviour _ball, Vector3 _impactVector, PawnController _thrower, float _damages, DamageSource _source, Vector3 _bumpModificators = default(Vector3)) { damageAfterBump = 0; Vector3 i_normalizedImpactVector; LockManager.UnlockTarget(this.transform); switch (_source) { case DamageSource.Dunk: Analytics.CustomEvent("DamageWithDunk", new Dictionary <string, object> { { "Zone", GameManager.GetCurrentZoneName() }, }); if (isBumpable) { if (enemyType == EnemyTypes.RedBarrel) { EnemyRedBarrel i_selfRef = GetComponent <EnemyRedBarrel>(); i_selfRef.willExplode = false; } damageAfterBump = _damages; i_normalizedImpactVector = new Vector3(_impactVector.x, 0, _impactVector.z); BumpMe(i_normalizedImpactVector.normalized, BumpForce.Force2); } else { Damage(_damages); } break; case DamageSource.RedBarrelExplosion: if (isBumpable && enemyType != EnemyTypes.RedBarrel) { damageAfterBump = _damages; i_normalizedImpactVector = new Vector3(_impactVector.x, 0, _impactVector.z); BumpMe(i_normalizedImpactVector.normalized, BumpForce.Force2); } else { Damage(_damages); } break; case DamageSource.Ball: Upgrade passLevel = AbilityManager.GetAbilityLevel(ConcernedAbility.Pass); if ((int)passLevel > 0 && GetHealth() / GetMaxHealth() <= AbilityManager.instance.level1PassDamageTreshold) { _damages = _damages * AbilityManager.instance.level1PassDamageMultiplier; FeedbackManager.SendFeedback("event.PassUpgradedShot", this, _ball.transform.position, _impactVector, _impactVector); } Analytics.CustomEvent("DamageWithBall", new Dictionary <string, object> { { "Zone", GameManager.GetCurrentZoneName() }, }); animator.SetTrigger("HitTrigger"); FeedbackManager.SendFeedback("event.BallHittingEnemy", this, _ball.transform.position, _impactVector, _impactVector); EnergyManager.IncreaseEnergy(energyGainedOnHit); Damage(_damages); break; case DamageSource.PerfectReceptionExplosion: Damage(_damages); FeedbackManager.SendFeedback("event.BallHittingEnemy", this, _ball.transform.position, _impactVector, _impactVector); BallDatas bd = _ball.GetCurrentBallDatas(); float ballChargePercent = (_ball.GetCurrentDamageModifier() - 1) / (bd.maxDamageModifierOnPerfectReception - 1); // Bump or push depending on Ball charge value if (ballChargePercent >= bd.minimalChargeForBump) { BumpMe(_impactVector.normalized, BumpForce.Force1); } else if (ballChargePercent >= bd.minimalChargeForHeavyPush) { Push(PushType.Heavy, _impactVector.normalized, PushForce.Force1); } else if (ballChargePercent >= bd.minimalChargeForLightPush) { Push(PushType.Light, _impactVector.normalized, PushForce.Force1); } break; case DamageSource.Laser: Damage(_damages); break; case DamageSource.ReviveExplosion: Push(PushType.Heavy, _impactVector, PushForce.Force2); break; case DamageSource.DeathExplosion: Push(PushType.Heavy, _impactVector, PushForce.Force2); break; case DamageSource.SpawnImpact: Push(PushType.Light, _impactVector, PushForce.Force1); break; } }