Example #1
0
    public override void OnCreated()
    {
        _IsCheckInvincible = false;
        _Join              = null;
        _chasingTarget     = null;
        PeekedNestPosition = Vector3.zero;
        _castHitNumber     = _overLapCollideNumber = 0;
        _currentMoveActionCumulativeTime = 0f;
        RemoveDeadlock = false;
        _particleStopLoopWhenRemoveStartFlag = _arrowFadeWhenRemovingStartFlag = _arrowFadeWhenRemovingWholeFlag = false;
        _moveActionSequenceValueSet.Clear();
        _currentMoveAction.isValid = false;
        _projectileMoveActionSequenceList.Clear();
        RecursiveKey           = 0;
        Gravity                = 0f;
        AccelerationFactor     = 1f;
        _isIgnoreObstacle      = _isIgnoreUnit = false;
        _isActive              = false;
        _isOnHeartBeat         = false;
        _fixedUpdateAction     = null;
        _collideUnitAction     = null;
        _collideObstacleAction = null;
        _expiredLifeAction     = null;
        _onHeartBeatAction     = null;
        _onWhileRemovingAction = null;
        _onRemoveStart         = null;
        _onRemoveEnd           = null;

        Type = ProjectileFactory.Type.None;
        _maxColliderNumber = 0;
        CollidedUnitGroup.Clear();
        ExCollidedUnitGroup.Clear();

        _mRenderer.enabled = true;
        Velocity           = Acceleration = Vector3.zero;
        SetDirection(Vector3.forward);
        LifeTime            = ElapsedTime = 0f;
        RemoveDelayCount    = 0;
        RemoveDelay         = 0f;
        _projectileType     = ProjectileType.Box;
        _maxNumberOfHitTime = 1;

        for (var i = 0; i < _particleList.Length; i++)
        {
            SetParticleSystemIndexEnable(i, true);
        }
    }
Example #2
0
    private bool CheckCollisionAboutUnit(Action <CommomActionArgs> p_ActionWhenOccurCollision = null, bool decreaseHitNum = true)
    {
        if (!_isIgnoreUnit)
        {
            if (p_ActionWhenOccurCollision == null)
            {
                return(false);
            }

            CollidedUnitGroup.Clear();

            _overLapCollideNumber = CheckCollisionWithCast(CastHitGroup, _halfExtents, PeekedNestPosition, UnitColliderLayerMask,
                                                           Transform.position);
            _castHitNumber = CheckCollisionWithOverlap(ColliderGroup, _halfExtents, UnitColliderLayerMask, Transform.position);
            var l_loopCount      = Mathf.Min(Mathf.Max(_overLapCollideNumber, _castHitNumber), _maxColliderNumber);
            var ignoreFilterMask = UnitFilter.Condition.IsPositive;
            if (!_IsCheckInvincible)
            {
                ignoreFilterMask |= UnitFilter.Condition.IsOrCondition | UnitFilter.Condition.IsInvincible;
            }
            for (var index = 0; index < l_loopCount; index++)
            {
                #region <CollisionCheckByHitCast>

                if (index >= _overLapCollideNumber)
                {
                    goto SECTION_HIT_CHECK_OVER;
                }
                var hittedUnit = CastHitGroup[index].collider.GetComponent <Unit>();
                if (UnitFilter.Check(Caster, hittedUnit, ignoreFilterMask))
                {
                    goto SECTION_HIT_CHECK_OVER;
                }
                foreach (var collided in ExCollidedUnitGroup)
                {
                    if (UnitFilter.Check(collided, hittedUnit, ignoreFilterMask))
                    {
                        goto SECTION_HIT_CHECK_OVER;
                    }
                }
                ExCollidedUnitGroup.Add(hittedUnit);
                CollidedUnitGroup.Add(hittedUnit);
SECTION_HIT_CHECK_OVER:

                #endregion

                #region <CollisionCheckbyOverlap>

                if (index >= _castHitNumber)
                {
                    goto SECTION_COLLIDE_CHECK_OVER;
                }
                var collidedUnit = ColliderGroup[index].GetComponent <Unit>();
                if (UnitFilter.Check(Caster, collidedUnit, ignoreFilterMask))
                {
                    goto SECTION_COLLIDE_CHECK_OVER;
                }
                foreach (var exCollided in ExCollidedUnitGroup)
                {
                    if (UnitFilter.Check(exCollided, collidedUnit, ignoreFilterMask))
                    {
                        goto SECTION_COLLIDE_CHECK_OVER;
                    }
                }
                ExCollidedUnitGroup.Add(collidedUnit);
                CollidedUnitGroup.Add(collidedUnit);
                SECTION_COLLIDE_CHECK_OVER :;

                #endregion
            }

            // CASE#2: has been collided on any negative unit.
            if (CollidedUnitGroup.Count > 0)
            {
                // Defined Action: Collided Unit.
                p_ActionWhenOccurCollision(new CommomActionArgs()
                                           .SetMorphable(this)
                                           );

                if (!decreaseHitNum)
                {
                    ExCollidedUnitGroup.Clear();
                }
                else if (_maxNumberOfHitTime > 1)
                {
                    _maxNumberOfHitTime--;
                    ExCollidedUnitGroup.Clear();
                }

                return(true);
            }
        }
        return(false);
    }