public void DrawTooltip() //Has to be separate so it draws on top of all buttons. { if (showTooltip) { string leftStr = Math.Truncate(assignedEffect.expiresAt.Subtract(DateTime.Now).TotalSeconds).ToString(); string tooltipStr = assignedEffect.name + (assignedEffect.family != StatusEffectFamily.None ? Environment.NewLine + "(" + assignedEffect.family.ToString() + ")" : "") + Environment.NewLine + Environment.NewLine + assignedEffect.description + (assignedEffect.doesExpire ? Environment.NewLine + Environment.NewLine + leftStr + " sec" : ""); tooltip.Text = tooltipStr; var x_pos = (tooltipPos.X + 10 + tooltip.Width + 5) > CluwneLib.CurrentClippingViewport.Width ? 0 - tooltip.Width - 10 : 10 + 5; tooltip.Position = new Vector2i(tooltipPos.X + x_pos + 5, tooltipPos.Y + 5 + 10); CluwneLib.drawRectangle(tooltipPos.X + x_pos, tooltipPos.Y + 10, tooltip.Width + 5, tooltip.Height + 5, new Color(70, 130, 180)); CluwneLib.drawRectangle(tooltipPos.X + x_pos, tooltipPos.Y + 10, tooltip.Width + 5, tooltip.Height + 5, new Color(72, 61, 139)); tooltip.Draw(); } }
public override bool Update(ScreenCoordinates mouseS) { if (mouseS.MapID == MapManager.NULLSPACE) { return(false); } mouseScreen = mouseS; mouseCoords = CluwneLib.ScreenToCoordinates(mouseScreen); var snapsize = mouseCoords.Grid.SnapSize; //Find snap size. var mouselocal = new Vector2( //Round local coordinates onto the snap grid (float)Math.Round((mouseCoords.X / (double)snapsize), MidpointRounding.AwayFromZero) * snapsize, (float)Math.Round((mouseCoords.Y / (double)snapsize), MidpointRounding.AwayFromZero) * snapsize); //Convert back to original world and screen coordinates after applying offset mouseCoords = new LocalCoordinates(mouselocal + new Vector2(pManager.CurrentPrototype.PlacementOffset.X, pManager.CurrentPrototype.PlacementOffset.Y), mouseCoords.Grid); mouseScreen = CluwneLib.WorldToScreen(mouseCoords); if (!RangeCheck()) { return(false); } return(true); }
public override bool Update(ScreenCoordinates mouseS) { if (mouseS.MapID == MapId.Nullspace) { return(false); } MouseScreen = mouseS; MouseCoords = CluwneLib.ScreenToCoordinates(MouseScreen); CurrentTile = MouseCoords.Grid.GetTile(MouseCoords); var tileSize = MouseCoords.Grid.TileSize; if (!RangeCheck()) { return(false); } if (pManager.CurrentPermission.IsTile) { MouseCoords = new LocalCoordinates(CurrentTile.X + tileSize / 2, CurrentTile.Y + tileSize / 2, MouseCoords.Grid); MouseScreen = CluwneLib.WorldToScreen(MouseCoords); } else { MouseCoords = new LocalCoordinates(CurrentTile.X + tileSize / 2 + pManager.CurrentPrototype.PlacementOffset.X, CurrentTile.Y + tileSize / 2 + pManager.CurrentPrototype.PlacementOffset.Y, MouseCoords.Grid); MouseScreen = CluwneLib.WorldToScreen(MouseCoords); } return(true); }
public override sealed void Update(float frameTime) { hotbarBG.Position = CluwneLib.PointToVector2(Position); int y_dist = 30; int x_pos = 175; int max_x = 0; int max_y = 0; foreach (GuiComponent comp in slots) { comp.Position = new Point(Position.X + x_pos, Position.Y + y_dist); comp.Update(frameTime); if (comp.ClientArea.Right > max_x) { max_x = comp.ClientArea.Right; } if (comp.ClientArea.Bottom > max_y) { max_y = comp.ClientArea.Bottom; } x_pos += comp.ClientArea.Width + 1; } //ClientArea = new Rectangle(Position, new Size((int)max_x - Position.X + 5, (int)max_y - Position.Y + 5)); ClientArea = Rectangle.Round(hotbarBG.AABB); }
public override void Render() { if (drawColor != Color4.White) { _textboxLeft.Color = drawColor.Convert(); _textboxMain.Color = drawColor.Convert(); _textboxRight.Color = drawColor.Convert(); } _textboxLeft.SetTransformToRect(_clientAreaLeft); _textboxMain.SetTransformToRect(_clientAreaMain); _textboxRight.SetTransformToRect(_clientAreaRight); _textboxLeft.Draw(); _textboxMain.Draw(); _textboxRight.Draw(); if (Focus && blinkCount <= 0.25f) { CluwneLib.drawRectangle(Label.Position.X + _caretPos - _caretWidth, Label.Position.Y + (Label.Height / 2f) - (_caretHeight / 2f), _caretWidth, _caretHeight, new Color4(255, 255, 250, 255)); } if (drawColor != Color4.White) { _textboxLeft.Color = Color.White; _textboxMain.Color = Color.White; _textboxRight.Color = Color.White; } Label.Color = textColor; Label.Text = _displayText; Label.Draw(); }
public void CreateStarScroller_ShouldCreateStars() { base.InitializeCluwneLib(1280, 720, false, 60); Stars = new StarScroller(); renderimage = new RenderImage("StarScroller", 1920, 1080); while (CluwneLib.IsRunning) { var lastFrameTime = clock.ElapsedTime.AsSeconds(); clock.Restart(); _frameEvent = new FrameEventArgs(lastFrameTime); CluwneLib.ClearCurrentRendertarget(SFML.Graphics.Color.Black); CluwneLib.Screen.DispatchEvents(); renderimage.BeginDrawing(); // set temp as CRT (Current Render Target) renderimage.Clear(); //Clear base.GetResourceManager.GetSprite("AAAA").Draw(); //Draw NoSpritelogo renderimage.EndDrawing(); // set previous rendertarget as CRT (screen in this case) renderimage.Blit(0, 0, 1280, 768); // draw blurred nosprite logo CluwneLib.Screen.Display(); } }
private void DebugTex(RenderImage src, RenderImage dst) { CluwneLib.ResetShader(); dst.BeginDrawing(); src.Blit(0, 0, dst.Width, dst.Height, BlitterSizeMode.Scale); dst.EndDrawing(); }
public override bool Update(Vector2i mouseS, IMapManager currentMap) { if (currentMap == null) { return(false); } mouseScreen = mouseS; mouseWorld = CluwneLib.ScreenToWorld(mouseScreen); if (!(ongrid = currentMap.TryFindGridAt(mouseWorld, out IMapGrid currentgrid))) //Cant find a grid { return(false); } var mouselocal = currentgrid.WorldToLocal(mouseWorld); //Convert code to local grid coordinates snapsize = currentgrid.SnapSize; //Find snap size. mouselocal = new Vector2( //Round local coordinates onto the snap grid (float)(Math.Round((mouselocal.X / (double)snapsize - 0.5), MidpointRounding.AwayFromZero) + 0.5) * snapsize, (float)(Math.Round((mouselocal.Y / (double)snapsize - 0.5), MidpointRounding.AwayFromZero) + 0.5) * snapsize); //Convert back to original world and screen coordinates after applying offset mouseWorld = currentgrid.LocalToWorld(mouselocal) + new Vector2(pManager.CurrentPrototype.PlacementOffset.X, pManager.CurrentPrototype.PlacementOffset.Y); mouseScreen = (Vector2i)CluwneLib.WorldToScreen(mouseWorld); if (!RangeCheck()) { return(false); } return(true); }
public override bool Update(Vector2i mouseS, IMapManager currentMap) { if (currentMap == null) { return(false); } mouseScreen = mouseS; mouseWorld = CluwneLib.ScreenToWorld(mouseScreen); currentTile = currentMap.GetDefaultGrid().GetTile(mouseWorld); if (!RangeCheck()) { return(false); } var entitymanager = IoCManager.Resolve <IClientEntityManager>(); var failtoplace = entitymanager.AnyEntitiesIntersecting(new Box2(new Vector2(currentTile.X, currentTile.Y), new Vector2(currentTile.X + 0.99f, currentTile.Y + 0.99f))); if (pManager.CurrentPermission.IsTile) { mouseWorld = new Vector2(currentTile.X + 0.5f, currentTile.Y + 0.5f); mouseScreen = (Vector2i)CluwneLib.WorldToScreen(mouseWorld); } else { mouseWorld = new Vector2(currentTile.X + 0.5f + pManager.CurrentPrototype.PlacementOffset.X, currentTile.Y + 0.5f + pManager.CurrentPrototype.PlacementOffset.Y); mouseScreen = (Vector2i)CluwneLib.WorldToScreen(mouseWorld); } return(failtoplace); }
public void GaussianBlurRadius9_ShouldBlur() { preblur = new RenderImage("testGaussianBlur", 1280, 768); blur = new RenderImage("testGaussianBlur1", 1280, 768); _gaussianBlur = new GaussianBlur(_resourceCache); _gaussianBlur.SetRadius(9); _gaussianBlur.SetAmount(2); _gaussianBlur.SetSize(new Vector2(preblur.Width, preblur.Height)); while (CluwneLib.IsRunning) { var lastFrameTime = clock.ElapsedTimeAsSeconds(); clock.Restart(); _frameEvent = new FrameEventArgs(lastFrameTime); CluwneLib.ClearCurrentRendertarget(Color4.Black); CluwneLib.Window.DispatchEvents(); preblur.BeginDrawing(); // set temp as CRT preblur.Clear(); //Clear _resourceCache.GetSprite("flashlight_mask").Draw(); //Draw NoSpritelogo preblur.EndDrawing(); // set previous rendertarget as CRT (screen in this case) _gaussianBlur.PerformGaussianBlur(preblur); // blur rendertarget preblur.Blit(0, 0, 1280, 768); // draw blurred nosprite logo CluwneLib.Window.Graphics.Display(); } }
private void ShowSplashScreen() { // Do nothing when we're on DEBUG builds. // The splash is just annoying. const uint SIZE_X = 600; const uint SIZE_Y = 300; // Size of the NT logo in the bottom right. const float NT_SIZE_X = SIZE_X / 10f; const float NT_SIZE_Y = SIZE_Y / 10f; var window = CluwneLib.ShowSplashScreen(new VideoMode(SIZE_X, SIZE_Y)).Graphics; var logo = _resourceCache.GetSprite("ss14_logo"); logo.Position = new Vector2f(SIZE_X / 2 - logo.TextureRect.Width / 2, SIZE_Y / 2 - logo.TextureRect.Height / 2); var background = _resourceCache.GetSprite("ss14_logo_background"); background.Scale = new Vector2f((float)SIZE_X / background.TextureRect.Width, (float)SIZE_Y / background.TextureRect.Height); var nanotrasen = _resourceCache.GetSprite("ss14_logo_nt"); nanotrasen.Scale = new Vector2f(NT_SIZE_X / nanotrasen.TextureRect.Width, NT_SIZE_Y / nanotrasen.TextureRect.Height); nanotrasen.Position = new Vector2f(SIZE_X - NT_SIZE_X - 5, SIZE_Y - NT_SIZE_Y - 5); nanotrasen.Color = new Color(255, 255, 255, 64); window.Draw(background); window.Draw(logo); window.Draw(nanotrasen); window.Display(); }
public override bool Update(ScreenCoordinates mouseS) { if (mouseS.MapID == MapManager.NULLSPACE) { return(false); } mouseScreen = mouseS; mouseCoords = CluwneLib.ScreenToCoordinates(mouseScreen); currentTile = mouseCoords.Grid.GetTile(mouseCoords); var tilesize = mouseCoords.Grid.TileSize; if (!RangeCheck()) { return(false); } if (pManager.CurrentPermission.IsTile) { mouseCoords = new LocalCoordinates(currentTile.X + tilesize / 2, currentTile.Y + tilesize / 2, mouseCoords.Grid); mouseScreen = CluwneLib.WorldToScreen(mouseCoords); } else { mouseCoords = new LocalCoordinates(currentTile.X + tilesize / 2 + pManager.CurrentPrototype.PlacementOffset.X, currentTile.Y + tilesize / 2 + pManager.CurrentPrototype.PlacementOffset.Y, mouseCoords.Grid); mouseScreen = CluwneLib.WorldToScreen(mouseCoords); } return(true); }
public override void Render(Vector2 topLeft, Vector2 bottomRight) { if (!visible) { return; } var position = Owner.GetComponent <ITransformComponent>().Position; if (position.X < topLeft.X || position.X > bottomRight.X || position.Y < topLeft.Y || position.Y > bottomRight.Y) { return; } base.Render(topLeft, bottomRight); if (_speechBubble != null) { _speechBubble.Draw(CluwneLib.WorldToScreen(position), new Vector2(), currentBaseSprite); } }
public virtual void Render(Vector2f topLeft, Vector2f bottomRight) { //Render slaves beneath IEnumerable <SpriteComponent> renderablesBeneath = from SpriteComponent c in slaves //FIXTHIS orderby c.DrawDepth ascending where c.DrawDepth < DrawDepth select c; foreach (SpriteComponent component in renderablesBeneath.ToList()) { component.Render(topLeft, bottomRight); } //Render this sprite if (!visible) { return; } if (currentBaseSprite == null) { return; } Sprite spriteToRender = GetActiveDirectionalSprite(); Vector2f renderPos = CluwneLib.WorldToScreen(Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position); var bounds = spriteToRender.GetLocalBounds(); SetSpriteCenter(spriteToRender, renderPos); if (Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position.X + bounds.Left + bounds.Width < topLeft.X || Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position.X > bottomRight.X || Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position.Y + bounds.Top + bounds.Height < topLeft.Y || Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position.Y > bottomRight.Y) { return; } spriteToRender.Scale = new SFML.System.Vector2f(HorizontalFlip ? -1 : 1, 1); spriteToRender.Draw(); //Render slaves above IEnumerable <SpriteComponent> renderablesAbove = from SpriteComponent c in slaves //FIXTHIS orderby c.DrawDepth ascending where c.DrawDepth >= DrawDepth select c; foreach (SpriteComponent component in renderablesAbove.ToList()) { component.Render(topLeft, bottomRight); } //Draw AABB var aabb = AABB; CluwneLib.drawRectangle((int)(renderPos.X - aabb.Width / 2), (int)(renderPos.Y - aabb.Height / 2), aabb.Width, aabb.Height, new SFML.Graphics.Color(0, 255, 0)); }
public override void Render() { if (drawColor != Color.White) { _textboxLeft.Color = CluwneLib.SystemColorToSFML(drawColor); _textboxMain.Color = CluwneLib.SystemColorToSFML(drawColor); _textboxRight.Color = CluwneLib.SystemColorToSFML(drawColor); } _textboxLeft.Draw(_clientAreaLeft); _textboxMain.Draw(_clientAreaMain); _textboxRight.Draw(_clientAreaRight); if (Focus && blinkCount <= 0.25f) { //Draw Textbox // CluwneLib.CurrentRenderTarget.Draw(_caretPos - _caretWidth, Label.Position.Y + (Label.Height/2f) - (_caretHeight/2f),_caretWidth, _caretHeight, new Color(255,255,250)); if (drawColor != Color.White) { _textboxLeft.Color = CluwneLib.SystemColorToSFML(Color.White); _textboxMain.Color = CluwneLib.SystemColorToSFML(Color.White); _textboxRight.Color = CluwneLib.SystemColorToSFML(Color.White); } } Label.Color = textColor; Label.Text = _displayText; Label.Draw(); }
private void ShowSplashScreen() { // Do nothing when we're on DEBUG builds. // The splash is just annoying. const int SIZE_X = 600; const int SIZE_Y = 300; var Size = new Vector2i(SIZE_X, SIZE_Y); // Size of the NT logo in the bottom right. const float NT_SIZE_X = SIZE_X / 10f; const float NT_SIZE_Y = SIZE_Y / 10f; var NTSize = new Vector2(NT_SIZE_X, NT_SIZE_Y); var window = CluwneLib.ShowSplashScreen(new VideoMode(SIZE_X, SIZE_Y)).Graphics; var logo = _resourceCache.GetSprite("ss14_logo"); logo.Position = Size / 2 - logo.TextureRect.Size / 2; var background = _resourceCache.GetSprite("ss14_logo_background"); background.Scale = (Vector2)Size / background.TextureRect.Size; var nanotrasen = _resourceCache.GetSprite("ss14_logo_nt"); nanotrasen.Scale = NTSize / nanotrasen.TextureRect.Size; nanotrasen.Position = Size - NTSize - 5; nanotrasen.Color = Color.White.WithAlpha(64); window.Draw(background); window.Draw(logo); window.Draw(nanotrasen); window.Display(); }
public override bool Update(Vector2i mouseS, IMapManager currentMap) { if (currentMap == null) { return(false); } mouseScreen = mouseS; mouseWorld = CluwneLib.ScreenToWorld(mouseScreen); currentTile = currentMap.GetDefaultGrid().GetTile(mouseWorld); if (!RangeCheck()) { return(false); } if (pManager.CurrentPermission.IsTile) { mouseWorld = new Vector2(currentTile.X + 0.5f, currentTile.Y + 0.5f); mouseScreen = (Vector2i)CluwneLib.WorldToScreen(mouseWorld); } else { mouseWorld = new Vector2(currentTile.X + 0.5f + pManager.CurrentPrototype.PlacementOffset.X, currentTile.Y + 0.5f + pManager.CurrentPrototype.PlacementOffset.Y); mouseScreen = (Vector2i)CluwneLib.WorldToScreen(mouseWorld); // if (CheckCollision()) // return false; } return(true); }
public void Render(Vector2 v1, Vector2 v2) { // Ok this is dumb. You have to draw a non existant filledrectangle so the verts will draw, as drawing // one of these makes gorgon accept a TriangleList when you use the Draw() method, otherwise it will // want a pointlist which is no good to us. CluwneLib.drawRectangle(0, 0, 0, 0, Color.Black); }
private void ApplyHorizontalReduction(RenderImage source, RenderImage destination) { int step = reductionChainCount - 1; RenderImage s = source; RenderImage d = reductionRT[step]; // CluwneLib.CurrentShader = reductionEffect.Techniques["HorizontalReduction"]; while (step >= 0) { d = reductionRT[step]; CluwneLib.CurrentRenderTarget = d; d.Clear(Color.White); // reductionEffect.Parameters["SourceTexture"].SetValue(s); var textureDim = new Vector2(1.0f / s.Width, 1.0f / s.Height); // reductionEffect.Parameters["TextureDimensions"].SetValue(textureDim); quadRender.Render(new Vector2(1, 1) * -1, new Vector2(1, 1)); s = d; step--; } //copy to destination CluwneLib.CurrentRenderTarget = destination; // CluwneLib.CurrentShader = reductionEffect.Techniques["Copy"]; // reductionEffect.Parameters["SourceTexture"].SetValue(d); CluwneLib.CurrentRenderTarget.Clear(CluwneLib.SystemColorToSFML(Color.White)); quadRender.Render(new Vector2(1, 1) * -1, new Vector2(1, 1)); // reductionEffect.Parameters["SourceTexture"].SetValue(reductionRT[reductionChainCount - 1]); CluwneLib.CurrentRenderTarget = null; }
public override bool Update(ScreenCoordinates mouseS) { if (mouseS.MapID == MapManager.NULLSPACE) { return(false); } mouseScreen = mouseS; mouseCoords = CluwneLib.ScreenToCoordinates(mouseScreen); var snapsize = mouseCoords.Grid.SnapSize; //Find snap size. var mouselocal = new Vector2( //Round local coordinates onto the snap grid (float)(Math.Round((mouseCoords.Position.X / (double)snapsize - 0.5), MidpointRounding.AwayFromZero) + 0.5) * snapsize, (float)(Math.Round((mouseCoords.Position.Y / (double)snapsize - 0.5), MidpointRounding.AwayFromZero) + 0.5) * snapsize); //Adjust mouseCoords to new calculated position mouseCoords = new LocalCoordinates(mouselocal + new Vector2(pManager.CurrentPrototype.PlacementOffset.X, pManager.CurrentPrototype.PlacementOffset.Y), mouseCoords.Grid); mouseScreen = CluwneLib.WorldToScreen(mouseCoords); if (!RangeCheck()) { return(false); } return(true); }
public void GaussianBlurRadius11_ShouldBlur() { preblur = new RenderImage("testGaussianBlur", 1280, 768); _gaussianBlur = new GaussianBlur(_resourceCache); _gaussianBlur.SetRadius(11); _gaussianBlur.SetAmount(2); _gaussianBlur.SetSize(preblur.Size); while (CluwneLib.IsRunning) { var lastFrameTime = clock.ElapsedTimeAsSeconds(); clock.Restart(); _frameEvent = new FrameEventArgs(lastFrameTime); CluwneLib.ClearCurrentRendertarget(Color4.Black); CluwneLib.Window.DispatchEvents(); preblur.BeginDrawing(); // set temp as CRT (Current Render Target) //preblur.Clear(); //Clear sprite = _resourceCache.GetSprite("flashlight_mask"); sprite.Position = Vector2.Zero; sprite.Draw(); preblur.EndDrawing(); // set previous rendertarget as CRT (screen in this case) //_gaussianBlur.PerformGaussianBlur(preblur); // blur rendertarget preblur.Blit(0, 0, preblur.Width, preblur.Height, Color.White, BlitterSizeMode.Crop); // draw blurred nosprite logo CluwneLib.Window.Graphics.Display(); } }
private void ShowSplashScreen() { // Do nothing when we're on DEBUG builds. // The splash is just annoying. #if !DEBUG const uint SIZE_X = 600; const uint SIZE_Y = 300; // Size of the NT logo in the bottom left. const float NT_SIZE_X = SIZE_X / 10f; const float NT_SIZE_Y = SIZE_Y / 10f; CluwneWindow window = CluwneLib.ShowSplashScreen(new VideoMode(SIZE_X, SIZE_Y)); var logoTexture = new Texture(_resourceManager.ContentFileRead(@"Textures/Logo/logo.png")); var logo = new SFML.Graphics.Sprite(logoTexture); var logoSize = logoTexture.Size; logo.Position = new Vector2f(SIZE_X / 2 - logoSize.X / 2, SIZE_Y / 2 - logoSize.Y / 2); var backgroundTexture = new Texture(_resourceManager.ContentFileRead(@"Textures/Logo/background.png")); var background = new SFML.Graphics.Sprite(backgroundTexture); var backgroundSize = backgroundTexture.Size; background.Scale = new Vector2f((float)SIZE_X / backgroundSize.X, (float)SIZE_Y / backgroundSize.Y); var nanotrasenTexture = new Texture(_resourceManager.ContentFileRead(@"Textures/Logo/nanotrasen.png")); var nanotrasen = new SFML.Graphics.Sprite(nanotrasenTexture); var nanotrasenSize = nanotrasenTexture.Size; nanotrasen.Scale = new Vector2f(NT_SIZE_X / nanotrasenSize.X, NT_SIZE_Y / nanotrasenSize.Y); nanotrasen.Position = new Vector2f(SIZE_X - NT_SIZE_X - 5, SIZE_Y - NT_SIZE_Y - 5); nanotrasen.Color = new Color(255, 255, 255, 64); window.Draw(background); window.Draw(logo); window.Draw(nanotrasen); window.Display(); #endif }
private void CleanupSplashScreen() { // Do nothing when we're on DEBUG builds. // The splash is just annoying. #if !DEBUG CluwneLib.CleanupSplashScreen(); #endif }
/// <summary> /// Runs a tick of the simulation. /// </summary> /// <param name="e">Current GameTiming.FrameTime</param> private void Update(FrameEventArgs e) { _networkManager.ProcessPackets(); CluwneLib.RunIdle(this, e); AssemblyLoader.BroadcastUpdate(AssemblyLoader.UpdateLevel.PreEngine, e.Elapsed); _stateManager.Update(e); AssemblyLoader.BroadcastUpdate(AssemblyLoader.UpdateLevel.PostEngine, e.Elapsed); }
public override void Render() { CluwneLib.drawRectangle(ClientArea.Left, ClientArea.Top, ClientArea.Width, ClientArea.Height, selected ? new Color4(34, 139, 34, 255) : new Color4(255, 250, 240, 255)); objectSprite.Draw(); name.Draw(); }
public override bool Update(Vector2i mouseS, IMapManager currentMap) { if (currentMap == null) { return(false); } spriteToDraw = GetSprite(pManager.CurrentBaseSpriteKey); mouseScreen = mouseS; mouseWorld = CluwneLib.ScreenToWorld(mouseScreen); var bounds = spriteToDraw.GetLocalBounds(); var spriteSize = CluwneLib.PixelToTile(new Vector2f(bounds.Width, bounds.Height)); var spriteRectWorld = new FloatRect(mouseWorld.X - (spriteSize.X / 2f), mouseWorld.Y - (spriteSize.Y / 2f), spriteSize.X, spriteSize.Y); currentTile = currentMap.GetTileRef(mouseWorld); //if (currentMap.IsSolidTile(mouseWorld)) validPosition = false; var rangeSquared = pManager.CurrentPermission.Range * pManager.CurrentPermission.Range; if (rangeSquared > 0) { if ( (pManager.PlayerManager.ControlledEntity.GetComponent <TransformComponent>(ComponentFamily.Transform) .Position - mouseWorld).LengthSquared() > rangeSquared) { return(false); } } if (pManager.CurrentPermission.IsTile) { mouseWorld = new Vector2f(currentTile.X + 0.5f, currentTile.Y + 0.5f); mouseScreen = CluwneLib.WorldToScreen(mouseWorld).Round(); } else { mouseWorld = new Vector2f(currentTile.X + 0.5f + pManager.CurrentTemplate.PlacementOffset.Key, currentTile.Y + 0.5f + pManager.CurrentTemplate.PlacementOffset.Value); mouseScreen = CluwneLib.WorldToScreen(mouseWorld).Round(); spriteRectWorld = new FloatRect(mouseWorld.X - (bounds.Width / 2f), mouseWorld.Y - (bounds.Height / 2f), bounds.Width, bounds.Height); if (pManager.CollisionManager.IsColliding(spriteRectWorld)) { return(false); } //Since walls also have collisions, this means we can't place objects on walls with this mode. } return(true); }
public override void Render() { CluwneLib.drawRectangle(ClientArea.Left, ClientArea.Top, ClientArea.Width, ClientArea.Height, selected ? new SFML.Graphics.Color(34, 139, 34) : new SFML.Graphics.Color(255, 250, 240)); CluwneLib.drawRectangle(ClientArea.Left, ClientArea.Top, ClientArea.Width, ClientArea.Height, Color.Black); objectSprite.Draw(); name.Draw(); }
public override bool Update(Vector2i mouseS, IMapManager currentMap) { if (currentMap == null) { return(false); } spriteToDraw = GetDirectionalSprite(pManager.CurrentBaseSpriteKey); mouseScreen = mouseS; mouseWorld = CluwneLib.ScreenToWorld(mouseScreen); var bounds = spriteToDraw.GetLocalBounds(); currentTile = currentMap.GetTileRef(mouseWorld); if (!currentTile.Tile.TileDef.IsWall) { return(false); } var rangeSquared = pManager.CurrentPermission.Range * pManager.CurrentPermission.Range; if (rangeSquared > 0) { if ( (pManager.PlayerManager.ControlledEntity.GetComponent <ITransformComponent>() .Position - mouseWorld).LengthSquared() > rangeSquared) { return(false); } } if (pManager.CurrentPermission.IsTile) { mouseWorld = new Vector2f(currentTile.X + 0.5f, currentTile.Y + 0.5f); mouseScreen = CluwneLib.WorldToScreen(mouseWorld).Round(); } else { mouseWorld = new Vector2f(currentTile.X + 0.5f + pManager.CurrentPrototype.PlacementOffset.X, currentTile.Y + 0.5f + pManager.CurrentPrototype.PlacementOffset.Y); mouseScreen = CluwneLib.WorldToScreen(mouseWorld).Round(); FloatRect spriteRectWorld = new FloatRect(mouseWorld.X - (bounds.Width / 2f), mouseWorld.Y - (bounds.Height / 2f), bounds.Width, bounds.Height); if (pManager.CollisionManager.IsColliding(spriteRectWorld)) { return(false); } //Since walls also have collisions, this means we can't place objects on walls with this mode. } return(true); }
public override void Render() { if (disposing || !IsVisible()) { return; } _eraserButton.Color = _placementManager.Eraser ? CluwneLib.SystemColorToSFML(Color.Tomato) : CluwneLib.SystemColorToSFML(Color.White); base.Render(); }
public override void Render() { CluwneLib.drawRectangle(ClientArea.X, ClientArea.Y, ClientArea.Width, ClientArea.Height, selected ? Color.ForestGreen : Color.FloralWhite); CluwneLib.drawRectangle(ClientArea.X, ClientArea.Y, ClientArea.Width, ClientArea.Height, Color.Black); objectSprite.Draw(); name.Draw(); }