public Spider(WorldLayer _layer) : base(EALNouns.Spider, _layer, 120 + World.Rnd.Next(20)) { var lcd = 0.5f + (Nn % 20 - 10) / 10f; LerpColor = new FColor(0.3f, lcd * (float)World.Rnd.NextDouble()/2, lcd * (float)World.Rnd.NextDouble(), lcd * (float)World.Rnd.NextDouble()/2); Behaviour = EMonsterBehaviour.IDLE; }
public void Set(FColor _fColor) { R = _fColor.R; G = _fColor.G; B = _fColor.B; A = _fColor.A; }
public Wolf(WorldLayer _layer) : base(EALNouns.Wolf, _layer, 80 + World.Rnd.Next(20)) { var lcd = 0.5f + (Nn % 10 - 5) / 10f; LerpColor = new FColor(0.3f, lcd * (float)World.Rnd.NextDouble(), lcd * (float)World.Rnd.NextDouble(), lcd * (float)World.Rnd.NextDouble() / 2f); Behaviour = EMonsterBehaviour.IDLE; }
/// <summary> /// Если размер мира 1*1 в зависимости от сида генерим тот или иной тестовый мир, иначе генерим по чсестному /// </summary> public Surface() { Ambient = new FColor(1f, 1f, 1f, 0.9f).Multiply(1.0f); switch (Constants.WORLD_MAP_SIZE) { case 1: var r1 = new TestSurfaceGenerator1x1(World.Rnd); m_worldMap = r1.Generate(); City = new SuperCity(this, new Point(0, 0)); break; case 2: var r2 = new TestSurfaceGenerator2x2(World.Rnd); m_worldMap = r2.Generate(); City = new SuperCity(this, new Point(0, 0)); break; default: var worldMapGenerator = new WorldMapGenerator(Constants.WORLD_MAP_SIZE, World.Rnd); m_worldMap = worldMapGenerator.Generate(); if (Constants.WORLD_MAP_SIZE > 31) { var cityBlockIds = worldMapGenerator.FindCityPlace((int)Math.Sqrt(Constants.WORLD_MAP_SIZE) / 2).ToArray(); foreach (var id in cityBlockIds) { m_worldMap[id.X, id.Y] = EMapBlockTypes.CITY; } City = new SuperCity(this, cityBlockIds.Select(_point => new Point(_point.X - Constants.WORLD_MAP_SIZE / 2, _point.Y - Constants.WORLD_MAP_SIZE / 2)).ToArray()); } break; } }
protected UIBlock(Rct _rct, Frame _frame, FColor _color) { BlockFrame = _frame; ForeColor = _color; Rct = _rct; BackgroundColor = new FColor(1, 0, 0, 0); UpdateContentRct(); }
public void DrawString(EFonts _font, string _string, float _x, float _y, FColor _color) { var qFont = m_resourceProvider[_font]; QFont.Begin(); qFont.Options.Colour = new Color4(_color.R, _color.G, _color.B, _color.A); qFont.Print(_string, new OpenTK.Vector2(_x, _y)); QFont.End(); }
static MiniMapUiBlock() { foreach (EMapBlockTypes type in Enum.GetValues(typeof(EMapBlockTypes))) { FColor color; switch (type) { case EMapBlockTypes.NONE: color = FColor.Empty; break; case EMapBlockTypes.GROUND: color = new FColor(1f, 0.1f, 0.5f, 0.2f); break; case EMapBlockTypes.FOREST: color = new FColor(1f, 0.0f, 0.3f, 0.0f); break; case EMapBlockTypes.SEA: color = new FColor(1f, 0.0f, 0.2f, 0.5f); break; case EMapBlockTypes.DEEP_SEA: color = new FColor(1f, 0.0f, 0.1f, 0.3f); break; case EMapBlockTypes.FRESH_WATER: color = new FColor(1f, 0.3f, 0.4f, 0.7f); break; case EMapBlockTypes.DEEP_FRESH_WATER: color = new FColor(1f, 0.1f, 0.2f, 0.5f); break; case EMapBlockTypes.CITY: color = FColor.Black; //color = new FColor(1f, 0.5f, 0.4f, 0.2f); break; case EMapBlockTypes.COAST: color = FColor.SandyBeach; break; case EMapBlockTypes.LAKE_COAST: color = FColor.SandyBrown; break; case EMapBlockTypes.MOUNT: color = FColor.DarkGray; break; case EMapBlockTypes.SWAMP: color = new FColor(1f, 0.2f, 0.3f, 0.1f); break; case EMapBlockTypes.ETERNAL_SNOW: color = FColor.White; break; case EMapBlockTypes.SHRUBS: color = new FColor(1f, 0.0f, 0.4f, 0.1f); break; default: throw new ArgumentOutOfRangeException(); } m_colors[type] = color; } }
public Rat(WorldLayer _layer) : base(EALNouns.Rat, _layer, 100 + World.Rnd.Next(20)) { Sex = ESex.FEMALE; var lcd = 0.5f + (Nn % 3 - 1) / 10f; LerpColor = new FColor(0.3f, lcd * (float)World.Rnd.NextDouble(), lcd * (float)World.Rnd.NextDouble(), lcd * (float)World.Rnd.NextDouble()); Behaviour = EMonsterBehaviour.IDLE; }
protected float DrawLine(TextPortion.TextLine _textLine, FColor _color, int _lineNumber, float _indent, EAlignment _alignment) { var line = _textLine.Text; var part = line.Split(TextPortion.Punctuation).ToArray(); var processedChars = 0; var x = (float) ContentRct.Left*Constants.TILE_SIZE; var lineSize = DrawHelper.MeasureString(Font, line); switch (_alignment) { case EAlignment.NORMAL: x += _indent + _textLine.Left; break; case EAlignment.LEFT: x += _indent; break; case EAlignment.RIGHT: x += ContentRct.Width*Constants.TILE_SIZE - lineSize.Width - _indent; break; case EAlignment.CENTER: x += ContentRct.Width*Constants.TILE_SIZE/2f - lineSize.Width/2f; break; } var y = ContentRct.Top*Constants.TILE_SIZE + _lineNumber*LineHeight; for (var partIndex = 0; partIndex < part.Length; partIndex++) { var color = _color; var addStr = part[partIndex]; FColor highlight; if (_textLine.Highlights != null && _textLine.Highlights.TryGetValue(addStr, out highlight)) { color = highlight; processedChars += addStr.Length; } else { processedChars += addStr.Length; addStr += (processedChars >= line.Length) ? "" : line[processedChars].ToString(); processedChars++; } var size = DrawHelper.MeasureString(Font, addStr); DrawHelper.DrawString(Font, addStr, x, y, color); x += size.Width + 2; } return x; }
public void DrawRect(RectangleF _rct, FColor _toFColor) { GL.BindTexture(TextureTarget.Texture2D, 0); GL.Color4(_toFColor.R, _toFColor.G, _toFColor.B, _toFColor.A); GL.Begin(BeginMode.Quads); GL.Vertex2(_rct.Left, _rct.Top); GL.Vertex2(_rct.Right + 1, _rct.Top); GL.Vertex2(_rct.Right + 1, _rct.Bottom + 1); GL.Vertex2(_rct.Left, _rct.Bottom + 1); GL.End(); }
protected void DrawLine(TextPortion.TextLine _textLine, FColor _color, float _x, float _y) { var line = _textLine.Text; var part = line.Split(TextPortion.Punctuation).ToArray(); var processedChars = 0; var x = _x + _textLine.Left; for (var partIndex = 0; partIndex < part.Length; partIndex++) { var color = _color; var addStr = part[partIndex]; FColor highlight; if (_textLine.Highlights != null && _textLine.Highlights.TryGetValue(addStr, out highlight)) { color = highlight; } processedChars += addStr.Length; addStr += (processedChars == 0 || processedChars >= line.Length) ? "" : line[processedChars].ToString(); processedChars++; var size = DrawHelper.MeasureString(Font, addStr); DrawHelper.DrawString(Font, addStr, x, _y, color); x += size.Width; } }
public void ClearTiles(Rct _rct, FColor _backgroundColor) { if(m_gameProvider.TileMapRenderer==null) return; m_gameProvider.TileMapRenderer.Clear(_rct, _backgroundColor); }
public ATile CreateTile(int _col, int _row, FColor _color) { var openTKTile = new OpenTKTile(_col, _row, _color); Tiles.Add(openTKTile); return openTKTile; }
public float DrawLine(string _text, FColor _color, int _lineNumber, float _indent, EAlignment _alignment) { return DrawLine(new TextPortion.TextLine(_text, 0, null), _color, _lineNumber, _indent, _alignment); }
protected override void OnRenderFrame(FrameEventArgs _e) { base.OnRenderFrame(_e); GL.ClearColor(0f, 0f, 0f, 0f); GL.Clear(ClearBufferMask.ColorBufferBit); using (new FboWrapper.DrawHelper(m_fboWrapper)) { #region #1 //dfbo.BeginDrawIn(0); GL.ClearColor(0f, 0f, 0f, 0f); GL.Clear(ClearBufferMask.ColorBufferBit); GL.Disable(EnableCap.Texture2D); GL.Begin(BeginMode.Polygon); { const int center = Map.SIZE*SZ/2; GL.Color3(1f, 1f, 0.7f); GL.Vertex2(center, center); GL.Color3(0f, 0f, 0f); const float step = (float) Math.PI/10f; for (float f = 0; f < Math.PI*2 + step; f += step) { var x = Math.Sin(f)*LIGHTRADIUS + center; var y = Math.Cos(f)*LIGHTRADIUS + center; GL.Vertex2(x, y); } GL.Color3(1f, 1f, 0.7f); GL.Vertex2(center, center); } GL.End(); #endregion m_fboWrapper.BlitTo(m_fboWrapperBlit, 0); } using (new FboWrapper.DrawHelper(m_fboWrapper)) { DrawShadows(new PointF(Mouse.X * SZ / VSZ, Mouse.Y * SZ / VSZ)); m_fboWrapper.BlitTo(m_fboWrapperBlit, 1); } const float sz = Map.SIZE * VSZ;//Map.SIZE; //512f / SZ; const float to = ((float)Map.SIZE * SZ) / FboWrapper.SIZE; if (true) { using (new FboWrapper.DrawHelper(m_fboWrapper)) { GL.Color4(1f, 1f, 1f, 1f); GL.Enable(EnableCap.Texture2D); m_fboWrapperBlit.BindTexture(1); GL.Begin(BeginMode.Quads); { GL.TexCoord2(0f, 0f); GL.Vertex2(0f, 0f); GL.TexCoord2(to, 0f); GL.Vertex2(sz, 0f); GL.TexCoord2(to, to); GL.Vertex2(sz, sz); GL.TexCoord2(0f, to); GL.Vertex2(0f, sz); } GL.End(); GL.BindTexture(TextureTarget.ProxyTexture2D, 0); GL.Disable(EnableCap.Texture2D); var arr = new FColor[Map.SIZE, Map.SIZE]; GL.ReadPixels(0, 0, Map.SIZE, Map.SIZE, PixelFormat.Rgba, PixelType.Float, arr); var bmp = new Bitmap(Map.SIZE, Map.SIZE, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); for (int i = 0; i < Map.SIZE; i++) { for (int j = 0; j < Map.SIZE; j++) { bmp.SetPixel(j, i, Color.FromArgb((int) (arr[i, j].A*255), (int) (arr[i, j].R*255), (int) (arr[i, j].G*255), (int) (arr[i, j].B*255))); } } bmp.Save("d:\\eee.png", ImageFormat.Png); } } GL.UseProgram(m_shaderProgramHandle); BindTexture(m_t2, TextureUnit.Texture1, "Shadow0"); BindTexture(m_t1, TextureUnit.Texture0, "Spot"); GL.Color3(1f, 1f, 1f); GL.Begin(BeginMode.Quads); { GL.TexCoord2(0f, 0f); GL.Vertex2(0f, 0f); GL.TexCoord2(to, 0f); GL.Vertex2(sz, 0f); GL.TexCoord2(to, to); GL.Vertex2(sz, sz); GL.TexCoord2(0f, to); GL.Vertex2(0f, sz); } GL.End(); GL.BindTexture(TextureTarget.Texture2D, 0); GL.Disable(EnableCap.Texture2D); GL.UseProgram(0); GL.Flush(); //var arr = new FColor[Map.SIZE, Map.SIZE]; //GL.ReadPixels(0, 0, Map.SIZE, Map.SIZE, PixelFormat.Rgba, PixelType.Float, arr); //var bmp = new Bitmap(Map.SIZE, Map.SIZE, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); //for (int i = 0; i < Map.SIZE; i++) //{ // for (int j = 0; j < Map.SIZE; j++) // { // bmp.SetPixel(j, i, Color.FromArgb((int)(arr[i, j].A * 255), (int)(arr[i, j].R * 255), (int)(arr[i, j].G * 255), (int)(arr[i, j].B * 255))); // } //} //bmp.Save("d:\\aaa.png",ImageFormat.Png); SwapBuffers(); Title = string.Format("fps:{0} per frame", Math.Round(1/_e.Time)); }
public Bitmap this[XTileInfoVM _tile, FColor _fColor, bool _removeTransparency, bool _grayScale] { get { if (_tile == null) return null; return this[_tile.Texture, _tile.X, _tile.Y, _fColor, _removeTransparency, _grayScale, _tile.Parent is XTerrainSetVM, _tile.PlusHalfX, _tile.PlusHalfY]; } }
public Bitmap this[ETextureSet _texture, int _x, int _y, FColor _fColor, bool _removeTransparency, bool _grayScale, bool _isTerrain, bool _plusHalfX, bool _plusHalfY] { get { Dictionary<Tuple<int, int, FColor, bool, bool, bool, bool>, Bitmap> dictionary; if (!m_tiles.TryGetValue(_texture, out dictionary)) { dictionary = new Dictionary<Tuple<int, int, FColor, bool, bool, bool, bool>, Bitmap>(); m_tiles[_texture] = dictionary; } Bitmap bitmap; var key = new Tuple<int, int, FColor, bool, bool, bool, bool>(_x, _y, _fColor, _removeTransparency, _grayScale, _plusHalfX, _plusHalfY); if (!dictionary.TryGetValue(key, out bitmap)) { var txtr = this[_texture, _isTerrain]; bitmap = new Bitmap(Constants.TILE_SIZE, Constants.TILE_SIZE); using(var gr = Graphics.FromImage(bitmap)) { gr.DrawImage(txtr, 0, 0, new Rectangle( Constants.TILE_SIZE * _x + (_plusHalfX ? (Constants.TILE_SIZE / 2) : 0), Constants.TILE_SIZE * _y + (_plusHalfY ? (Constants.TILE_SIZE / 2) : 0), Constants.TILE_SIZE, Constants.TILE_SIZE), GraphicsUnit.Pixel); } var transparent = txtr.GetPixel(0, 0); var rct = new Rct(0, 0, Constants.TILE_SIZE, Constants.TILE_SIZE); foreach (var point in rct.AllPoints) { var pixel = bitmap.GetPixel(point.X, point.Y); if (pixel == transparent) continue; var fcolor = new FColor(pixel.A, pixel.R, pixel.G, pixel.B).Multiply(1f / 255f); if(_grayScale) { fcolor = fcolor.ToGrayScale(); } var result = fcolor.Multiply(_fColor).GetColor();//.Multiply(255); if (_removeTransparency) { result.A = 255; } bitmap.SetPixel(point.X, point.Y, Color.FromArgb(result.A, result.R, result.G, result.B)); } dictionary.Add(key, bitmap); } return bitmap; } }
public void SetLerpColor(FColor _fColor) { m_lerpColor = _fColor; }
public void Clear(FColor _color) { m_core.SetClearColor(_color.R, _color.G, _color.B); m_core.Clear(); }
protected UiBlockWithText(Rct _rct, Frame _frame, FColor _color, EFonts _font = EFonts.COMMON) : base(_rct, _frame, _color) { Font = _font; LineHeight = DrawHelper.MeasureString(_font, "Ay").Height; }
protected ATile(int _x, int _y, FColor _color) { Color = _color; Point = new Point(_x, _y); SrcPoint = new Point(_x, _y); }
public void DrawTile(OpenTKTile _tile, int _x, int _y, FColor _color, EDirections _direction, bool _isCorpse) { if(_x<0 || _y<0 || _x>=m_tilesInRow || _y>=m_tilesInColumn) return; var info = m_tiles[_x, _y]; info.IsFogged = false; info.AddLayer(_tile, _color, _direction, _isCorpse); }
public OpenTKTile(int _x, int _y, FColor _color) : base(_x, _y, _color) { Texcoords = new TexCoord[4]; X = _x; Y = _y; }
public void AddLayer(OpenTKTile _tile, FColor _color, EDirections _direction, bool _isCorpse) { m_layers.Add(new LayerInfo(){Tile = _tile, Color = _color, Direction = _direction, IsCorpse = _isCorpse}); }
public override void Draw(Point _point, FColor _color) { GameProvider.TileMapRenderer.DrawTile(this, _point.X, _point.Y, _color, EDirections.DOWN, false); }
public override void Draw(Point _point, FColor _color, EDirections _direction, bool _isCorpse) { GameProvider.TileMapRenderer.DrawTile(this, _point.X, _point.Y, _color, _direction, _isCorpse); }
public abstract void Draw(Point _point, FColor _color, EDirections _direction, bool _isCorpse);
public abstract void Draw(Point _point, FColor _color);
public void Clear(Rct _rct, FColor _backgroundColor) { GL.BindTexture(TextureTarget.Texture2D, 0); GL.Begin(BeginMode.Quads); var xy = new Point(_rct.Left, _rct.Top) * Constants.TILE_SIZE; var xy1 = new Point(_rct.Right + 1, _rct.Bottom + 1) * Constants.TILE_SIZE; GL.Color4(_backgroundColor.R, _backgroundColor.G, _backgroundColor.B, _backgroundColor.A); GL.Vertex2(xy.X, xy.Y); GL.Vertex2(xy1.X, xy.Y); GL.Vertex2(xy1.X, xy1.Y); GL.Vertex2(xy.X, xy1.Y); GL.End(); for (var i = _rct.Left; i <= _rct.Right; i++) { for (var j = _rct.Top; j <= _rct.Bottom; j++) { m_tiles[i, j].Clear(); } } }
public static void Screenshot(string _filename) { var arr = new FColor[LosManagerEx.MAP_SIZE, LosManagerEx.MAP_SIZE]; GL.ReadPixels(0, 0, LosManagerEx.MAP_SIZE, LosManagerEx.MAP_SIZE, PixelFormat.Rgba, PixelType.Float, arr); var bmp = new Bitmap(LosManagerEx.MAP_SIZE, LosManagerEx.MAP_SIZE, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); for (var i = 0; i < LosManagerEx.MAP_SIZE; i++) { for (var j = 0; j < LosManagerEx.MAP_SIZE; j++) { bmp.SetPixel(j, i, Color.FromArgb((int) (arr[i, j].A*255), (int) (arr[i, j].R*255), (int) (arr[i, j].G*255), (int) (arr[i, j].B*255))); } } bmp.Save(_filename, ImageFormat.Png); }