Example #1
0
    protected bool _processSingleBase(PlayerBaseComponent baseComponent)
    {
        if (baseComponent.mAttackingEntity == null)
        {
            return(false);
        }

        float currHealth = Mathf.Max(0.0f, baseComponent.mHealth - baseComponent.mAttackingEntity.mConfigs.mDamage);

        EventBus.NotifyOnBaseHealthChanged(currHealth);

        baseComponent.mHealth = currHealth;

        DestroyedComponent enemyDestroyer = baseComponent.mAttackingEntity.GetComponent <DestroyedComponent>();

        enemyDestroyer.mShouldBeDestroyed = true;                /// kill the enemy

        /// reset the field
        baseComponent.mAttackingEntity = null;

        if (currHealth < 1e-3f)
        {
            EventBus.NotifyOnDefeat();

            return(false);
        }

        return(true);
    }
    protected void OnTriggerEnter(Collider collider)
    {
        PlayerBaseComponent baseComponent = collider.GetComponent <PlayerBaseComponent>();

        // it's not a base object
        if (baseComponent == null)
        {
            return;
        }

        baseComponent.mAttackingEntity = GetComponent <EnemyComponent>();
    }