Ejemplo n.º 1
0
    private void Update()
    {
        switch (state)
        {
        case WorldState.IDLE:

            break;

        case WorldState.CHARGING:

            if (currentBossBar >= maxBossBar)
            {
                fillImage.fillAmount = 1;
                GoToBossState();
            }
            else
            {
                currentBossBar      -= bossBarDecreasePerSecond * Time.deltaTime;
                currentBossBar       = Mathf.Max(0, currentBossBar);
                fillImage.fillAmount = currentBossBar / maxBossBar;
            }

            break;

        case WorldState.BOSS:


            if (boss == null || boss.HP <= 0)
            {
                word.words = "CLAIM THE CROWN";
                word.CreateWord();
                state = WorldState.ENDSTATE;
                fillImage.fillAmount = 0;



                foreach (Unit g in UnityEngine.Object.FindObjectsOfType <Unit>())
                {
                    if (g is ItemManager)
                    {
                    }
                    else
                    {
                        Destroy(g.gameObject);
                    }
                }

                EnemySpawner.instance.StopAllCoroutines();
                PickupAndItemSpawner.instance.StopAllCoroutines();

                crown.gameObject.SetActive(true);
            }
            else
            {
                if (Time.time > lastHeal)
                {
                    boss.HP++;
                    if (boss.HP > boss.MaxHP)
                    {
                        boss.HP = boss.MaxHP;
                    }
                    lastHeal = Time.time + healInterval;
                }


                fillImage.fillAmount = (float)boss.HP / (float)boss.MaxHP;
            }

            break;

        case WorldState.ENDSTATE:

            break;
        }
    }