Пример #1
0
		public void DrawPortalSelector (Portal exit, Generator.InoutType type)
		{
			int entersNum = 0;
			for (int g=0; g<MapMagic.instance.gens.list.Length; g++)
			{
				Portal portal = MapMagic.instance.gens.list[g] as Portal;
				if (portal == null) continue;
				if (portal.form == Portal.PortalForm.Out) continue;
				if (portal.type != type) continue;

				entersNum++;
			}
			
			PopupMenu.MenuItem[] popupItems = new PopupMenu.MenuItem[entersNum];
			int counter = 0;
			for (int g=0; g<MapMagic.instance.gens.list.Length; g++)
			{
				Portal enter = MapMagic.instance.gens.list[g] as Portal;
				if (enter == null) continue;
				if (enter.form == Portal.PortalForm.Out) continue;
				if (enter.type != type) continue;

				popupItems[counter] = new PopupMenu.MenuItem( enter.input.guiName, delegate () { exit.input.Link(enter.output, enter); MapMagic.instance.gens.ChangeGenerator(exit); } );
				counter++;
			}

			PopupMenu.DrawPopup(popupItems, Event.current.mousePosition, closeAllOther:true);

		}
Пример #2
0
		public void DrawPortalSelector (Portal exit, Generator.InoutType type)
		{
			//if (MapMagic.instance.guiGens == null) MapMagic.instance.guiGens = MapMagic.instance.gens;
			//GeneratorsAsset gens = MapMagic.instance.guiGens;
			//if (MapMagic.instance.guiGens != null) gens = MapMagic.instance.guiGens;

			int entersNum = 0;
			for (int g=0; g<gens.list.Length; g++)
			{
				Portal portal = gens.list[g] as Portal;
				if (portal == null) continue;
				if (portal.form == Portal.PortalForm.Out) continue;
				if (portal.type != type) continue;

				entersNum++;
			}
			
			PopupMenu.MenuItem[] popupItems = new PopupMenu.MenuItem[entersNum];
			int counter = 0;
			for (int g=0; g<gens.list.Length; g++)
			{
				Portal enter = gens.list[g] as Portal;
				if (enter == null) continue;
				if (enter.form == Portal.PortalForm.Out) continue;
				if (enter.type != type) continue;

				popupItems[counter] = new PopupMenu.MenuItem( enter.name, delegate () 
					{ 
						if (gens.CheckDependence(exit,enter)) { Debug.LogError("MapMagic: Linking portals this way will create dependency loop."); return; }
						exit.input.Link(enter.output, enter); 
						if (mapMagic!=null) 
						{
							mapMagic.ClearResults(exit);
							mapMagic.Generate();
						}
					} );
				counter++;
			}

			PopupMenu.DrawPopup(popupItems, Event.current.mousePosition, closeAllOther:true);

		}