private static UI.Layout GetValue(UI.Layout c1, Texture2D texture) { var cc1 = c1.AddChild(new UI.Layout(0, 0, 100, 60)); cc1.Visible = true; cc1.AddLayoutter(new UI.Layout.LayoutChildren(UI.Layout.Mode.Horizontal)); //cc1.AddLayoutter(new UI.Layout.CenterX()); var a = cc1.AddChild(new UI.TextButton(25, 25, 50, 50, "buttontest")); a.AddChild(new UI.Image(10, 10, 20, 20, texture)); a.AddChild(new UI.Label(30, 30, 10, 10, "labell")); a.AddChild(new UI.TextRect(0, 0, 36, 10, "rect")); cc1.AddChild(new UI.SwappableButton(25, 25, 50, 50)).AddChild(new UI.Image(1, 1, 48, 48, texture)).IgnoreInput = true; cc1.AddChild(new UI.SwappableButton(25, 25, 50, 50)).AddChild(new UI.Image(1, 1, 20, 20, texture)).IgnoreInput = true; cc1.AddChild(new UI.SwappableButton(25, 25, 50, 50)).AddChild(new UI.Image(1, 1, 30, 30, texture)).IgnoreInput = true; cc1.AddChild(new UI.SwappableButton(25, 25, 50, 50)); cc1.AddChild(new UI.Button(25, 25, 50, 50)); cc1.AddChild(new UI.Image(25, 25, 50, 50, texture)).IgnoreInput = false; cc1.AddChild(new UI.DraggableButton(25, 25, 50, 50)); cc1.AddChild(new UI.UIRect(25, 25, 50, 50)); cc1.AddChild(new UI.UIRect(25, 25, 50, 50)); cc1.AddChild(new UI.UIRect(25, 25, 50, 50)); cc1.AddChild(new UI.UIRect(25, 25, 50, 50)); cc1.AddChild(new UI.UIRect(25, 25, 50, 50)); cc1.AddChild(new UI.UIRect(25, 25, 50, 50)); return(cc1); }
protected override void Initialize() { Atlas.RegisterPipelineAssets(); ExplosionSound = Sound.Cache.explosion; //create our player Entity player = new Entity(new Vector2(8, 15)); // new Quad(player, new QuadData(Atlas.player)); new Sprite(player, new SpriteData(Vector2.One * 8, Color.White, Atlas.player.GetSprite().UvToPixels())); new PlayerScript(player); new LightOccluder(player, LightOccluder.OccluderShape.Horizontal, 2f); new SoundPlayer(player, Sound.laser); //jesus christ :( //we add a light for the player ship Texture2D lightTexture = Content.Load <Texture2D>(Other.light); Entity headlight = new Entity(player.Position + Vector2.UnitX, Vector2.UnitX); //pointing right (unitx) new LightProjector(headlight, 20, -15, lightTexture, Color.White); //we parent the light to the player entity new EntityContainer(player).AddChild(headlight); //create some rotating lights clearColor = Color.DarkGray; lightsBlendMode = BlendState.Additive; LightProjector.Systems.Default.BlendState = BlendState.Additive; LightOccluder.Systems.Default.shadowBias = 0; for (int i = 1; i < 4; i++) { for (int j = 0; j < 2; j++) { var light = new Entity(new Vector2(i * 9, j * 23)); new LightProjector(light, 20, -15, lightTexture, Randy.NextSaturatedColor()); new Rotate(light, Randy.Range(-3f, 3f)); } } //subscribe event OnBeforePhysicsUpdate += SpawnEnemy; //audio MediaPlayer.Play(Music.Cache.bgm); MediaPlayer.Volume = 0.4f; //list all sprites in some UI UI.Layout spritesLo = UI.RootRect.AddChild(new UI.Layout(0, 0, 40, 40)); spritesLo.AddLayoutter(new UI.Layout.ExpandToParentSize(UI.Layout.Mode.Horizontal)); spritesLo.AddLayoutter(new UI.Layout.AlignRelativeToParent(1, 1)); spritesLo.AddLayoutter(new UI.Layout.LayoutChildren(UI.Layout.Mode.Horizontal)); foreach (var sprite in Sheet.Sprites) { spritesLo.AddChild(new SpriteUIRect(0, 0, 56, 32, sprite.Key)); } //some help UI UI.RootRect.AddChild(new UI.TextRect(0, 0, 200, 10, "Controls: W,A,LMB. Drag and drop sprites from bottom onto scene, press 1 to save scene, 2 to load" )); //subscribe event, dropping sprites onto scene creates entities with the sprite UI.RootRect.OnDrop += WorldDropFromUI; //saving and loading scene OnBeforeLogicUpdate += () => { if (Keys.D1.WasPressed()) { Entity.SaveAll("savedata"); } else if (Keys.D2.WasPressed()) { Entity.DestroyAll(); Entity.LoadAll("savedata"); } }; }