예제 #1
0
    public GuiObject BuildHearthFireWindow(HearthFire h)
    {
        GuiObject window = new GuiObject(new Rect(0, 0, 300, 500), "LeftPane", "Hearth Fire");

        window.AddChild(new GuiObject(new Rect(5, 30, 290, 25),
                                      (g) => {
            GUI.Label(g.rect, "Remaining Fuel: ");
            GUI.Box(new Rect(120, 30, 170, 25), "");
            GUI.Box(new Rect(120, 30, 170 * h.currentFuel / h.maxFuel, 25), "");
            GUI.Label(new Rect(120, 30, 240, 25), h.currentFuel + "/" + h.maxFuel);
        }, "FuelCount", ""));

        window.AddChild(new GuiObject(new Rect(5, 65, 290, 30),
                                      (g) => {
            GUI.Box(new Rect(5, 65, 290, 25), "");
            GUI.Box(new Rect(5, 65, (int)(290 * (60f / h.fuelPerMinute - h.timer) / (60f / h.fuelPerMinute)), 25), "");
        }, "Fueltimer", ""));

        Inventory inv = man.GetComponent <Inventory>();

        window.AddChild(new GuiObject(new Rect(5, 100, 290, 400),
                                      (g) => {
            int i = 0;
            int[] currentResources = inv.GetAmounts(h.acceptedFuels);
            foreach (ItemCount rc in h.acceptedFuels)
            {
                GUI.Label(new Rect(5, 90 + i * 25, 290, 25), "Add " + rc.item.name + ", adds " + rc.amount + " fuel");
                if (currentResources[i] < 1 || h.currentFuel >= h.maxFuel)
                {
                    GUI.enabled = false;
                }
                if (GUI.Button(new Rect(220, 90 + i * 25, 40, 25), "Add"))
                {
                    h.AddFuel(rc.item);
                    inv.AddToInventory(rc.item, -1);
                }
                GUI.enabled = true;
                SetColor(() => { return(currentResources[i] > 0); });
                GUI.Label(new Rect(270, 90 + i * 25, 25, 25), "(" + currentResources[i] + ")");
                SetColor();
                i++;
            }
        }, "FuelAdder", ""));

        window.Draw += (g) => {
            GUI.Box(g.rect, g.text);
            if (!Static.Man.AtFire)
            {
                NewWindowTask = CloseWindow;
                NewWindow     = window;
            }
            else
            {
                window.DrawAllChildren();
            }
        };
        return(window);
    }
예제 #2
0
	public GuiObject BuildHearthFireWindow(HearthFire h) {
		GuiObject window = new GuiObject(new Rect(0, 0, 300, 500), "LeftPane", "Hearth Fire");
		
		window.AddChild(new GuiObject(new Rect(5, 30, 290, 25),
			(g) => {
				GUI.Label(g.rect, "Remaining Fuel: ");
				GUI.Box(new Rect(120, 30, 170, 25), "");
				GUI.Box(new Rect(120, 30, 170 * h.currentFuel / h.maxFuel, 25), "");
				GUI.Label(new Rect(120, 30, 240, 25), h.currentFuel + "/" + h.maxFuel);
			}, "FuelCount", ""));
		
		window.AddChild(new GuiObject(new Rect(5, 65, 290, 30),
			(g) => {
				GUI.Box(new Rect(5, 65, 290, 25), "");
				GUI.Box(new Rect(5, 65, (int)(290 * (60f / h.fuelPerMinute - h.timer)/(60f/h.fuelPerMinute)), 25), "");
			}, "Fueltimer", ""));
		
		Inventory inv = man.GetComponent<Inventory>();
		window.AddChild(new GuiObject(new Rect(5, 100, 290, 400), 
			(g) => {
				int i = 0;
				int[] currentResources = inv.GetAmounts(h.acceptedFuels);
				foreach (ItemCount rc in h.acceptedFuels) {					
					GUI.Label(new Rect(5, 90 + i * 25, 290, 25), "Add " + rc.item.name + ", adds " + rc.amount + " fuel");
					if (currentResources[i] < 1 || h.currentFuel >= h.maxFuel) GUI.enabled = false; 
					if (GUI.Button(new Rect(220, 90 + i * 25, 40, 25), "Add")) {
						h.AddFuel(rc.item);
						inv.AddToInventory(rc.item, -1);
					}
					GUI.enabled = true;
					SetColor(() => {return currentResources[i] > 0;});
					GUI.Label(new Rect(270, 90 + i * 25, 25, 25), "(" + currentResources[i] + ")");
					SetColor();
					i++;
				}
			
			}, "FuelAdder", ""));
			
		window.Draw += (g) => {
			GUI.Box(g.rect, g.text);
			if (!Static.Man.AtFire){
				NewWindowTask=CloseWindow;
				NewWindow=window;
			}else
				window.DrawAllChildren();
		};
		return window;
	}