public DefaultTowerSelectionPanelForTesting(Vector2D position, Game game)
		{
			towerPanel = new Scene();
			clickedPosition = position;
			this.game = game;
			DisplayTowerSelectionPanel();
		}
Ejemplo n.º 2
0
		private void LoadAndSetup()
		{
			menuScene = BlocksContent.Load<Scene>("MainMenu");
			foreach (var control in menuScene.Controls)
			{
				if (!control.GetType().IsSubclassOf(typeof(Button)))
					continue;
				var button = control as Button;
				if (button.Name=="StartGame")
				{
					button.Clicked += InvokeGameStart;
				}
				if (button.Name=="HowToPlay")
				{
					button.Clicked += ShowHowToPlaySubMenu;
				}
				if (button.Name=="QuitGame")
				{
					button.Clicked += TryInvokeQuit;
				}
				if (button.Name=="ContentSwitcher")
				{
					button.Clicked += SwitchContent;
				}
			}
		}
Ejemplo n.º 3
0
		public DrenchMenu()
		{
			scene = new Scene();
			CreateTheme();
			AddOptionButtons();
			AddSliders();
		}
Ejemplo n.º 4
0
			public HowToPlaySubMenu(Scene parent, Theme menuTheme)
			{
				this.parent = parent;
				this.menuTheme = menuTheme;
				SetQuadraticBackground("SidescrollerMainMenuBackground");
				AddControlDescription();
				AddBackButton();
			}
Ejemplo n.º 5
0
		public void Setup()
		{
			scene = new Scene();
			for (int i = 0; i < 5; ++i)
				scene.Add(new Button(new Rectangle()));
			for (int i = 0; i < 5; ++i)
				scene.Add(new Slider(new Rectangle()));
			generator = new SceneCodeGenerator(new MockService("", "TestProject"), scene, "TestScene");
			generator.GenerateSourceCodeClass();
		}
Ejemplo n.º 6
0
		public Number(Scene scene, Material[] materials, float left, float top, float height,
			Alignment align, int digitCount, Color color, GameRenderLayer layer = GameRenderLayer.Hud)
		{
			this.scene = scene;
			this.materials = materials;
			this.align = align;
			this.digitCount = digitCount;
			this.layer = layer;
			this.color = color;
			digitHeight = height;
			digitWidth = height / materials[0].DiffuseMap.PixelSize.AspectRatio;
			this.left = left;
			this.top = top;
		}
Ejemplo n.º 7
0
		protected override void Preview(string contentName)
		{
			var scene = ContentLoader.Load<Scene>(contentName);
			Scene = new Scene();
			foreach (var control in scene.Controls)
			{
				control.IsActive = true;
				if (!control.Contains<AnchoringState>())
					control.Add(new AnchoringState());
				CheckIfAnyMaterialIsCorrupt((Control)control);
				AddControlToScene((Control)control);
				control.IsActive = false;
			}
		}
Ejemplo n.º 8
0
 public TreeManager(Team playerTeam)
 {
     gameScene = new Scene();
     MainMenu.PlayerTeam = playerTeam;
     if (MainMenu.State != GameState.CountDown)
         MainMenu.State = GameState.Game;
     statusText = new FontText(MainMenu.Font, "",
         Rectangle.FromCenter(new Vector2D(0.5f, 0.25f), new Size(0.2f)));
     statusText.RenderLayer = 5;
     statusText.Color = Team.HumanYellow.ToColor();
     var logo = new Sprite(new Material(Shader.Position2DUV, "Logo"),
         new Rectangle(0.02f, 0.205f, 0.15f, 0.15f));
     logo.RenderLayer = -15;
     gameScene.Add(logo);
     CreateArrowSelectionAndBars();
     OnClickSelectTree();
 }
Ejemplo n.º 9
0
 public UIEditorViewModel(Service service)
 {
     this.service = service;
     Messenger.Default.Send("ClearScene", "ClearScene");
     uiEditorScene = new UIEditorScene();
     uiEditorScene.ControlProcessor = new ControlProcessor(this);
     uiControl = new UIControl();
     controlAdder = new ControlAdder();
     controlChanger = new ControlChanger();
     Adder = new ControlAdder();
     Scene = new Scene();
     InitializeDefaults();
     InitializeGrid();
     FillContentImageList();
     FillMaterialList();
     FillSceneNames();
     FillListOfAvailableFonts();
     SetMouseCommands("");
     SetMessengers();
     CreateCenteredControl("Button");
     UIName = "MyScene";
     CheckIfCanSaveScene();
     new Command(() => DeleteSelectedControl("")).Add(new KeyTrigger(Key.Delete));
 }
Ejemplo n.º 10
0
 //ncrunch: no coverage start
 public HowToPlaySubMenu(Scene parent, Theme menuTheme, BlocksContent content)
 {
     this.parent = parent;
     this.menuTheme = menuTheme;
     var backgroundImage = content.Load<Image>("Background");
     var backgroundMaterial = new Material(ContentLoader.Load<Shader>(Shader.Position2DUV),
         backgroundImage, backgroundImage.PixelSize);
     SetViewportBackground(backgroundMaterial);
     var gameLogoImage = content.Load<Image>("GameLogo");
     var gameLogoMaterial = new Material(ContentLoader.Load<Shader>(Shader.Position2DUV),
         gameLogoImage, gameLogoImage.PixelSize);
     Add(new Sprite(gameLogoMaterial, Rectangle.FromCenter(0.5f, 0.35f, 0.4f, 0.2f)));
     AddControlDescription();
     AddBackButton();
 }
Ejemplo n.º 11
0
		public SceneCodeGenerator(Service service, Scene scene, string sceneName)
		{
			this.service = service;
			this.scene = scene;
			sceneClassName = sceneName;
		}
Ejemplo n.º 12
0
 public HowToPlaySubMenu(Scene parent, Theme menuTheme)
 {
     this.parent = parent;
     this.menuTheme = menuTheme;
     SetViewportBackground("SnakeMainMenuBackground");
     AddControlDescription();
     AddBackButton();
 }
Ejemplo n.º 13
0
 public HowToPlaySubMenu(Scene parent, Theme menuTheme, int renderLayer)
 {
     this.parent = parent;
     this.menuTheme = menuTheme;
     this.renderLayer = renderLayer;
     SetViewportBackground("AsteroidsMainMenuBackground");
     AddControlDescription();
     AddBackButton();
 }
Ejemplo n.º 14
0
		private static MemoryStream SaveEmptyScene()
		{
			var emptyScene = new Scene();
			var data = BinaryDataExtensions.SaveToMemoryStream(emptyScene);
			data.Seek(0, SeekOrigin.Begin);
			return data;
		}
Ejemplo n.º 15
0
		public void GenerateSourceCodeShouldApplyToCodingStyle()
		{
			var newScene = new Scene();
			newScene.Add(new Button(new Rectangle()));
			newScene.Add(new Slider(new Rectangle()));
			generator = new SceneCodeGenerator(new MockService("", "TestProject"), newScene,
				"" + "FullTestScene");
			generator.GenerateSourceCodeClass();
			CheckIfGeneratedCodeIsValid();
		}
Ejemplo n.º 16
0
 public MainMenu(Window window)
 {
     menuScene = new Scene();
     CreateMainMenu();
     new Command(Command.Exit, window.CloseAfterFrame);
 }
Ejemplo n.º 17
0
		public void CreateClassInProjectFolder()
		{
			var sceneSpy = new Scene();
			var spyGenerator = new SceneCodeGeneratorSpy(new MockService("", "TestProject"), sceneSpy,
				"TestScene");
			spyGenerator.GenerateSourceCodeClass();
			Assert.IsTrue(spyGenerator.CreatedSourceClass);
			Assert.IsTrue(
				spyGenerator.csprojString.Contains("<Compile Include=" + '"' + "TestScene" + ".cs" + '"' +
					" />"));
		}
Ejemplo n.º 18
0
		public SceneCodeGeneratorSpy(Service service, Scene scene, string sceneName)
			: base(service, scene, sceneName) {}
Ejemplo n.º 19
0
		public Number CreateNumber(Scene scene, float left, float top, float height, Alignment align,
			int digitCount, Color color, GameRenderLayer layer = GameRenderLayer.Hud)
		{
			return new Number(scene, materials, left, top, height, align, digitCount, color, layer);
		}
Ejemplo n.º 20
0
		public void OverwriteCreatedClass()
		{
			var sceneSpy = new Scene();
			var spyGenerator = new SceneCodeGeneratorSpy(new MockService("", "TestProject"), sceneSpy,
				"TestScene");
			spyGenerator.GenerateSourceCodeClass();
			var firstClassString = spyGenerator.CreatedSourceClass;
			Assert.IsTrue(spyGenerator.CreatedSourceClass);
			sceneSpy.Add(new Button(new Rectangle()));
			spyGenerator.GenerateSourceCodeClass();
			Assert.AreNotEqual(firstClassString, spyGenerator.CreatedClassString);
		}
Ejemplo n.º 21
0
		private static Stream SaveSceneWithASlider()
		{
			var scene = new Scene();
			scene.Controls.Add(new Slider(new Theme(), Rectangle.One));
			var data = BinaryDataExtensions.SaveToMemoryStream(scene);
			data.Seek(0, SeekOrigin.Begin);
			return data;
		}
Ejemplo n.º 22
0
		private static Stream SaveSceneWithAButtonWithFontText()
		{
			var scene = new Scene();
			scene.Controls.Add(new Button(new Theme(), Rectangle.One, "Hello"));
			var data = BinaryDataExtensions.SaveToMemoryStream(scene);
			data.Seek(0, SeekOrigin.Begin);
			return data;
		}
Ejemplo n.º 23
0
		private static Stream SaveSceneWithAButtonWithMaterial()
		{
			var scene = new Scene();
			scene.Controls.Add(new Button(new Theme(), Rectangle.One, "Hello"));
			var material = new Material(ShaderFlags.Position2DColoredTextured, "DeltaEngineLogo");
			scene.Controls[0].Get<Theme>().Button = material;
			scene.Controls[0].Get<Theme>().ButtonDisabled = material;
			scene.Controls[0].Get<Theme>().ButtonMouseover = material;
			scene.Controls[0].Get<Theme>().ButtonPressed = material;
			var data = BinaryDataExtensions.SaveToMemoryStream(scene);
			data.Seek(0, SeekOrigin.Begin);
			return data;
		}
Ejemplo n.º 24
0
		public bool LoadScene()
		{
			if (!ContentLoader.Exists(UIName, ContentType.Scene))
				return true; //ncrunch: no coverage
			editorService.Viewport.DestroyRenderedEntities();
			Messenger.Default.Send("ClearScene", "ClearScene");
			var scene = new Scene();
			Scene = new Scene();
			try
			{
				scene = ContentLoader.Load<Scene>(UIName);
				foreach (var control in scene.Controls)
					ActivateControl((Control)control);
			}
			catch
			{
				foreach (var control in EntitiesRunner.Current.GetEntitiesOfType<Control>())
					ActivateControl((Control)control);
			}
			UISceneGrid.DrawGrid();
			uiSceneGrid.UpdateGridOutline(SceneResolution);
			controlTransformer = new ControlTransformer(editorService);
			return false;
		}
Ejemplo n.º 25
0
 public void LoadScene()
 {
     if (!ContentLoader.Exists(uiEditorScene.UIName, ContentType.Scene))
         return;
     foreach (var entity in EntitiesRunner.Current.GetEntitiesOfType<DrawableEntity>())
         entity.IsActive = false;
     Messenger.Default.Send("ClearScene", "ClearScene");
     try
     {
         var scene = ContentLoader.Load<Scene>(uiEditorScene.UIName);
         Scene = new Scene();
         foreach (Control control in scene.Controls)
         {
             control.IsActive = true;
             controlAdder.AddControlToScene(control, uiEditorScene);
             Messenger.Default.Send(control.GetTags()[0], "AddToHierachyList");
             control.IsActive = false;
             if (uiEditorScene.GridRenderLayer <= control.RenderLayer)
                 uiEditorScene.GridRenderLayer = control.RenderLayer + 1;
         }
     }
     catch
     {
         return;
     }
     uiEditorScene.ControlProcessor.CreateNewLines();
     uiEditorScene.DrawGrid();
     CheckIfCanSaveScene();
     SetMouseCommands("");
 }
Ejemplo n.º 26
0
		private void InitializeLists()
		{
			Scene = new Scene();
			AvailableFontsInProject = new ObservableCollection<string>();
			MaterialList = new ObservableCollection<string>();
			UIImagesInList = new ObservableCollection<string>();
			ContentImageListList = new ObservableCollection<string>();
			SceneNames = new ObservableCollection<string>();
			ResolutionList = new ObservableCollection<string>();
			SelectedEntity2DList = new List<Entity2D>();
			SelectedControlNamesInList = new List<string>();
		}
Ejemplo n.º 27
0
		//ncrunch: no coverage start
		public virtual void RenderLevel()
		{
			if (Camera == null)
				return;
			scene = new Scene();
			scene.SetQuadraticBackground("LevelBackgroundSpace");
			levelModel = new Model(ModelName, Vector3D.Zero);
		}
Ejemplo n.º 28
0
 public HighscoreSubMenu(Scene parent, Theme menuTheme, int renderLayer)
 {
     this.parent = parent;
     this.menuTheme = menuTheme;
     this.renderLayer = renderLayer;
     SetViewportBackground("AsteroidsMainMenuBackground");
     scoreboard = new FontText(Font.Default, "", new Vector2D(0.5f, 0.45f));
     scoreboard.RenderLayer = renderLayer + 2;
     Add(scoreboard);
     AddBackButton();
 }
Ejemplo n.º 29
0
		public void AddControlToScene(Control control, Scene scene)
		{
			Control newControl = null;
			if (control.GetType() == typeof(Picture))
				newControl = new Picture((control as Picture).Theme, control.Material, control.DrawArea);
			else if (control.GetType() == typeof(Label))
			{
				newControl = new Label((control as Picture).Theme, control.DrawArea, (control as Label).Text);
				newControl.Set(control.Get<BlendMode>());
				newControl.Set(control.Material);
			}
			else if (control.GetType() == typeof(Button))
				newControl = new Button((control as Picture).Theme, control.DrawArea, (control as Button).Text);
			else if (control.GetType() == typeof(InteractiveButton))
				newControl = new InteractiveButton((control as Picture).Theme, control.DrawArea,
					(control as Button).Text);
			else if (control.GetType() == typeof(Slider))
				newControl = new Slider((control as Picture).Theme, control.DrawArea);
			newControl.Name = control.Name;
			if (newControl.Name == null && newControl.GetTags()[0] != null)
				newControl.Name = newControl.GetTags()[0];
			newControl.RenderLayer = control.RenderLayer;
			if (!control.Contains<AnchoringState>())
				newControl.Set(new AnchoringState()); //ncrunch: no coverage
			else
				newControl.Set(control.Get<AnchoringState>());
			scene.Add(newControl);
		}
Ejemplo n.º 30
0
		private void SwitchContent()
		{
			contentSwitched = !contentSwitched;
			BlocksContent = contentSwitched
				? new JewelBlocksContent() : (BlocksContent)new FruitBlocksContent();
			Clear();
			if (howToPlay != null)
				howToPlay.Clear();
			howToPlay = null;
			menuScene = null;
			LoadAndSetup();
		}