Exemple #1
0
    /****************************************************************************
    * Methods
    ****************************************************************************/
    /****************************************************************************
     * applyDamage */
    /**
     * Method to call when a Collidable Section of the tank was hit.
     *
     * @param  adp  ApplyDamagePayload object.
     ****************************************************************************/
    public void applyDamage(ApplyDamagePayload adp)
    {
        if (!tankData.godMode)
        {
            tankData.hp -= adp.damage;
        }

        Debug.Log(tankData.hp + " " + adp.damage + " " + adp.source);

        /** Check if tank is dead. */
        if (tankData.hp <= 0)
        {
            Debug.Log(tankData.name + " died.");

            /** Increase the score of the opposing that hit this tank. */
            GameObject.Find(adp.source).GetComponent <TankData>().score += tankData.pointValue;

            //tankData.audioSource.PlayOneShot(tankData.soundTankDestroyed);
            AudioSource.PlayClipAtPoint(tankData.soundTankDestroyed, gameObject.transform.position, tankData.audioSource.volume);
        }

        /** Play tank hit sound. */
        else
        {
            /** Change Doom Head animation to Hit. */
            if (mDHAM != null)
            {
                mDHAM.changeToHitState();
            }

            //tankData.audioSource.PlayOneShot(tankData.soundTankHit);
            AudioSource.PlayClipAtPoint(tankData.soundTankHit, gameObject.transform.position, tankData.audioSource.volume);
        }
    }