// Update is called once per frame
    private void Update()
    {
        // do not update the attack UI if the ATTACKING state is frozen
        if (UIController.instance.frozenState != UIController.UIState.PAUSE)
        {
            return;
        }

        if (ArenaManager.instance.firstTurn)
        {
            return;
        }
        for (int i = 0; i < allFightUiInstances.Count; i++)
        {
            if (!boundFightUiInstances.Contains(allFightUiInstances[i]))
            {
                if (allFightUiInstances[i].Finished())
                {
                    allFightUiInstances[i].slice.Remove();
                    if (allFightUiInstances[i].lifeBar)
                    {
                        Destroy(allFightUiInstances[i].lifeBar.gameObject);
                        Destroy(allFightUiInstances[i].damageText.gameObject);
                        Destroy(allFightUiInstances[i].gameObject);
                    }
                    allFightUiInstances.RemoveAt(i);
                    i--;
                }
            }
        }

        if (finishingFade)
        {
            float resizeProg = 1.0f - ArenaManager.instance.getProgress();
            setAlpha(resizeProg);
            if (resizeProg != 0.0f)
            {
                return;
            }
            while (boundFightUiInstances.Count != 0)
            {
                allFightUiInstances.Remove(boundFightUiInstances[boundFightUiInstances.Count - 1]);
                Destroy(boundFightUiInstances[boundFightUiInstances.Count - 1].lifeBar.gameObject);
                Destroy(boundFightUiInstances[boundFightUiInstances.Count - 1].damageText.gameObject);
                Destroy(boundFightUiInstances[boundFightUiInstances.Count - 1].gameObject);
                boundFightUiInstances.RemoveAt(boundFightUiInstances.Count - 1);
            }
            targetRt.gameObject.SetActive(true);
            gameObject.GetComponent <Image>().enabled = true;
            finishingFade = false;
            if (allFightUiInstances.Count == 0)
            {
                gameObject.SetActive(false);
            }
            return;
        }
        if (boundFightUiInstances.Count != 0)
        {
            bool pass = boundFightUiInstances.All(t => t.slice.animcomplete && !t.slice.keyframes.enabled && stopped && t.waitingToFade);
            if (pass && boundFightUiInstances.All(fightUi => !fightUi.shakeInProgress))
            {
                initFade();
            }
        }

        if (stopped)
        {
            return;
        }

        float mv = xSpeed * Time.deltaTime;

        targetRt.anchoredPosition = new Vector2(targetRt.anchoredPosition.x + mv, 0);
        if (!Finished() || boundFightUiInstances.Count == 0)
        {
            return;
        }
        stopped = true;
        StationaryMissScript smc = Resources.Load <StationaryMissScript>("Prefabs/StationaryMiss");

        foreach (FightUI fightUi in boundFightUiInstances)
        {
            fightUi.enemy.HandleAttack(-1);
            StationaryMissScript smc2 = Instantiate(smc);
            if (fightUi.enemy.NoAttackMissText != null)
            {
                smc2.SetText(fightUi.enemy.NoAttackMissText);
            }
            smc2.transform.SetParent(GameObject.Find("Canvas").transform);
            if (fightUi.enemy.NoAttackMissText != null)
            {
                smc2.setXPosition(fightUi.enePos.x - 10 * fightUi.enemy.NoAttackMissText.Length + 20);
            }
            else
            {
                smc2.setXPosition(fightUi.enePos.x);
            }
        }
        initFade();
    }