Esempio n. 1
0
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    void Damage()
    {
        //--------------

        if (dead == false)
        {
            amountDamage += currentDamage;
            if (amountDamage > amountLife * 0.75f && runAwayAdditionally == false)
            {
                runAway = true;
            }
            if (amountDamage > amountLife)
            {
                if (Mathf.Sqrt(Class_Controller.SqrMagnitudeToPlayer(thisTransform)) < thisAudioSource.maxDistance)
                {
                    thisAudioSource.pitch     = Random.Range(0.7f, 1.2f);
                    thisAudioSource.panStereo = Random.Range(-0.1f, 0.1f);
                    thisAudioSource.PlayOneShot(soundsFx[Random.Range(2, 5)], Random.Range(0.6f, 1.0f));
                }
                dead  = true;
                speed = 0;
                aiAgr = attack = contusion = false;
                Class_AI.amountEnemyAIs -= 1;
                if (injuredByPlayer == true)
                {
                    Class_AI.RandomMinerals(thisTransform, true);
                    PlayerPrefs.SetInt("DestroyedEnemies", PlayerPrefs.GetInt("DestroyedEnemies") + 1);
                }
            }
        }

        //--------------
    }
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    void HelpPlayer()
    {
        //--------------

        if (variableRotation != 2)
        {
            variableRotation = 2;
        }

        if (playerIsVisible == true)
        {
            if (distanceToPlayer < atackDistance2 && distanceToPlayer > atackDistance3 && speed != 5)
            {
                speed = 5;
            }
            else if (distanceToPlayer < atackDistance3 && distanceToPlayer > 33 && speed != 1)
            {
                speed = 1;
            }
            else if (distanceToPlayer < 33)
            {
                thisAudioSource.pitch     = Random.Range(0.7f, 1.0f);
                thisAudioSource.panStereo = Random.Range(-0.1f, 0.1f);
                thisAudioSource.PlayOneShot(soundsFx[Random.Range(2, 5)], Random.Range(0.4f, 0.7f));
                playerIsVisible = false;
                if (speed != -3)
                {
                    speed = -4;
                }
                Class_AI.RandomMinerals(thisTransform, true);
            }
        }

        thisQuaternion = Quaternion.LookRotation(Class_Controller.playerPosition - thisTransform.position);

        if (counter23++ > 5)
        {
            counter23    = 0;
            gravityValid = true;
        }
        else
        {
            gravityValid = false;
        }

        //--------------
    }