Example #1
0
    protected override void OnCollisionBegin(Collider_ other)
    {
        var c = 0;
        var k = other.GetInstanceID();

        if (m_cols.TryGetValue(k, out c))
        {
            m_cols[k] = c + 1;
        }
        else
        {
            m_cols.Add(k, 1);
        }

        #region Debug log
        #if (DEVELOPMENT_BUILD || UNITY_EDITOR) && DETAIL_BATTLE_LOG
        if (creature)
        {
            Logger.LogWarning("[{2}:{3}-{4}], Creature {0} attack box collision begin with [{1}]", creature.name, m_cols[k], Level.levelTime, creature.frameTime, creature.frameCount);
        }
        #endif

        #if AI_LOG
        Module_AI.LogBattleMsg(creature, "[attack box collision begin with {0}]", m_cols[k]);
        #endif
        #endregion
    }
Example #2
0
    private void CheckCollision(Collider_ trigger, ref int count, ref int i)
    {
        for (var j = 0; j < count;)
        {
            if (j == i)
            {
                ++j;
                continue;
            }

            var other = m_colliders[j];

            if (!other || !other.isActive)
            {
                m_colliders.RemoveAt(j);
                LogColliders();
                --count;
                if (j < i)
                {
                    --i;
                }
            }
            else
            {
                ++j;

                if (other.isTrigger)
                {
                    continue;
                }

                CheckCollision(trigger, other);
            }
        }
    }
Example #3
0
 protected override void OnCollisionBegin(Collider_ other)
 {
     if (CheckValidCollider(other))
     {
         base.OnCollisionBegin(other);
         Creature c = (other as CreatureHitCollider).creature;
         OnCreatureEnterTrigger(c);
     }
 }
Example #4
0
 protected override void OnCollisionEnd(Collider_ _other)
 {
     if (CheckValidCollider(_other))
     {
         base.OnCollisionEnd(_other);
         Creature c = (_other as CreatureHitCollider).creature;
         OnCreatureExitTrigger(c);
     }
 }
    protected override void OnCollisionBegin(Collider_ other)
    {
        base.OnCollisionBegin(other);

        // We only handle ground hit here, normal hit will handled by OnRealHitTarget
        if (other.gameObject.layer == 11)  // We hit ground!
        {
            effect.OnHit(null);
        }
    }
Example #6
0
    public void BeginCollision(Collider_ other)
    {
        if (m_touched.Contains(other))
        {
            return;
        }

        m_touched.Add(other);
        OnCollisionBegin(other);
    }
Example #7
0
    public void Register(Collider_ collider)
    {
        if (m_colliders.Contains(collider))
        {
            return;
        }

        m_colliders.Add(collider);

        LogColliders();
    }
Example #8
0
    private static void UpdateTouched(Collider_ trigger, Collider_ receiver, bool old, bool now)
    {
        if (old == now)
        {
            return;
        }

        if (old)
        {
            trigger.EndCollision(receiver);
            receiver.EndCollision(trigger);
        }
        else
        {
            trigger.BeginCollision(receiver);
            receiver.BeginCollision(trigger);
        }
    }
Example #9
0
    public void EndCollision(Collider_ other)
    {
        var idx = m_touched.IndexOf(other);

        if (idx < 0)
        {
            return;
        }

        m_touched.RemoveAt(idx);
        if (idx <= m_touchIdx)
        {
            --m_touchIdx;
            --m_touchCount;
        }

        OnCollisionEnd(other);
    }
Example #10
0
    private void CheckCollision(Collider_ trigger, Collider_ receiver)
    {
        var mask    = trigger.targetMask;
        var touched = trigger.Touched(receiver);
        var test    = (!trigger.ignoreSameGroup || trigger.transform.parent != receiver.transform.parent) && mask.BitMask(receiver.layer);

        if (test)
        {
            test = trigger.isActiveAndEnabled && receiver.isActiveAndEnabled && trigger.CollisionTest(receiver);
        }

        if (touched != test)
        {
            FightRecordManager.RecordLog <LogCheckCollider>(l =>
            {
                l.tag             = (byte)TagType.LogCheckCollider;
                l.test            = test;
                l.ignoreSameGroup = trigger.ignoreSameGroup;
                l.mask            = mask;
                l.layer           = receiver.layer;
            });
        }
        UpdateTouched(trigger, receiver, touched, test);
    }
 public void CollisionBegin(Collider_ other)
 {
     OnCollisionBegin(other);
 }
Example #12
0
 /// <summary>
 /// Event callback when begin collision with other collider
 /// </summary>
 protected virtual void OnCollisionBegin(Collider_ other)
 {
 }
Example #13
0
 /// <summary>
 /// Event callback when end collision with other collider
 /// </summary>
 protected virtual void OnCollisionEnd(Collider_ _other)
 {
 }
Example #14
0
 public int AttackedCount(Collider_ other)
 {
     return(m_cols.Get(other.GetInstanceID()));
 }
Example #15
0
 public override bool CollisionTest(Collider_ other)
 {
     return(other.CollisionTest(ref m_sphere));
 }
Example #16
0
    protected override void OnCollisionBegin(Collider_ other)
    {
        if (!enabled || m_creature == null)
        {
            return;
        }

        var c  = other as AttackCollider;
        var cc = c ? c.creature : null;

        if (!cc || cc.clearAttack || m_creature.SameCampWith(cc) || c.AttackedCount(this) > 1)
        {
            return;
        }

        if (!m_stateMachine)
        {
            m_stateMachine = m_creature.stateMachine;
        }

        var bullet = c.type == AttackColliderTypes.Bullet;
        var effect = c.type == AttackColliderTypes.Effect || c.type == AttackColliderTypes.Bullet;
        var ai     = bullet && (m_stateMachine.GetBool(StateMachineParam.weak) || cc.HawkEye) ? c.bulletAttackInfo : c.attackInfo;
        var a      = AttackInfo.Get(ai);

        if (!a || a.targetStates.Length < 1)
        {
            if (ai == 0)
            {
                c.OnRealHitTarget(this, a);
            }
            return;
        }

        if (!a.ignoreInvincible && m_creature.invincible)
        {
            return;                                                 // Invincible check
        }
        if (a.lockTarget && (m_stateMachine.passiveSource != cc || !m_stateMachine.GetBool(StateMachineParam.passiveCatchState)))
        {
            return;                                                                                                                         // Lock target check
        }
        a.fromBullet = bullet;
        a.fromEffect = effect;

        var mask    = m_stateMachine.GetInt(StateMachineParam.groupMask);
        var tss     = a.targetStates;
        var isCatch = cc.currentState.info.catchState != 0;

        for (int i = 0, count = tss.Length; i < count; ++i)
        {
            var ts = tss[i];
            if (mask.BitMask(ts.fromGroup))
            {
                var iid = (uint)c.creature.id << 16 | (uint)(a.ID & 0xFFFF);
                var ac  = m_attinfos.Get(iid);
                if (!m_creature.tough || isCatch)
                {
                    ac += 1;
                    m_attinfos.Set(iid, ac);
                }

                var ti = (byte)i;

                if (ac > a.comboLimit)
                {
                    if (isCatch)
                    {
                        cc.DispatchEvent(CreatureEvents.ATTACK_HIT_FAILED, Event_.Pop(m_creature));
                        break;
                    }
                    ti = byte.MaxValue;
                }

                OnHit(c, a, ti);
                c.OnRealHitTarget(this, a);

                break;
            }
        }
    }
Example #17
0
 private bool CheckValidCollider(Collider_ c)
 {
     return(state == EnumTriggerState.Open && c is CreatureHitCollider);
 }
Example #18
0
 /// <summary>
 /// Event callback per frame when stay with other collider
 /// </summary>
 protected virtual void OnCollisionTouch(Collider_ _other)
 {
 }
Example #19
0
 /// <summary>
 /// Event callback when check collision with other Collider
 /// </summary>
 /// <param name="other"></param>
 public abstract bool CollisionTest(Collider_ other);
Example #20
0
 public bool Touched(Collider_ other)
 {
     return(m_touched.Contains(other));
 }