// Update is called once per frame
    void Update()
    {
        if (TerritoryMgr == null || curAnim != null || (StateToCall = StateToCall.ToUpperInvariant()) == currentStateId)
        {
            return;
        }

        Debug.Log("StateToCall=" + StateToCall + ", curState=" + currentStateId + "");

        if (currentStateId != "")
        {
            currentStateId = "";
            if (currentState != null)
            {
                Destroy(currentState);
            }
            for (int i = 0; i < ActivateDuringCallout.Length; i++)
            {
                ActivateDuringCallout[i].SetActive(false);
            }
        }

        if (StateToCall == null || StateToCall.Length < 1)
        {
            return;
        }

        var stateData = TerritoryMgr.GetStateByShortId(StateToCall.ToUpperInvariant());

        if (stateData != null)
        {
            currentStateId = stateData.ShortId;
            curAnim        = StartCoroutine(animatedCallout(stateData));
        }
    }
    void updatePlaying()
    {
        if (StateInfo.AllStates.Length < 1)
        {
            return;
        }

        Gradient g;

        if (mode == 0)
        {
            g = FoundedColors;
            ModeDisplayText.text = "Sorting by Founding Date";
            StateInfo.SortByFounded();
        }
        else if (mode == 1)
        {
            g = PopulationColors;
            ModeDisplayText.text = "Sorting by Population";
            StateInfo.SortByPopulation();
        }
        else if (mode == 2)
        {
            g = LandAreaColors;
            ModeDisplayText.text = "Sorting by Total Land Area";
            StateInfo.SortByLandArea();
        }
        else
        {
            throw new UnityException("Unknown mode=" + mode);
        }

        pos = Mathf.Min(1, pos + Time.deltaTime / AnimationTime);

        for (int i = 0, count = StateInfo.AllStates.Length; i < count; i++)
        {
            Color c = DefaultColor;
            float p = (i / (count - 1f));
            if (pos >= p)
            {
                c = g.Evaluate(p);
            }

            var stateData = TerritoryMgr.GetStateByShortId(StateInfo.AllStates[i].StateId);

            if (stateData.UiImage.color != c)
            {
                stateData.UiImage.color = c;
                if (c != DefaultColor)
                {
                    StartCoroutine(scaleAnim(stateData.Object.transform));
                }
            }
        }

        if (pos >= 1)
        {
            isPaused = true;
        }
    }