Ejemplo n.º 1
0
 void Start()
 {
     Tracker        = FindObjectOfType <ManagerTracker>();
     StartingScale  = transform.localScale;
     CurrentChanges = (float)Tracker.GetType().GetField(ValueNameCurrent).GetValue(Tracker);
 }
Ejemplo n.º 2
0
    void FixedUpdate()
    {
        if (!Tracker.FullyFunctional)
        {
            return;
        }

        float current = (float)Tracker.GetType().GetField(ValueNameCurrent).GetValue(Tracker);
        float max     = (float)Tracker.GetType().GetField(ValueNameMax).GetValue(Tracker);

        //Reverse static
        if (ReverseStaticOnIncrease == true)
        {
            //print(FakeVelo);
            if (CurrentChanges < current && RunOnce == true)
            {
                if (UseStaticBarChange == true)
                {
                    UseStaticBarChange = false;
                }
                else
                {
                    UseStaticBarChange = true;
                }
                RunOnce = false;
            }
            else
            {
                if (RunOnce == false)
                {
                    if (UseStaticBarChange == true)
                    {
                        if (UseStaticBarChange == true)
                        {
                            UseStaticBarChange = false;
                        }
                        else
                        {
                            UseStaticBarChange = true;
                        }
                        RunOnce = true;
                    }
                    else if (ReverseStaticOnIncrease == true)
                    {
                        //print(FakeProgress + "/" + (Realprogress - Mathf.Epsilon));
                        if (FakeProgress >= (current / max) - Mathf.Epsilon)
                        {
                            if (RunOnce == false)
                            {
                                if (UseStaticBarChange == true)
                                {
                                    UseStaticBarChange = false;
                                }
                                else
                                {
                                    UseStaticBarChange = true;
                                }
                                RunOnce = true;
                            }
                        }
                    }
                }
            }
        }

        if (UseStaticBarChange == true)
        {
            //Get a percentage of bar value left
            float progress = (current / max);
            FakeProgress = progress;
            Vector3 modifiedScale = StartingScale;
            if (Horizontal == true)
            {
                modifiedScale = new Vector3(StartingScale.x * FakeProgress, StartingScale.y, StartingScale.z);
            }
            else
            {
                modifiedScale = new Vector3(StartingScale.x, StartingScale.y * FakeProgress, StartingScale.z);
            }
            transform.localScale = modifiedScale;
        }
        else
        {
            float progress = (current / max);
            //Get a percentage of bar value left
            FakeProgress = Mathf.SmoothDamp(FakeProgress, progress, ref FakeVelo, Smoothness);
            Vector3 modifiedScale = StartingScale;
            if (Horizontal == true)
            {
                modifiedScale = new Vector3(StartingScale.x * FakeProgress, StartingScale.y, StartingScale.z);
            }
            else
            {
                modifiedScale = new Vector3(StartingScale.x, StartingScale.y * FakeProgress, StartingScale.z);
            }
            transform.localScale = modifiedScale;
        }
        CurrentChanges = current;
    }
Ejemplo n.º 3
0
    void Update()
    {
        if (!Tracker.FullyFunctional)
        {
            return;
        }
        bool visible = (bool)Tracker.GetType().GetField(ValueToWatch).GetValue(Tracker);

        if (visible)
        {
            if (!RunOnce)
            {
                return;
            }
            if (TheText != null)
            {
                TheText.enabled = true;
            }
            else if (TheImage != null)
            {
                if (TheButton != null)
                {
                    TheImage.enabled  = true;
                    TheButton.enabled = true;
                }
                else
                {
                    TheImage.enabled = true;
                }
            }
            else if (TheMeshRenderer != null)
            {
                TheMeshRenderer.enabled = true;
            }
            RunOnce = false;
        }
        else
        {
            if (RunOnce)
            {
                return;
            }
            if (TheText != null)
            {
                TheText.enabled = false;
            }
            else if (TheImage != null)
            {
                if (TheButton != null)
                {
                    TheImage.enabled  = false;
                    TheButton.enabled = false;
                }
                else
                {
                    TheImage.enabled = false;
                }
            }
            else if (TheMeshRenderer != null)
            {
                TheMeshRenderer.enabled = false;
            }
            RunOnce = true;
        }
    }