예제 #1
0
    // Update is called once per frame
    void Update()
    {
        //This part is to give the change in the boss' scale an acceleration effect
        //instead of just setting the acceleration value whic makes it a little bit smoother
        float currentSize = transform.localScale.x;
        float desiredSize = healthComp.currentHealth * SIZEOVERHEALTH;

        if (Mathf.Abs(currentSize - desiredSize) <= 0.02f)
        {
            currentSize = desiredSize;
        }
        if (desiredSize < currentSize)
        {
            if ((currentSize - desiredSize) * 0.1f > 0.02f)
            {
                currentSize = currentSize - ((currentSize - desiredSize) * 0.1f);
            }
            else
            {
                currentSize -= 0.02f;
            }
        }
        else if (desiredSize > currentSize)
        {
            if ((desiredSize - currentSize) * 0.1f > 0.02f)
            {
                currentSize = currentSize + ((desiredSize - currentSize) * 0.1f);
            }
            else
            {
                currentSize += 0.02f;
            }
        }
        transform.localScale = new Vector3(currentSize, currentSize, currentSize);
        // ------  ends here ---------

        if (healthComp.currentHealth <= 0)
        {
            GC.GameWon();
        }

        if (healthComp.currentHealth <= maxHealth * ((remainingWaves - 1) / (float)(remainingWaves)) && healthComp.currentHealth > 0)
        {
            spawnWave();
            maxHealth = maxHealth * ((remainingWaves - 1) / (float)(remainingWaves));
            remainingWaves--;
        }
    }