예제 #1
0
    /// <summary>
    /// Returns all enemy hitboxes and hit-points from given raycast hits.
    /// </summary>
    /// <param name="raycastHitsArg"></param>
    /// <returns></returns>
    private List <(HitboxController, Vector3)> GetAllEnemyHitSetsFromRaycastHits(RaycastHit[] raycastHitsArg)
    {
        // initialize return var as fresh empty list
        List <(HitboxController, Vector3)> enemyHitSets = new List <(HitboxController, Vector3)>();

        // initialize var for upcoming loop
        HitboxController iterHitbox;

        // loop through all raycast hits
        foreach (RaycastHit iterRayHit in raycastHitsArg)
        {
            // get hitbox component of enemy that was hit
            iterHitbox = iterRayHit.collider.gameObject.GetComponent <HitboxController>();

            // if object hit was NOT an enemy hitbox
            if (iterHitbox == null)
            {
                // skip to next loop iteration
                continue;
            }

            // if hitbox can be harmed by this character
            if (GeneralMethods.CanHarmHitboxTarget(_characterMasterController.CharData, iterHitbox))
            {
                // add the enemy's hit set to list
                enemyHitSets.Add((iterHitbox, iterRayHit.point));
            }
        }

        // return populated list
        return(enemyHitSets);
    }
예제 #2
0
    private void OnTriggerStay(Collider other)
    {
        // if collision should NOT be effected by damage touch
        if (!IsEffectableCollision(other))
        {
            // DONT continue code
            return;
        }

        // if touch damaging is ON a cooldown
        if (onDamageCooldown)
        {
            // DONT continue code
            return;
        }

        // get collididng object's hitbox component
        HitboxController collidingHitbox = other.GetComponent <HitboxController>();

        // if can harm the hitbox target
        if (GeneralMethods.CanHarmHitboxTarget(_charMaster.CharData, collidingHitbox))
        {
            OnTargetTouch(collidingHitbox);
        }
    }
예제 #3
0
    private void OnTriggerEnter(Collider other)
    {
        // get collididng object's hitbox component
        HitboxController collidingHitbox = other.GetComponent <HitboxController>();

        // if can harm the hitbox target
        if (GeneralMethods.CanHarmHitboxTarget(_charMaster.CharData, collidingHitbox))
        {
            OnEnemyTargetDetection(collidingHitbox);
        }
    }
    protected virtual void OnTriggerEnter(Collider other)
    {
        // get collididng object's hitbox component
        HitboxController collidingHitbox = other.GetComponent <HitboxController>();

        // if can harm the hitbox target
        if (GeneralMethods.CanHarmHitboxTarget(_casterCharData, collidingHitbox))
        {
            // call to denote that made contact with an opposing character
            OnContactWithEnemy(collidingHitbox);
        }
    }