コード例 #1
0
    void Update()
    {
        if (paused)
        {
            return;
        }

        if (time > -1)
        {
            if (time > duration * numberOfShifts)
            {
                Debug.Log("counting and time > duration index is " + index.ToString());
                displayer.Remove(this);
                Fade();
                time           = 0f;
                counting       = false;
                numberOfShifts = 1;
            }
            else
            {
                timerImage.fillAmount = time / duration;
                time += Time.deltaTime;
            }
        }

        if (shiftParam > -1)
        {
            if (shiftParam >= 1f)
            {
                shiftParam = -1f;
            }
            else
            {
                // shift left;
                transform.localPosition = new Vector3(leftOffset + (1 + index) * width - width * moveFunction(shiftParam), yVal, 0f);
                shiftParam += Time.deltaTime / shiftLifetime;
            }
        }
        if (fadeParam > -1)
        {
            if (fadeParam >= 1f)
            {
                fadeParam          = -1f;
                abilityImage.color = new Color(abilityImage.color.r, abilityImage.color.g, abilityImage.color.b, 0f);
                timerImage.color   = new Color(timerImage.color.r, timerImage.color.g, timerImage.color.b, 0f);
            }
            else
            {
                abilityImage.color = new Color(abilityImage.color.r, abilityImage.color.g, abilityImage.color.b, fadeFunction(fadeParam));
                timerImage.color   = new Color(timerImage.color.r, timerImage.color.g, timerImage.color.b, fadeFunction(fadeParam));
                fadeParam         += Time.deltaTime / fadeLifetime;
            }
        }
    }
コード例 #2
0
ファイル: CollisionTracker.cs プロジェクト: smhx/Spawn
    void Update()
    {
        for (int i = 0; i < numAbilities; ++i)
        {
            if (usesIcon[i] && endPoints[i].Count > 0)
            {
                if (i == (int)AbilityTypes.Freeze && ObjectPooler.SharedInstance.GetAllActiveGameObjects("Brick").Count == 0)
                {
                    //end freeze early if there are no active bricks
                    time[i] = 0f;
                    endPoints[i].Clear();
                    expectedDuration[i] = 0f;
                    abilityForBrick[i].EndAbility();
                    displayer.Remove(AbilityTypes.Freeze);
                    continue;
                }

                Ability a = abilityForBrick[i];

                displayer.UpdateIconStatus(a.type, time[i] / expectedDuration[i]);
                if (endPoints[i].Count == 0)
                {
                    Debug.LogError("CollisionTracker::Update: No endPoints for ability " + (a.type).ToString());
                }
                while (endPoints[i].Count != 0 && time[i] > endPoints[i].Peek())
                {
                    endPoints[i].Dequeue();
                }

                if (endPoints[i].Count == 0)
                {
                    a.EndAbility();
                    displayer.Remove(a.type);
                }
                time[i] += Time.deltaTime * timeScale;
            }
        }
    }