Ejemplo n.º 1
0
        private IPhoton GetMostNearestTarget()
        {
            Collider2D[] colliders    = new Collider2D[32];
            int          overlapCount = _collider.OverlapCollider(_filter, colliders);

            if (overlapCount == 0)
            {
                return(null);
            }

            var candidates = colliders.Where(candidate => candidate != null)
                             .Where(candidate => TeamChecker.IsNotSameTeam(candidate.gameObject, _skillUserObj));

            if (candidates.Count() == 0)
            {
                return(null);
            }

            var targetCollider = candidates.Select(candidate =>
                                                   new {
                Candidate = candidate,
                Distance  = Vector3.Distance(candidate.transform.position, _skillUserObj.transform.position)
            })
                                 .Aggregate((min, tmp) => (min.Distance < tmp.Distance) ? min : tmp).Candidate;

            var target = targetCollider.gameObject.GetComponent <IPhoton>();

            return(target);
        }
Ejemplo n.º 2
0
        void OnTriggerStay2D(Collider2D collider)
        {
            var target = collider.gameObject.GetComponent <IPhoton>();

            if (target == null)
            {
                return;
            }

            if (target.PhotonView.isMine && _animator.GetCurrentAnimatorStateInfo(0).IsName("Space"))
            {
                if (TeamChecker.IsNotSameTeam(collider.gameObject, _skillUserObj))
                {
                    return;
                }
                if (_healRistrictor.ShouldRistrict(collider.gameObject))
                {
                    return;
                }

                _synchronizer.SyncHeal(target.PhotonView.viewID, GetHealQuantity());
            }

            if (PhotonNetwork.isMasterClient && _animator.GetCurrentAnimatorStateInfo(0).IsName("SpaceBreak"))
            {
                if (TeamChecker.IsSameTeam(collider.gameObject, _skillUserObj))
                {
                    return;
                }
                if (_hitRistrictor.ShouldRistrict(collider.gameObject))
                {
                    return;
                }

                DamageCalculator.Calculate(_skillUserObj, _attackInfo);

                _synchronizer.SyncAttack(_skillUserViewID, target.PhotonView.viewID, DamageCalculator.Damage, DamageCalculator.IsCritical, HitEffectType.Warrior);
            }
        }
Ejemplo n.º 3
0
        void OnTriggerStay2D(Collider2D collider)
        {
            var target = collider.gameObject.GetComponent <IPhoton>();

            if (target == null)
            {
                return;
            }

            if (target.PhotonView.isMine)
            {
                if (TeamChecker.IsNotSameTeam(collider.gameObject, _skillUserObj))
                {
                    return;
                }
                if (_hitRistrictor.ShouldRistrict(collider.gameObject))
                {
                    return;
                }

                _synchronizer.SyncHeal(target.PhotonView.viewID, _quantity);
            }
        }