Пример #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
	void OnGUI () {
		NewWindowTask = null;
		NewWindow = null;
		if (GuiItems != null) {
			foreach (GuiObject g in GuiItems) {
				g.DrawElement();
			}
			
			if (NewWindowTask != null) {
				NewWindowTask(NewWindow);
			}
		}
		
	}
Пример #3
0
    void OnGUI()
    {
        NewWindowTask = null;
        NewWindow     = null;
        if (GuiItems != null)
        {
            foreach (GuiObject g in GuiItems)
            {
                g.DrawElement();
            }

            if (NewWindowTask != null)
            {
                NewWindowTask(NewWindow);
            }
        }
    }
Пример #4
0
	public GuiObject BuildToolBar() {
		int x = 300, y = 0, w = 400, h = 50;
		GuiObject bar = new GuiObject(new Rect(x, y, w, h), "MainToolBar", "");
		
		bar.AddChild(new GuiObject(new Rect(50, 5, 40, 40), 
									(g) => {if (GUI.Button(g.rect, g.text)) {
											NewWindowTask = ToggleWindow;
											NewWindow = BuildDebugWindow();
									}},
									"RightPane", "Debug")); 

		//Time.deltaTime is passed by value in - dis iz broken.
//		bar.AddChild(new GuiObject(new Rect(95, 5, 3f /Time.deltaTime, 40), "FPS", "FPS: " + 1f /Time.deltaTime));
				
		bar.Draw += (g) => {
			GUI.Box(g.rect, g.text);
			g.DrawAllChildren();
		};
		return bar;
	}
Пример #5
0
    public GuiObject BuildToolBar()
    {
        int       x = 300, y = 0, w = 400, h = 50;
        GuiObject bar = new GuiObject(new Rect(x, y, w, h), "MainToolBar", "");

        bar.AddChild(new GuiObject(new Rect(50, 5, 40, 40),
                                   (g) => { if (GUI.Button(g.rect, g.text))
                                            {
                                                NewWindowTask = ToggleWindow;
                                                NewWindow     = BuildDebugWindow();
                                            }
                                   },
                                   "RightPane", "Debug"));

        //Time.deltaTime is passed by value in - dis iz broken.
//		bar.AddChild(new GuiObject(new Rect(95, 5, 3f /Time.deltaTime, 40), "FPS", "FPS: " + 1f /Time.deltaTime));

        bar.Draw += (g) => {
            GUI.Box(g.rect, g.text);
            g.DrawAllChildren();
        };
        return(bar);
    }
Пример #6
0
    public GuiObject BuildBenchWindow(Bench bench)
    {
        GuiObject window         = new GuiObject(new Rect(0, 0, 300, 500), "LeftPane", bench.customname);
        var       playerPosition = Static.Man.transform.position;

        window.Draw += (g) => {
            GUI.Box(g.rect, g.text);
            Debug.Log(Vector3.Distance(playerPosition, Static.Man.transform.position));
            if (Vector3.Distance(playerPosition, Static.Man.transform.position) > 2)
            {
                NewWindowTask = CloseWindow;
                NewWindow     = window;
                return;
            }
            int i, o, boxH, boxY = 25;
            foreach (CraftingConversion cc in bench.craftables)
            {
                i = o = 0;

                int[] hasInInventory = man.GetComponent <Inventory>().GetAmounts(cc.reqs);
                boxH = Mathf.Max(cc.reqs.Length, cc.yields.Length) * 25 + 35;

                GUI.Box(new Rect(5, boxY, 290, boxH - 5), "");
                int  index    = 0;
                bool cancraft = true;
                foreach (var rc in cc.reqs)
                {
                    SetColor(() => { return(hasInInventory[index] >= rc.amount); });
                    if (hasInInventory[index] < rc.amount)
                    {
                        cancraft = false;
                    }
                    GUI.Label(new Rect(10, boxY + 5 + i * 20, 150, 25), hasInInventory[index++] + "/" + rc.amount + " " + rc.item.GetName());
                    i++;
                }
                foreach (ItemCount y in cc.yields)
                {
                    GUI.Label(new Rect(225, boxY + 5 + o * 20, 70, 25), y.amount + " " + y.item.GetName());
                    o++;
                }

                GUI.Label(new Rect(130, boxY + 5, 60, 25), "------>");

                SetColor();
                GUI.Label(new Rect(10, boxY + boxH - 35, 130, 25), cc.name);

                GUI.enabled = cancraft;
                if (GUI.Button(new Rect(225, boxY + boxH - 35, 60, 25), "Craft"))
                {
                    Inventory inv = man.GetComponent <Inventory>();
                    foreach (ItemCount rc in cc.reqs)
                    {
                        inv.AddToInventory(rc.item, -rc.amount);
                    }
                    foreach (ItemCount y in cc.yields)
                    {
                        inv.AddToInventory(y.item, y.amount);
                    }
                }

                GUI.enabled = true;
                boxY       += boxH;
            }
        };

        return(window);
    }
Пример #7
0
    public GuiObject BuildBenchUpgradeWindow(Table t, Knowledge k)
    {
        GuiObject window = new GuiObject(new Rect(0, 0, 300, 500), "LeftPane", "Upgrade Bench");

        var playerPosition = Static.Man.transform.position;

        window.Draw += (g) => {
            GUI.Box(g.rect, g.text);
            int boxY = 30, inc = 0;
            Debug.Log(Vector3.Distance(playerPosition, Static.Man.transform.position));
            if (Vector3.Distance(playerPosition, Static.Man.transform.position) > 2)
            {
                NewWindowTask = CloseWindow;
                NewWindow     = window;
                return;
            }

            foreach (Bench b_ in k.benches)
            {
                var b = b_;
                inc = 0;
                int[] inv  = man.GetComponent <Inventory>().GetAmounts(b.buildcost);
                int   boxH = 30 + inv.Length * 25;
                GUI.Box(new Rect(5, boxY, 290, boxH), "");
                GUI.Label(new Rect(10, 5 + boxY, 200, 25), b.customname);
                GUI.Label(new Rect(10, boxY + boxH - 25, 150, boxH - 30), b.description);

                int  i        = 0;
                bool canbuild = true;
                foreach (ItemCount rc in b.buildcost)
                {
                    SetColor(() => { return(inv[i] >= rc.amount); });
                    if (inv[i] < rc.amount)
                    {
                        canbuild = false;
                    }

                    GUI.Label(new Rect(210, 5 + boxY + inc, 150, 25), inv[i] + "/" + rc.amount + " " + rc.item.GetName());
                    inc += 20;
                    i++;
                }

                SetColor();
                GUI.enabled = canbuild;

                if (GUI.Button(new Rect(240, boxY + boxH - 30, 45, 25), "Build"))
                {
                    queue.Enqueue(control.SimpleAction(
                                      (d) => {
                        t.bench = b;
                        foreach (var rc in b.buildcost)
                        {
                            man.GetComponent <Inventory>().AddToInventory(rc.item, -rc.amount);
                        }
                        OpenWindow(BuildBenchWindow(b));
                        d.state = ActionState.Done;
                    }));
                }
                GUI.enabled = true;
                boxY       += boxH + 5;
            }
        };
        return(window);
    }
Пример #8
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;
	}
Пример #9
0
	public GuiObject BuildBenchWindow(Bench bench) {
		GuiObject window = new GuiObject(new Rect(0, 0, 300, 500), "LeftPane", bench.customname);
		var playerPosition = Static.Man.transform.position;
		window.Draw += (g) => {
			GUI.Box(g.rect, g.text);
			Debug.Log (Vector3.Distance(playerPosition,Static.Man.transform.position));
			if (Vector3.Distance(playerPosition,Static.Man.transform.position)>2){
				NewWindowTask=CloseWindow;
				NewWindow=window;
				return;
			}
			int i, o, boxH, boxY = 25;
			foreach(CraftingConversion cc in bench.craftables) {
			
				i = o = 0;
				
				int[] hasInInventory = man.GetComponent<Inventory>().GetAmounts(cc.reqs);
				boxH = Mathf.Max(cc.reqs.Length, cc.yields.Length) * 25 + 35;
				
				GUI.Box(new Rect(5, boxY, 290, boxH - 5), "");
				int index = 0;
				bool cancraft = true;
				foreach (var rc in cc.reqs) {
					SetColor(() => {return hasInInventory[index] >= rc.amount;});
					if (hasInInventory[index] < rc.amount) cancraft = false;
					GUI.Label(new Rect(10, boxY + 5 + i * 20, 150, 25), hasInInventory[index++] + "/" + rc.amount + " " + rc.item.GetName());
					i++;
				}
				foreach (ItemCount y in cc.yields) {
					GUI.Label(new Rect(225, boxY + 5 + o * 20, 70, 25), y.amount + " " + y.item.GetName());
					o++;
				}
				
				GUI.Label(new Rect(130, boxY + 5, 60, 25), "------>");
				
				SetColor();
				GUI.Label(new Rect(10, boxY + boxH - 35, 130, 25), cc.name);
				
				GUI.enabled = cancraft;
				if (GUI.Button(new Rect(225, boxY + boxH - 35, 60, 25), "Craft")) {
					Inventory inv = man.GetComponent<Inventory>();
					foreach (ItemCount rc in cc.reqs) {
						inv.AddToInventory(rc.item, -rc.amount);
					}
					foreach (ItemCount y in cc.yields) {
						inv.AddToInventory(y.item, y.amount);
					}
				}
				
				GUI.enabled = true;
				boxY += boxH;
			}
		};
		
		return window;
	}
Пример #10
0
	public GuiObject BuildBenchUpgradeWindow(Table t, Knowledge k) {
		GuiObject window = new GuiObject(new Rect(0, 0, 300, 500), "LeftPane", "Upgrade Bench");	
	
		var playerPosition = Static.Man.transform.position;
		window.Draw += (g) => {
			GUI.Box(g.rect, g.text);
			int boxY = 30, inc = 0;
			Debug.Log (Vector3.Distance(playerPosition,Static.Man.transform.position));
			if (Vector3.Distance(playerPosition,Static.Man.transform.position)>2){
				NewWindowTask=CloseWindow;
				NewWindow=window;
				return;
			}
			
			foreach (Bench b_ in k.benches) {
				
				var b = b_;
				inc = 0;
				int[] inv = man.GetComponent<Inventory>().GetAmounts(b.buildcost);
				int boxH = 30 + inv.Length * 25;
				GUI.Box(new Rect(5, boxY, 290, boxH), "");
				GUI.Label(new Rect(10, 5 + boxY, 200, 25), b.customname);
				GUI.Label(new Rect(10, boxY + boxH - 25, 150, boxH - 30), b.description);
				
				int i = 0;
				bool canbuild = true;
				foreach(ItemCount rc in b.buildcost) {
					
					SetColor(() => {return inv[i] >= rc.amount;});
					if (inv[i] < rc.amount) {canbuild = false;}
					
					GUI.Label(new Rect(210, 5 + boxY + inc, 150, 25), inv[i] + "/" + rc.amount + " " + rc.item.GetName());
					inc += 20;
					i++;
				}
				
				SetColor();
				GUI.enabled = canbuild;
				
				if (GUI.Button(new Rect(240, boxY + boxH - 30, 45, 25), "Build")) {
					queue.Enqueue(control.SimpleAction(
						(d) => {
							t.bench = b;
							foreach (var rc in b.buildcost) {
								man.GetComponent<Inventory>().AddToInventory(rc.item, -rc.amount);
							}
							OpenWindow(BuildBenchWindow(b));
							d.state = ActionState.Done;
						}));
				}
				GUI.enabled = true;
				boxY += boxH + 5;
			}
		};
		return window;
	}