public MainScreen(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; Padding = new Border(0,0,0,0); Background = new TextureBrush(assets.LoadTexture(typeof(ScreenComponent), "background"), TextureBrushMode.Stretch); StackPanel stack = new StackPanel(manager); Controls.Add(stack); Button startButton = Button.TextButton(manager, Languages.OctoClient.Start); startButton.HorizontalAlignment = HorizontalAlignment.Stretch; startButton.Margin = new Border(0, 0, 0, 10); startButton.LeftMouseClick += (s, e) => { manager.NavigateToScreen(new LoadScreen(manager)); }; stack.Controls.Add(startButton); Button optionButton = Button.TextButton(manager, Languages.OctoClient.Options); optionButton.HorizontalAlignment = HorizontalAlignment.Stretch; optionButton.Margin = new Border(0, 0, 0, 10); optionButton.MinWidth = 300; optionButton.LeftMouseClick += (s, e) => { manager.NavigateToScreen(new OptionsScreen(manager)); }; stack.Controls.Add(optionButton); Button creditsButton = Button.TextButton(manager, Languages.OctoClient.CreditsCrew); creditsButton.HorizontalAlignment = HorizontalAlignment.Stretch; creditsButton.Margin = new Border(0, 0, 0, 10); creditsButton.LeftMouseClick += (s, e) => { manager.NavigateToScreen(new CreditsScreen(manager)); }; stack.Controls.Add(creditsButton); Button webButton = Button.TextButton(manager, "Octoawesome.net"); webButton.VerticalAlignment = VerticalAlignment.Bottom; webButton.HorizontalAlignment = HorizontalAlignment.Right; webButton.Margin = new Border(10, 10, 10, 10); webButton.LeftMouseClick += (s, e) => { Process.Start("http://octoawesome.net/"); }; Controls.Add(webButton); Button exitButton = Button.TextButton(manager, Languages.OctoClient.Exit); exitButton.HorizontalAlignment = HorizontalAlignment.Stretch; exitButton.Margin = new Border(0, 0, 0, 10); exitButton.LeftMouseClick += (s, e) => { manager.Exit(); }; stack.Controls.Add(exitButton); }
public CrosshairControl(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; Transparency = 0.5f; Color = Color.White; Texture = assets.LoadTexture(GetType(), "octocross"); }
public CompassControl(ScreenComponent screenManager) : base(screenManager) { assets = screenManager.Game.Assets; Player = screenManager.Player; Padding = Border.All(7); Texture2D background = assets.LoadTexture(typeof(ScreenComponent), "buttonLong_brown_pressed"); Background = NineTileBrush.FromSingleTexture(background, 7, 7); compassTexture = assets.LoadTexture(GetType(), "compass"); }
public PauseScreen(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; // IsOverlay = true; // Background = new BorderBrush(new Color(Color.Black, 0.5f)); Background = new TextureBrush(assets.LoadTexture(typeof(ScreenComponent), "background"), TextureBrushMode.Stretch); StackPanel stack = new StackPanel(manager); Controls.Add(stack); Button resumeButton = Button.TextButton(manager, Languages.OctoClient.Resume); resumeButton.HorizontalAlignment = HorizontalAlignment.Stretch; resumeButton.Margin = new Border(0, 0, 0, 10); resumeButton.LeftMouseClick += (s, e) => { manager.NavigateBack(); }; stack.Controls.Add(resumeButton); Button optionButton = Button.TextButton(manager, Languages.OctoClient.Options); optionButton.HorizontalAlignment = HorizontalAlignment.Stretch; optionButton.Margin = new Border(0, 0, 0, 10); optionButton.MinWidth = 300; optionButton.LeftMouseClick += (s, e) => { manager.NavigateToScreen(new OptionsScreen(manager)); }; stack.Controls.Add(optionButton); Button creditsButton = Button.TextButton(manager, Languages.OctoClient.CreditsCrew); creditsButton.HorizontalAlignment = HorizontalAlignment.Stretch; creditsButton.Margin = new Border(0, 0, 0, 10); creditsButton.LeftMouseClick += (s, e) => { manager.NavigateToScreen(new CreditsScreen(manager)); }; stack.Controls.Add(creditsButton); Button mainMenuButton = Button.TextButton(manager, Languages.OctoClient.ToMainMenu); mainMenuButton.HorizontalAlignment = HorizontalAlignment.Stretch; mainMenuButton.Margin = new Border(0, 0, 0, 10); mainMenuButton.LeftMouseClick += (s, e) => { manager.Player.RemovePlayer(); manager.Game.Simulation.ExitGame(); manager.NavigateHome(); }; stack.Controls.Add(mainMenuButton); }
public OctoGame() { //graphics = new GraphicsDeviceManager(this); //graphics.PreferredBackBufferWidth = 1080; //graphics.PreferredBackBufferHeight = 720; //Content.RootDirectory = "Content"; Title = "OctoAwesome"; IsMouseVisible = true; Icon = Properties.Resources.octoawesome; //Window.AllowUserResizing = true; Settings = new Settings(); ResourceManager.Settings = Settings; //TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 15); int width = 1080, height = 720; if (Settings.KeyExists("Width")) width = Settings.Get<int>("Width"); if (Settings.KeyExists("Height")) height = Settings.Get<int>("Height"); Window.ClientSize = new Size(width, height); if (Settings.KeyExists("EnableFullscreen") && Settings.Get<bool>("EnableFullscreen")) Window.Fullscreen = true; if (Settings.KeyExists("Viewrange")) { var viewrange = Settings.Get<int>("Viewrange"); if (viewrange < 1) throw new NotSupportedException("Viewrange in app.config darf nicht kleiner 1 sein"); SceneControl.VIEWRANGE = viewrange; } Assets = new AssetComponent(this); Components.Add(Assets); Simulation = new SimulationComponent(this); Simulation.UpdateOrder = 4; Components.Add(Simulation); Player = new PlayerComponent(this); Player.UpdateOrder = 2; Components.Add(Player); Camera = new CameraComponent(this); Camera.UpdateOrder = 3; Components.Add(Camera); Screen = new ScreenComponent(this); Screen.UpdateOrder = 1; Screen.DrawOrder = 1; Components.Add(Screen); KeyMapper = new KeyMapper(Screen, Settings); /*Resize += (s, e) => { //if (Window.ClientBounds.Height == graphics.PreferredBackBufferHeight && // Window.ClientBounds.Width == graphics.PreferredBackBufferWidth) // return; //graphics.PreferredBackBufferHeight = Window.ClientBounds.Height; //graphics.PreferredBackBufferWidth = Window.ClientBounds.Width; //graphics.ApplyChanges(); };*/ SetKeyBindings(); }
public OptionsScreen(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; Padding = new Border(0, 0, 0, 0); Title = Languages.OctoClient.Options; Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel"); SetDefaultBackground(); TabControl tabs = new TabControl(manager) { Padding = new Border(20, 20, 20, 20), Width = 700, TabPageBackground = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), TabBrush = NineTileBrush.FromSingleTexture(assets.LoadTexture(typeof(ScreenComponent), "buttonLong_brown"), 15, 15), TabActiveBrush = NineTileBrush.FromSingleTexture(assets.LoadTexture(typeof(ScreenComponent), "buttonLong_beige"), 15, 15), }; Controls.Add(tabs); #region OptionsPage TabPage optionsPage = new TabPage(manager, Languages.OctoClient.Options); tabs.Pages.Add(optionsPage); OptionsOptionControl optionsOptions = new OptionsOptionControl(manager, this) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; optionsPage.Controls.Add(optionsOptions); #endregion #region BindingsPage TabPage bindingsPage = new TabPage(manager, Languages.OctoClient.KeyBindings); bindingsPage.Padding = Border.All(10); tabs.Pages.Add(bindingsPage); BindingsOptionControl bindingsOptions = new BindingsOptionControl(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; bindingsPage.Controls.Add(bindingsOptions); #endregion #region TexturePackPage TabPage resourcePackPage = new TabPage(manager, "Resource Packs"); tabs.Pages.Add(resourcePackPage); ResourcePacksOptionControl resourcePacksOptions = new ResourcePacksOptionControl(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; resourcePackPage.Controls.Add(resourcePacksOptions); #endregion #region ExtensionPage TabPage extensionPage = new TabPage(manager, Languages.OctoClient.Extensions); tabs.Pages.Add(extensionPage); ExtensionsOptionControl extensionOptions = new ExtensionsOptionControl(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; extensionPage.Controls.Add(extensionOptions); #endregion ////////////////////////////////////////////Restart Button//////////////////////////////////////////// exitButton = new TextButton(manager, Languages.OctoClient.RestartGameToApplyChanges); exitButton.VerticalAlignment = VerticalAlignment.Top; exitButton.HorizontalAlignment = HorizontalAlignment.Right; exitButton.Enabled = false; exitButton.Visible = false; exitButton.LeftMouseClick += (s, e) => Program.Restart(); exitButton.Margin = new Border(10, 10, 10, 10); Controls.Add(exitButton); }
public SceneControl(ScreenComponent manager, string style = "") : base(manager, style) { player = manager.Player; camera = manager.Camera; assets = manager.Game.Assets; Manager = manager; simpleShader = manager.Game.Content.Load<Effect>("simple"); sunTexture = assets.LoadTexture(typeof(ScreenComponent), "sun"); //List<Bitmap> bitmaps = new List<Bitmap>(); var definitions = DefinitionManager.Instance.GetBlockDefinitions(); int textureCount = 0; foreach (var definition in definitions) { textureCount += definition.Textures.Length; } int bitmapSize = 128; blockTextures = new Texture2DArray(manager.GraphicsDevice, 1, bitmapSize, bitmapSize, textureCount); int layer = 0; foreach (var definition in definitions) { foreach (var bitmap in definition.Textures) { System.Drawing.Bitmap texture = manager.Game.Assets.LoadBitmap(definition.GetType(), bitmap); var scaled = texture;//new Bitmap(bitmap, new System.Drawing.Size(bitmapSize, bitmapSize)); int[] data = new int[scaled.Width * scaled.Height]; var bitmapData = scaled.LockBits(new System.Drawing.Rectangle(0, 0, scaled.Width, scaled.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); System.Runtime.InteropServices.Marshal.Copy(bitmapData.Scan0, data, 0, data.Length); blockTextures.SetData(data, layer); scaled.UnlockBits(bitmapData); layer++; } } /*int size = (int)Math.Ceiling(Math.Sqrt(bitmaps.Count)); Bitmap blocks = new Bitmap(size * TEXTURESIZE, size * TEXTURESIZE); using (Graphics g = Graphics.FromImage(blocks)) { int counter = 0; foreach (var bitmap in bitmaps) { int x = counter % size; int y = (int)(counter / size); g.DrawImage(bitmap, new System.Drawing.Rectangle(TEXTURESIZE * x, TEXTURESIZE * y, TEXTURESIZE, TEXTURESIZE)); counter++; } } using (MemoryStream stream = new MemoryStream()) { blocks.Save(stream, ImageFormat.Png); stream.Seek(0, SeekOrigin.Begin); blockTextures = Texture2D.FromStream(manager.GraphicsDevice, stream); }*/ planet = ResourceManager.Instance.GetPlanet(0); // TODO: evtl. Cache-Size (Dimensions) VIEWRANGE + 1 int range = ((int)Math.Pow(2, VIEWRANGE) - 2) / 2; localChunkCache = new LocalChunkCache(ResourceManager.Instance.GlobalChunkCache, VIEWRANGE, range); chunkRenderer = new ChunkRenderer[ (int)Math.Pow(2, VIEWRANGE) * (int)Math.Pow(2, VIEWRANGE), planet.Size.Z]; orderedChunkRenderer = new List<ChunkRenderer>( (int)Math.Pow(2, VIEWRANGE) * (int)Math.Pow(2, VIEWRANGE) * planet.Size.Z); for (int i = 0; i < chunkRenderer.GetLength(0); i++) { for (int j = 0; j < chunkRenderer.GetLength(1); j++) { ChunkRenderer renderer = new ChunkRenderer(simpleShader, manager.GraphicsDevice, camera.Projection, blockTextures); chunkRenderer[i, j] = renderer; orderedChunkRenderer.Add(renderer); } } backgroundThread = new Thread(BackgroundLoop); backgroundThread.Priority = ThreadPriority.Lowest; backgroundThread.IsBackground = true; backgroundThread.Start(); var selectionVertices = new[] { new VertexPositionColor(new Vector3(-0.001f, +1.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, +1.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(-0.001f, -0.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, -0.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(-0.001f, +1.001f, -0.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, +1.001f, -0.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(-0.001f, -0.001f, -0.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, -0.001f, -0.001f), Color.Black * 0.5f), }; var billboardVertices = new[] { new VertexPositionTexture(new Vector3(-0.5f, 0.5f, 0), new Vector2(0, 0)), new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0), new Vector2(1, 0)), new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0), new Vector2(0, 1)), new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0), new Vector2(1, 0)), new VertexPositionTexture(new Vector3(0.5f, -0.5f, 0), new Vector2(1, 1)), new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0), new Vector2(0, 1)), }; var selectionIndices = new short[] { 0, 1, 0, 2, 1, 3, 2, 3, 4, 5, 4, 6, 5, 7, 6, 7, 0, 4, 1, 5, 2, 6, 3, 7 }; selectionLines = new VertexBuffer(manager.GraphicsDevice, VertexPositionColor.VertexDeclaration, selectionVertices.Length); selectionLines.SetData(selectionVertices); selectionIndexBuffer = new IndexBuffer(manager.GraphicsDevice, DrawElementsType.UnsignedShort, selectionIndices.Length); selectionIndexBuffer.SetData(selectionIndices); billboardVertexbuffer = new VertexBuffer(manager.GraphicsDevice, VertexPositionTexture.VertexDeclaration, billboardVertices.Length); billboardVertexbuffer.SetData(billboardVertices); sunEffect = new BasicEffect(manager.GraphicsDevice); sunEffect.TextureEnabled = true; selectionEffect = new BasicEffect(manager.GraphicsDevice); selectionEffect.VertexColorEnabled = true; MiniMapTexture = new RenderTarget2D(manager.GraphicsDevice, 128, 128, PixelInternalFormat.Rgb8); // , false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents); miniMapProjectionMatrix = Matrix.CreateOrthographic(128, 128, 1, 10000); }
public MainScreen(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; Padding = new Border(0, 0, 0, 0); Background = new TextureBrush(assets.LoadTexture(typeof(ScreenComponent), "background"), TextureBrushMode.Stretch); StackPanel stack = new StackPanel(manager); Controls.Add(stack); Button startButton = Button.TextButton(manager, Languages.OctoClient.Start); startButton.HorizontalAlignment = HorizontalAlignment.Stretch; startButton.Margin = new Border(0, 0, 0, 10); startButton.LeftMouseClick += (s, e) => { ((ContainerResourceManager)manager.Game.ResourceManager) .CreateManager(manager.Game.ExtensionLoader, manager.Game.DefinitionManager, manager.Game.Settings, false); manager.NavigateToScreen(new LoadScreen(manager)); }; stack.Controls.Add(startButton); Button multiplayerButton = Button.TextButton(manager, Languages.OctoClient.Multiplayer); multiplayerButton.HorizontalAlignment = HorizontalAlignment.Stretch; multiplayerButton.Margin = new Border(0, 0, 0, 10); multiplayerButton.LeftMouseClick += (s, e) => { manager.NavigateToScreen(new ConnectionScreen(manager)); }; stack.Controls.Add(multiplayerButton); Button optionButton = Button.TextButton(manager, Languages.OctoClient.Options); optionButton.HorizontalAlignment = HorizontalAlignment.Stretch; optionButton.Margin = new Border(0, 0, 0, 10); optionButton.MinWidth = 300; optionButton.LeftMouseClick += (s, e) => { manager.NavigateToScreen(new OptionsScreen(manager)); }; stack.Controls.Add(optionButton); Button creditsButton = Button.TextButton(manager, Languages.OctoClient.CreditsCrew); creditsButton.HorizontalAlignment = HorizontalAlignment.Stretch; creditsButton.Margin = new Border(0, 0, 0, 10); creditsButton.LeftMouseClick += (s, e) => { manager.NavigateToScreen(new CreditsScreen(manager)); }; stack.Controls.Add(creditsButton); Button webButton = Button.TextButton(manager, "Octoawesome.net"); webButton.VerticalAlignment = VerticalAlignment.Bottom; webButton.HorizontalAlignment = HorizontalAlignment.Right; webButton.Margin = new Border(10, 10, 10, 10); webButton.LeftMouseClick += (s, e) => { Process.Start("http://octoawesome.net/"); }; Controls.Add(webButton); Button exitButton = Button.TextButton(manager, Languages.OctoClient.Exit); exitButton.HorizontalAlignment = HorizontalAlignment.Stretch; exitButton.Margin = new Border(0, 0, 0, 10); exitButton.LeftMouseClick += (s, e) => { manager.Exit(); }; stack.Controls.Add(exitButton); }
public InventoryScreen(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; foreach (var item in manager.Game.DefinitionManager.GetDefinitions()) { Texture2D texture = manager.Game.Assets.LoadTexture(item.GetType(), item.Icon); toolTextures.Add(item.GetType().FullName, texture); } player = manager.Player; IsOverlay = true; Background = new BorderBrush(Color.Black * 0.3f); backgroundBrush = new BorderBrush(Color.Black); hoverBrush = new BorderBrush(Color.Brown); Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel"); Grid grid = new Grid(manager) { Width = 800, Height = 500, }; grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 600 }); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 200 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Fixed, Height = 100 }); Controls.Add(grid); inventory = new InventoryControl(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), }; grid.AddControl(inventory, 0, 0); StackPanel infoPanel = new StackPanel(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), Margin = Border.All(10, 0, 0, 0), }; nameLabel = new Label(manager); infoPanel.Controls.Add(nameLabel); massLabel = new Label(manager); infoPanel.Controls.Add(massLabel); volumeLabel = new Label(manager); infoPanel.Controls.Add(volumeLabel); grid.AddControl(infoPanel, 1, 0); Grid toolbar = new Grid(manager) { Margin = Border.All(0, 10, 0, 0), Height = 100, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), }; toolbar.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); for (int i = 0; i < ToolBarComponent.TOOLCOUNT; i++) { toolbar.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 50 }); } toolbar.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); toolbar.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); images = new Image[ToolBarComponent.TOOLCOUNT]; for (int i = 0; i < ToolBarComponent.TOOLCOUNT; i++) { Image image = images[i] = new Image(manager) { Width = 42, Height = 42, Background = backgroundBrush, HorizontalAlignment = HorizontalAlignment.Center, Tag = i, Padding = Border.All(2), }; image.StartDrag += (e) => { InventorySlot slot = player.Toolbar.Tools[(int)image.Tag]; if (slot != null) { e.Handled = true; e.Icon = toolTextures[slot.Definition.GetType().FullName]; e.Content = slot; e.Sender = toolbar; } }; image.DropEnter += (e) => { image.Background = hoverBrush; }; image.DropLeave += (e) => { image.Background = backgroundBrush; }; image.EndDrop += (e) => { e.Handled = true; if (e.Sender is Grid) // && ShiftPressed { // Swap int targetIndex = (int)image.Tag; InventorySlot targetSlot = player.Toolbar.Tools[targetIndex]; InventorySlot sourceSlot = e.Content as InventorySlot; int sourceIndex = player.Toolbar.GetSlotIndex(sourceSlot); player.Toolbar.SetTool(sourceSlot, targetIndex); player.Toolbar.SetTool(targetSlot, sourceIndex); } else { // Inventory Drop InventorySlot slot = e.Content as InventorySlot; player.Toolbar.SetTool(slot, (int)image.Tag); } }; toolbar.AddControl(image, i + 1, 0); } grid.AddControl(toolbar, 0, 1, 2); Title = Languages.OctoClient.Inventory; }
public override object Remove(Type compCls) { if (compCls == typeof(AreaTriggerComponent)) { this.AreaTriggerComp = null; } else if (compCls == typeof(ArmoryComponent)) { this.ArmoryComp = null; } else if (compCls == typeof(AssetComponent)) { this.AssetComp = null; } else if (compCls == typeof(AttackerComponent)) { this.AttackerComp = null; } else if (compCls == typeof(BarracksComponent)) { this.BarracksComp = null; } else if (compCls == typeof(BoardItemComponent)) { this.BoardItemComp = null; } else if (compCls == typeof(BuildingAnimationComponent)) { this.BuildingAnimationComp = null; } else if (compCls == typeof(BuildingComponent)) { this.BuildingComp = null; } else if (compCls == typeof(CantinaComponent)) { this.CantinaComp = null; } else if (compCls == typeof(ChampionComponent)) { this.ChampionComp = null; } else if (compCls == typeof(CivilianComponent)) { this.CivilianComp = null; } else if (compCls == typeof(ClearableComponent)) { this.ClearableComp = null; } else if (compCls == typeof(DamageableComponent)) { this.DamageableComp = null; } else if (compCls == typeof(DefenderComponent)) { this.DefenderComp = null; } else if (compCls == typeof(DefenseLabComponent)) { this.DefenseLabComp = null; } else if (compCls == typeof(DroidComponent)) { this.DroidComp = null; } else if (compCls == typeof(DroidHutComponent)) { this.DroidHutComp = null; } else if (compCls == typeof(SquadBuildingComponent)) { this.SquadBuildingComp = null; } else if (compCls == typeof(NavigationCenterComponent)) { this.NavigationCenterComp = null; } else if (compCls == typeof(FactoryComponent)) { this.FactoryComp = null; } else if (compCls == typeof(FleetCommandComponent)) { this.FleetCommandComp = null; } else if (compCls == typeof(FollowerComponent)) { this.FollowerComp = null; } else if (compCls == typeof(GameObjectViewComponent)) { this.GameObjectViewComp = null; } else if (compCls == typeof(GeneratorComponent)) { this.GeneratorComp = null; } else if (compCls == typeof(GeneratorViewComponent)) { this.GeneratorViewComp = null; } else if (compCls == typeof(HealerComponent)) { this.HealerComp = null; } else if (compCls == typeof(HealthComponent)) { this.HealthComp = null; } else if (compCls == typeof(TroopShieldComponent)) { this.TroopShieldComp = null; } else if (compCls == typeof(TroopShieldViewComponent)) { this.TroopShieldViewComp = null; } else if (compCls == typeof(TroopShieldHealthComponent)) { this.TroopShieldHealthComp = null; } else if (compCls == typeof(HealthViewComponent)) { this.HealthViewComp = null; } else if (compCls == typeof(HQComponent)) { this.HQComp = null; } else if (compCls == typeof(KillerComponent)) { this.KillerComp = null; } else if (compCls == typeof(LootComponent)) { this.LootComp = null; } else if (compCls == typeof(MeterShaderComponent)) { this.MeterShaderComp = null; } else if (compCls == typeof(OffenseLabComponent)) { this.OffenseLabComp = null; } else if (compCls == typeof(PathingComponent)) { this.PathingComp = null; } else if (compCls == typeof(SecondaryTargetsComponent)) { this.SecondaryTargetsComp = null; } else if (compCls == typeof(ShieldBorderComponent)) { this.ShieldBorderComp = null; } else if (compCls == typeof(ShieldGeneratorComponent)) { this.ShieldGeneratorComp = null; } else if (compCls == typeof(SizeComponent)) { this.SizeComp = null; } else if (compCls == typeof(ShooterComponent)) { this.ShooterComp = null; } else if (compCls == typeof(StarportComponent)) { this.StarportComp = null; } else if (compCls == typeof(StateComponent)) { this.StateComp = null; } else if (compCls == typeof(StorageComponent)) { this.StorageComp = null; } else if (compCls == typeof(SupportComponent)) { this.SupportComp = null; } else if (compCls == typeof(SupportViewComponent)) { this.SupportViewComp = null; } else if (compCls == typeof(TacticalCommandComponent)) { this.TacticalCommandComp = null; } else if (compCls == typeof(ChampionPlatformComponent)) { this.ChampionPlatformComp = null; } else if (compCls == typeof(TeamComponent)) { this.TeamComp = null; } else if (compCls == typeof(TrackingComponent)) { this.TrackingComp = null; } else if (compCls == typeof(TrackingGameObjectViewComponent)) { this.TrackingGameObjectViewComp = null; } else if (compCls == typeof(TransformComponent)) { this.TransformComp = null; } else if (compCls == typeof(TransportComponent)) { this.TransportComp = null; } else if (compCls == typeof(TroopComponent)) { this.TroopComp = null; } else if (compCls == typeof(TurretBuildingComponent)) { this.TurretBuildingComp = null; } else if (compCls == typeof(TurretShooterComponent)) { this.TurretShooterComp = null; } else if (compCls == typeof(WalkerComponent)) { this.WalkerComp = null; } else if (compCls == typeof(WallComponent)) { this.WallComp = null; } else if (compCls == typeof(BuffComponent)) { this.BuffComp = null; } else if (compCls == typeof(TrapComponent)) { this.TrapComp = null; } else if (compCls == typeof(TrapViewComponent)) { this.TrapViewComp = null; } else if (compCls == typeof(HousingComponent)) { this.HousingComp = null; } return(base.Remove(compCls)); }
protected override Entity AddComponentAndDispatchAddEvent(ComponentBase comp, Type compCls) { bool flag = false; if (comp is AreaTriggerComponent) { this.AreaTriggerComp = (AreaTriggerComponent)comp; flag = true; } if (comp is ArmoryComponent) { this.ArmoryComp = (ArmoryComponent)comp; flag = true; } if (comp is AssetComponent) { this.AssetComp = (AssetComponent)comp; flag = true; } if (comp is AttackerComponent) { this.AttackerComp = (AttackerComponent)comp; flag = true; } if (comp is BarracksComponent) { this.BarracksComp = (BarracksComponent)comp; flag = true; } if (comp is BoardItemComponent) { this.BoardItemComp = (BoardItemComponent)comp; flag = true; } if (comp is BuildingAnimationComponent) { this.BuildingAnimationComp = (BuildingAnimationComponent)comp; flag = true; } if (comp is BuildingComponent) { this.BuildingComp = (BuildingComponent)comp; flag = true; } if (comp is ChampionComponent) { this.ChampionComp = (ChampionComponent)comp; flag = true; } if (comp is CivilianComponent) { this.CivilianComp = (CivilianComponent)comp; flag = true; } if (comp is ClearableComponent) { this.ClearableComp = (ClearableComponent)comp; flag = true; } if (comp is DamageableComponent) { this.DamageableComp = (DamageableComponent)comp; flag = true; } if (comp is DefenderComponent) { this.DefenderComp = (DefenderComponent)comp; flag = true; } if (comp is DefenseLabComponent) { this.DefenseLabComp = (DefenseLabComponent)comp; flag = true; } if (comp is DroidComponent) { this.DroidComp = (DroidComponent)comp; flag = true; } if (comp is DroidHutComponent) { this.DroidHutComp = (DroidHutComponent)comp; flag = true; } if (comp is SquadBuildingComponent) { this.SquadBuildingComp = (SquadBuildingComponent)comp; flag = true; } if (comp is NavigationCenterComponent) { this.NavigationCenterComp = (NavigationCenterComponent)comp; flag = true; } if (comp is FactoryComponent) { this.FactoryComp = (FactoryComponent)comp; flag = true; } if (comp is CantinaComponent) { this.CantinaComp = (CantinaComponent)comp; flag = true; } if (comp is FleetCommandComponent) { this.FleetCommandComp = (FleetCommandComponent)comp; flag = true; } if (comp is FollowerComponent) { this.FollowerComp = (FollowerComponent)comp; flag = true; } if (comp is GameObjectViewComponent) { this.GameObjectViewComp = (GameObjectViewComponent)comp; flag = true; } if (comp is GeneratorComponent) { this.GeneratorComp = (GeneratorComponent)comp; flag = true; } if (comp is GeneratorViewComponent) { this.GeneratorViewComp = (GeneratorViewComponent)comp; flag = true; } if (comp is HealerComponent) { this.HealerComp = (HealerComponent)comp; flag = true; } if (comp is TroopShieldComponent) { this.TroopShieldComp = (TroopShieldComponent)comp; flag = true; } if (comp is TroopShieldViewComponent) { this.TroopShieldViewComp = (TroopShieldViewComponent)comp; flag = true; } if (comp is TroopShieldHealthComponent) { this.TroopShieldHealthComp = (TroopShieldHealthComponent)comp; flag = true; } if (comp is HealthComponent) { this.HealthComp = (HealthComponent)comp; flag = true; } if (comp is HealthViewComponent) { this.HealthViewComp = (HealthViewComponent)comp; flag = true; } if (comp is HQComponent) { this.HQComp = (HQComponent)comp; flag = true; } if (comp is KillerComponent) { this.KillerComp = (KillerComponent)comp; flag = true; } if (comp is LootComponent) { this.LootComp = (LootComponent)comp; flag = true; } if (comp is MeterShaderComponent) { this.MeterShaderComp = (MeterShaderComponent)comp; flag = true; } if (comp is OffenseLabComponent) { this.OffenseLabComp = (OffenseLabComponent)comp; flag = true; } if (comp is PathingComponent) { this.PathingComp = (PathingComponent)comp; flag = true; } if (comp is SecondaryTargetsComponent) { this.SecondaryTargetsComp = (SecondaryTargetsComponent)comp; flag = true; } if (comp is ShieldBorderComponent) { this.ShieldBorderComp = (ShieldBorderComponent)comp; flag = true; } if (comp is ShieldGeneratorComponent) { this.ShieldGeneratorComp = (ShieldGeneratorComponent)comp; flag = true; } if (comp is SizeComponent) { this.SizeComp = (SizeComponent)comp; flag = true; } if (comp is ShooterComponent) { this.ShooterComp = (ShooterComponent)comp; flag = true; } if (comp is StarportComponent) { this.StarportComp = (StarportComponent)comp; flag = true; } if (comp is StateComponent) { this.StateComp = (StateComponent)comp; flag = true; } if (comp is StorageComponent) { this.StorageComp = (StorageComponent)comp; flag = true; } if (comp is SupportComponent) { this.SupportComp = (SupportComponent)comp; flag = true; } if (comp is SupportViewComponent) { this.SupportViewComp = (SupportViewComponent)comp; flag = true; } if (comp is TacticalCommandComponent) { this.TacticalCommandComp = (TacticalCommandComponent)comp; flag = true; } if (comp is ChampionPlatformComponent) { this.ChampionPlatformComp = (ChampionPlatformComponent)comp; flag = true; } if (comp is TeamComponent) { this.TeamComp = (TeamComponent)comp; flag = true; } if (comp is TrackingComponent) { this.TrackingComp = (TrackingComponent)comp; flag = true; } if (comp is TrackingGameObjectViewComponent) { this.TrackingGameObjectViewComp = (TrackingGameObjectViewComponent)comp; flag = true; } if (comp is TransformComponent) { this.TransformComp = (TransformComponent)comp; flag = true; } if (comp is TransportComponent) { this.TransportComp = (TransportComponent)comp; flag = true; } if (comp is TroopComponent) { this.TroopComp = (TroopComponent)comp; flag = true; } if (comp is TurretBuildingComponent) { this.TurretBuildingComp = (TurretBuildingComponent)comp; flag = true; } if (comp is TurretShooterComponent) { this.TurretShooterComp = (TurretShooterComponent)comp; flag = true; } if (comp is WalkerComponent) { this.WalkerComp = (WalkerComponent)comp; flag = true; } if (comp is WallComponent) { this.WallComp = (WallComponent)comp; flag = true; } if (comp is BuffComponent) { this.BuffComp = (BuffComponent)comp; flag = true; } if (comp is TrapComponent) { this.TrapComp = (TrapComponent)comp; flag = true; } if (comp is TrapViewComponent) { this.TrapViewComp = (TrapViewComponent)comp; flag = true; } if (comp is HousingComponent) { this.HousingComp = (HousingComponent)comp; flag = true; } if (comp is ScoutTowerComponent) { this.ScoutTowerComp = (ScoutTowerComponent)comp; flag = true; } if (!flag && compCls != null) { Service.Get <StaRTSLogger>().Error("Invalid component add: " + compCls.get_Name()); } return(base.AddComponentAndDispatchAddEvent(comp, compCls)); }
public BaseScreen(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; }
public PauseScreen(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; // IsOverlay = true; // Background = new BorderBrush(new Color(Color.Black, 0.5f)); Background = new TextureBrush(assets.LoadTexture(typeof(ScreenComponent), "background"), TextureBrushMode.Stretch); StackPanel stack = new StackPanel(manager); Controls.Add(stack); Button resumeButton = new TextButton(manager, Languages.OctoClient.Resume); resumeButton.HorizontalAlignment = HorizontalAlignment.Stretch; resumeButton.Margin = new Border(0, 0, 0, 10); resumeButton.LeftMouseClick += (s, e) => { manager.NavigateBack(); }; stack.Controls.Add(resumeButton); Button optionButton = new TextButton(manager, Languages.OctoClient.Options); optionButton.HorizontalAlignment = HorizontalAlignment.Stretch; optionButton.Margin = new Border(0, 0, 0, 10); optionButton.MinWidth = 300; optionButton.LeftMouseClick += (s, e) => { manager.NavigateToScreen(new OptionsScreen(manager)); }; stack.Controls.Add(optionButton); Button creditsButton = new TextButton(manager, Languages.OctoClient.CreditsCrew); creditsButton.HorizontalAlignment = HorizontalAlignment.Stretch; creditsButton.Margin = new Border(0, 0, 0, 10); creditsButton.LeftMouseClick += (s, e) => { manager.NavigateToScreen(new CreditsScreen(manager)); }; stack.Controls.Add(creditsButton); Button mainMenuButton = new TextButton(manager, Languages.OctoClient.ToMainMenu); mainMenuButton.HorizontalAlignment = HorizontalAlignment.Stretch; mainMenuButton.Margin = new Border(0, 0, 0, 10); mainMenuButton.LeftMouseClick += (s, e) => { manager.Player.SetEntity(null); manager.Game.Simulation.ExitGame(); foreach (var gameScreen in manager.History.OfType <GameScreen>()) { gameScreen.Unload(); } manager.NavigateHome(); }; stack.Controls.Add(mainMenuButton); }
public DebugControl(ScreenComponent screenManager) : base(screenManager) { framebuffer = new float[buffersize]; Player = screenManager.Player; manager = screenManager; assets = screenManager.Game.Assets; //Brush for Debug Background BorderBrush bg = new BorderBrush(Color.Black * 0.2f); //The left side of the Screen leftView = new StackPanel(ScreenManager) { Background = bg, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, }; //The right Side of the Screen rightView = new StackPanel(ScreenManager) { Background = bg, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, }; //Creating all Labels devText = new Label(ScreenManager); devText.Text = Languages.OctoClient.DevelopmentVersion; leftView.Controls.Add(devText); loadedChunks = new Label(ScreenManager); leftView.Controls.Add(loadedChunks); loadedTextures = new Label(ScreenManager); leftView.Controls.Add(loadedTextures); loadedInfo = new Label(ScreenManager); leftView.Controls.Add(loadedInfo); position = new Label(ScreenManager); rightView.Controls.Add(position); rotation = new Label(ScreenManager); rightView.Controls.Add(rotation); fps = new Label(ScreenManager); rightView.Controls.Add(fps); controlInfo = new Label(ScreenManager); leftView.Controls.Add(controlInfo); temperatureInfo = new Label(ScreenManager); rightView.Controls.Add(temperatureInfo); precipitationInfo = new Label(ScreenManager); rightView.Controls.Add(precipitationInfo); gravityInfo = new Label(ScreenManager); rightView.Controls.Add(gravityInfo); activeTool = new Label(ScreenManager); rightView.Controls.Add(activeTool); toolCount = new Label(ScreenManager); rightView.Controls.Add(toolCount); flyInfo = new Label(ScreenManager); rightView.Controls.Add(flyInfo); //This Label gets added to the root and is set to Bottom Left box = new Label(ScreenManager); box.VerticalAlignment = VerticalAlignment.Bottom; box.HorizontalAlignment = HorizontalAlignment.Left; box.TextColor = Color.White; Controls.Add(box); //Add the left & right side to the root Controls.Add(leftView); Controls.Add(rightView); //Label Setup - Set Settings for all Labels in one place foreach (Control control in leftView.Controls) { control.HorizontalAlignment = HorizontalAlignment.Left; if (control is Label) { ((Label)control).TextColor = Color.White; } } foreach (Control control in rightView.Controls) { control.HorizontalAlignment = HorizontalAlignment.Right; if (control is Label) { ((Label)control).TextColor = Color.White; } } }
public DebugControl(ScreenComponent screenManager) : base(screenManager) { framebuffer = new float[buffersize]; Player = screenManager.Player; //Get ResourceManager for further Information later... resMan = ResourceManager.Instance; assets = screenManager.Game.Assets; //Brush for Debug Background BorderBrush bg = new BorderBrush(Color.Black * 0.2f); //The left side of the Screen leftView = new StackPanel(ScreenManager) { Background = bg, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, }; //The right Side of the Screen rightView = new StackPanel(ScreenManager) { Background = bg, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, }; //Creating all Labels devText = new Label(ScreenManager); devText.Text = Languages.OctoClient.DevelopmentVersion; leftView.Controls.Add(devText); loadedChunks = new Label(ScreenManager); leftView.Controls.Add(loadedChunks); loadedTextures = new Label(ScreenManager); leftView.Controls.Add(loadedTextures); loadedInfo = new Label(ScreenManager); leftView.Controls.Add(loadedInfo); position = new Label(ScreenManager); rightView.Controls.Add(position); rotation = new Label(ScreenManager); rightView.Controls.Add(rotation); fps = new Label(ScreenManager); rightView.Controls.Add(fps); controlInfo = new Label(ScreenManager); leftView.Controls.Add(controlInfo); temperatureInfo = new Label(ScreenManager); rightView.Controls.Add(temperatureInfo); precipitationInfo = new Label(ScreenManager); rightView.Controls.Add(precipitationInfo); activeTool = new Label(ScreenManager); rightView.Controls.Add(activeTool); toolCount = new Label(ScreenManager); rightView.Controls.Add(toolCount); flyInfo = new Label(ScreenManager); rightView.Controls.Add(flyInfo); //This Label gets added to the root and is set to Bottom Left box = new Label(ScreenManager); box.VerticalAlignment = VerticalAlignment.Bottom; box.HorizontalAlignment = HorizontalAlignment.Left; box.TextColor = Color.White; Controls.Add(box); //Add the left & right side to the root Controls.Add(leftView); Controls.Add(rightView); //Label Setup - Set Settings for all Labels in one place foreach (Control control in leftView.Controls) { control.HorizontalAlignment = HorizontalAlignment.Left; if (control is Label) { ((Label)control).TextColor = Color.White; } } foreach (Control control in rightView.Controls) { control.HorizontalAlignment = HorizontalAlignment.Right; if (control is Label) { ((Label)control).TextColor = Color.White; } } }
public void PlayerJoin(EntityBase entity) { ConnectionComponent connectComp = entity.GetComp <ConnectionComponent>(); PlayerComponent playerComp = null; if (!entity.GetExistComp <PlayerComponent>()) { playerComp = new PlayerComponent(); entity.AddComp(playerComp); } else { playerComp = entity.GetComp <PlayerComponent>(); } //将角色ID传入游戏 playerComp.characterID = connectComp.m_session.player.characterID; playerComp.nickName = connectComp.m_session.player.nickName; Debug.Log("characterID ->" + playerComp.characterID + "<-"); if (playerComp.characterID == "" || playerComp.characterID == null) { playerComp.characterID = "1"; } ElementData e1 = new ElementData(); e1.id = 100; e1.num = 10; playerComp.elementData.Add(e1); ElementData e2 = new ElementData(); e2.id = 101; e2.num = 10; playerComp.elementData.Add(e2); ElementData e3 = new ElementData(); e3.id = 102; e3.num = 10; playerComp.elementData.Add(e3); ElementData e4 = new ElementData(); e4.id = 103; e4.num = 00; playerComp.elementData.Add(e4); if (!entity.GetExistComp <CommandComponent>()) { CommandComponent c = new CommandComponent(); entity.AddComp(c); } if (!entity.GetExistComp <TransfromComponent>()) { TransfromComponent c = new TransfromComponent(); c.pos.FromVector(new Vector3(15, 0, 0)); entity.AddComp(c); } if (!entity.GetExistComp <AssetComponent>()) { AssetComponent c = new AssetComponent(); c.m_assetName = playerComp.CharacterData.m_ModelID; entity.AddComp(c); } if (!entity.GetExistComp <MoveComponent>()) { MoveComponent c = new MoveComponent(); c.pos.FromVector(new Vector3(15, 0, 0)); entity.AddComp(c); } if (!entity.GetExistComp <SkillStatusComponent>()) { SkillStatusComponent c = new SkillStatusComponent(); DataTable data = DataManager.GetData("SkillData"); for (int i = 0; i < data.TableIDs.Count; i++) { c.m_skillList.Add(new SkillData(data.TableIDs[i], i)); c.m_CDList.Add(0); } entity.AddComp(c); } if (!entity.GetExistComp <CDComponent>()) { CDComponent c = new CDComponent(); entity.AddComp(c); } if (!entity.GetExistComp <CampComponent>()) { CampComponent c = new CampComponent(); c.creater = entity.ID; entity.AddComp(c); } if (!entity.GetExistComp <MoveComponent>()) { MoveComponent c = new MoveComponent(); entity.AddComp(c); } if (!entity.GetExistComp <CollisionComponent>()) { CollisionComponent c = new CollisionComponent(); c.area.areaType = AreaType.Circle; c.area.radius = playerComp.CharacterData.m_Radius; entity.AddComp(c); } if (!entity.GetExistComp <LifeComponent>()) { LifeComponent c = new LifeComponent(); c.maxLife = playerComp.CharacterData.m_hp; c.life = playerComp.CharacterData.m_hp; entity.AddComp(c); } if (!entity.GetExistComp <BlowFlyComponent>()) { BlowFlyComponent c = new BlowFlyComponent(); entity.AddComp(c); } //预测一个输入 //TODO 放在框架中 if (entity.GetExistComp <ConnectionComponent>()) { ConnectionComponent cc = entity.GetComp <ConnectionComponent>(); cc.m_lastInputCache = new CommandComponent(); cc.m_defaultInput = new CommandComponent(); } GameTimeComponent gtc = m_world.GetSingletonComp <GameTimeComponent>(); gtc.GameTime = 50 * 60 * 1000; }
public InventoryScreen(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; foreach (var item in DefinitionManager.Instance.GetItemDefinitions()) { Texture2D texture = manager.Game.Assets.LoadTexture(item.GetType(), item.Icon); toolTextures.Add(item.GetType().FullName, texture); } player = manager.Player; IsOverlay = true; Background = new BorderBrush(Color.Black * 0.5f); backgroundBrush = new BorderBrush(Color.Black); hoverBrush = new BorderBrush(Color.Brown); Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel"); Grid grid = new Grid(manager) { Width = 800, Height = 500, }; grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 600 }); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 200 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Fixed, Height = 100 }); Controls.Add(grid); inventory = new InventoryControl(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), }; grid.AddControl(inventory, 0, 0); StackPanel infoPanel = new StackPanel(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), Margin = Border.All(10, 0, 0, 0), }; nameLabel = new Label(manager); infoPanel.Controls.Add(nameLabel); massLabel = new Label(manager); infoPanel.Controls.Add(massLabel); volumeLabel = new Label(manager); infoPanel.Controls.Add(volumeLabel); grid.AddControl(infoPanel, 1, 0); Grid toolbar = new Grid(manager) { Margin = Border.All(0, 10, 0, 0), Height = 100, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), }; toolbar.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); for (int i = 0; i < Player.TOOLCOUNT; i++) toolbar.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 50 }); toolbar.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); toolbar.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); images = new Image[Player.TOOLCOUNT]; for (int i = 0; i < Player.TOOLCOUNT; i++) { Image image = images[i] = new Image(manager) { Width = 42, Height = 42, Background = backgroundBrush, HorizontalAlignment = HorizontalAlignment.Center, Tag = i, Padding = Border.All(2), }; image.StartDrag += (e) => { InventorySlot slot = player.ActorHost.Player.Tools[(int)image.Tag]; if (slot != null) { e.Handled = true; e.Icon = toolTextures[slot.Definition.GetType().FullName]; e.Content = slot; e.Sender = toolbar; } }; image.DropEnter += (e) => { image.Background = hoverBrush; }; image.DropLeave += (e) => { image.Background = backgroundBrush; }; image.EndDrop += (e) => { e.Handled = true; if (e.Sender is Grid) // && ShiftPressed { // Swap int targetIndex = (int)image.Tag; InventorySlot targetSlot = player.ActorHost.Player.Tools[targetIndex]; int sourceIndex = -1; InventorySlot sourceSlot = e.Content as InventorySlot; for (int j = 0; j < player.ActorHost.Player.Tools.Length; j++) { if (player.ActorHost.Player.Tools[j] == sourceSlot) { sourceIndex = j; break; } } SetTool(sourceSlot, targetIndex); SetTool(targetSlot, sourceIndex); } else { // Inventory Drop InventorySlot slot = e.Content as InventorySlot; SetTool(slot, (int)image.Tag); } }; toolbar.AddControl(image, i + 1, 0); } grid.AddControl(toolbar, 0, 1, 2); Title = Languages.OctoClient.Inventory; }
public TargetScreen(ScreenComponent manager, Action <int, int> tp, int x, int y) : base(manager) { assets = manager.Game.Assets; IsOverlay = true; Background = new BorderBrush(Color.Black * 0.5f); Title = Languages.OctoClient.SelectTarget; Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel"); Panel panel = new Panel(manager) { Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; Controls.Add(panel); StackPanel spanel = new StackPanel(manager); panel.Controls.Add(spanel); Label headLine = new Label(manager) { Text = Title, Font = Skin.Current.HeadlineFont, HorizontalAlignment = HorizontalAlignment.Stretch }; spanel.Controls.Add(headLine); StackPanel vstack = new StackPanel(manager); vstack.Orientation = Orientation.Vertical; spanel.Controls.Add(vstack); StackPanel xStack = new StackPanel(manager); xStack.Orientation = Orientation.Horizontal; vstack.Controls.Add(xStack); Label xLabel = new Label(manager); xLabel.Text = "X:"; xStack.Controls.Add(xLabel); Textbox xText = new Textbox(manager) { Background = new BorderBrush(Color.Gray), Width = 150, Margin = new Border(2, 10, 2, 10), Text = x.ToString() }; xStack.Controls.Add(xText); StackPanel yStack = new StackPanel(manager); yStack.Orientation = Orientation.Horizontal; vstack.Controls.Add(yStack); Label yLabel = new Label(manager); yLabel.Text = "Y:"; yStack.Controls.Add(yLabel); Textbox yText = new Textbox(manager) { Background = new BorderBrush(Color.Gray), Width = 150, Margin = new Border(2, 10, 2, 10), Text = y.ToString() }; yStack.Controls.Add(yText); Button closeButton = Button.TextButton(manager, Languages.OctoClient.Teleport); closeButton.HorizontalAlignment = HorizontalAlignment.Stretch; closeButton.LeftMouseClick += (s, e) => { if (tp != null) { tp(int.Parse(xText.Text), int.Parse(yText.Text)); } else { manager.NavigateBack(); } }; spanel.Controls.Add(closeButton); KeyDown += (s, e) => { if (e.Key == engenious.Input.Keys.Escape) { manager.NavigateBack(); } e.Handled = true; }; }
public ResourcePacksOptionControl(ScreenComponent manager) : base(manager) { Grid grid = new Grid(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Margin = Border.All(15), }; Controls.Add(grid); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 100 }); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 }); StackPanel buttons = new StackPanel(manager) { VerticalAlignment = VerticalAlignment.Stretch, }; grid.AddControl(buttons, 1, 0); #region Manipulationsbuttons addButton = Button.TextButton(manager, Languages.OctoClient.Add); addButton.HorizontalAlignment = HorizontalAlignment.Stretch; addButton.Visible = false; buttons.Controls.Add(addButton); removeButton = Button.TextButton(manager, Languages.OctoClient.Remove); removeButton.HorizontalAlignment = HorizontalAlignment.Stretch; removeButton.Visible = false; buttons.Controls.Add(removeButton); moveUpButton = Button.TextButton(manager, Languages.OctoClient.Up); moveUpButton.HorizontalAlignment = HorizontalAlignment.Stretch; moveUpButton.Visible = false; buttons.Controls.Add(moveUpButton); moveDownButton = Button.TextButton(manager, Languages.OctoClient.Down); moveDownButton.HorizontalAlignment = HorizontalAlignment.Stretch; moveDownButton.Visible = false; buttons.Controls.Add(moveDownButton); #endregion applyButton = Button.TextButton(manager, Languages.OctoClient.Apply); applyButton.HorizontalAlignment = HorizontalAlignment.Right; applyButton.VerticalAlignment = VerticalAlignment.Bottom; grid.AddControl(applyButton, 0, 2, 3); infoLabel = new Label(ScreenManager) { HorizontalTextAlignment = HorizontalAlignment.Left, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top, WordWrap = true, }; grid.AddControl(infoLabel, 0, 1, 3); #region Listen loadedPacksList = new Listbox <ResourcePack>(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, SelectedItemBrush = new BorderBrush(Color.SaddleBrown * 0.7f), TemplateGenerator = ListTemplateGenerator, }; grid.AddControl(loadedPacksList, 0, 0); activePacksList = new Listbox <ResourcePack>(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, SelectedItemBrush = new BorderBrush(Color.SaddleBrown * 0.7f), TemplateGenerator = ListTemplateGenerator, }; grid.AddControl(activePacksList, 2, 0); #endregion #region Info Grid //Grid infoGrid = new Grid(ScreenManager) //{ // HorizontalAlignment = HorizontalAlignment.Stretch, //}; //infoGrid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Auto, Width = 1 }); //infoGrid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); //infoGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 }); //infoGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 }); //infoGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 }); //Label nameLabel = new Label(ScreenManager) //{ // Text = "Name:", //}; //infoGrid.AddControl(nameLabel, 0, 0); //Label authorLabel = new Label(ScreenManager) //{ // Text = "Author:", //}; //infoGrid.AddControl(authorLabel, 0, 1); //Label descriptionLabel = new Label(ScreenManager) //{ // Text = "Description:", //}; //infoGrid.AddControl(descriptionLabel, 0, 2); //grid.AddControl(infoGrid, 0, 1, 3); #endregion loadedPacksList.SelectedItemChanged += loadedList_SelectedItemChanged; activePacksList.SelectedItemChanged += activeList_SelectedItemChanged; addButton.LeftMouseClick += (s, e) => { ResourcePack pack = loadedPacksList.SelectedItem; loadedPacksList.Items.Remove(pack); activePacksList.Items.Add(pack); activePacksList.SelectedItem = pack; }; removeButton.LeftMouseClick += (s, e) => { ResourcePack pack = activePacksList.SelectedItem; activePacksList.Items.Remove(pack); loadedPacksList.Items.Add(pack); loadedPacksList.SelectedItem = pack; }; moveUpButton.LeftMouseClick += (s, e) => { ResourcePack pack = activePacksList.SelectedItem; if (pack == null) { return; } int index = activePacksList.Items.IndexOf(pack); if (index > 0) { activePacksList.Items.Remove(pack); activePacksList.Items.Insert(index - 1, pack); activePacksList.SelectedItem = pack; } }; moveDownButton.LeftMouseClick += (s, e) => { ResourcePack pack = activePacksList.SelectedItem; if (pack == null) { return; } int index = activePacksList.Items.IndexOf(pack); if (index < activePacksList.Items.Count - 1) { activePacksList.Items.Remove(pack); activePacksList.Items.Insert(index + 1, pack); activePacksList.SelectedItem = pack; } }; applyButton.LeftMouseClick += (s, e) => { manager.Game.Assets.ApplyResourcePacks(activePacksList.Items); Program.Restart(); }; // Daten laden AssetComponent assets = manager.Game.Assets; foreach (var item in assets.LoadedResourcePacks) { loadedPacksList.Items.Add(item); } foreach (var item in manager.Game.Assets.ActiveResourcePacks) { activePacksList.Items.Add(item); if (loadedPacksList.Items.Contains(item)) { loadedPacksList.Items.Remove(item); } } }
public SceneControl(ScreenComponent manager, string style = "") : base(manager, style) { Mask = (int)Math.Pow(2, VIEWRANGE) - 1; Span = (int)Math.Pow(2, VIEWRANGE); SpanOver2 = Span >> 1; player = manager.Player; camera = manager.Camera; assets = manager.Game.Assets; entities = manager.Game.Entity; Manager = manager; simpleShader = manager.Game.Content.Load <Effect>("simple"); sunTexture = assets.LoadTexture(typeof(ScreenComponent), "sun"); //List<Bitmap> bitmaps = new List<Bitmap>(); var definitions = Manager.Game.DefinitionManager.GetBlockDefinitions(); int textureCount = 0; foreach (var definition in definitions) { textureCount += definition.Textures.Length; } int bitmapSize = 128; blockTextures = new Texture2DArray(manager.GraphicsDevice, 1, bitmapSize, bitmapSize, textureCount); int layer = 0; foreach (var definition in definitions) { foreach (var bitmap in definition.Textures) { System.Drawing.Bitmap texture = manager.Game.Assets.LoadBitmap(definition.GetType(), bitmap); var scaled = texture;//new Bitmap(bitmap, new System.Drawing.Size(bitmapSize, bitmapSize)); int[] data = new int[scaled.Width * scaled.Height]; var bitmapData = scaled.LockBits(new System.Drawing.Rectangle(0, 0, scaled.Width, scaled.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); System.Runtime.InteropServices.Marshal.Copy(bitmapData.Scan0, data, 0, data.Length); blockTextures.SetData(data, layer); scaled.UnlockBits(bitmapData); layer++; } } planet = Manager.Game.ResourceManager.GetPlanet(player.Position.Position.Planet); // TODO: evtl. Cache-Size (Dimensions) VIEWRANGE + 1 int range = ((int)Math.Pow(2, VIEWRANGE) - 2) / 2; localChunkCache = new LocalChunkCache(planet.GlobalChunkCache, VIEWRANGE, range); chunkRenderer = new ChunkRenderer[ (int)Math.Pow(2, VIEWRANGE) * (int)Math.Pow(2, VIEWRANGE), planet.Size.Z]; orderedChunkRenderer = new List <ChunkRenderer>( (int)Math.Pow(2, VIEWRANGE) * (int)Math.Pow(2, VIEWRANGE) * planet.Size.Z); for (int i = 0; i < chunkRenderer.GetLength(0); i++) { for (int j = 0; j < chunkRenderer.GetLength(1); j++) { ChunkRenderer renderer = new ChunkRenderer(this, Manager.Game.DefinitionManager, simpleShader, manager.GraphicsDevice, camera.Projection, blockTextures); chunkRenderer[i, j] = renderer; orderedChunkRenderer.Add(renderer); } } backgroundThread = new Thread(BackgroundLoop) { Priority = ThreadPriority.Lowest, IsBackground = true }; backgroundThread.Start(); backgroundThread2 = new Thread(ForceUpdateBackgroundLoop) { Priority = ThreadPriority.Lowest, IsBackground = true }; backgroundThread2.Start(); var additional = Environment.ProcessorCount / 3; additional = additional == 0 ? 1 : additional; _fillIncrement = additional + 1; additionalFillResetEvents = new AutoResetEvent[additional]; _additionalRegenerationThreads = new Thread[additional]; for (int i = 0; i < additional; i++) { var t = new Thread(AdditionalFillerBackgroundLoop) { Priority = ThreadPriority.Lowest, IsBackground = true }; var are = new AutoResetEvent(false); t.Start(new object[] { are, i }); additionalFillResetEvents[i] = are; _additionalRegenerationThreads[i] = t; } var selectionVertices = new[] { new VertexPositionColor(new Vector3(-0.001f, +1.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, +1.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(-0.001f, -0.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, -0.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(-0.001f, +1.001f, -0.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, +1.001f, -0.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(-0.001f, -0.001f, -0.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, -0.001f, -0.001f), Color.Black * 0.5f), }; var billboardVertices = new[] { new VertexPositionTexture(new Vector3(-0.5f, 0.5f, 0), new Vector2(0, 0)), new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0), new Vector2(1, 0)), new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0), new Vector2(0, 1)), new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0), new Vector2(1, 0)), new VertexPositionTexture(new Vector3(0.5f, -0.5f, 0), new Vector2(1, 1)), new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0), new Vector2(0, 1)), }; var selectionIndices = new short[] { 0, 1, 0, 2, 1, 3, 2, 3, 4, 5, 4, 6, 5, 7, 6, 7, 0, 4, 1, 5, 2, 6, 3, 7 }; selectionLines = new VertexBuffer(manager.GraphicsDevice, VertexPositionColor.VertexDeclaration, selectionVertices.Length); selectionLines.SetData(selectionVertices); selectionIndexBuffer = new IndexBuffer(manager.GraphicsDevice, DrawElementsType.UnsignedShort, selectionIndices.Length); selectionIndexBuffer.SetData(selectionIndices); billboardVertexbuffer = new VertexBuffer(manager.GraphicsDevice, VertexPositionTexture.VertexDeclaration, billboardVertices.Length); billboardVertexbuffer.SetData(billboardVertices); sunEffect = new BasicEffect(manager.GraphicsDevice) { TextureEnabled = true }; selectionEffect = new BasicEffect(manager.GraphicsDevice) { VertexColorEnabled = true }; MiniMapTexture = new RenderTarget2D(manager.GraphicsDevice, 128, 128, PixelInternalFormat.Rgb8); // , false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents); miniMapProjectionMatrix = Matrix.CreateOrthographic(128, 128, 1, 10000); }
public CrewMemberScreen(ScreenComponent manager, CrewMember member) : base(manager) { assets = manager.Game.Assets; VerticalAlignment = VerticalAlignment.Stretch; HorizontalAlignment = HorizontalAlignment.Stretch; Title = Languages.OctoClient.CreditsCrew + ": " + member.Username; SpriteFont boldFont = manager.Content.Load<SpriteFont>("BoldFont"); Padding = new Border(0, 0, 0, 0); SetDefaultBackground(); //The Panel Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel"); Panel panel = new Panel(manager) { MaxWidth = 750, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = new Border(15, 15, 15, 15), }; Controls.Add(panel); //The Main Stack - Split the Panel in half Horizontal StackPanel horizontalStack = new StackPanel(manager) { HorizontalAlignment = HorizontalAlignment.Center, Orientation = Orientation.Horizontal }; panel.Controls.Add(horizontalStack); //The Profile Image Image profileImage = new Image(manager) { Height = 200, Width = 200, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, Padding = new Border(0, 0, 10, 0) }; if (member.PictureFilename == null) profileImage.Texture = assets.LoadTexture(typeof(CrewMember), "base"); else profileImage.Texture = assets.LoadTexture(typeof(CrewMember), member.PictureFilename); horizontalStack.Controls.Add(profileImage); //The Text Stack StackPanel textStack = new StackPanel(manager); textStack.VerticalAlignment = VerticalAlignment.Stretch; textStack.HorizontalAlignment = HorizontalAlignment.Left; textStack.Width = 430; horizontalStack.Controls.Add(textStack); //The Username Label username = new Label(manager) { Text = member.Username, Font = manager.Content.Load<SpriteFont>("HeadlineFont"), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; textStack.Controls.Add(username); //The Alias Label alias = new Label(manager) { Text = member.Alias, HorizontalAlignment = HorizontalAlignment.Left }; textStack.Controls.Add(alias); //Achievements string achievementString = string.Join(", ", member.AchievementList.Select(a => a.ToString())); StackPanel achievementStack = new StackPanel(manager) { VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, Orientation = Orientation.Horizontal, }; textStack.Controls.Add(achievementStack); Label achievementsTitle = new Label(manager) { Text = Languages.OctoClient.Achievements + ": ", Font = boldFont, HorizontalAlignment = HorizontalAlignment.Left }; achievementStack.Controls.Add(achievementsTitle); Label achievements = new Label(manager) { Text = achievementString, HorizontalAlignment = HorizontalAlignment.Left }; achievementStack.Controls.Add(achievements); // Links string linkString = string.Join(", ", member.Links.Select(a => a.Title)); StackPanel linkStack = new StackPanel(manager) { VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, Orientation = Orientation.Horizontal, }; textStack.Controls.Add(linkStack); Label linkTitle = new Label(manager) { Text = Languages.OctoClient.Links + ": ", Font = boldFont, HorizontalAlignment = HorizontalAlignment.Left }; linkStack.Controls.Add(linkTitle); foreach (var link in member.Links) { if (CheckHttpUrl(link.Url)) { Button linkButton = Button.TextButton(manager, link.Title); linkButton.LeftMouseClick += (s, e) => Process.Start(link.Url); linkStack.Controls.Add(linkButton); } } Panel descriptionPanel = new Panel(manager) { VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, }; textStack.Controls.Add(descriptionPanel); Label description = new Label(manager) { Text = member.Description, WordWrap = true, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Left, HorizontalTextAlignment = HorizontalAlignment.Left, VerticalTextAlignment = VerticalAlignment.Top, }; description.InvalidateDimensions(); descriptionPanel.Controls.Add(description); panel.Width = 700; }
public OptionsScreen(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; Padding = new Border(0, 0, 0, 0); Title = Languages.OctoClient.Options; Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel"); SetDefaultBackground(); TabControl tabs = new TabControl(manager) { Padding = new Border(20, 20, 20, 20), Width = 700, TabPageBackground = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), TabBrush = NineTileBrush.FromSingleTexture(assets.LoadTexture(typeof(ScreenComponent), "buttonLong_brown"), 15, 15), TabActiveBrush = NineTileBrush.FromSingleTexture(assets.LoadTexture(typeof(ScreenComponent), "buttonLong_beige"), 15, 15), }; Controls.Add(tabs); #region OptionsPage TabPage optionsPage = new TabPage(manager, Languages.OctoClient.Options); tabs.Pages.Add(optionsPage); OptionsOptionControl optionsOptions = new OptionsOptionControl(manager, this) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; optionsPage.Controls.Add(optionsOptions); #endregion #region BindingsPage TabPage bindingsPage = new TabPage(manager, Languages.OctoClient.KeyBindings); tabs.Pages.Add(bindingsPage); BindingsOptionControl bindingsOptions = new BindingsOptionControl(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; bindingsPage.Controls.Add(bindingsOptions); #endregion #region TexturePackPage TabPage resourcePackPage = new TabPage(manager, "Resource Packs"); tabs.Pages.Add(resourcePackPage); ResourcePacksOptionControl resourcePacksOptions = new ResourcePacksOptionControl(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; resourcePackPage.Controls.Add(resourcePacksOptions); #endregion ////////////////////////////////////////////Restart Button//////////////////////////////////////////// exitButton = Button.TextButton(manager, Languages.OctoClient.RestartGameToApplyChanges); exitButton.VerticalAlignment = VerticalAlignment.Top; exitButton.HorizontalAlignment = HorizontalAlignment.Right; exitButton.Enabled = false; exitButton.Visible = false; exitButton.LeftMouseClick += (s, e) => Program.Restart(); exitButton.Margin = new Border(10, 10, 10, 10); Controls.Add(exitButton); }
public TargetScreen(ScreenComponent manager, Action<int, int> tp, int x, int y) : base(manager) { assets = manager.Game.Assets; IsOverlay = true; Background = new BorderBrush(Color.Black * 0.5f); Title = "Select target"; Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel"); Panel panel = new Panel(manager) { Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; Controls.Add(panel); StackPanel spanel = new StackPanel(manager); panel.Controls.Add(spanel); Label headLine = new Label(manager) { Text = Title, Font = Skin.Current.HeadlineFont, HorizontalAlignment = HorizontalAlignment.Stretch }; spanel.Controls.Add(headLine); StackPanel vstack = new StackPanel(manager); vstack.Orientation = Orientation.Vertical; spanel.Controls.Add(vstack); StackPanel xStack = new StackPanel(manager); xStack.Orientation = Orientation.Horizontal; vstack.Controls.Add(xStack); Label xLabel = new Label(manager); xLabel.Text = "X:"; xStack.Controls.Add(xLabel); Textbox xText = new Textbox(manager) { Background = new BorderBrush(Color.Gray), Width = 150, Margin = new Border(2, 10, 2, 10), Text = x.ToString() }; xStack.Controls.Add(xText); StackPanel yStack = new StackPanel(manager); yStack.Orientation = Orientation.Horizontal; vstack.Controls.Add(yStack); Label yLabel = new Label(manager); yLabel.Text = "Y:"; yStack.Controls.Add(yLabel); Textbox yText = new Textbox(manager) { Background = new BorderBrush(Color.Gray), Width = 150, Margin = new Border(2, 10, 2, 10), Text = y.ToString() }; yStack.Controls.Add(yText); Button closeButton = Button.TextButton(manager, "Teleport"); closeButton.HorizontalAlignment = HorizontalAlignment.Stretch; closeButton.LeftMouseClick += (s, e) => { if (tp != null) tp(int.Parse(xText.Text), int.Parse(yText.Text)); else manager.NavigateBack(); }; spanel.Controls.Add(closeButton); }
public CrewMemberScreen(ScreenComponent manager, CrewMember member) : base(manager) { assets = manager.Game.Assets; VerticalAlignment = VerticalAlignment.Stretch; HorizontalAlignment = HorizontalAlignment.Stretch; Title = Languages.OctoClient.CreditsCrew + ": " + member.Username; SpriteFont boldFont = manager.Content.Load <SpriteFont>("Fonts/BoldFont"); Padding = new Border(0, 0, 0, 0); SetDefaultBackground(); //The Panel Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel"); Panel panel = new Panel(manager) { MaxWidth = 750, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = new Border(15, 15, 15, 15), }; Controls.Add(panel); //The Main Stack - Split the Panel in half Horizontal StackPanel horizontalStack = new StackPanel(manager) { HorizontalAlignment = HorizontalAlignment.Center, Orientation = Orientation.Horizontal }; panel.Controls.Add(horizontalStack); //The Profile Image Image profileImage = new Image(manager) { Height = 200, Width = 200, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, Padding = new Border(0, 0, 10, 0) }; if (member.PictureFilename == null) { profileImage.Texture = assets.LoadTexture(typeof(CrewMember), "base"); } else { profileImage.Texture = assets.LoadTexture(typeof(CrewMember), member.PictureFilename); } horizontalStack.Controls.Add(profileImage); //The Text Stack StackPanel textStack = new StackPanel(manager); textStack.VerticalAlignment = VerticalAlignment.Stretch; textStack.HorizontalAlignment = HorizontalAlignment.Left; textStack.Width = 430; horizontalStack.Controls.Add(textStack); //The Username & Alias string usernameText = member.Username; if (member.Alias != member.Username) { usernameText += " (" + member.Alias + ")"; } Label username = new Label(manager) { Text = usernameText, Font = manager.Content.Load <SpriteFont>("Fonts/HeadlineFont"), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; textStack.Controls.Add(username); //Achievements string achievementString = string.Join(", ", member.AchievementList.Select(a => a.ToString())); StackPanel achievementStack = new StackPanel(manager) { VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, Orientation = Orientation.Horizontal, }; textStack.Controls.Add(achievementStack); Label achievementsTitle = new Label(manager) { Text = Languages.OctoClient.Achievements + ": ", Font = boldFont, HorizontalAlignment = HorizontalAlignment.Left }; achievementStack.Controls.Add(achievementsTitle); Label achievements = new Label(manager) { Text = achievementString, HorizontalAlignment = HorizontalAlignment.Left }; achievementStack.Controls.Add(achievements); // Links string linkString = string.Join(", ", member.Links.Select(a => a.Title)); StackPanel linkStack = new StackPanel(manager) { VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, Orientation = Orientation.Horizontal, }; textStack.Controls.Add(linkStack); Label linkTitle = new Label(manager) { Text = Languages.OctoClient.Links + ": ", Font = boldFont, HorizontalAlignment = HorizontalAlignment.Left }; linkStack.Controls.Add(linkTitle); foreach (var link in member.Links) { if (CheckHttpUrl(link.Url)) { Button linkButton = new TextButton(manager, link.Title); linkButton.LeftMouseClick += (s, e) => Process.Start(link.Url); linkStack.Controls.Add(linkButton); } } Panel descriptionPanel = new Panel(manager) { VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, }; textStack.Controls.Add(descriptionPanel); Label description = new Label(manager) { Text = member.Description, WordWrap = true, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Left, HorizontalTextAlignment = HorizontalAlignment.Left, VerticalTextAlignment = VerticalAlignment.Top, }; description.InvalidateDimensions(); descriptionPanel.Controls.Add(description); panel.Width = 700; }
public BaseScreen(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; }
public SceneControl(ScreenComponent manager, string style = "") : base(manager, style) { player = manager.Player; camera = manager.Camera; assets = manager.Game.Assets; Manager = manager; simpleShader = manager.Game.Content.Load <Effect>("simple"); sunTexture = assets.LoadTexture(typeof(ScreenComponent), "sun"); //List<Bitmap> bitmaps = new List<Bitmap>(); var definitions = DefinitionManager.Instance.GetBlockDefinitions(); int textureCount = 0; foreach (var definition in definitions) { textureCount += definition.Textures.Length; } int bitmapSize = 128; blockTextures = new Texture2DArray(manager.GraphicsDevice, 1, bitmapSize, bitmapSize, textureCount); int layer = 0; foreach (var definition in definitions) { foreach (var bitmap in definition.Textures) { System.Drawing.Bitmap texture = manager.Game.Assets.LoadBitmap(definition.GetType(), bitmap); var scaled = texture;//new Bitmap(bitmap, new System.Drawing.Size(bitmapSize, bitmapSize)); int[] data = new int[scaled.Width * scaled.Height]; var bitmapData = scaled.LockBits(new System.Drawing.Rectangle(0, 0, scaled.Width, scaled.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); System.Runtime.InteropServices.Marshal.Copy(bitmapData.Scan0, data, 0, data.Length); blockTextures.SetData(data, layer); scaled.UnlockBits(bitmapData); layer++; } } /*int size = (int)Math.Ceiling(Math.Sqrt(bitmaps.Count)); * Bitmap blocks = new Bitmap(size * TEXTURESIZE, size * TEXTURESIZE); * using (Graphics g = Graphics.FromImage(blocks)) * { * int counter = 0; * foreach (var bitmap in bitmaps) * { * int x = counter % size; * int y = (int)(counter / size); * g.DrawImage(bitmap, new System.Drawing.Rectangle(TEXTURESIZE * x, TEXTURESIZE * y, TEXTURESIZE, TEXTURESIZE)); * counter++; * } * } * * using (MemoryStream stream = new MemoryStream()) * { * blocks.Save(stream, ImageFormat.Png); * stream.Seek(0, SeekOrigin.Begin); * blockTextures = Texture2D.FromStream(manager.GraphicsDevice, stream); * }*/ planet = ResourceManager.Instance.GetPlanet(0); // TODO: evtl. Cache-Size (Dimensions) VIEWRANGE + 1 int range = ((int)Math.Pow(2, VIEWRANGE) - 2) / 2; localChunkCache = new LocalChunkCache(ResourceManager.Instance.GlobalChunkCache, VIEWRANGE, range); chunkRenderer = new ChunkRenderer[ (int)Math.Pow(2, VIEWRANGE) * (int)Math.Pow(2, VIEWRANGE), planet.Size.Z]; orderedChunkRenderer = new List <ChunkRenderer>( (int)Math.Pow(2, VIEWRANGE) * (int)Math.Pow(2, VIEWRANGE) * planet.Size.Z); for (int i = 0; i < chunkRenderer.GetLength(0); i++) { for (int j = 0; j < chunkRenderer.GetLength(1); j++) { ChunkRenderer renderer = new ChunkRenderer(simpleShader, manager.GraphicsDevice, camera.Projection, blockTextures); chunkRenderer[i, j] = renderer; orderedChunkRenderer.Add(renderer); } } backgroundThread = new Thread(BackgroundLoop); backgroundThread.Priority = ThreadPriority.Lowest; backgroundThread.IsBackground = true; backgroundThread.Start(); var selectionVertices = new[] { new VertexPositionColor(new Vector3(-0.001f, +1.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, +1.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(-0.001f, -0.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, -0.001f, +1.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(-0.001f, +1.001f, -0.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, +1.001f, -0.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(-0.001f, -0.001f, -0.001f), Color.Black * 0.5f), new VertexPositionColor(new Vector3(+1.001f, -0.001f, -0.001f), Color.Black * 0.5f), }; var billboardVertices = new[] { new VertexPositionTexture(new Vector3(-0.5f, 0.5f, 0), new Vector2(0, 0)), new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0), new Vector2(1, 0)), new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0), new Vector2(0, 1)), new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0), new Vector2(1, 0)), new VertexPositionTexture(new Vector3(0.5f, -0.5f, 0), new Vector2(1, 1)), new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0), new Vector2(0, 1)), }; var selectionIndices = new short[] { 0, 1, 0, 2, 1, 3, 2, 3, 4, 5, 4, 6, 5, 7, 6, 7, 0, 4, 1, 5, 2, 6, 3, 7 }; selectionLines = new VertexBuffer(manager.GraphicsDevice, VertexPositionColor.VertexDeclaration, selectionVertices.Length); selectionLines.SetData(selectionVertices); selectionIndexBuffer = new IndexBuffer(manager.GraphicsDevice, DrawElementsType.UnsignedShort, selectionIndices.Length); selectionIndexBuffer.SetData(selectionIndices); billboardVertexbuffer = new VertexBuffer(manager.GraphicsDevice, VertexPositionTexture.VertexDeclaration, billboardVertices.Length); billboardVertexbuffer.SetData(billboardVertices); sunEffect = new BasicEffect(manager.GraphicsDevice); sunEffect.TextureEnabled = true; selectionEffect = new BasicEffect(manager.GraphicsDevice); selectionEffect.VertexColorEnabled = true; MiniMapTexture = new RenderTarget2D(manager.GraphicsDevice, 128, 128, PixelInternalFormat.Rgb8); // , false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents); miniMapProjectionMatrix = Matrix.CreateOrthographic(128, 128, 1, 10000); }