コード例 #1
0
ファイル: Environment.cs プロジェクト: Xangotrick/CYGNUS
    public static void Light01Run(socketIG Tsock, float inte, float range)
    {

        if (Tsock.asock.getvals.vbool)
        {
            if (Tsock.asock.getelec.buffer > 0)
            {

                Tsock.asock.getelec.buffer = Tsock.asock.getelec.buffer - Tsock.asock.getelec.energyuse * Time.deltaTime;

                if (Tsock.asock.getelec.buffer > 2 * Tsock.asock.getelec.energyuse * Time.deltaTime)
                {
                    Tsock.asock.getelec.buffer = Tsock.asock.getelec.buffer - Tsock.asock.getelec.energyuse * Time.deltaTime;
                }
                else
                {
                    Tsock.asock.getelec.buffer = Tsock.asock.getelec.buffer - Tsock.asock.getelec.buffer / 10f;
                }
            }
            else
            {
                Tsock.asock.getelec.buffer = 0;
            }

            //print(Tsock.asock.getelec.energyuse * Time.deltaTime);  
            Light child = Tsock.instance.transform.GetComponentInChildren<Light>();
            ///NO SOLVE
            if (child != null)
            {
                if (Tsock.asock.getelec.buffer > 0)
                {

                    float thefloat = Math.Min(1, (Tsock.asock.getelec.buffer) / (1f * Tsock.asock.getelec.intake));
                    child.intensity = inte * thefloat;
                    child.range = range * thefloat;
                    Tsock.instance.GetComponent<MeshRenderer>().materials[0].SetColor("_EmissionColor", guitools.RGB(Tsock.asock.getvals.vVector3.x * thefloat, Tsock.asock.getvals.vVector3.y * thefloat, Tsock.asock.getvals.vVector3.z * thefloat, 255));

                }
                else
                {
                    child.intensity = 0;
                    Tsock.instance.GetComponent<MeshRenderer>().materials[0].SetColor("_EmissionColor", guitools.RGB(0, 0, 0, 255));
                }
            }
        }
    }
コード例 #2
0
ファイル: sprop.cs プロジェクト: Xangotrick/CYGNUS
        public void ElecHandling(socketIG Tsock)
        {
            if (Tsock.asock.getvals.vbool)
            {
                if (Tsock.asock.getelec.buffer > 0)
                {

                   /// Tsock.asock.getelec.buffer = Tsock.asock.getelec.buffer - Tsock.asock.getelec.energyuse * Time.deltaTime;

                    if (Tsock.asock.getelec.buffer > 2 * Tsock.asock.getelec.energyuse * Time.deltaTime * Tsock.asock.getvals.vfloat)
                    {
                        Tsock.asock.getelec.buffer = Tsock.asock.getelec.buffer - Tsock.asock.getelec.energyuse * Time.deltaTime * Tsock.asock.getvals.vfloat;
                    }
                    else
                    {
                        Tsock.asock.getelec.buffer = Tsock.asock.getelec.buffer - Tsock.asock.getelec.buffer / 10f;
                    }
                }
                else
                {
                    Tsock.asock.getelec.buffer = 0;
                }
            }

            float thefloat = Math.Min(1, (Tsock.asock.getelec.buffer) / (1f * Tsock.asock.getelec.intake)) * Tsock.asock.getvals.vfloat;

            if (!Tsock.asock.getvals.vbool)
            {
                thefloat = 0;
            }

            Tsock.instance.GetComponentInChildren<oxsource>().range = range * thefloat;
        }
コード例 #3
0
ファイル: gui.cs プロジェクト: Xangotrick/CYGNUS
    void DrawChest01Menu(socketIG thesock)
    {
        GUIStyle MenuStyle = new GUIStyle(prettyskin.label);

        guitools.SetStyle(MenuStyle, guitools.RGB(255, 255, 255, 255), Color.black, (int)Math.Round(18f));

        Rect darect = guitools.GRectRelative(0.25f, 0f, 0.5f, 0.5f, SmallerRect);
        darect = guitools.GRectRelative(0.9f, darect);
        darect = guitools.RectFromCenter(new Vector2(darect.x + darect.width/2f, darect.y + darect.height / 2f ), darect.height, darect.height);


        GUI.Label(darect, "", MenuStyle);

        darect = guitools.GRectRelative(0.8f, darect);
        Rect line1 = guitools.GRectRelative(0, 0, 1, 0.25f, darect);
        Rect line2 = guitools.GRectRelative(0, 0.25f, 1, 0.25f, darect);
        Rect line3 = guitools.GRectRelative(0, 0.5f, 1, 0.25f, darect);
        Rect line4 = guitools.GRectRelative(0, 0.75f, 1, 0.25f, darect);
        Rect currect = line1;



        guitools.SetStyle(MenuStyle, guitools.RGB(150, 150, 150, 255), Color.black, (int)Math.Round(18f));
        guitools.TextureStyle(MenuStyle, Twhite);

        guitools.TextureStyle(MenuStyle, Tvoid);
        Inventory theinv = thesock.asock.getinvs.aninv;
        for (int k = 0; k < theinv.inv.Length; k++)
        {
            currect = line1;
            if (k > 3)
            {
                currect = line2;
            }
            if (k > 7)
            {
                currect = line3;
            }
            if (k > 11)
            {
                currect = line4;
            }
            int mink = k % 4;
            currect = guitools.GRectRelative(mink / 4f, 0, 1 / 4f, 1, currect);
            Inventory.InvItem curritem = theinv.inv[k];



            guitools.TextureStyle(MenuStyle, Twhite);
            guitools.SetStyle(MenuStyle, guitools.RGB(220, 220, 220, 255), Color.black, (int)Math.Round(18f));
            GUI.Label(guitools.GRectRelative(0.9f, currect), "", MenuStyle);
            if (curritem.socket.asock.name != "")
            {
                Vector2 mousepos = Converters.MouseToScreen(Input.mousePosition);
                curritem.DrawItem(currect, MenuStyle, Tvoid);
                if (guitools.isinrect(mousepos, currect))
                {
                    inventoryname = curritem.socket.asock.disname;
                }
            }

            guitools.TextureStyle(MenuStyle, Tvoid);
            guitools.SetStyle(MenuStyle, guitools.RGB(255, 255, 255, 255), Color.black, (int)Math.Round(18f));
            if (GUI.Button(guitools.GRectRelative(0.9f, currect), "", MenuStyle))
            {
                MouseInvHeld = curritem.InteractItem(MouseInvHeld, theinv, k);
            }

        }
    }
コード例 #4
0
ファイル: gui.cs プロジェクト: Xangotrick/CYGNUS
    void DrawCaleFactor(socketIG thesock)
    {
        GUIStyle MenuStyle = new GUIStyle(prettyskin.label);

        guitools.SetStyle(MenuStyle, guitools.RGB(255, 255, 255, 255), Color.black, (int)Math.Round(18f));

        Rect darect = guitools.GRectRelative(0.25f, 0f, 0.5f, 0.5f, SmallerRect);
        darect = guitools.RectFromCenter(new Vector2(darect.x + darect.width / 2f, darect.y + darect.height / 2f), darect.height, darect.height);


        GUI.Label(guitools.GRectRelative(0, 0, 1, 0.1f, darect), "BURNING: " + Mathf.RoundToInt(thesock.asock.getvals.vfloat * 100) + "%", MenuStyle);
    }
コード例 #5
0
ファイル: gui.cs プロジェクト: Xangotrick/CYGNUS
    void DrawElecMenu(Rect arect, socketIG thesock, sprop.elec elec)
    {
        GUIStyle MenuStyle = new GUIStyle(prettyskin.label);

        guitools.SetStyle(MenuStyle, guitools.RGB(255, 255, 255, 255), Color.black, (int)Math.Round(18f));
        GUI.Label(arect, "", MenuStyle);

        List<string> alist = new List<string>();
        alist.Add("Max Power: " + elec.maxpower+ " EU/s");
        alist.Add("Max Power Output: " + elec.energyoutput + " EU/s");
        alist.Add("Power Intake: " + elec.intake + " EU/s");
        alist.Add("Power Usage: " + elec.energyuse + " EU/s");
        alist.Add("Buffer: " + Math.Round(thesock.asock.getelec.buffer) + " EU");
        alist.Add("Max Buffer: " + elec.maxbuffer + " EU");
        alist.Add("Efficiency: " + elec.loss*100 + "%");

        guitools.TextureStyle(MenuStyle, Tsquareh);

        for (int k = -2; k < alist.Count; k++)
        {
            if (k != -2)
            {
                if (k == -1)
                {
                    Rect newrect = guitools.GRectRelative(0, 0, 1, 2 / (alist.Count + 2f), arect);
                    guitools.SetStyle(MenuStyle, guitools.RGB(0, 0, 0, 255), Color.black, (int)Math.Round(10f));
                    GUI.Label(guitools.GRectRelative(0, 0, 1, 1, newrect), "Electric Panel", MenuStyle);
                }
                else
                {
                    guitools.SetStyle(MenuStyle, guitools.RGB(0, 0, 0, 255), Color.black, (int)Math.Round(7f));
                    Rect newrect = guitools.GRectRelative(0, (2 + k) * 1 / (alist.Count + 2f), 1, 1 / (alist.Count + 2f), arect);
                    GUI.Label(guitools.GRectRelative(0, 0, 0.2f, 1, newrect), k + ".", MenuStyle);
                    MenuStyle.alignment = TextAnchor.MiddleLeft;
                    GUI.Label(guitools.GRectRelative(0.2f, 0, 0.8f, 1, newrect), alist[k], MenuStyle);
                    MenuStyle.alignment = TextAnchor.MiddleCenter;
                }
            }
        }
    }
コード例 #6
0
ファイル: gui.cs プロジェクト: Xangotrick/CYGNUS
    void DrawAirGen01Menu(Rect arect, socketIG thesock, sprop.elec elec, sprop.vals valis)
    {
        GUIStyle MenuStyle = new GUIStyle(prettyskin.label);

        guitools.SetStyle(MenuStyle, guitools.RGB(255, 255, 255, 255), Color.black, (int)Math.Round(18f));

        GUI.Label(arect, "", MenuStyle);

        if (GUI.Button(guitools.GRectRelative(0, 0.9f, 1, 0.1f, arect), "OK", MenuStyle))
        {
            isinteracting = false;
            NetworkerPhoton.RPCSetInteract(thesock.location, false, fserial.saveasstring(thesock.asock.props));
            Cursor.visible = false;
            Cursor.lockState = CursorLockMode.Locked;
            cam.controlmouse = true;
            cam.controlkeys = true;
        }

        Rect OffOnn = guitools.GRectRelative(0, 0.1f, 1, 0.1f, arect);

        if (valis.vbool)
        {
            GUI.Label(guitools.GRectRelative(0, 0, 1, 0.1f, arect), "STATUS : ONLINE", MenuStyle);
            valis.vbool = GUI.Toggle(guitools.GRectRelative(0.8f, (guitools.GRectRelative(0, 0, 1, 1, OffOnn))), valis.vbool, "TURN OFF", MenuStyle);
        }
        else
        {
            GUI.Label(guitools.GRectRelative(0, 0, 1, 0.1f, arect), "STATUS : OFFLINE", MenuStyle);
            valis.vbool = GUI.Toggle(guitools.GRectRelative(0.8f, (guitools.GRectRelative(0, 0, 1, 1, OffOnn))), valis.vbool, "TURN ON", MenuStyle);
        }

        Rect PowerEmmission = guitools.GRectRelative(0, 0.2f, 1, 0.1f, arect);
        GUI.Label(PowerEmmission, "sAIR PRODUCTION: " + Mathf.RoundToInt(valis.vfloat * 100) + "%", MenuStyle);
        PowerEmmission = guitools.GRectRelative(0, 0.3f, 1, 0.1f, arect);
        guitools.SetStyle(MenuStyle, guitools.RGB(200, 200, 200, 255), Color.black, (int)Math.Round(18f));
        GUIStyle MenuStyle2 = new GUIStyle(prettyskin.label);
        guitools.SetStyle(MenuStyle2, guitools.RGB(150, 150, 150, 255), Color.black, (int)Math.Round(18f));
        valis.vfloat = GUI.HorizontalSlider(guitools.GRectRelative(0.8f, PowerEmmission), valis.vfloat, 0, 1, MenuStyle, MenuStyle2);

    }
コード例 #7
0
ファイル: Environment.cs プロジェクト: Xangotrick/CYGNUS
    public static void M01TREADDIV(socketIG Tsock)
    {
        socketIG front = Environment.getmapwmap(Tsock.location + Tsock.instance.transform.forward);
        socketIG right = Environment.getmapwmap(Tsock.location + Tsock.instance.transform.right);
        socketIG left = Environment.getmapwmap(Tsock.location - Tsock.instance.transform.right);
        socketIG back = Environment.getmapwmap(Tsock.location - Tsock.instance.transform.forward);

        int raw = 0;
        int real = 0;

        if (front != null)
        {
            if (front.asock.israwinv)
            {
                raw++;
            }
            if (front.asock.isinv)
            {
                real++;
            }
        }
        if (right != null)
        {
            if (right.asock.israwinv)
            {
                raw++;
            }
            if (right.asock.isinv)
            {
                real++;
            }
        }
        if (left != null)
        {
            if (left.asock.israwinv)
            {
                raw++;
            }
            if (left.asock.isinv)
            {
                real++;
            }
        }
        int num = 0;

        for (int k = 0; k < Tsock.asock.getinvs.aninv.inv.Length; k++)
        {
            if (Tsock.asock.getinvs.aninv.inv[k].num != 0)
            {
                num = Tsock.asock.getinvs.aninv.inv[k].num;
            }
        }

        int[] disthem = new int[real];
        int rest = 0;
        if (real > 1)
        {
            for (int k = 0; k < real - 1; k++)
            {
                disthem[k] = num / real;
                rest += num / real;
            }
            disthem[real - 1] = num - rest;
        }
        else
        {
            disthem[0] = num;
        }


        int id = 0;

        if (front != null)
        {
            if (front.asock.isinv)
            {
                for (int k = 0; k < Tsock.asock.getinvs.aninv.inv.Length; k++)
                {
                    if (Tsock.asock.getinvs.aninv.inv[k].num != 0)
                    {
                        front.asock.getinvs.aninv.add(Tsock.asock.getinvs.aninv.inv[k].socket.asock.name, disthem[id]);
                        id++;
                        break;
                    }
                }
            }
            if (front.asock.israwinv)
            {
                if (Tsock.asock.getrawinvs.aninv.inv.Count != 0)
                {
                    front.asock.getrawinvs.aninv.add(Tsock.asock.getrawinvs.aninv.inv[0].id, Tsock.asock.getrawinvs.aninv.inv[0].kg/ (raw * 1f));
                }
            }
        }
        if (left != null)
        {
            if (left.asock.isinv)
            {
                for (int k = 0; k < Tsock.asock.getinvs.aninv.inv.Length; k++)
                {
                    if (Tsock.asock.getinvs.aninv.inv[k].num != 0)
                    {
                        left.asock.getinvs.aninv.add(Tsock.asock.getinvs.aninv.inv[k].socket.asock.name, disthem[id]);
                        id++;
                        break;
                    }
                }
            }
            if (left.asock.israwinv)
            {
                if (Tsock.asock.getrawinvs.aninv.inv.Count != 0)
                {
                    left.asock.getrawinvs.aninv.add(Tsock.asock.getrawinvs.aninv.inv[0].id, Tsock.asock.getrawinvs.aninv.inv[0].kg / (raw * 1f));
                }
            }
        }
        if (right != null)
        {
            if (right.asock.isinv)
            {
                for (int k = 0; k < Tsock.asock.getinvs.aninv.inv.Length; k++)
                {
                    if (Tsock.asock.getinvs.aninv.inv[k].num != 0)
                    {
                        right.asock.getinvs.aninv.add(Tsock.asock.getinvs.aninv.inv[k].socket.asock.name, disthem[id]);
                        id++;
                        break;
                    }
                }
            }
            if (right.asock.israwinv)
            {
                if (Tsock.asock.getrawinvs.aninv.inv.Count != 0)
                {
                    right.asock.getrawinvs.aninv.add(Tsock.asock.getrawinvs.aninv.inv[0].id, Tsock.asock.getrawinvs.aninv.inv[0].kg / (raw * 1f));
                }
            }
        }


        for (int k = 0; k < Tsock.asock.getinvs.aninv.inv.Length; k++)
        {
            if (Tsock.asock.getinvs.aninv.inv[k].num != 0)
            {
                Tsock.asock.getinvs.aninv.inv[k] = new Inventory.InvItem();
                break;
            }
        }
        if (Tsock.asock.getrawinvs.aninv.inv.Count != 0)
        {
            Tsock.asock.getrawinvs.aninv.inv.RemoveAt(0);
        }


        if (back != null)
        {
            if (back.asock.isinv)
            {
                if (!back.asock.getinvs.aninv.protectsuction)
                {
                    for (int k = 0; k < back.asock.getinvs.aninv.inv.Length; k++)
                    {
                        if (back.asock.getinvs.aninv.inv[k].num != 0)
                        {
                            Tsock.asock.getinvs.aninv.add(back.asock.getinvs.aninv.inv[k].socket.asock.name, back.asock.getinvs.aninv.inv[k].num);

                            back.asock.getinvs.aninv.inv[k] = new Inventory.InvItem();
                            break;
                        }
                    }
                }
            }
            if (back.asock.israwinv)
            {
                if (!back.asock.getrawinvs.aninv.protectsuction)
                {
                    if (back.asock.getrawinvs.aninv.inv.Count != 0)
                    {
                        Tsock.asock.getrawinvs.aninv.add(back.asock.getrawinvs.aninv.inv[0].id, back.asock.getrawinvs.aninv.inv[0].kg);
                        back.asock.getrawinvs.aninv.inv.RemoveAt(0);
                    }
                }
            }
        }
    }
コード例 #8
0
ファイル: gui.cs プロジェクト: Xangotrick/CYGNUS
    void DrawRawInv(RawInv araw, socketIG thesock, Rect darect)
    {
        GUIStyle MenuStyle = new GUIStyle(prettyskinloseend.label);
        GUI.Label( darect, "", MenuStyle);
        RawInv theinv = araw;
        Rect lineend = guitools.GRectRelative(0, 0.85f, 1, 0.15f, darect);
        guitools.SetStyle(MenuStyle, guitools.RGB(150, 150, 150, 255), Color.black, (int)Math.Round(10f));
        GUI.Label(guitools.GRectRelative(0, 0, 1, 0.1f, darect,0.9f), "Raw Ressource", MenuStyle);
        guitools.SetStyle(MenuStyle, guitools.RGB(150, 150, 150, 255), Color.black, (int)Math.Round(10f));
        GUI.Label(guitools.GRectRelative(0, 0.9f, 1, 0.1f, darect, 0.9f), "MASS: " + theinv.readkg + "kg OF " + theinv.maxmass + "kg", MenuStyle);

        if (theinv.inv.Count < 10)
        {
            for (int k = 0; k < 10; k++)
            {
                Rect workingrect = guitools.GRectRelative(0, 0.1f, 1, 0.8f, darect);
                int mink = k % 10;
                Rect slotrect = guitools.GRectRelative(0, mink / 10f, 1, 1 / 10f, workingrect, 0.9f);

                guitools.SetStyle(MenuStyle, guitools.RGB(230, 230, 230, 255), Color.black, (int)Math.Round(7f));
                GUI.Label(slotrect, "", MenuStyle);

                if (k < theinv.inv.Count)
                {
                    guitools.SetStyle(MenuStyle, guitools.RGB(200, 200, 200, 255), Color.black, (int)Math.Round(5f));
                    GUI.Label(slotrect, "", MenuStyle);
                    guitools.TextureStyle(MenuStyle, Tvoid);
                    MenuStyle.alignment = TextAnchor.MiddleLeft;
                    GUI.Label(guitools.GRectRelative(0, 0, 2 / 3f, 1, slotrect), theinv.inv[k].raw.name + ": ", MenuStyle);
                    MenuStyle.alignment = TextAnchor.MiddleRight;
                    GUI.Label(guitools.GRectRelative(0, 0, 2 / 3f, 1, slotrect), theinv.inv[k].readkg + "kg", MenuStyle);

                    MenuStyle.alignment = TextAnchor.MiddleCenter;
                    guitools.TextureStyle(MenuStyle, TArrowRight);
                    guitools.SetStyle(MenuStyle, guitools.RGB(100, 100, 100, 255), Color.black, (int)Math.Round(7f));
                    GUI.Label(guitools.GRectRelative(0.2f, 0, 0.6f, 1, guitools.GRectRelative(2 / 3f, 0, 1 / 6f, 1, slotrect, 0.9f)), "", MenuStyle);
                    MenuStyle = new GUIStyle(prettyskin.label);
                    guitools.SetStyle(MenuStyle, guitools.RGB(175, 175, 175, 100), Color.black, (int)Math.Round(7f));
                    if (GUI.Button(guitools.GRectRelative(2 / 3f, 0, 1 / 6f, 1, slotrect), "", MenuStyle))
                    {
                        float rest = worldgen.maininfo.rawinv.add(theinv.inv[k].id, theinv.inv[k].kg);
                        foreach (RawInv.rawlibitem item in theinv.inv)
                        {
                            if (item.id == theinv.inv[k].id)
                            {
                                item.kg = rest;
                            }
                        }
                    reset:
                        if (theinv.inv.Count > 0)
                        {
                            for (int k2 = 0; k2 < theinv.inv.Count; k2++)
                            {
                                if (theinv.inv[k2].kg <= 0)
                                {
                                    theinv.inv.RemoveAt(k2);
                                    goto reset;
                                }
                            }
                        }
                    }



                    MenuStyle.alignment = TextAnchor.MiddleCenter;
                    guitools.TextureStyle(MenuStyle, Twhite);
                }

            }
        }
    }
コード例 #9
0
ファイル: Environment.cs プロジェクト: Xangotrick/CYGNUS
    public static void M01Miner(socketIG Tsock)
    {
        if (Tsock.asock.getelec.buffer > 0 && Tsock.asock.getvals.vbool)
        {
            Tsock.asock.getelec.buffer = Tsock.asock.getelec.buffer - Tsock.asock.getelec.energyuse * Time.deltaTime;
            float rand = charnetworkbehavior.arand.Next(100);
            rand = rand / 100f;
            if (rand < 0.5f)
            {
                if (rand < 0.2f)
                {
                    Tsock.asock.getrawinvs.aninv.add("Rough Coal", Time.deltaTime * 2 / 60f);
                }
                else
                {
                    if (rand < 0.35f)
                    {
                    }
                    else
                    {
                        if (rand < 0.45f)
                        {
                            Tsock.asock.getrawinvs.aninv.add("Silicon", Time.deltaTime * 2 / 60f);
                        }
                        else
                        {

                        }
                    }
                }
            }
            else
            {
                Tsock.asock.getrawinvs.aninv.add("Iron Oxide", Time.deltaTime * 4 / 60f);
            }
        }
        else
        {
            Tsock.asock.getelec.buffer = 0;
        }
    }
コード例 #10
0
ファイル: Environment.cs プロジェクト: Xangotrick/CYGNUS
    public static void M01TREAD(socketIG Tsock)
    {
        socketIG front = Environment.getmapwmap(Tsock.location + Tsock.instance.transform.forward);
        socketIG back = Environment.getmapwmap(Tsock.location - Tsock.instance.transform.forward);

        if (front != null)
        {
            if (front.asock.isinv)
            {
                for (int k = 0; k < Tsock.asock.getinvs.aninv.inv.Length; k++)
                {
                    if (Tsock.asock.getinvs.aninv.inv[k].num != 0)
                    {
                        front.asock.getinvs.aninv.add(Tsock.asock.getinvs.aninv.inv[k].socket.asock.name, Tsock.asock.getinvs.aninv.inv[k].num);

                        Tsock.asock.getinvs.aninv.inv[k] = new Inventory.InvItem();
                        break;
                    }
                }
            }
            if (front.asock.israwinv)
            {
                if (Tsock.asock.getrawinvs.aninv.inv.Count != 0)
                {
                    front.asock.getrawinvs.aninv.add(Tsock.asock.getrawinvs.aninv.inv[0].id, Tsock.asock.getrawinvs.aninv.inv[0].kg);
                    Tsock.asock.getrawinvs.aninv.inv.RemoveAt(0);
                }
            }
        }

        if (back != null)
        {
            if (back.asock.isinv)
            {
                if (!back.asock.getinvs.aninv.protectsuction)
                {
                    for (int k = 0; k < back.asock.getinvs.aninv.inv.Length; k++)
                    {
                        if (back.asock.getinvs.aninv.inv[k].num != 0)
                        {
                            Tsock.asock.getinvs.aninv.add(back.asock.getinvs.aninv.inv[k].socket.asock.name, 1);

                            if (back.asock.getinvs.aninv.inv[k].num == 1)
                            {
                                back.asock.getinvs.aninv.inv[k] = new Inventory.InvItem();
                            }
                            else
                            {
                                back.asock.getinvs.aninv.inv[k].num--;
                            }
                            break;
                        }
                    }
                }
            }
            if (back.asock.israwinv)
            {
                if (!back.asock.getrawinvs.aninv.protectsuction)
                {
                    if (back.asock.getrawinvs.aninv.inv.Count != 0)
                    {
                        if (back.asock.getrawinvs.aninv.inv[0].kg < 1)
                        {
                            Tsock.asock.getrawinvs.aninv.add(back.asock.getrawinvs.aninv.inv[0].id, 1);
                            back.asock.getrawinvs.aninv.inv.RemoveAt(0);
                        }
                        else
                        {
                            Tsock.asock.getrawinvs.aninv.add(back.asock.getrawinvs.aninv.inv[0].id, 1);
                            back.asock.getrawinvs.aninv.inv[0].kg--;
                        }
                    }
                }
            }
        }
    }
コード例 #11
0
ファイル: Environment.cs プロジェクト: Xangotrick/CYGNUS
 public static void M01STEAMGEN(socketIG Tsock)
 {
     sprop.vals val = Tsock.asock.getvals;
     sprop.rawinvs raw = Tsock.asock.getrawinvs;
     if (val.vbool)
     {
         raw.aninv.add("Sulfur", refresh / 240f);
     }
 }
コード例 #12
0
ファイル: Environment.cs プロジェクト: Xangotrick/CYGNUS
 public static void M01COALGEN(socketIG Tsock)
 {
     sprop.vals val = Tsock.asock.getvals;
     sprop.rawinvs raw = Tsock.asock.getrawinvs;
     val.vbool = (val.vfloat > 0);
     if (val.vfloat == 0)
     {
         val.vfloat = raw.aninv.getcount("Rough Coal");
         if (val.vfloat != 0)
         {
             val.vint = 1;
             return;
         }
         val.vfloat = raw.aninv.getcount("Coal");
         if (val.vfloat != 0)
         {
             val.vint = 2;
             return;
         }
         val.vfloat = raw.aninv.getcount("Graphite");
         if (val.vfloat != 0)
         {
             val.vint = 3;
             return;
         }
     }
     else
     {
         switch (val.vint)
         {
             case 1:
                 raw.aninv.rem("Rough Coal", refresh / 60f);
                 val.vfloat = raw.aninv.getcount("Rough Coal");
                 break;
             case 2:
                 raw.aninv.rem("Coal", refresh / 120f);
                 val.vfloat = raw.aninv.getcount("Coal");
                 break;
             case 3:
                 raw.aninv.rem("Graphite", refresh / 180f);
                 val.vfloat = raw.aninv.getcount("Graphite");
                 break;
         }
     }
 }
コード例 #13
0
ファイル: Environment.cs プロジェクト: Xangotrick/CYGNUS
    public static void M01Calefactor(socketIG Tsock)
    {
        if (Tsock.asock.getvals.vbool)
        {
            if (Tsock.asock.getelec.buffer > 0)
            {
                Tsock.asock.getelec.buffer = Tsock.asock.getelec.buffer - Tsock.asock.getelec.energyuse * Time.deltaTime;
            }
            else
            {
                Tsock.asock.getelec.buffer = 0;
            }
        }
        sprop.vals val = Tsock.asock.getvals;
        val.vbool = (val.vfloat != 0);
        if (val.vfloat == 0)
        {
            if (Tsock.asock.getinvs.aninv.inv[0].num != 0)
            {
                val.vfloat = 1;
                switch (Tsock.asock.getinvs.aninv.inv[0].socket.asock.name)
                {
                    case "woodlog":
                        val.vint = 3;
                        break;
                    case "woodplank":
                        val.vint = 2;
                        break;
                    default:
                        val.vint = 1;
                        break;
                }

                Tsock.asock.getinvs.aninv.inv[0].num--;
                val.vfloat = 1;
                if (Tsock.asock.getinvs.aninv.inv[0].num == 0)
                {
                    Tsock.asock.getinvs.aninv.inv[0] = new Inventory.InvItem();
                }
            }
        }
        else
        {
            if (Tsock.asock.getelec.buffer > 0)
            {
                val.vfloat = val.vfloat - val.vint * Time.deltaTime * 1 / 60f;
                Tsock.asock.getrawinvs.aninv.add("Rough Coal", val.vint * Time.deltaTime * 1 / 60f);
            }
        }

        if (val.vfloat < 0)
        {
            val.vfloat = 0;
        }
    }
コード例 #14
0
ファイル: MechGrid.cs プロジェクト: Xangotrick/CYGNUS
 public MechGrid(socketIG astart)
 {
     thelist = new List<socketIG>();
     thelist.Add(astart);
     totalpower = 0;
 }
コード例 #15
0
ファイル: Environment.cs プロジェクト: Xangotrick/CYGNUS
    public static void GenEnvironment()
    {
        refresh = 0.5f;
        cmap = new socketIG[512,128,512];
        loadmap = new loadmapitem[cmap.GetLength(0) / 16, cmap.GetLength(2) / 16];
        heightmap = new int[cmap.GetLength(0), cmap.GetLength(02)];
        elecgrids = new List<ElectricGrid>();
        mechgrids = new List<MechGrid>();
        parcellist = new List<parcel>();
        markdeath = new List<Vector3>();
        markbuild = new List<Vector3>();
        marksocket = new List<socket>();
        markrot = new List<Vector3>();

        Vector3 avect = new Vector3();


        Vector3 cpos = convmaptoc(new Vector3(0, 0, 0));
        int[] thecoords = new int[] { Mathf.RoundToInt(cpos.x), Mathf.RoundToInt(cpos.y), Mathf.RoundToInt(cpos.z) };

        int[] chunkcoords = findchunk(thecoords[0], thecoords[2]);

        for (int k1 = 0; k1 < loadmap.GetLength(0); k1++)
        {
            for (int k2 = 0; k2 < loadmap.GetLength(1); k2++)
            {
                loadmap[k1, k2] = new loadmapitem(k1, k2, false);
            }
        }
        for (int k1 = 0; k1 < heightmap.GetLength(0); k1++)
        {
            for (int k2 = 0; k2 < heightmap.GetLength(1); k2++)
            {
                heightmap[k1, k2] = 75;
            }
        }


        for (int k1 = 0; k1 < loadmap.GetLength(0); k1++)
        {
            int[] bounds = boundaries(k1, loadmap.GetLength(1));
            Instantiate((GameObject)Resources.Load("prefab/" + "sinvwall2"), convctomap(new Vector3(bounds[0], 0, bounds[2])), Quaternion.identity);
            bounds = boundaries(k1, -1);
            Instantiate((GameObject)Resources.Load("prefab/" + "sinvwall2"), convctomap(new Vector3(bounds[0], 0, bounds[2])), Quaternion.identity);
        }
        for (int k1 = 0; k1 < loadmap.GetLength(1); k1++)
        {
            int[] bounds = boundaries(loadmap.GetLength(0), k1);
            Instantiate((GameObject)Resources.Load("prefab/" + "sinvwall2"), convctomap(new Vector3(bounds[0], 0, bounds[2])), Quaternion.identity);
            bounds = boundaries(-1, k1);
            Instantiate((GameObject)Resources.Load("prefab/" + "sinvwall2"), convctomap(new Vector3(bounds[0], 0, bounds[2])), Quaternion.identity);
        }
        /*
        for (int k1 = 0; k1 < cmap.GetLength(0); k1++)
        {
            for (int k2 = 0; k2 < cmap.GetLength(1); k2++)
            {
                for (int k3 = 0; k3 < cmap.GetLength(2); k3++)
                {
                    cmap[k1, k2, k3] = new socketIG(socket.socketlib[0], avect, null);
                }
            }
        }

        for (int kx = -7; kx < 7; kx++)
        {
            for (int kz = -7; kz < 7; kz++)
            {
                for (int ky = 0; ky < 65; ky++)
                {
                    //setmapwmap(new Vector3(kx, 0, kz), "dirt");
                    setmapwmap(new Vector3(kx, ky, kz), socket.socketlib[randomite.Next(2) + 1]);
                    setmapwmap(new Vector3(kx, ky, kz), socket.socketlib[randomite.Next(2) + 1]);
                }
            }
        }*/

        //LoadChunk(chunkcoords[0], chunkcoords[1]);


        
        
        
        worldgen.LoadWorld();
        //print("hei");
        /*
        for (int k1 = 0; k1 < cmap.GetLength(0); k1++)
        {
            for (int k2 = 0; k2 < cmap.GetLength(1); k2++)
            {
                for (int k3 = 0; k3 < cmap.GetLength(2); k3++)
                {
                    //setmapwmap(convctomap(new Vector3(k1, k2, k3)), cmap[k1, k2, k3].asock.name);
                }
            }
        }
        */
    }
コード例 #16
0
ファイル: MechGrid.cs プロジェクト: Xangotrick/CYGNUS
 public static bool areconnected(socketIG A, socketIG B)
 {
     if ((A.location - B.location).magnitude == 1)
     {
         return true;
     }
     return false;
 }
コード例 #17
0
ファイル: Environment.cs プロジェクト: Xangotrick/CYGNUS
    public static void AddBlock(Vector3 mappos, socket tsock, Vector3 eulerrot)
    {
        mappos = new Vector3(Mathf.RoundToInt(mappos.x), Mathf.RoundToInt(mappos.y), Mathf.RoundToInt(mappos.z));
        socket newsocket = socket.copysocket(tsock);
        setmapwmap(mappos, newsocket);
        GameObject theinstance = getmapwmap(mappos).instance;
        if (!tsock.iswire)
        {
            if (tsock.name == "m01tread")
            {
                theinstance.transform.eulerAngles = new Vector3(0, eulerrot.y, eulerrot.z);
            }
            else
            {
                theinstance.transform.eulerAngles = eulerrot;
            }

        }
        socketIG result = new socketIG(newsocket, mappos, theinstance);

        if (newsocket.iselec)
        {
            HandleElecGridAdd(mappos, tsock, result);
            if (newsocket.name == "m01gensteam")
            {
                socketIG under = getmapwmap(mappos - new Vector3(0, 1, 0));
                if (under != null)
                {
                    if (under.asock.name == "basaltsource")
                    {
                        newsocket.getvals.vbool = true;
                    }
                }
            }
            if (newsocket.name == "m01miner")
            {
                socketIG under = getmapwmap(mappos - new Vector3(0, 1, 0));
                if (under != null)
                {
                    if (under.asock.name == "basalt")
                    {
                        newsocket.getvals.vbool = true;
                    }
                }
            }
        }

        if (newsocket.ismech)
        {
            HandleMechGridAdd(mappos, tsock, result);
        }
    }
コード例 #18
0
ファイル: gui.cs プロジェクト: Xangotrick/CYGNUS
    void Inputs()
    {
        if (Input.GetKeyDown(KeyCode.E) && !lexicon.ison && !controls.isfightingmode)
        {
            gui.isinvopen = !gui.isinvopen;

            if (gui.isinvopen)
            {
                Cursor.visible = true;
                Cursor.lockState = CursorLockMode.None;
                cam.controlmouse = false;
            }
            else
            {
                Cursor.visible = false;
                Cursor.lockState = CursorLockMode.Locked;
                cam.controlmouse = true;
            }
        }
        if (Input.GetKeyDown(KeyCode.H) && !isinteracting && !ischangingname && !isinvopen)
        {
            lexicon.ison = !lexicon.ison;
            if (lexicon.ison)
            {
                soundsys.SHon.Play();
                Cursor.lockState = CursorLockMode.None;
            }
            else
            {
                soundsys.Scancel.Play();
                Cursor.lockState = CursorLockMode.Locked;
            }
            Cursor.visible = lexicon.ison;
            Cursor.lockState = CursorLockMode.None;
            cam.controlmouse = !lexicon.ison;
            cam.controlkeys = !lexicon.ison;

        }
        if (controls.aimedpoint.y > -800 && controls.toolbar[controls.seltoolbar].socket.asock.name == "")
        {
            socketIG thesock = Environment.getmapwmap(controls.aimedpoint);

            try
            {
                if (thesock.asock != null)
                {
                    if (thesock.asock.props.Count != 0)
                    {
                        if (Input.GetKeyDown(KeyCode.B) && !isinteracting && !lexicon.ison)
                        {
                            ischangingname = true;
                            Cursor.visible = true;
                            Cursor.lockState = CursorLockMode.None;
                            cam.controlmouse = false;
                            cam.controlkeys = false;
                            workingon = thesock;
                        }
                        if (Input.GetMouseButtonDown(1) && !ischangingname)
                        {
                            if (thesock.asock.isinteract)
                            {
                                if (!thesock.asock.getinteract.abool)
                                {
                                    controls.hissoundsyst.SScrew.Play();
                                    page = 0;
                                    currentrecipe = 0;
                                    isinteracting = true;
                                    NetworkerPhoton.RPCSetInteract(thesock.location, true, "");
                                    Cursor.visible = true;
                                    Cursor.lockState = CursorLockMode.None;
                                    cam.controlmouse = false;
                                    cam.controlkeys = false;
                                    workingon = thesock;
                                    lexicon.ison = false;
                                    if (thesock.asock.isinv || thesock.asock.israwinv)
                                    {
                                        isinvopen = true;
                                    }
                                }
                            }
                        }
                    }
                    if (Input.GetMouseButtonDown(2))
                    {
                        NetworkerPhoton.RPCSetColorBlock(thesock.location, controls.randforcolor);
                    }
                }
            }
            catch (NullReferenceException)
            {
            }
        }
    }
コード例 #19
0
ファイル: Environment.cs プロジェクト: Xangotrick/CYGNUS
    public static void HandleMechGridAdd(Vector3 mappos, socket tsock, socketIG result)
    {
        List<int> foundgrid = new List<int>();

        if (mechgrids.Count > 0)
        {
            for (int kg = 0; kg < mechgrids.Count; kg++)
            {
                foreach (socketIG asock in mechgrids[kg].thelist)
                {
                    bool thebool = asock.location == mappos + new Vector3(01, 0, 0) || asock.location == mappos + new Vector3(0, 01, 0) || asock.location == mappos + new Vector3(0, 0, 01) || asock.location == mappos + new Vector3(-1, 0, 0) || asock.location == mappos + new Vector3(0, -1, 0) || asock.location == mappos + new Vector3(0, 0, -1);

                    if (thebool)
                    {
                        foundgrid.Add(kg);
                        break;
                    }
                }
            }
        }


        if (foundgrid.Count == 0)
        {
            MechGrid thegrid = new MechGrid(result);
            mechgrids.Add(thegrid);
            thegrid.refreshoncreate();
            parcellist = new List<parcel>();
        }

        if (foundgrid.Count == 1)
        {
            mechgrids[foundgrid[0]].thelist.Add(result);
            mechgrids[foundgrid[0]].refreshoncreate();
            parcellist = new List<parcel>();
        }

        if (foundgrid.Count > 1)
        {
            List<socketIG> alist = new List<socketIG>();
            for (int k = 0; k < foundgrid.Count; k++)
            {
                for (int k2 = 0; k2 < mechgrids[foundgrid[k]].thelist.Count; k2++)
                {
                    alist.Add(mechgrids[foundgrid[k]].thelist[k2]);
                }
            }
            alist.Add(result);

            for (int k = mechgrids.Count - 1; k >= 0; k--)
            {
                bool isequal = false;
                foreach (int anint in foundgrid)
                {
                    if (k == anint)
                    {
                        isequal = true;
                    }
                }
                if (isequal)
                {
                    mechgrids.RemoveAt(k);
                }
            }

            mechgrids.Add(new MechGrid(alist));
            mechgrids[mechgrids.Count - 1].refreshoncreate();
        }
    }
コード例 #20
0
ファイル: gui.cs プロジェクト: Xangotrick/CYGNUS
    void DrawMechMenu(Rect arect, socketIG thesock, sprop.mech mech)
    {
        GUIStyle MenuStyle = new GUIStyle(prettyskin.label);

        guitools.SetStyle(MenuStyle, guitools.RGB(255, 255, 255, 255), Color.black, (int)Math.Round(18f));
        GUI.Label(arect, "", MenuStyle);

        List<string> alist = new List<string>();
        alist.Add("ONLINE: " + mech.powered );
        alist.Add("Power Intake: " + mech.load + " MU");
        alist.Add("Power Output: " + mech.production + " MU");
        alist.Add("Max Power Output: " + mech.maxprod + " MU");
        alist.Add("Conversion Rate: " + mech.convratio * 100 + "%");

        guitools.TextureStyle(MenuStyle, Tsquareh);

        for (int k = -2; k < alist.Count; k++)
        {
            if (k != -2)
            {
                if (k == -1)
                {
                    Rect newrect = guitools.GRectRelative(0, 0, 1, 2 / (alist.Count + 2f), arect);
                    guitools.SetStyle(MenuStyle, guitools.RGB(0, 0, 0, 255), Color.black, (int)Math.Round(10f));
                    GUI.Label(guitools.GRectRelative(0, 0, 1, 1, newrect), "Mechanical Panel", MenuStyle);
                }
                else
                {
                    guitools.SetStyle(MenuStyle, guitools.RGB(0, 0, 0, 255), Color.black, (int)Math.Round(7f));
                    Rect newrect = guitools.GRectRelative(0, (2 + k) * 1 / (alist.Count + 2f), 1, 1 / (alist.Count + 2f), arect);
                    GUI.Label(guitools.GRectRelative(0, 0, 0.2f, 1, newrect), k + ".", MenuStyle);
                    MenuStyle.alignment = TextAnchor.MiddleLeft;
                    GUI.Label(guitools.GRectRelative(0.2f, 0, 0.8f, 1, newrect), alist[k], MenuStyle);
                    MenuStyle.alignment = TextAnchor.MiddleCenter;
                }
            }
        }
    }
コード例 #21
0
ファイル: Inventory.cs プロジェクト: Xangotrick/CYGNUS
 public InvItem()
 {
     socket = new socketIG();
     num = 0;
 }
コード例 #22
0
ファイル: gui.cs プロジェクト: Xangotrick/CYGNUS
    void DrawLight01Menu(Rect arect, socketIG thesock, sprop.elec elec, sprop.vals valis)
    {
        GUIStyle MenuStyle = new GUIStyle(prettyskin.label);

        guitools.SetStyle(MenuStyle, guitools.RGB(255, 255, 255, 255), Color.black, (int)Math.Round(18f));

        GUI.Label(arect, "", MenuStyle);

        if (GUI.Button(guitools.GRectRelative(0, 0.9f, 1, 0.1f, arect), "OK", MenuStyle))
        {
            isinteracting = false;
            NetworkerPhoton.RPCSetInteract(thesock.location, false, fserial.saveasstring(thesock.asock.props));
            Cursor.visible = false;
            cam.controlmouse = true;
            cam.controlkeys = true;
            Cursor.lockState = CursorLockMode.Locked;
        }

        Rect OffOnn = guitools.GRectRelative(0, 0.1f, 1, 0.1f, arect);

        if (valis.vbool)
        {
            GUI.Label(guitools.GRectRelative(0, 0, 1, 0.1f, arect), "STATUS : ONLINE", MenuStyle);
            valis.vbool = GUI.Toggle(guitools.GRectRelative(0.8f, (guitools.GRectRelative(0, 0, 1, 1, OffOnn))), valis.vbool, "TURN OFF", MenuStyle);
        }
        else
        {
            GUI.Label(guitools.GRectRelative(0, 0, 1, 0.1f, arect), "STATUS : OFFLINE", MenuStyle);
            valis.vbool = GUI.Toggle(guitools.GRectRelative(0.8f, (guitools.GRectRelative(0, 0, 1, 1, OffOnn))), valis.vbool, "TURN ON", MenuStyle);
        }

        guitools.SetStyle(MenuStyle, guitools.RGB(255, 255, 255, 255), Color.black, (int)Math.Round(12f));
        Rect Colore = guitools.GRectRelative(0, 0.2f, 1, 0.1f, arect);
        GUI.Label(Colore, "COLOR: ", MenuStyle);
        Colore = guitools.GRectRelative(0, 0.3f, 0.2f, 0.1f, arect);
        GUI.Label(Colore, "R:" + Mathf.RoundToInt(valis.vVector3.x), MenuStyle);
        Colore = guitools.GRectRelative(0, 0.4f, 0.2f, 0.1f, arect);
        GUI.Label(Colore, "G:" + Mathf.RoundToInt(valis.vVector3.y), MenuStyle);
        Colore = guitools.GRectRelative(0, 0.5f, 0.2f, 0.1f, arect);
        GUI.Label(Colore, "B:" + Mathf.RoundToInt(valis.vVector3.z), MenuStyle);

        guitools.SetStyle(MenuStyle, guitools.RGB(valis.vVector3.x, valis.vVector3.y, valis.vVector3.z, 255), Color.black, (int)Math.Round(18f));
        Rect Colores = guitools.GRectRelative(0.8f, 0.3f, 0.2f, 0.3f, arect);
        GUI.Label(Colores, "", MenuStyle);


        float A = 0;
        float B = 0;
        float C = 0;
        guitools.SetStyle(MenuStyle, guitools.RGB(200, 200, 200, 255), Color.black, (int)Math.Round(18f));
        GUIStyle MenuStyle2 = new GUIStyle(prettyskin.label);
        guitools.SetStyle(MenuStyle2, guitools.RGB(150, 150, 150, 255), Color.black, (int)Math.Round(18f));
        Colore = guitools.GRectRelative(0.2f, 0.3f, 0.6f, 0.1f, arect);
        A = GUI.HorizontalSlider(guitools.GRectRelative(0.8f, Colore), valis.vVector3.x, 0, 255, MenuStyle, MenuStyle2);
        Colore = guitools.GRectRelative(0.2f, 0.4f, 0.6f, 0.1f, arect);
        B = GUI.HorizontalSlider(guitools.GRectRelative(0.8f, Colore), valis.vVector3.y, 0, 255, MenuStyle, MenuStyle2);
        Colore = guitools.GRectRelative(0.2f, 0.5f, 0.6f, 0.1f, arect);
        C = GUI.HorizontalSlider(guitools.GRectRelative(0.8f, Colore), valis.vVector3.z, 0, 255, MenuStyle, MenuStyle2);

        Transform child = thesock.instance.transform.Find("light");
        child.GetComponent<Light>().color = guitools.RGB(valis.vVector3.x, valis.vVector3.y, valis.vVector3.z, 255);

        child.GetComponent<Light>().enabled = valis.vbool;
        if (!valis.vbool)
        {
            thesock.instance.GetComponent<MeshRenderer>().materials[0].SetColor("_EmissionColor", guitools.RGB(0, 0, 0, 255));
        }


        valis.vVector3 = new Vector3(A, B, C);

    }
コード例 #23
0
ファイル: Inventory.cs プロジェクト: Xangotrick/CYGNUS
 public InvItem(socketIG sock, int numio)
 {
     socket = sock;
     num = numio;
 }
コード例 #24
0
ファイル: gui.cs プロジェクト: Xangotrick/CYGNUS
    void DrawSingleSloatChest(socketIG thesock)
    {
        GUIStyle MenuStyle = new GUIStyle(prettyskin.label);

        guitools.SetStyle(MenuStyle, guitools.RGB(255, 255, 255, 255), Color.black, (int)Math.Round(18f));

        Rect darect = guitools.GRectRelative(0.25f, 0f, 0.5f, 0.5f, SmallerRect);
        darect = guitools.GRectRelative(0.9f, darect);
        darect = guitools.RectFromCenter(new Vector2(darect.x + darect.width / 2f, darect.y + darect.height / 2f), darect.height, darect.height);


        GUI.Label(darect, "", MenuStyle);

        darect = guitools.GRectRelative(0.25f, darect);
        Rect currect = darect;



        guitools.SetStyle(MenuStyle, guitools.RGB(150, 150, 150, 255), Color.black, (int)Math.Round(18f));
        guitools.TextureStyle(MenuStyle, Twhite);

        guitools.TextureStyle(MenuStyle, Tvoid);
        Inventory theinv = thesock.asock.getinvs.aninv;
        currect = guitools.GRectRelative(0.9f, currect);
        Inventory.InvItem curritem = theinv.inv[0];



        guitools.TextureStyle(MenuStyle, Twhite);
        guitools.SetStyle(MenuStyle, guitools.RGB(220, 220, 220, 255), Color.black, (int)Math.Round(18f));
        GUI.Label(guitools.GRectRelative(0.9f, currect), "", MenuStyle);
        if (curritem.socket.asock.name != "")
        {
            Vector2 mousepos = Converters.MouseToScreen(Input.mousePosition);
            curritem.DrawItem(currect, MenuStyle, Tvoid);
            if (guitools.isinrect(mousepos, currect))
            {
                inventoryname = curritem.socket.asock.disname;
            }
        }

        guitools.TextureStyle(MenuStyle, Tvoid);
        guitools.SetStyle(MenuStyle, guitools.RGB(255, 255, 255, 255), Color.black, (int)Math.Round(18f));
        if (GUI.Button(guitools.GRectRelative(0.9f, currect), "", MenuStyle))
        {
            MouseInvHeld = curritem.InteractItem(MouseInvHeld, theinv, 0);
        }
    }
コード例 #25
0
ファイル: Inventory.cs プロジェクト: Xangotrick/CYGNUS
 public InvItem(string name, int numio)
 {
     socket = new socketIG(name);
     num = numio;
 }
コード例 #26
0
ファイル: gui.cs プロジェクト: Xangotrick/CYGNUS
    void DrawM01Crafter(socketIG thesock)
    {
        bool crafting = false;
        float craftlevel = 0;
        if (thesock.asock.getcraft.vfloat != -1)
        {
            if (Time.time - thesock.asock.getcraft.vfloat < thesock.asock.getcraft.vfloat2)
            {
                //currentrecipe = thesock.asock.getcraft.vint;
                craftlevel = (Time.time - thesock.asock.getcraft.vfloat) / (1f * thesock.asock.getcraft.vfloat2);
                crafting = true;
            }
            else
            {
                foreach (Inventory.InvItem item in thesock.asock.getcraft.Result)
                {
                    for (int k = 0; k < 4; k++)
                    {
                        if (thesock.asock.getinvs.aninv.inv[k].socket.asock.name == item.socket.asock.name)
                        {
                            thesock.asock.getinvs.aninv.inv[k].num += item.num;
                            break;
                        }
                        else
                        {
                            if (thesock.asock.getinvs.aninv.inv[k].num == 0)
                            {
                                thesock.asock.getinvs.aninv.inv[k] = new Inventory.InvItem(item.socket, item.num);
                                break;
                            }
                        }
                    }
                }
                foreach (RawInv.rawlibitem item in thesock.asock.getcraft.ResultRaw)
                {
                    thesock.asock.getrawinvs.aninv.add(item.id, item.kg);
                }
                thesock.asock.getcraft.vfloat = -1;
            }
        }


        GUIStyle MenuStyle = new GUIStyle(prettyskinloseend.label);

        guitools.SetStyle(MenuStyle, guitools.RGB(255, 255, 255, 255), Color.black, (int)Math.Round(18f));

        Rect darect = guitools.GRectRelative(0.25f, 0f, 0.5f, 0.5f, SmallerRect);
        darect = guitools.GRectRelative(-0.125f, 0, 1.25f, 1, darect);
        //darect = guitools.GRectRelative(0.9f, darect);
        //darect = guitools.RectFromCenter(new Vector2(darect.x + darect.width/2f, darect.y + darect.height / 2f ), darect.height, darect.height);
        Rect rectA = guitools.GRectRelative(0, 0, 0.2f, 1, darect,0.9f);
        Rect rectB = guitools.GRectRelative(0.2f, 0, 0.4f, 1, darect, 0.9f);
        Rect rectC = guitools.GRectRelative(0.6f, 0.45f, 0.2f, 0.1f, darect, 0.9f);
        rectC = guitools.GRectRelative(0, -0.5f, 1, 1.5f, rectC);
        Rect rectD = guitools.GRectRelative(0.8f, 0, 0.2f, 1, darect, 0.9f);


        GUI.Label(rectA, "", MenuStyle);
        GUI.Label(rectB, "", MenuStyle);
        GUI.Label(guitools.GRectRelative(0,0,1,1.5f,rectC), "", MenuStyle);
        //GUI.Label(darect, "", MenuStyle);

        ///A Recipes
        guitools.SetStyle(MenuStyle, guitools.RGB(200, 200, 200, 255), Color.black, (int)Math.Round(8f));
        List<Recipe> reciplist = thesock.asock.getcraft.Recipes;
        int numofpages = (((reciplist.Count) - (reciplist.Count % 9))/9);
        GUI.Label(guitools.GRectRelative(0.25f,0,0.5f,0.1f,rectA,0.95f), "PAGE "+(page+1)+"/"+(numofpages+1), MenuStyle);
        if (GUI.Button(guitools.GRectRelative(0, 0, 0.25f, 0.1f, rectA, 0.95f), "<<", MenuStyle))
        {
            if (page > 0)
            {
                page--;
            }
        }
        if (GUI.Button(guitools.GRectRelative(0.75f, 0, 0.25f, 0.1f, rectA, 0.95f), ">>", MenuStyle))
        {
            if (page < numofpages)
            {
                page++;
            }
        }
        for (int k = 0; k < 9; k++)
        {
            int rk = k + 9 * page;
            if (rk < reciplist.Count)
            {
                if (GUI.Button(guitools.GRectRelative(0, 0.1f * (k + 1), 0.8f, 0.1f, rectA, 0.95f), reciplist[rk].name, MenuStyle) && !crafting)
                {
                    currentrecipe = rk;
                }
                int res = -1;
                foreach (int anint in thesock.asock.getcraft.autos)
                {
                    if (rk == anint)
                    {
                        res = rk;
                        break;
                    }
                }
                if (res != -1)
                {
                    guitools.SetStyle(MenuStyle, guitools.RGB(150, 250, 150, 255), Color.black, (int)Math.Round(8f));

                    if (GUI.Button(guitools.GRectRelative(0.8f, 0.1f * (k + 1), 0.2f, 0.1f, rectA, 0.95f), "A", MenuStyle) && !crafting)
                    {
                        thesock.asock.getcraft.autos.Remove(rk);
                    }
                }
                else
                {
                    guitools.SetStyle(MenuStyle, guitools.RGB(250, 150, 150, 255), Color.black, (int)Math.Round(8f));
                    if (GUI.Button(guitools.GRectRelative(0.8f, 0.1f * (k + 1), 0.2f, 0.1f, rectA, 0.95f), "A", MenuStyle) && !crafting)
                    {
                        thesock.asock.getcraft.autos.Add(rk);
                    }
                }
                guitools.SetStyle(MenuStyle, guitools.RGB(200, 200, 200, 255), Color.black, (int)Math.Round(8f));
            }
        }


        guitools.SetStyle(MenuStyle, guitools.RGB(200, 200, 200, 255), Color.black, (int)Math.Round(8f));
        ///B
        if (currentrecipe < reciplist.Count)
        {
            GUI.Label(guitools.GRectRelative(0.25f, 0, 0.5f, 0.1f, rectB, 0.95f), reciplist[currentrecipe].name, MenuStyle);
        }
        else
        {
            GUI.Label(guitools.GRectRelative(0, 0, 1, 0.1f, rectB, 0.95f), "RECIPE:", MenuStyle);
        }
        GUI.Label(guitools.GRectRelative(0, 0.1f, 0.5f, 0.1f, rectB, 0.95f), "REQUIRES:", MenuStyle);
        GUI.Label(guitools.GRectRelative(0.5f, 0.1f, 0.5f, 0.1f, rectB, 0.95f), "CRAFTS:", MenuStyle);

        List<string> write = new List<string>();
        foreach (Inventory.InvItem item in reciplist[currentrecipe].Items)
        {
            write.Add(item.socket.asock.disname + ": " + item.num);
        }
        foreach (RawInv.rawlibitem item in reciplist[currentrecipe].RawItems)
        {
            write.Add(item.raw.name + ": " + item.kg+"kg");
        }

        MenuStyle.alignment = TextAnchor.MiddleLeft;
        if (write.Count != 0)
        {
            for (int k = 0; k < write.Count; k++)
            {
                GUI.Label(guitools.GRectRelative(0, 0.2f + (0.8f) / (write.Count * 1f) * k, 0.5f, (0.8f) / (write.Count * 1f), rectB, 0.95f), write[k], MenuStyle);
            }
        }


        write = new List<string>();
        foreach (Inventory.InvItem item in reciplist[currentrecipe].Result)
        {
            write.Add(item.socket.asock.disname + ": " + item.num);
        }
        foreach (RawInv.rawlibitem item in reciplist[currentrecipe].ResultRaw)
        {
            write.Add(item.raw.name + ": " + item.kg + "kg");
        }
        if (write.Count != 0)
        {
            for (int k = 0; k < write.Count; k++)
            {
                GUI.Label(guitools.GRectRelative(0.5f, 0.2f + (0.8f) / (write.Count * 1f) * k, 0.5f, (0.8f) / (write.Count * 1f), rectB, 0.95f), write[k], MenuStyle);
            }
        }

        MenuStyle.alignment = TextAnchor.MiddleCenter;

        ///C
        GUI.Label(guitools.GRectRelative(0, 0, 1, 0.5f, rectC, 0.8f), "COST: " + reciplist[currentrecipe].eleccost + "EU", MenuStyle);
        GUI.Label(guitools.GRectRelative(0, 1, 1, 0.5f, rectC, 0.8f), "TIME: " + reciplist[currentrecipe].time + "", MenuStyle);
        if (crafting)
        {
            guitools.TextureStyle(MenuStyle, Twhite);
            guitools.SetStyle(MenuStyle, guitools.RGB(180, 180, 180, 255), Color.black, (int)Math.Round(8f));
            GUI.Label(guitools.GRectRelative(0, 0.5f, 1, 0.5f, rectC, 0.8f), "", MenuStyle);
            guitools.SetStyle(MenuStyle, guitools.RGB(120, 120, 120, 255), Color.black, (int)Math.Round(8f));
            GUI.Label(guitools.GRectRelative(0, 0.5f, 1* craftlevel, 0.5f, rectC, 0.8f), "", MenuStyle);


            guitools.TextureStyle(MenuStyle, Tvoid);
            GUI.Label(guitools.GRectRelative(0, 0.5f, 1, 0.5f, rectC, 0.8f), "CRAFT", MenuStyle);
            MenuStyle = new GUIStyle(prettyskinloseend.label);
        }
        else
        {
            if (GUI.Button(guitools.GRectRelative(0, 0.5f, 1, 0.5f, rectC, 0.8f), "CRAFT", MenuStyle))
            {
                bool candoit = true;

                if (thesock.asock.getelec.buffer < reciplist[currentrecipe].eleccost)
                {
                    candoit = false;
                }

                foreach (Inventory.InvItem item in reciplist[currentrecipe].Items)
                {
                    if (worldgen.maininfo.inv.getcount(item.socket.asock.name) < item.num)
                    {
                        candoit = false;
                    }
                }
                foreach (RawInv.rawlibitem item in reciplist[currentrecipe].RawItems)
                {
                    if (worldgen.maininfo.rawinv.getcount(item.id) < item.kg)
                    {
                        candoit = false;
                    }
                }
                if (candoit)
                {
                    thesock.asock.getelec.buffer -= reciplist[currentrecipe].eleccost;
                    foreach (Inventory.InvItem item in reciplist[currentrecipe].Items)
                    {
                        worldgen.maininfo.inv.remamount(item.socket.asock.name, item.num);
                    }
                    foreach (RawInv.rawlibitem item in reciplist[currentrecipe].RawItems)
                    {
                        worldgen.maininfo.rawinv.rem(item.id, item.kg);
                    }

                    thesock.asock.getcraft.vfloat = Time.time;
                    thesock.asock.getcraft.vfloat2 = reciplist[currentrecipe].time;
                    thesock.asock.getcraft.Result = reciplist[currentrecipe].Result;
                    thesock.asock.getcraft.ResultRaw = reciplist[currentrecipe].ResultRaw;

                    controls.hissoundsyst.stoaudio("mclang").Play();
                }
            }
        }
         
        
        ///D
        

        Inventory theinv = thesock.asock.getinvs.aninv;
        for (int k = 0; k < theinv.inv.Length; k++)
        {
            Rect therect = guitools.RectFromCenter(new Vector2(rectD.x + rectD.width / 2f, rectD.y + rectD.height / 2f), rectD.height / 4f,rectD.height);
            therect = guitools.GRectRelative(0.9f, therect);
            GUI.Label(therect, "", MenuStyle);



            guitools.SetStyle(MenuStyle, guitools.RGB(150, 150, 150, 255), Color.black, (int)Math.Round(18f));
            guitools.TextureStyle(MenuStyle, Twhite);
            guitools.TextureStyle(MenuStyle, Tvoid);
            int mink = k;
            Rect currect = guitools.GRectRelative(0,mink / 4f, 1, 1 / 4f, therect,0.75f);
            Inventory.InvItem curritem = theinv.inv[k];



            guitools.TextureStyle(MenuStyle, Twhite);
            guitools.SetStyle(MenuStyle, guitools.RGB(220, 220, 220, 255), Color.black, (int)Math.Round(18f));
            GUI.Label(guitools.GRectRelative(0.9f, currect), "", MenuStyle);
            if (curritem.socket.asock.name != "")
            {
                Vector2 mousepos = Converters.MouseToScreen(Input.mousePosition);
                curritem.DrawItem(currect, MenuStyle, Tvoid);
                if (guitools.isinrect(mousepos, currect))
                {
                    inventoryname = curritem.socket.asock.disname;
                }
            }

            guitools.TextureStyle(MenuStyle, Tvoid);
            guitools.SetStyle(MenuStyle, guitools.RGB(255, 255, 255, 255), Color.black, (int)Math.Round(18f));
            if (GUI.Button(guitools.GRectRelative(0.9f, currect), "", MenuStyle))
            {
                MouseInvHeld = curritem.InteractItem(MouseInvHeld, theinv, k);
            }

        }
    }
コード例 #27
0
ファイル: ElectricGrid.cs プロジェクト: Xangotrick/CYGNUS
 public ElectricGrid(socketIG astart)
 {
     thelist = new List<socketIG>();
     thelist.Add(astart);
 }