public virtual IEnumerator ElectronToTray()
    {
        TrayGUI[] allTrays = (TrayGUI[])UnityEngine.Object.FindObjectsOfType(typeof(TrayGUI));
        TrayGUI   theTray  = null;
        int       i        = 0;

        while (i < allTrays.Length)
        {
            if (allTrays[i].acceptTypes[2] == 1)
            {
                theTray = allTrays[i];
            }
            i++;
        }
        Vector2           origin = DragNDrop.WorldToScreen(Vector3.right * this.orbitals.shells[this.orbitals.outerShell].radius);
        GameObject        obj    = new GameObject("Draggable");
        Draggable_Nucleon dr     = (Draggable_Nucleon)obj.AddComponent(typeof(Draggable_Nucleon));

        dr.type = PType.E;
        float time      = 0.8f;
        float startTime = Time.time;

        while (Time.time < (startTime + time))
        {
            float amt = (Time.time - startTime) / time;
            dr.position = (origin * (1f - amt)) + ((theTray.position - new Vector2(0, ((UnityScript.Lang.UnityBuiltins.parseFloat(theTray.dimensions.y) - 0.5f) * theTray.itemSize.y) * 0.5f)) * amt);
            yield return(null);
        }
        theTray.Drop(dr);
        dr.Die();
    }
Пример #2
0
    public virtual IEnumerator Start()
    {
        PType   type       = default(PType);
        Vector2 screenSize = new Vector2(Screen.width, Screen.height);
        int     i          = 0;
        int     ii         = 0;

        this.mainDisplayStyle = new GUIStyle();
        this.mainDisplayStyle.normal.background = this.mainDisplayTexture;
        this.mainDisplayStyle.border            = this.mainDisplayBorder;
        this.labelStyle = new GUIStyle();
        this.labelStyle.normal.textColor = this.color;
        this.labelStyle.font             = this.font;
        this.labelStyle.padding          = this.boxEdge;
        this.labelStyle.padding.left     = this.labelStyle.padding.left + 5;
        this.buttonStyle = new GUIStyle();
        this.buttonStyle.normal.background = this.buttonTexture;
        this.buttonStyle.hover.background  = this.buttonTextureHover;
        this.boxStyle      = new GUIStyle();
        this.boxStyle.font = this.font;
        this.boxStyle.normal.background = this.boxTexture;
        this.boxStyle.normal.textColor  = this.color;
        this.boxStyle.hover.background  = this.boxTextureHover;
        this.boxStyle.hover.textColor   = Color.white;
        this.boxStyle.padding.left      = 6;
        this.boxStyle.padding.top       = 4;
        this.boxStyle.border            = this.boxBorder;
        this.trays = new TrayGUI[3];
        i          = 0;
        while (i < 3)
        {
            type = (PType)(i + 1);
            GameObject obj = new GameObject(("" + type) + " Tray");
            obj.transform.parent = this.transform;
            TrayGUI tray = (TrayGUI)obj.AddComponent(typeof(TrayGUI));
            tray.texture  = this.boxTexture;
            tray.border   = this.boxBorder.right;
            tray.itemSize = (new Vector2(1, 1) * this.itemSize) * CreatorGUI.guiScale;
            this.traySize = new Vector2(tray.itemSize.x + (tray.border * 1.4f), (tray.itemSize.y * (this.trayHeight - 1)) + (tray.border * 0.5f));
            Vector2 traySpacing = new Vector2(tray.itemSize.x + (tray.border * 1.35f), tray.itemSize.y * (this.trayHeight - 1));
            tray.position    = new Vector2((traySpacing.x * (UnityScript.Lang.UnityBuiltins.parseFloat(i) + 0.5f)) + (tray.border * 0.3f), screenSize.y - ((traySpacing.y * 0.5f) - (tray.itemSize.y * 0.5f)));
            tray.dimensions  = new Vector2(1, this.trayHeight);
            tray.acceptTypes = new int[3];
            ii = 0;
            while (ii < tray.acceptTypes.Length)
            {
                tray.acceptTypes[i] = 0;
                ii++;
            }
            tray.acceptTypes[i] = 1;
            this.trays[i]       = tray;
            i++;
        }
        yield return(null);

        i = 0;
        while (i < 3)
        {
            type = (PType)(i + 1);
            this.trays[i].contents[0].type = PType.Empty;
            ii = 1;
            while (ii < this.trays[i].contents.Length)
            {
                this.trays[i].contents[ii].type = type;
                ii++;
            }
            i++;
        }
        this.initialized = true;
    }