Example #1
0
    // Override: Monobehaviour::OnControllerColliderHit()
    public void OnControllerColliderHit(ControllerColliderHit _hit)
    {
        // Local variables
        Hitable hitable = _hit.gameObject.GetComponent <Hitable>();

        // Collided sidewards?
        if ((m_controller.collisionFlags & CollisionFlags.CollidedSides) != 0 && hitable is Projectile == false)
        {
            m_needTurnAround = true;
            //m_controller.Move(Vector3.right * -m_direction * m_worldScale.x * 0.05f);
            //turnAround();
        }

        // Hitable?
        if (hitable == null)
        {
            return;
        }

        // Hit from above?
        if (Vector3.Dot(_hit.normal, Vector3.down) >= GameConfig.ENEMY_PLAYER_ABOVE_FACTOR)
        {
            // Player?
            if (hitable is Player)
            {
                (hitable as Player).jumpingFromAnEnemy();
            }
            onHit(hitable);
            return;
        }

        // Notify
        hitable.onHit(this);
    }
Example #2
0
    /**
     *
     */
    public void OnCharacterControllerHit(object _hitInfo)
    {
        // Local variables
        ControllerColliderHit hitInfo = _hitInfo as ControllerColliderHit;
        Hitable hitable = null;

        // Useless message?
        if (hitInfo == null)
        {
            return;
        }

        // Hitable?
        hitable = hitInfo.controller.gameObject.GetComponent <Hitable>();
        if (hitable == null)
        {
            return;
        }

        // Hit from above?
        if (Vector3.Dot(hitInfo.normal, Vector3.up) >= GameConfig.ENEMY_PLAYER_ABOVE_FACTOR)
        {
            // Player?
            if (hitable is Player)
            {
                (hitable as Player).jumpingFromAnEnemy();
            }
            onHit(hitable);
            return;
        }

        // Notify
        hitable.onHit(this);
    }
Example #3
0
    // Override: Monobehaviour::OnControllerColliderHit()
    public void OnControllerColliderHit(ControllerColliderHit _hit)
    {
        // Local variables
        Hitable hitable = _hit.gameObject.GetComponent <Hitable>();

        // Hitable?
        if (hitable == null)
        {
            return;
        }

        // Hit from above?
        if (Vector3.Dot(_hit.normal, Vector3.down) >= GameConfig.ENEMY_PLAYER_ABOVE_FACTOR)
        {
            // Player?
            if (hitable is Player)
            {
                (hitable as Player).jumpingFromAnEnemy();
            }
            onHit(hitable);
            return;
        }

        // Notify
        hitable.onHit(this);
    }
    // Override: Monobehaviour::OnControllerColliderHit()
    public void OnControllerColliderHit(ControllerColliderHit _hit)
    {
        // Local variables
        Hitable hitable = _hit.gameObject.GetComponent <Hitable>();

        // Hitable?
        if (hitable == null)
        {
            return;
        }

        // Notify
        hitable.onHit(this);
    }
Example #5
0
    // Override: Hitable::onHit()
    public override void onHit(Hitable _source)
    {
        // not alive?
        if (!m_alive)
        {
            return;
        }

        // die
        m_alive = false;

        // Do damage
        _source.onHit(this);

        // Destroy game-object
        GameObject.Destroy(gameObject);
    }
Example #6
0
    /**
     * distibte hits to player if he stay in the trigger
     */
    void OnTriggerStay(Collider _other)
    {
        // the hit collider isnt the player?
        if (!_other.gameObject.CompareTag(Tags.TAG_PLAYER))
        {
            return;
        }

        // get the player script
        Hitable _hit = _other.gameObject.GetComponent <Hitable>();

        // havent a player script?
        if (_hit == null)
        {
            return;
        }
        _hit.onHit(this);
    }
Example #7
0
    // Override: MonoBehaviour::OnCollisionEnter()
    void OnCollisionEnter(Collision _c)
    {
        // Local variables
        Hitable hitable = null;

        // Destroy game-object
        GameObject.Destroy(gameObject);
        m_alive = false;

        // Hitable?
        hitable = _c.gameObject.GetComponent <Hitable>();
        if (hitable == null)
        {
            return;
        }

        // Do damage
        hitable.onHit(this);

        // TODO Particle effect
    }
Example #8
0
    // Override: Hitable::onHit()
    public override void onHit(Hitable _source)
    {
        // Dont take a hit?
        if (m_lastHit + GameConfig.BILLY_TIME_BETWEEN_TWO_ACCEPT_HITS > Time.time)
        {
            return;
        }

        StartCoroutine("doHitFlash");

        // distribute a hit
        if (m_playerData.isPowerUpAvailable(PlayerData.PowerUpType.PUT_KIWANO) && m_playerData.getPowerUpStockSize(PlayerData.PowerUpType.PUT_KIWANO) > 0)
        {
            _source.onHit(this);
            m_playerData.decreaseStockSizeByValue(PlayerData.PowerUpType.PUT_KIWANO, 1);
            m_lastHit = Time.time;
            return;
        }

        m_lastHit  = Time.time;
        m_loseLife = true;
    }
    /**
     *
     */
    public void OnCharacterControllerHit(object _hitInfo)
    {
        // Local variables
        ControllerColliderHit hitInfo = _hitInfo as ControllerColliderHit;
        Hitable hitable = null;

        // Useless message?
        if (hitInfo == null)
        {
            return;
        }

        // Hitable?
        hitable = hitInfo.controller.gameObject.GetComponent <Hitable>();
        if (hitable == null)
        {
            return;
        }

        // Notify
        hitable.onHit(this);
    }