コード例 #1
0
        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();
        }
コード例 #2
0
        public void Init(BattlePlayer player, BattlePlayerInputController controller, IBattlePlayerInputDelegate inputDelegate)
        {
            player_        = player;
            controller_    = controller;
            inputDelegate_ = inputDelegate;

            Initialize();
        }
コード例 #3
0
 public void InitInput(BattlePlayer player, IBattlePlayerInputDelegate inputDelegate)
 {
     foreach (var component in playerInputComponents_)
     {
         component.Init(player, this, inputDelegate);
     }
     EnableInput(PriorityKey.Internal);
 }
コード例 #4
0
        // 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);
        }
コード例 #5
0
        // 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));
        }
コード例 #6
0
        // 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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 // PRAGMA MARK - Public Interface
 public void Init(BattlePlayer player)
 {
     player_ = player;
 }
コード例 #9
0
 public static bool IsHuman(BattlePlayer battlePlayer)
 {
     return(!PlayerSpawner.GetPlayerFor(battlePlayer).IsAI);
 }
コード例 #10
0
 public static Vector2 XZVectorFromTo(BattlePlayer playerA, BattlePlayer playerB)
 {
     return((playerB.transform.position - playerA.transform.position).Vector2XZValue());
 }
コード例 #11
0
 public static float WeightedRatio(this BattlePlayer player)
 {
     return(player.BaseWeight / player.Weight);
 }