示例#1
0
    public GuiObject GetGUIObject()
    {
        GuiObject bar = new GuiObject(new Rect(0, Screen.height - hearthIcon.width, hearthIcon.width, hearthIcon.height), "Hearth Button", "");

        bar.Draw += (g) =>
        {
            if (Static.HearthFire == null)
            {
                if (GUI.Button(g.rect, hearthIconDown))
                {
                    Instantiate(Static.HearthFirePrefab, Static.Man.transform.position + Static.Man.transform.forward.normalized, Quaternion.identity);
                    Static.Man.MoveTo(Static.Man.transform.position);
                }
            }
            else
            if (Static.Man.AtFire)
            {
                if (GUI.Button(g.rect, hearthIconUp))
                {
                    Destroy(Static.HearthFire.gameObject);
                }
            }
            else
            {
                if (GUI.Button(g.rect, hearthIcon))
                {
                    Static.Man.transform.position = Static.HearthFire.transform.position + Vector3.up;
                    Static.Man.MoveTo(Static.HearthFire.transform.position);
                }
            }
        };
        return(bar);
    }
示例#2
0
        private void Dan_DragDrop(object sender, DragEventArgs e)
        {
            var formats = e.Data.GetFormats();
            var data    = e.Data.GetData(typeof(Predmet));

            Predmet p = data as Predmet;

            data = e.Data.GetData(typeof(Termin));
            Termin   t = data as Termin;
            DateTime pocetakTermina = getDateTimeFromMousePoint((Panel)sender, e.X, e.Y);

            if (p != null)
            {
                Termin termin = new Termin(pocetakTermina, p.BrCasova, p, GuiObject);
                if (GuiObject.isSlobodan(termin))
                {
                    DataControllercs.addAction(new CreateAction(termin));
                }
            }
            if (t != null)
            {
                Termin   termin      = t;
                TimeSpan ts          = t.KrajTermina - t.PocetakTermina;
                DateTime krajTermina = pocetakTermina.Add(ts);
                if (GuiObject.isSlobodan(pocetakTermina, krajTermina, t))
                {
                    transferTerminToNewDate((Panel)sender, termin, pocetakTermina, krajTermina);
                }
            }
        }
示例#3
0
    public GuiObject BuildInventoryWindow()
    {
        Debug.Log("building");
        GuiObject window = new GuiObject(new Rect(Screen.width - 150, Screen.height - 300, 150, 300), "Inventory", "Inventory");

        int tileWidth  = 265;
        int tileHeight = 20;

        window.Draw += (g) =>
        {
            GUI.Box(g.rect, g.text);
            int num = 1;
            var d   = man.GetComponent <Inventory>().GetInventory();
            foreach (var i in d)
            {
                GUI.Box(new Rect(g.rect.x, g.rect.y + num * (tileHeight + 5), g.rect.width, tileHeight),
                        i.Key.GetName() + " -- " + i.Value);
                if (i.Key.IsUsable() &&
                    GUI.Button(new Rect(g.rect.x + g.rect.width - 20, g.rect.y + num * (tileHeight + 5), 20, 20), ""))
                {
                    i.Key.Use(man);
                    Debug.Log("Used " + i.Key.GetName());
                }
                num++;
            }
            ;
        };

        window.Draw += (g) => {
            g.DrawAllChildren();
        };

        return(window);
    }
示例#4
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);
    }
示例#5
0
    public void OpenWindow(GuiObject window)
    {
        int index;

        if (WindowIsOpen(window.name, out index))
        {
            GuiItems.RemoveAt(index);
        }
        GuiItems.Add(window);
        control.AddGUIRect(window.name, window.rect);
    }
示例#6
0
    public void CloseWindow(GuiObject window)
    {
        int index;

        if (!WindowIsOpen(window.name, out index))
        {
            return;
        }
        GuiItems.RemoveAt(index);
        control.RemoveGUIRect(window.name);
    }
示例#7
0
 public void Regist(string key, GuiObject hdlObject)
 {
     if (null == mActionDic)
     {
         mActionDic = new Dictionary <string, GuiObject> ();
     }
     if (!mActionDic.ContainsKey(key))
     {
         mActionDic.Add(key, hdlObject);
         UpdateKeyArray();
     }
 }
    // -------------------------------------------------------------------------------------------------------------------

    public bool ObjectSelected(GuiObject guiObject)
    {
        // Check if changing selection is allowed
        if (!((MonoBehaviour)guiObject).enabled || (m_guiObject != null) && !m_guiObject.unmarkSelected())
        {
            return(false);
        }

        m_guiObject = guiObject;
        m_guiObject.markSelected();

        return(true);
    }
示例#9
0
	void OnGUI () {
		NewWindowTask = null;
		NewWindow = null;
		if (GuiItems != null) {
			foreach (GuiObject g in GuiItems) {
				g.DrawElement();
			}
			
			if (NewWindowTask != null) {
				NewWindowTask(NewWindow);
			}
		}
		
	}
示例#10
0
    private void ToggleWindow(GuiObject window)
    {
        int index;

        if (WindowIsOpen(window.name, out index))
        {
            GuiItems.RemoveAt(index);
            control.RemoveGUIRect(window.name);
        }
        else
        {
            GuiItems.Add(window);
            control.AddGUIRect(window.name, window.rect);
        }
    }
示例#11
0
        public override GuiObject SideMenu()
        {
            GuiObject  dimensionCopy = Sim.instance.sideMenu;
            StackPanel p             = new StackPanel(dimensionCopy.x, dimensionCopy.y, dimensionCopy.width, dimensionCopy.height);

            p.AddChild(new GuiText(0, 0, 100, 50, Assets.Font24, "&l", new ObjectLinker(this, "Name")));

            p.AddChild(new GuiText(0, 50, 100, 50, Assets.Font18, "&l", new ObjectLinker(this, "ParkedString")));
            p.AddChild(new GuiText(0, 100, 100, 50, Assets.Font18, "Speed: &l", new ObjectLinker(this, "Speed")));
            p.AddChild(new GuiText(0, 150, 100, 50, Assets.Font18, "Speed goal: &l", new ObjectLinker(this, "MinLimit")));
            p.AddChild(new GuiText(0, 200, 100, 50, Assets.Font18, "Last visited: &l", new ObjectLinker(this, "LastVisitedString")));
            p.AddChild(new GuiText(0, 250, 100, 50, Assets.Font18, "&l", new ObjectLinker(this, "LimitsString")));


            return(p);
        }
示例#12
0
    void OnGUI()
    {
        NewWindowTask = null;
        NewWindow     = null;
        if (GuiItems != null)
        {
            foreach (GuiObject g in GuiItems)
            {
                g.DrawElement();
            }

            if (NewWindowTask != null)
            {
                NewWindowTask(NewWindow);
            }
        }
    }
示例#13
0
    public GuiObject BuildArmoryWindow(Armory armory)
    {
        GuiObject window = new GuiObject(new Rect(0, 0, 300, 500), "LeftPane", "Armory");

        Func <ItemCount, int, int, int> DrawItemBox = delegate(ItemCount i, int y, int w) {
            GUI.Box(new Rect(5, y, w - 110, 40), i.item.GetName() + " -- " + i.amount);
            GUI.Label(new Rect(10, y + 20, w - 110, 20), i.item.GetDescription());
            if (GUI.Button(new Rect(w - 100, y, 80, 20), "Take"))
            {
                man.GetComponent <Inventory>().AddToInventory(armory.TakeItem(i.item));
            }
            if (i.amount > 1 && GUI.Button(new Rect(w - 100, y + 22, 80, 18), "Take All"))
            {
                man.GetComponent <Inventory>().AddToInventory(armory.TakeItem(i.item, i.amount));
            }
            return(45);
        };

        Vector2 pos = Vector2.zero;

        window.AddChild(new GuiObject(new Rect(5, 25, 290, 470),
                                      (g) => {
            int numItems = armory.GetNumItems();
            pos          = GUI.BeginScrollView(g.rect, pos, new Rect(0, 0, g.rect.width - 20, numItems * 45 + 40));
            int ypos     = 5;

            foreach (var a in armory.armors)
            {
                ypos += DrawItemBox(a, ypos, (int)g.rect.width);
            }
            ypos += 20;
            foreach (var w in armory.weapons)
            {
                ypos += DrawItemBox(w, ypos, (int)g.rect.width);
            }
            ypos += 20;
            foreach (var p in armory.potions)
            {
                ypos += DrawItemBox(p, ypos, (int)g.rect.width);
            }

            GUI.EndScrollView();
        }, "ItemList", ""));

        return(window);
    }
示例#14
0
        protected override void Update(GameTime gameTime)
        {
            updateCounter++;
            if (updateCounter == Util.ToTicks(1))
            {
                updateCounter = 0;
                time         += MINUTES_PER_SECOND;
                if (time == 60 * 24)
                {
                    time = 0;
                    day++;
                }
            }

            sideMenu.Update();
            foreach (Vehicle v in vehicles)
            {
                v.Update();
            }
            foreach (SimObject o in debugObjects)
            {
                o.Update();
            }
            city.Update();

            MouseState mouse = Mouse.GetState();

            if (oldMouse == null)
            {
                oldMouse = mouse;
            }

            if (mouse.LeftButton == ButtonState.Pressed && oldMouse.LeftButton == ButtonState.Released)
            {
                foreach (Vehicle v in vehicles)
                {
                    if (v.MouseHitTest(mouse.X, mouse.Y))
                    {
                        sideMenu = v.SideMenu();
                    }
                }
            }
            oldMouse = mouse;
        }
示例#15
0
    public GuiObject BuildCombatWindow(IFightable friend, IFightable enemy, Combat combat)
    {
        CloseWindow("LeftPane");
        GuiObject window = new GuiObject(new Rect(100, 50, 400, 300), "CentrePane", "Combat!");
        Status    friendStatus = friend.GetStatus(), enemyStatus = enemy.GetStatus();

        combat = new Combat(friend, enemy);
        string report = combat.Phase()();

        window.AddChild(new GuiObject(new Rect(10, 25, 490, 370),
                                      (g) => {
            GUI.Label(g.rect, "Night has fallen and you were attacked!\n" + report);
            if (GUI.Button(new Rect(175, 260, 50, 25), "OK"))
            {
                CloseWindow("CentrePane");
            }
        }, "Report", ""));

        return(window);
    }
示例#16
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;
	}
示例#17
0
    public GuiObject BuildDebugWindow()
    {
        GuiObject window = new GuiObject(new Rect(750, 50, 270, 400), "RightPane", "Debug");

        window.Draw += (g) => {
            GUI.Box(g.rect, g.text);
            g.DrawAllChildren();
        };

        window.AddChild(new GuiObject(new Rect(5, 20, 270, 400),
                                      (g) => {
            GUI.Box(new Rect(5, 85, 40, 20 + peon.queue.Size() * 20), peon.queue.Size().ToString());
            GUI.Label(g.rect, peon.state.ToString());
            if (GUI.Button(new Rect(5, 40, 40, 40), "Skip"))
            {
                peon.queue.CancelCurrent();
            }
        },
                                      "info", ""));
        return(window);
    }
示例#18
0
    public GuiObject BuildGraphs()
    {
        int       x = 700, y = 0, w = 200, h = 50;
        GuiObject box = new GuiObject(new Rect(x, y, w, h), "GraphsBox", "");

        box.AddChild(new GuiObject(new Rect(0, 0, w / 2 - 2, (h - 5) / 2),
                                   (g) => {
            GUI.Box(g.rect, g.name);
            GUI.Box(new Rect(g.rect.x, g.rect.y, g.rect.width * ((float)man.GetStatus().health / 100.0f), g.rect.height), "");
        },
                                   "HealthBar", "Health"));

        box.AddChild(new GuiObject(new Rect(w / 2 + 3, 0, w / 2 - 2, (h - 5) / 2),
                                   (g) => {
            GUI.Box(g.rect, g.name);
            GUI.Box(new Rect(g.rect.x, g.rect.y, g.rect.width * ((float)man.GetStatus().hunger / 100.0f), g.rect.height), "");
        },
                                   "HungerBar", "Hunger"));

        box.AddChild(new GuiObject(new Rect(0, 5 + (h - 5) / 2, w / 2 - 2, (h - 5) / 2),
                                   (g) => {
            GUI.Box(g.rect, g.name);
            GUI.Box(new Rect(g.rect.x, g.rect.y, g.rect.width * ((float)man.GetStatus().energy / 100.0f), g.rect.height), "");
        },
                                   "EnergyBar", "Energy"));

        box.AddChild(new GuiObject(new Rect(w / 2 + 3, 5 + (h - 5) / 2, w / 2 - 2, (h - 5) / 2),
                                   (g) => {
            GUI.Box(g.rect, g.name);
            GUI.Box(new Rect(g.rect.x, g.rect.y, g.rect.width * ((float)man.GetStatus().thirst / 100.0f), g.rect.height), "");
        },
                                   "ThirstBar", "Thirst"));

        box.Draw += (g) => {
            GUI.Box(g.rect, "");
            g.DrawAllChildren();
        };
        return(box);
    }
示例#19
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);
    }
示例#20
0
	public GuiObject BuildGraphs() {
		int x = 700, y = 0, w = 200, h = 50;
		GuiObject box = new GuiObject(new Rect(x, y, w, h), "GraphsBox", "");
		box.AddChild(new GuiObject(new Rect(0, 0 , w / 2-2, (h - 5)/2), 
			(g) => {
				GUI.Box(g.rect, g.name);
				GUI.Box(new Rect(g.rect.x, g.rect.y, g.rect.width * ((float)man.GetStatus().health / 100.0f), g.rect.height), "");
			},
			"HealthBar", "Health")); 
		
		box.AddChild(new GuiObject(new Rect( w / 2 + 3, 0 , w / 2-2, (h - 5)/2), 
			(g) => {
				GUI.Box(g.rect, g.name);
				GUI.Box(new Rect(g.rect.x, g.rect.y, g.rect.width * ((float)man.GetStatus().hunger / 100.0f), g.rect.height), "");
			},
			"HungerBar", "Hunger")); 
		
		box.AddChild(new GuiObject(new Rect(0, 5 + (h - 5)/2, w / 2-2, (h - 5)/2), 
			(g) => {
				GUI.Box(g.rect, g.name);
				GUI.Box(new Rect(g.rect.x, g.rect.y, g.rect.width * ((float)man.GetStatus().energy / 100.0f), g.rect.height), "");
			},
			"EnergyBar", "Energy")); 
		
		box.AddChild(new GuiObject(new Rect(w / 2 + 3, 5 + (h - 5)/2, w / 2-2, (h - 5)/2), 
			(g) => {
				GUI.Box(g.rect, g.name);
				GUI.Box(new Rect(g.rect.x, g.rect.y, g.rect.width * ((float)man.GetStatus().thirst / 100.0f), g.rect.height), "");
			},
			"ThirstBar", "Thirst")); 
		
		box.Draw += (g) => {
			GUI.Box(g.rect, "");
			g.DrawAllChildren();
		};	
		return box;
	}
示例#21
0
	public GuiObject GetGUIObject(){
		GuiObject bar = new GuiObject(new Rect(0, Screen.height-hearthIcon.width, hearthIcon.width, hearthIcon.height), "Hearth Button", "");
			bar.Draw += (g) =>
			{
			if (Static.HearthFire==null){
				if (GUI.Button(g.rect,hearthIconDown)){
					Instantiate(Static.HearthFirePrefab, Static.Man.transform.position+Static.Man.transform.forward.normalized, Quaternion.identity);
					Static.Man.MoveTo(Static.Man.transform.position);

				}
			}else
			if (Static.Man.AtFire){
				if(GUI.Button(g.rect,hearthIconUp)){
					Destroy (Static.HearthFire.gameObject);
				}
			}else{
				if (GUI.Button(g.rect,hearthIcon)){
					Static.Man.transform.position=Static.HearthFire.transform.position+Vector3.up;
					Static.Man.MoveTo(Static.HearthFire.transform.position);
				}
			}
		};
		return bar;
	}
示例#22
0
 public void AddChild(GuiObject child)
 {
     children.Add(child);
 }
示例#23
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;
	}
示例#24
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;
	}
示例#25
0
	public GuiObject BuildArmoryWindow(Armory armory) {
		GuiObject window = new GuiObject(new Rect(0, 0, 300, 500), "LeftPane", "Armory");	
		
		Func<ItemCount, int, int, int> DrawItemBox = delegate(ItemCount i, int y, int w) {
			GUI.Box(new Rect(5, y, w - 110, 40), i.item.GetName() + " -- " + i.amount);
			GUI.Label(new Rect(10, y + 20, w - 110, 20), i.item.GetDescription());
			if (GUI.Button(new Rect(w - 100, y, 80, 20), "Take")) {
				man.GetComponent<Inventory>().AddToInventory(armory.TakeItem(i.item));
			}
			if (i.amount > 1 && GUI.Button(new Rect(w - 100, y + 22, 80, 18), "Take All")) {
				man.GetComponent<Inventory>().AddToInventory(armory.TakeItem(i.item, i.amount));
			}
			return 45;
		};
		
		Vector2 pos = Vector2.zero;
		window.AddChild(new GuiObject(new Rect(5, 25, 290, 470),
			(g) => {
				int numItems = armory.GetNumItems();
				pos = GUI.BeginScrollView(g.rect, pos, new Rect(0, 0, g.rect.width - 20, numItems * 45 + 40));
				int ypos = 5;
				
				foreach (var a in armory.armors) {
					ypos += DrawItemBox(a, ypos, (int)g.rect.width);
				}
				ypos += 20;
				foreach (var w in armory.weapons) {
					ypos += DrawItemBox(w, ypos, (int)g.rect.width);
				}
				ypos += 20;
				foreach (var p in armory.potions) {
					ypos += DrawItemBox(p, ypos, (int)g.rect.width);
				}
			
				GUI.EndScrollView();
				
			}, "ItemList", ""));
		
		return window;
	}
示例#26
0
	void AddBlocking(GuiObject g){
		control.AddGUIRect(g.name,g.rect);
		GuiItems.Add(g);
	}
示例#27
0
        /// <summary>
        /// Initialize graphics settings (screen size etc'), and call SetupGame.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            graphics.PreferredBackBufferWidth  = GAME_WIDTH;
            graphics.PreferredBackBufferHeight = GAME_HEIGHT;
            graphics.ApplyChanges();

            IsFixedTimeStep   = true;
            TargetElapsedTime = TimeSpan.FromMilliseconds(1000 / Util.ToTicks(1));

            IsMouseVisible = true;

            sideMenu = new StackPanel(GAME_WIDTH - 350, 0, 350, GAME_HEIGHT);

            CityBuilder builder = new CityBuilder();

            BuilderTrafficCircleNode i1 = new BuilderTrafficCircleNode(430, 415);
            BuilderAllWayStopNode    i2 = new BuilderAllWayStopNode(940, 415);

            BuilderDeadEndNode e1top    = new BuilderDeadEndNode(430, 50, 0);
            BuilderDeadEndNode e1left   = new BuilderDeadEndNode(65, 415, MathHelper.ToRadians(-90));
            BuilderDeadEndNode e1bottom = new BuilderDeadEndNode(430, 780, MathHelper.ToRadians(180));

            BuilderDeadEndNode e2top    = new BuilderDeadEndNode(940, 50, MathHelper.ToRadians(0));
            BuilderDeadEndNode e2right  = new BuilderDeadEndNode(1310, 415, MathHelper.ToRadians(90));
            BuilderDeadEndNode e2bottom = new BuilderDeadEndNode(940, 780, MathHelper.ToRadians(180));

            CityBuilderParkingTwoLanePath connection = new CityBuilderParkingTwoLanePath(i1, i2);

            i1.right = connection;
            i2.left  = connection;

            CityBuilderParkingTwoLanePath i1top = new CityBuilderParkingTwoLanePath(i1, e1top);

            i1.top = i1top;
            CityBuilderParkingTwoLanePath i1left = new CityBuilderParkingTwoLanePath(i1, e1left);

            i1.left = i1left;
            CityBuilderParkingTwoLanePath i1bottom = new CityBuilderParkingTwoLanePath(i1, e1bottom);

            i1.bottom = i1bottom;

            CityBuilderParkingTwoLanePath i2right = new CityBuilderParkingTwoLanePath(i2, e2right);

            i2.right = i2right;
            CityBuilderParkingTwoLanePath i2top = new CityBuilderParkingTwoLanePath(i2, e2top);

            i2.top = i2top;
            CityBuilderParkingTwoLanePath i2bottom = new CityBuilderParkingTwoLanePath(i2, e2bottom);

            i2.bottom = i2bottom;

            builder.nodes.Add(i1);
            builder.nodes.Add(i2);
            builder.nodes.Add(e1top);
            builder.nodes.Add(e1left);
            builder.nodes.Add(e1bottom);
            builder.nodes.Add(e2right);
            builder.nodes.Add(e2top);
            builder.nodes.Add(e2bottom);
            builder.paths.Add(connection);
            builder.paths.Add(i1top);
            builder.paths.Add(i1bottom);
            builder.paths.Add(i1left);
            builder.paths.Add(i2right);
            builder.paths.Add(i2top);
            builder.paths.Add(i2bottom);
            city = builder.Build();

            Random r = new Random();

            foreach (CityNode n in city.nodes)
            {
                if (n is ParkingNode)
                {
                    //vehicles.Add(new GasolineCar(n));
                }
            }

            CityNode work1 = new CityNode(1200, 300);
            CityNode work2 = new CityNode(1100, 600);

            city.nodes.Add(work1);
            city.nodes.Add(work2);

            CityNode n1 = city.NearestNode(1200, 300, CityPathType.pedestrians);

            work1.Connect(n1, CityPathType.pedestrians);
            n1.Connect(work1, CityPathType.pedestrians);
            CityNode n2 = city.NearestNode(1100, 600, CityPathType.pedestrians);

            work2.Connect(n2, CityPathType.pedestrians);
            n2.Connect(work2, CityPathType.pedestrians);


            CityNode[] homes = new CityNode[]
            {
                new CityNode(250, 200),
                new CityNode(270, 300),
                new CityNode(120, 300),
                new CityNode(570, 100),
                new CityNode(570, 210),
                new CityNode(220, 560),
                new CityNode(550, 560),
                new CityNode(580, 700),
                new CityNode(750, 560),
                new CityNode(780, 720),
                new CityNode(780, 310),
                new CityNode(1080, 720),
                new CityNode(1080, 100),
            };

            foreach (CityNode home in homes)
            {
                city.nodes.Add(home);
                CityNode n = city.NearestNode((int)home.x, (int)home.y, CityPathType.pedestrians);
                home.Connect(n, CityPathType.pedestrians);
                n.Connect(home, CityPathType.pedestrians);

                CityNode park = City.ClosestParking(n);

                GasolineCar c = new GasolineCar(park);
                vehicles.Add(c);

                Commuter guy = new Commuter(home, home, r.Next(2) == 0 ? work1 : work2, c);
                debugObjects.Add(guy);
            }
        }
示例#28
0
	public void AddChild(GuiObject child) {children.Add(child);}
示例#29
0
	public void OpenWindow(GuiObject window) {
		int index;
		if (WindowIsOpen(window.name, out index)) GuiItems.RemoveAt(index);	
		GuiItems.Add(window);
		control.AddGUIRect(window.name, window.rect);
	}
示例#30
0
	public GuiObject BuildCombatDebugWindow(IFightable friend, IFightable enemy, Combat combat) {
		CloseWindow("LeftPane");
		
		GuiObject window = new GuiObject(new Rect(20, 50, 800, 500), "CentrePane", "Combat!");	
		Status friendStatus = friend.GetStatus(), enemyStatus = enemy.GetStatus();
		combat = new Combat(friend, enemy);
		
		window.AddChild(new GuiObject( new Rect(20, 20, 800, 100),
			(g) => {
				GUI.Label(new Rect(10, 25, 780, 100), "Night has fallen, you are under attack!");
				
				if (GUI.Button(new Rect(345, 65, 100, 30), "Attack!")) {
						combat.Phase();
				}
			}, "Text", ""));
		
		window.AddChild(new GuiObject(new Rect(20, 100, 360, 390),
			(g) => {
				GUI.Box(g.rect, g.text);
				GUI.Label(new Rect(30, 200, 200, 25), "Attack: " + friendStatus.attack);
				if (friendStatus.attackbonus > 0f) {
					SetColor(() => true);
					GUI.Label(new Rect(90, 200, 200, 25), "+" + friendStatus.attackbonus);
					SetColor();
				}
				GUI.Label(new Rect(30, 220, 200, 25), "Armour: " + friendStatus.armour);
				if (friendStatus.armorbonus > 0f) {
					SetColor(() => true);
					GUI.Label(new Rect(90, 220, 200, 25), "+" + friendStatus.armorbonus);
					SetColor();
				}
				GUI.Label(new Rect(30, 240, 200, 25), "Speed: " + friendStatus.speed);
				if (friendStatus.speedbonus > 0f) {
					SetColor(() => true);
					GUI.Label(new Rect(90, 240, 200, 25), "+" + friendStatus.speedbonus);
					SetColor();
				}
				GUI.Label(new Rect(130, 200, 100, 25), "Health: " + friendStatus.health);
				GUI.Label(new Rect(130, 220, 100, 25), "Turn: " + friendStatus.turn);
			}, "FriendBox", "Friend"));
		
		window.AddChild(new GuiObject(new Rect(410, 100, 360, 390),
			(g) => {
				GUI.Box(g.rect, g.text);
				GUI.Label(new Rect(420, 200, 200, 25), "Attack: " + enemyStatus.attack);
				if (enemyStatus.attackbonus > 0f) {
					SetColor(() => true);
					GUI.Label(new Rect(480, 200, 200, 25), "+" + enemyStatus.attackbonus);
					SetColor();
				}
				GUI.Label(new Rect(420, 220, 200, 25), "Armour: " + enemyStatus.armour);
				if (enemyStatus.armorbonus > 0f) {
					SetColor(() => true);
					GUI.Label(new Rect(480, 220, 200, 25), "+" + enemyStatus.armorbonus);
					SetColor();
				}
				GUI.Label(new Rect(420, 240, 200, 25), "Speed: " + enemyStatus.speed);
				if (enemyStatus.speedbonus > 0f) {
					SetColor(() => true);
					GUI.Label(new Rect(480, 240, 200, 25), "+" + enemyStatus.speedbonus);
					SetColor();
				}
				GUI.Label(new Rect(520, 200, 100, 25), "Health: " + enemyStatus.health);
				GUI.Label(new Rect(520, 220, 100, 25), "Turn: " + enemyStatus.turn);
			}, "EnemyBox", "Enemy"));
		
		return window;
	}
示例#31
0
 void AddBlocking(GuiObject g)
 {
     control.AddGUIRect(g.name, g.rect);
     GuiItems.Add(g);
 }
示例#32
0
	public void CloseWindow(GuiObject window) {
		int index;
		if (!WindowIsOpen(window.name, out index)) return;
		GuiItems.RemoveAt(index);
		control.RemoveGUIRect(window.name);
	}
示例#33
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);
    }
示例#34
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);
    }
示例#35
0
	private void ToggleWindow(GuiObject window) {
		int index;
		if(WindowIsOpen(window.name, out index)) {
			GuiItems.RemoveAt(index);
			control.RemoveGUIRect(window.name);
		} else {
			GuiItems.Add(window);
			control.AddGUIRect(window.name, window.rect);
		}
	}
示例#36
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;
	}
示例#37
0
	public GuiObject BuildCombatWindow(IFightable friend, IFightable enemy, Combat combat) {
		CloseWindow("LeftPane");
		GuiObject window = new GuiObject(new Rect(100, 50, 400, 300), "CentrePane", "Combat!");
		Status friendStatus = friend.GetStatus(), enemyStatus = enemy.GetStatus();
		combat = new Combat(friend, enemy);
		string report = combat.Phase()();
		
		window.AddChild(new GuiObject(new Rect(10, 25, 490, 370),
			(g) => {
				GUI.Label(g.rect, "Night has fallen and you were attacked!\n" + report);
				if (GUI.Button(new Rect(175, 260, 50, 25), "OK")) {
					CloseWindow("CentrePane");
				}
			}, "Report", ""));
		
		return window;
	}
示例#38
0
	public GuiObject BuildInventoryWindow() {
		Debug.Log("building");
		GuiObject window = new GuiObject(new Rect(Screen.width-150, Screen.height-300, 150, 300), "Inventory", "Inventory");
		
		int tileWidth = 265;
		int tileHeight = 20;
		
		window.Draw += (g) =>
		{
			GUI.Box(g.rect, g.text);
			int num = 1;
			var d = man.GetComponent<Inventory>().GetInventory();
		foreach(var i in d) {
				GUI.Box(new Rect(g.rect.x, g.rect.y+num * (tileHeight + 5), g.rect.width, tileHeight),
					i.Key.GetName() + " -- " + i.Value);
				if (i.Key.IsUsable()
					&& GUI.Button(new Rect(g.rect.x + g.rect.width - 20, g.rect.y+num * (tileHeight + 5), 20, 20), "")) {
					i.Key.Use(man);
					Debug.Log("Used " + i.Key.GetName());
				}
				num++;
			};
		};

		window.Draw += (g) => {
			g.DrawAllChildren();
		};
		
		return window;
	}
示例#39
0
    public GuiObject BuildCombatDebugWindow(IFightable friend, IFightable enemy, Combat combat)
    {
        CloseWindow("LeftPane");

        GuiObject window = new GuiObject(new Rect(20, 50, 800, 500), "CentrePane", "Combat!");
        Status    friendStatus = friend.GetStatus(), enemyStatus = enemy.GetStatus();

        combat = new Combat(friend, enemy);

        window.AddChild(new GuiObject(new Rect(20, 20, 800, 100),
                                      (g) => {
            GUI.Label(new Rect(10, 25, 780, 100), "Night has fallen, you are under attack!");

            if (GUI.Button(new Rect(345, 65, 100, 30), "Attack!"))
            {
                combat.Phase();
            }
        }, "Text", ""));

        window.AddChild(new GuiObject(new Rect(20, 100, 360, 390),
                                      (g) => {
            GUI.Box(g.rect, g.text);
            GUI.Label(new Rect(30, 200, 200, 25), "Attack: " + friendStatus.attack);
            if (friendStatus.attackbonus > 0f)
            {
                SetColor(() => true);
                GUI.Label(new Rect(90, 200, 200, 25), "+" + friendStatus.attackbonus);
                SetColor();
            }
            GUI.Label(new Rect(30, 220, 200, 25), "Armour: " + friendStatus.armour);
            if (friendStatus.armorbonus > 0f)
            {
                SetColor(() => true);
                GUI.Label(new Rect(90, 220, 200, 25), "+" + friendStatus.armorbonus);
                SetColor();
            }
            GUI.Label(new Rect(30, 240, 200, 25), "Speed: " + friendStatus.speed);
            if (friendStatus.speedbonus > 0f)
            {
                SetColor(() => true);
                GUI.Label(new Rect(90, 240, 200, 25), "+" + friendStatus.speedbonus);
                SetColor();
            }
            GUI.Label(new Rect(130, 200, 100, 25), "Health: " + friendStatus.health);
            GUI.Label(new Rect(130, 220, 100, 25), "Turn: " + friendStatus.turn);
        }, "FriendBox", "Friend"));

        window.AddChild(new GuiObject(new Rect(410, 100, 360, 390),
                                      (g) => {
            GUI.Box(g.rect, g.text);
            GUI.Label(new Rect(420, 200, 200, 25), "Attack: " + enemyStatus.attack);
            if (enemyStatus.attackbonus > 0f)
            {
                SetColor(() => true);
                GUI.Label(new Rect(480, 200, 200, 25), "+" + enemyStatus.attackbonus);
                SetColor();
            }
            GUI.Label(new Rect(420, 220, 200, 25), "Armour: " + enemyStatus.armour);
            if (enemyStatus.armorbonus > 0f)
            {
                SetColor(() => true);
                GUI.Label(new Rect(480, 220, 200, 25), "+" + enemyStatus.armorbonus);
                SetColor();
            }
            GUI.Label(new Rect(420, 240, 200, 25), "Speed: " + enemyStatus.speed);
            if (enemyStatus.speedbonus > 0f)
            {
                SetColor(() => true);
                GUI.Label(new Rect(480, 240, 200, 25), "+" + enemyStatus.speedbonus);
                SetColor();
            }
            GUI.Label(new Rect(520, 200, 100, 25), "Health: " + enemyStatus.health);
            GUI.Label(new Rect(520, 220, 100, 25), "Turn: " + enemyStatus.turn);
        }, "EnemyBox", "Enemy"));

        return(window);
    }
示例#40
0
        public override GuiObject SideMenu()
        {
            GuiObject dimensionCopy = Sim.instance.sideMenu;

            return(new StackPanel(dimensionCopy.x, dimensionCopy.y, dimensionCopy.width, dimensionCopy.height));
        }
示例#41
0
	public GuiObject BuildDebugWindow() {
		GuiObject window = new GuiObject(new Rect(750, 50, 270, 400), "RightPane", "Debug");
		
		window.Draw += (g) => {
			GUI.Box(g.rect, g.text);
			g.DrawAllChildren();
		};
		
		window.AddChild(new GuiObject(new Rect(5, 20, 270, 400), 
			(g) => {
				GUI.Box(new Rect(5, 85, 40, 20 + peon.queue.Size() * 20), peon.queue.Size().ToString());
				GUI.Label(g.rect, peon.state.ToString());
				if (GUI.Button(new Rect(5, 40, 40, 40), "Skip")) {
					peon.queue.CancelCurrent();
				}
			},
			"info", ""));
		return window;
	}