private void CheckCollisionWithPlayer(Collider collider) { BattlePlayer battlePlayer = collider.gameObject.GetComponentInParent <BattlePlayer>(); if (battlePlayer == null) { return; } if (battlePlayer == Player_) { return; } Vector3 forward = Player_.Rigidbody.velocity; forward = forward.normalized; battlePlayer.Health.TakeDamage(DashDamage, forward, damageSource: Player_); Player_.Health.Knockback(-forward); GameNotifications.OnBattlePlayerDashHit.Invoke(battlePlayer, Player_); dashCollider_.enabled = false; OnDashCancelled.Invoke(); }
public void Init(BattlePlayer player, BattlePlayerInputController controller, IBattlePlayerInputDelegate inputDelegate) { player_ = player; controller_ = controller; inputDelegate_ = inputDelegate; Initialize(); }
public void InitInput(BattlePlayer player, IBattlePlayerInputDelegate inputDelegate) { foreach (var component in playerInputComponents_) { component.Init(player, this, inputDelegate); } EnableInput(PriorityKey.Internal); }
// PRAGMA MARK - Static Public Interface public static BattlePlayer GetClosestEnemyPlayerFor(BattlePlayer player, Predicate <BattlePlayer> whereCondition = null) { BattlePlayer closestEnemyPlayer = BattlePlayer.ActivePlayers.Where(p => p != player) .Where(p => !BattlePlayerTeams.AreOnSameTeam(player, p)) .Where(p => whereCondition != null ? whereCondition.Invoke(p) : true) .MinBy(p => (p.transform.position - player.transform.position).magnitude); return(closestEnemyPlayer); }
// PRAGMA MARK - Static Public Interface public static bool AreOnSameTeam(BattlePlayer player, BattlePlayer otherPlayer) { // if not on any teams if (!teamMap_.ContainsKey(player)) { return(false); } return(teamMap_[player].Contains(otherPlayer)); }
// PRAGMA MARK - Public Interface public static void MoveTo(this BattlePlayerInputController controller, BattlePlayer player, Vector3 endPosition, float duration, EaseType easeType, Action onFinishedCallback = null) { Vector3 startPosition = player.Rigidbody.position; float oldDrag = player.Rigidbody.drag; controller.DisableInput(BattlePlayerInputController.PriorityKey.Movement); player.Rigidbody.drag = BattlePlayer.kBaseDrag; player.Rigidbody.AddForce((endPosition - startPosition) * 10, ForceMode.Impulse); var coroutine = CoroutineWrapper.DoAfterDelay(duration, () => { player.Rigidbody.drag = oldDrag; controller.EnableInput(BattlePlayerInputController.PriorityKey.Movement); controller.CancelAnyAnimatedMovements(); if (onFinishedCallback != null) { onFinishedCallback.Invoke(); } }); controller.RegisterAnimatedMovement(coroutine); }
private void OnTriggerEnter(Collider collider) { if (!reflect_) { return; } Laser laser = collider.gameObject.GetComponentInParent <Laser>(); if (laser == null) { return; } if (reflectedLasers_.Contains(laser)) { return; } reflectedLasers_.Add(laser); GameNotifications.OnBattlePlayerReflectLaser.Invoke(laser, Player_); // reflect laser back to original shooter BattlePlayer laserSource = laser.BattlePlayer; if (laserSource != null && laserSource != Player_) { laser.transform.LookAt(laserSource.transform); } else { // just reflect backwards laser.transform.LookAt(laser.transform.position - laser.transform.forward); } AudioConstants.Instance.LaserShoot.PlaySFX(volumeScale: 0.5f); laser.HandleHit(destroy: false); laser.ChangeBattlePlayerSource(Player_); laser.AddSpeedFromVelocity(Player_.Rigidbody.velocity); }
// PRAGMA MARK - Public Interface public void Init(BattlePlayer player) { player_ = player; }
public static bool IsHuman(BattlePlayer battlePlayer) { return(!PlayerSpawner.GetPlayerFor(battlePlayer).IsAI); }
public static Vector2 XZVectorFromTo(BattlePlayer playerA, BattlePlayer playerB) { return((playerB.transform.position - playerA.transform.position).Vector2XZValue()); }
public static float WeightedRatio(this BattlePlayer player) { return(player.BaseWeight / player.Weight); }