示例#1
0
 public virtual void Go()
 {
     if (Ngnome.nMGMT)
     {
         Isotope iso          = AtomChart.ClosestStableNuclide(UserAtom.p, UserAtom.n);
         int     totalChanges = Mathf.Abs(iso.p - UserAtom.p) + Mathf.Abs(iso.n - UserAtom.n);
         if (totalChanges != 0)
         {
             this.dialog.enabled = true;
             this.dialog.mode    = 0;
         }
         else
         {
             //dialog.message = "it is not stable";
             Application.LoadLevel(1);
         }
     }
     else
     {
         Application.LoadLevel(1);
     }
 }
示例#2
0
    public virtual IEnumerator Go2()
    {
        if (this.going)
        {
            yield break;
        }
        this.going       = true;
        this.dnd.enabled = false;
        Isotope iso          = AtomChart.ClosestStableNuclide(UserAtom.p, UserAtom.n);
        int     totalChanges = Mathf.Abs(iso.p - UserAtom.p) + Mathf.Abs(iso.n - UserAtom.n);

        if (totalChanges == 0)
        {
            Application.LoadLevel(1);
            yield break;
        }
        while ((iso.p != UserAtom.p) || (iso.n != UserAtom.n))
        {
            bool add = false;
            bool pr  = false;
            if (iso.n < UserAtom.n)
            {
                add = false;
                pr  = false;
            }
            if (iso.n > UserAtom.n)
            {
                add = true;
                pr  = false;
            }
            if (iso.p < UserAtom.p)
            {
                add = false;
                pr  = true;
            }
            if (iso.p > UserAtom.p)
            {
                add = true;
                pr  = true;
            }
            float overallSpeed = Mathf.Max((0.5f + Mathf.Min(2, totalChanges / 6)) * (pr ? 0.3f : 1f), 0.25f);
            this.SetFrame(add ? 3 : 0, pr);
            float moveTime = 0.5f / overallSpeed;
            float leftPos  = -3.25f;
            float rightPos = this.sfr.TransformPoint(new Vector3(-0.5f, 0, 0)).x + 1f;
            float lastTime = Time.time;
            while (Time.time < (lastTime + moveTime))
            {
                {
                    float   _77 = this.SineLerp(leftPos, rightPos, (Time.time - lastTime) / moveTime);
                    Vector3 _78 = this.transform.position;
                    _78.x = _77;
                    this.transform.position = _78;
                }
                yield return(null);
            }
            this.SetFrame(add ? 2 : 1, pr);
            yield return(new WaitForSeconds(0.1f / overallSpeed));

            this.SetFrame(add ? 1 : 2, pr);
            if (add)
            {
                if (pr)
                {
                    this.nucleus.p++;
                }
                else
                {
                    this.nucleus.n++;
                }
            }
            else
            {
                if (pr)
                {
                    this.nucleus.p--;
                }
                else
                {
                    this.nucleus.n--;
                }
            }
            this.nucleus.Rebuild();
            lastTime = Time.time;
            while (Time.time < (lastTime + moveTime))
            {
                float amt = (Time.time - lastTime) / moveTime;
                if (amt > 0.2f)
                {
                    this.SetFrame(add ? 0 : 3, pr);
                }

                {
                    float   _79 = this.SineLerp(rightPos, leftPos, amt);
                    Vector3 _80 = this.transform.position;
                    _80.x = _79;
                    this.transform.position = _80;
                }
                yield return(null);
            }
        }
        this.dialog.enabled = true;
        this.dialog.mode    = 1;
        this.going          = false;
    }