/// <summary> /// 读取保存Screen /// </summary> /// <param name="operate"></param> public ScreenSaveLoadGame(SimulatorContext context, SaveLoadOperate operate) : base(context) { _curOperate = operate; _backgroudImage = Context.LibData.GetImage(2, operate == SaveLoadOperate.LOAD ? 16 : 15); _headImgs.Add(new List <ResImage>()); _headImgs.Add(new List <ResImage>()); _headImgs.Add(new List <ResImage>()); for (int i = 0; i < 3; i++) { string fileName = $"./assets/saves/{context.LibData.Hash}_{i}"; Stream stream = Context.StreamProvider.GetStream(fileName); if (stream != null) { try { _texts[i] = FormatSaveName(GetSceneNameAndHeads(stream, _headImgs[i])); } finally { stream.Dispose(); } } } }
/// <summary> /// Read images from resource catalog. /// </summary> public void Load() { // Assert resources catalog if (FileUtils.AssureFile(_resourcePath)) { // Stashing previous state of list and rollback, if something went wrong StashBackup(); // Get files info from catalog var extensions = new[] { "png", "jpg", "jpeg", "gif" }; var files = Directory.EnumerateFiles(_resourcePath, "*.*", SearchOption.AllDirectories) .Where(s => extensions.Contains(s.Split(".")[1])); // Zero the maxId _maxId = 0; // Iterate throug hthe images foreach (var file in files) { var fileInfo = new FileInfo(_resourcePath + file); // ResImage resImage = new ResImage(); resImage.Id = NextMaxId; resImage.filename = file; resImage.imageType = fileInfo.Extension; // TODO Maybe some day add rest of fields _maxId++; } FixMaxId(); } else { Console.WriteLine($"Couldn't read images from {_resourcePath}."); } }
public FrameAnimation(ResImage img, int startFrame, int endFrame) { mImage = img; mStartFrame = startFrame; mEndFrame = endFrame; mCurFrame = startFrame; }
public CommandSayOperate(ArraySegment <byte> data, SimulatorContext context) : base(context) { var start = data.Offset; var code = data.Array; _content = code.GetStringBytes(start + 2); //获取头像资源索引 var _picIndex = code.Get2BytesUInt(start); if (_picIndex == 0) //没有头像 { _rectangle = new Rectangle(9, 55, 142, 41 - 1); // new RectangleF(9, 55, 142, 41 - 0.5f); _rectangleTop = new Rectangle(14, 58, 131, 17); _rectangleBottom = new Rectangle(14, 76, 131, 17); } else //有头像 { _headImg = Context.LibData.GetImage(1, _picIndex); _rectangle = new Rectangle(9, 50, 142, 46 - 1); // new RectangleF(9, 50, 142, 46 - 0.5f); _rectangleTop = new Rectangle(44, 58, 101, 17); _rectangleBottom = new Rectangle(14, 76, 131, 17); } _paint.SetColor(Constants.COLOR_BLACK); _paint.SetStyle(PaintStyle.FILL_AND_STROKE); _indexOfText = 0; _indexOfNext = 0; }
/// <summary> /// 战斗胜利消息界面 /// </summary> /// <param name="context"></param> /// <param name="top">消息显示Y坐标</param> /// <param name="msg"></param> public MsgScreen(SimulatorContext context, int top, string msg) : base(context) { byte[] msgData; try { msgData = msg.GetBytes(); } catch (Exception ex) { Debug.WriteLine(ex); msgData = new byte[0]; } ResImage side = Context.LibData.GetImage(2, 8); _messageImg = Context.GraphicsFactory.NewImageBuilder(msgData.Length * 8 + 8, 24); ICanvas canvas = Context.GraphicsFactory.NewCanvas(_messageImg);; canvas.DrawColor(Constants.COLOR_WHITE); side.Draw(canvas, 1, 0, 0); side.Draw(canvas, 2, _messageImg.Width - 3, 0); Paint paint = new Paint(PaintStyle.FILL_AND_STROKE, Constants.COLOR_BLACK); canvas.DrawLine(0, 1, _messageImg.Width, 1, paint); canvas.DrawLine(0, 22, _messageImg.Width, 22, paint); TextRender.DrawText(canvas, msgData, 4, 4); _left = (160 - _messageImg.Width) / 2; _top = top; }
/// <summary> /// 战斗中显示玩家异常状态界面 /// </summary> /// <param name="context"></param> /// <param name="combatUI"></param> public MenuState(SimulatorContext context, CombatUI combatUI) : base(context, combatUI) { _background = Context.LibData.GetImage(2, 11); _marker = Context.LibData.GetImage(2, 12); _curCharacterIndex = _combatUI.CurCharacterIndex; }
/// <summary> /// 战斗精灵 /// </summary> /// <param name="context"></param> /// <param name="isMonster">是否为怪物</param> /// <param name="index"></param> public FightingSprite(SimulatorContext context, bool isMonster, int index) : base(context) { if (isMonster) //怪物 { _image = Context.LibData.GetCharacterImage(3, index); } else //玩家角色 { _image = Context.LibData.GetImage(3, index); } }
public IHttpActionResult GetResImage(int id) { ResImage resImage = db.ResImages.Find(id); if (resImage == null) { return(NotFound()); } return(Ok(resImage)); }
/// <summary> /// 设置数据 /// </summary> /// <param name="buf"></param> /// <param name="offset"></param> public override void SetData(byte[] buf, int offset) { Type = (int)buf[offset] & 0xFF; Index = (int)buf[offset + 1] & 0xFF; _enableLevel = (int)buf[offset + 3] & 0xFF; SumRound = (int)buf[offset + 4] & 0xff; _image = Context.LibData.GetGoodsImage(Type, (int)buf[offset + 5] & 0xff); Name = buf.GetString(offset + 6); BuyPrice = buf.Get2BytesUInt(offset + 0x12); SellPrice = buf.Get2BytesUInt(offset + 0x14); Description = buf.GetString(offset + 0x1e); EventId = buf.Get2BytesUInt(offset + 0x84); SetOtherData(buf, offset); }
public void Deserialize(BinaryReader binaryReader) { Type = binaryReader.ReadInt32(); Index = binaryReader.ReadInt32(); _imgHead = Context.LibData.GetImage(1, Index); LevelupChain = Context.LibData.GetLevelupChain(Index); SetWalkingSprite(new WalkingSprite(Context, Type, binaryReader.ReadInt32())); FightingSprite = new FightingSprite(Context, false, Index); Direction = (Direction)binaryReader.ReadInt32(); SetStep(binaryReader.ReadInt32()); SetPosInMap(binaryReader.ReadInt32(), binaryReader.ReadInt32()); var hasMagicChain = binaryReader.ReadBoolean(); if (hasMagicChain) { MagicChain = new ResMagicChain(Context); MagicChain.Deserialize(binaryReader); } Name = binaryReader.ReadString(); Level = binaryReader.ReadInt32(); MaxHP = binaryReader.ReadInt32(); HP = binaryReader.ReadInt32(); MaxMP = binaryReader.ReadInt32(); MP = binaryReader.ReadInt32(); Attack = binaryReader.ReadInt32(); Defend = binaryReader.ReadInt32(); Speed = binaryReader.ReadInt32(); Lingli = binaryReader.ReadInt32(); Luck = binaryReader.ReadInt32(); CurrentExp = binaryReader.ReadInt32(); for (int i = 0; i < 8; i++) { var type = binaryReader.ReadInt32(); var index = binaryReader.ReadInt32(); if (type != 0 && index != 0) { Equipments[i] = Context.LibData.GetGoods(type, index) as GoodsEquipment; } } }
public override void Draw(ICanvas canvas) { _backgroudImage.Draw(canvas, 1, 0, 0); for (int i = 0; i < _headImgs.Count; i++) { for (int j = 0; j < _headImgs[i].Count; j++) { ResImage img = _headImgs[i][j]; if (img != null) { img.Draw(canvas, 7, 8 + 20 * j, _textPos[i, 1] - 6); } } } TextRender.DrawText(canvas, _texts[0], _textPos[0, 0], _textPos[0, 1]); TextRender.DrawText(canvas, _texts[1], _textPos[1, 0], _textPos[1, 1]); TextRender.DrawText(canvas, _texts[2], _textPos[2, 0], _textPos[2, 1]); TextRender.DrawSelText(canvas, _texts[_index], _textPos[_index, 0], _textPos[_index, 1]); }
public CombatUI(SimulatorContext context, ICallBack callBack, int curPlayerIndex) : base(context) { mCallBack = callBack; CurCharacterIndex = curPlayerIndex; ScreenStack.Push(new MainMenu(Context, this)); ResImage tmpImg; tmpImg = Context.LibData.GetImage(2, 4); PlayerIndicator = new FrameAnimation(tmpImg, 1, 2); TargetIndicator = new FrameAnimation(tmpImg, 3, 4); tmpImg = Context.LibData.GetImage(2, 3); MonsterIndicator = new FrameAnimation(tmpImg); HeadImgs = new ResImage[] { Context.LibData.GetImage(1, 1), Context.LibData.GetImage(1, 2), Context.LibData.GetImage(1, 3) }; }
public ImageBuilder GetSmallSignedNumBitmap(int num) { byte[] nums = (num > 0 ? num : -num).ToString().GetBytes(); ResImage sign = Context.LibData.GetImage(2, num > 0 ? 6 : 7); ImageBuilder bmp = Context.GraphicsFactory.NewImageBuilder(sign.Width + nums.Length * imgSmallNum.Width + 1 + nums.Length, imgSmallNum.Height); var c = Context.GraphicsFactory.NewCanvas(bmp); sign.Draw(c, 1, 0, 0); int x = sign.Width + 1; for (int i = 0; i < nums.Length; i++) { imgSmallNum.Draw(c, nums[i] - '0' + 1, x, 0); x += imgSmallNum.Width + 1; } return(bmp); }
/* This is used for file accessing and post a file to a database using a server */ public String POST() { int counter = 0; // collecting files System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; string url = HttpContext.Current.Request.Url.AbsoluteUri; ResImage respic = new ResImage(); String Status = ""; for (int i = 0; i < files.Count; i++) { //get the posted files System.Web.HttpPostedFile file = files[i]; string fileName = new FileInfo(file.FileName).Name; if (file.ContentLength > 0) { Guid id = Guid.NewGuid(); string modifiedFileName = id.ToString() + "_" + fileName; byte[] imageb = new byte[file.ContentLength]; file.InputStream.Read(imageb, 0, file.ContentLength); respic.Image = imageb; db.ResImages.Add(respic); db.SaveChanges(); counter++; } } if (counter > 0) { return(Status); } return("Upload Failed"); }
/// <summary> /// 游戏开始菜单 /// </summary> /// <param name="context"></param> public ScreenMenuStart(SimulatorContext context) : base(context) { _menuImg = Context.LibData.GetImage(2, 14); var cursors = new List <ResSrs>(); for (int i = 250; i <= 255; i++) { if (Context.LibData.GetSrs(1, i) is ResSrs resSrs) { resSrs.StartAni(); cursors.Add(resSrs); } else { break; } } _cursors = cursors; _left = (160 - _menuImg.Width) / 2; _top = (96 - _menuImg.Height) / 2; }
public CommandShowGutOperate(ArraySegment <byte> data, SimulatorContext context) : base(context) { var start = data.Offset; var code = data.Array; int topImgIndex = code[start] & 0xFF | code[start + 1] << 8 & 0xFF00; int bottomImgIndex = code[start + 2] & 0xFF | code[start + 3] << 8 & 0xFF00; _topImg = Context.LibData.GetImage(5, topImgIndex); _bottomImg = Context.LibData.GetImage(5, bottomImgIndex); _content = code.GetString(start + 4); _curShowY = _bottomImg != null ? 96 - _bottomImg.Height : 96; int rectTop = _topImg != null ? _topImg.Height : 0; _textArea = new Rectangle(0, rectTop, 160, _curShowY - rectTop); _skip = false; _interval = 50; _timeCount = 0; _speed = 1; _curShowY = _bottomImg != null ? 96 - _bottomImg.Height : 96; }
public Tiles(SimulatorContext context, int index) : base(context) { _tileRes = Context.LibData.GetTileImage(1, index); }
public FrameAnimation(ResImage img) : this(img, 1, img.Number) { }
public MainMenu(SimulatorContext context, CombatUI combatUI) : base(context, combatUI) { _combatUI = combatUI; _menuIcon = Context.LibData.GetImage(2, 1); _playerInfoBackground = Context.LibData.GetImage(2, 2); }
public override void SetData(byte[] buf, int offset) { Type = buf[offset] & 0xFF; Index = buf[offset + 1] & 0xFF; _imgHead = Context.LibData.GetImage(1, Index); SetWalkingSprite(new WalkingSprite(Context, Type, buf[offset + 0x16] & 0xFF)); FightingSprite = new FightingSprite(Context, false, Index); Direction direction = Direction.North; switch (buf[offset + 2] & 0xFF) { case 1: direction = Direction.North; break; case 2: direction = Direction.East; break; case 3: direction = Direction.South; break; case 4: direction = Direction.West; break; } Direction = direction; SetStep(buf[offset + 3] & 0xff); SetPosInMap(buf[offset + 5] & 0xFF, buf[offset + 6] & 0xFF); MagicChain = Context.LibData.GetMagicChain(buf[offset + 0x17] & 0xff); if (MagicChain != null) { MagicChain.LearnFromChain(buf[offset + 9] & 0xff); } else { MagicChain = new ResMagicChain(Context); } Name = buf.GetString(offset + 0x0a); Level = buf[offset + 0x20] & 0xff; MaxHP = buf.Get2BytesUInt(offset + 0x26); HP = buf.Get2BytesUInt(offset + 0x28); MaxMP = buf.Get2BytesUInt(offset + 0x2a); MP = buf.Get2BytesUInt(offset + 0x2c); Attack = buf.Get2BytesUInt(offset + 0x2e); Defend = buf.Get2BytesUInt(offset + 0x30); Speed = buf[offset + 0x36] & 0xff; Lingli = buf[offset + 0x37] & 0xff; Luck = buf[offset + 0x38] & 0xff; CurrentExp = buf.Get2BytesUInt(offset + 0x32); LevelupChain = Context.LibData.GetLevelupChain(Index); int tmp; tmp = buf[offset + 0x1e] & 0xff; if (tmp != 0) { Equipments[0] = Context.LibData.GetGoods(6, tmp) as GoodsEquipment; } tmp = buf[offset + 0x1f] & 0xff; if (tmp != 0) { Equipments[1] = Context.LibData.GetGoods(6, tmp) as GoodsEquipment; } tmp = buf[offset + 0x1b] & 0xff; if (tmp != 0) { Equipments[2] = Context.LibData.GetGoods(5, tmp) as GoodsEquipment; } tmp = buf[offset + 0x1d] & 0xff; if (tmp != 0) { Equipments[3] = Context.LibData.GetGoods(3, tmp) as GoodsEquipment; } tmp = buf[offset + 0x1c] & 0xff; if (tmp != 0) { Equipments[4] = Context.LibData.GetGoods(7, tmp) as GoodsEquipment; } tmp = buf[offset + 0x19] & 0xff; if (tmp != 0) { Equipments[5] = Context.LibData.GetGoods(2, tmp) as GoodsEquipment; } tmp = buf[offset + 0x1a] & 0xff; if (tmp != 0) { Equipments[6] = Context.LibData.GetGoods(4, tmp) as GoodsEquipment; } tmp = buf[offset + 0x18] & 0xff; if (tmp != 0) { Equipments[7] = Context.LibData.GetGoods(1, tmp) as GoodsEquipment; } }
public void Init() { var canvas = Context.GraphicsFactory.NewCanvas(); Paint paint = new Paint(); paint.SetColor(Constants.COLOR_WHITE); paint.SetStyle(PaintStyle.FILL_AND_STROKE); if (bmpInformationBg == null) { bmpInformationBg = new ImageBuilder[5]; for (int i = 0; i < 5; i++) { bmpInformationBg[i] = Context.GraphicsFactory.NewImageBuilder(138, 23 + 16 * i); canvas.SetBitmap(bmpInformationBg[i]); canvas.DrawColor(Constants.COLOR_BLACK); canvas.DrawRect(1, 1, 135, 20 + 16 * i, paint); canvas.DrawRect(136, 0, 138, 3, paint); canvas.DrawLine(0, 21 + 16 * i, 3, 21 + 16 * i, paint); canvas.DrawLine(0, 22 + 16 * i, 3, 22 + 16 * i, paint); } } if (bmpSideFrame == null) { bmpSideFrame = Context.GraphicsFactory.NewImageBuilder(8, 96); canvas.SetBitmap(bmpSideFrame); canvas.DrawColor(Constants.COLOR_WHITE); paint.SetColor(Constants.COLOR_BLACK); for (int i = 0; i < 8; i += 2) { canvas.DrawLine(i, 0, i, 96, paint); } } if (bmpTriangleCursor == null) { bmpTriangleCursor = Context.GraphicsFactory.NewImageBuilder(7, 13); canvas.SetBitmap(bmpTriangleCursor); canvas.DrawColor(Constants.COLOR_WHITE); for (int i = 0; i < 7; ++i) { canvas.DrawLine(i, i, i, 13 - i, paint); } } if (imgSmallNum == null) { imgSmallNum = Context.LibData.GetImage(2, 5); } if (bmpChuandai == null) { bmpChuandai = Context.GraphicsFactory.NewImageBuilder(22, 39); int b = Constants.COLOR_BLACK, w = Constants.COLOR_WHITE; int[] pixels = { w, w, w, w, w, w, w, w, w, b, b, b, w, w, w, w, w, w, w, w, w, w, w, w, w, b, b, w, w, b, b, b, b, b, b, b, b, b, b, b, b, b, w, w, w, w, b, b, b, b, b, w, w, w, w, w, w, w, w, b, b, b, b, b, w, w, w, w, b, b, w, w, w, b, b, b, w, w, b, b, b, w, w, w, b, b, w, w, w, w, w, b, w, w, b, w, w, w, w, w, w, w, w, w, w, w, b, b, w, w, w, w, w, b, w, w, b, b, b, b, b, b, b, b, b, b, b, w, w, w, w, w, w, w, w, w, w, w, w, b, w, w, w, w, b, b, w, w, w, w, w, w, w, w, w, w, w, w, w, w, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, w, w, w, w, w, w, b, b, w, w, w, b, b, b, b, w, b, b, b, b, b, b, w, w, w, w, w, w, w, w, w, b, b, b, b, b, b, w, w, w, b, b, b, w, w, w, w, w, w, w, b, b, b, b, w, w, b, b, b, w, w, w, w, w, w, w, b, b, b, b, b, b, b, b, w, w, w, w, b, b, b, w, w, w, w, w, w, w, w, b, b, b, b, w, w, w, w, w, w, w, b, b, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, b, b, b, b, b, b, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, b, b, b, b, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, b, w, w, w, w, b, b, w, w, w, b, w, w, w, w, w, w, w, w, b, b, b, b, b, b, b, w, b, b, w, w, b, b, w, w, w, w, w, w, w, b, b, w, w, b, w, w, w, w, b, b, w, b, w, w, w, w, w, w, w, w, w, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, w, w, w, w, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, w, w, w, w, w, w, w, w, b, b, b, b, b, b, b, w, b, b, w, b, b, w, w, w, w, w, w, w, w, w, b, b, w, b, b, b, b, w, b, b, w, b, b, w, w, w, w, w, w, w, w, w, b, w, b, b, w, w, b, w, w, b, w, b, b, w, w, w, w, w, w, w, w, w, b, b, b, b, b, b, b, w, w, b, b, b, b, w, w, w, w, w, w, w, w, w, b, b, b, b, b, b, b, w, w, b, b, b, w, w, w, w, w, w, w, w, w, w, w, b, b, b, b, b, w, w, w, w, b, b, b, w, w, w, w, w, w, b, b, b, b, b, w, w, w, w, b, b, b, b, b, b, b, b, b, b, w, w, w, w, w, w, b, b, b, w, w, b, b, w, b, b, w, w, b, b, b, b, b, b, b, w, w, b, b, w, w, w, w, w, w, b, w, w, w, w, w, b, b, b, b, b, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, b, b, w, w, }; bmpChuandai.SetPixels(0, 0, 22, 39, ImageBuilderUtil.PixelsToBuffer(pixels), 0, 22); } }