public TabTaskOut SetTaskItem(UserTaskDataModel newTaskItem) { if (newTaskItem.Id == 0) { throw new Exception(Error.TaskNotExist); } var si = new SpriteImages(); var ti = new TabTaskOut { Id = newTaskItem.Id, StartTime = newTaskItem.DateActivate, SourceOwnType = newTaskItem.SourceOwnType, SourceOwnName = newTaskItem.SourceOwnName, SourceSystemName = newTaskItem.SourceSystemName, TargetPlanetName = newTaskItem.TargetPlanetName, //TargetSystemName = targetPlanetName.Substring(0, 5), TargetSystemName = newTaskItem.TargetSystemName, FlyDuration = newTaskItem.Duration, HangarInTask = UnitList.ConvertToHangar(newTaskItem.SourceFleet.CloneDeep()), IsAtack = newTaskItem.IsAtack, IsTransfer = newTaskItem.IsTransfer }; if (ti.SourceOwnType) { ti.LeftImage = ImageView.Img("t-LeftImage"); } else { ti.LeftImage = ImageView.Img(si.MapControlIcons("jumptomother").Icon); } ti.RightImage = ImageView.Img(si.MapControlIcons("jumptoplanetoid").Icon); TabTaskOut.InitComplexBtnItem(ti); return(ti); }
private TabSpyOut _writeAndReturnSpyItem(IDbConnection connection, int currentUserId, GDetailPlanetDataModel tPlanet) { var resource = MaterialResource.ConvertStorageToMaterial(tPlanet.Resources).ConvertToInt(); var planetType = _geometryPlanetService.GetGeometryPlanetById(connection, tPlanet.Id); var spyItem = new UserSpyDataModel { DateActivate = UnixTime.UtcNow(), TargetPlanetTypeId = planetType.TypeId, TargetPlanetName = tPlanet.Name, TargetPlanetId = tPlanet.Id, TargetPlanetHangar = tPlanet.Hangar, TargetResource = resource, SourceUserId = currentUserId, }; var isSkagry = false; if (tPlanet.UserId == Npc.SkagryGameUserId) { spyItem.TargetUserName = Npc.SkagyName; //todo сделать стиль скагрей spyItem.TargetUserImage = _spriteImages.MapControlIcons("interface-skagry-icon"); isSkagry = true; } else { var targetUser = _gameUserService.GetGameUser(connection, tPlanet.UserId); spyItem.TargetUserName = targetUser.Nickname; spyItem.TargetUserImage = targetUser.Avatar; } var newSpyItem = _uSpyService.AddOrUpdate(connection, spyItem); if (newSpyItem.Id == 0) { throw new Exception(Error.NoData); } var leftSprite = new SpriteImages(); leftSprite.MapControlIcons("jumptoplanetoid"); var j = new TabSpyOut { // SourceOwnType = false, Id = newSpyItem.Id, TargetUserName = newSpyItem.TargetUserName, TargetResource = newSpyItem.TargetResource, TargetHangar = UnitList.ConvertToHangar(tPlanet.Hangar), TargetPlanetId = newSpyItem.TargetPlanetId, TargetPlanetName = newSpyItem.TargetPlanetName, TargetSystemName = newSpyItem.TargetPlanetName.Substring(0, 5), LeftImage = ImageView.Img(leftSprite.Icon), RightImage = (isSkagry) ? ImageView.Img(spyItem.TargetUserImage.Icon) : ImageView.Img(spyItem.TargetUserImage.Icon, null, true), Date = UnixTime.GetDateFromTimeStamp(newSpyItem.DateActivate), TimeNow = UnixTime.GetTimeFromTimeStamp(newSpyItem.DateActivate) }; j.RightImage.Title = j.RightImage.Alt = j.TargetUserName; TabSpyOut.InitComplexBtnItem(j); return(j); }