public ISprite CreateClockItem(SpriteBatch spriteBatch, Vector2 startingPos, bool kept, bool resetKept) { IItem add = new ClockItem(spriteBatch, textures["clock"], startingPos, kept, resetKept); RoomItems.Instance.AddItem(add); return(add); }
public async Task <ClockItem> GetSingleClockItem(int userId, int id) { ClockItem clockItem = await _context.ClockItems .Where(c => c.userId == userId) .Where(c => c.Id == id) .FirstOrDefaultAsync(); return(clockItem); }
public async Task <IActionResult> GetClockItem(int id) { int userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); ClockItem clockItem = await _repo.GetSingleClockItem(userId, id); ClockItemForReturnDto clockItemForReturn = _mapper.Map <ClockItemForReturnDto>(clockItem); return(Ok(clockItemForReturn)); }
public void UpdateWorldAroundX(int x) { var newLeftChunkLimit = x - (int)(renderChunkWidth / 2); trimCells(newLeftChunkLimit); leftChunkLimit = newLeftChunkLimit; mMapGenerator.SetCurrentChunkHead(leftChunkLimit); mMapGenerator.SetCurrentChunkTail(rightChunkLimit); for (int i = 0; i < 2; i++) { /* * This external for is a "workaround" for the weird ground block being * placed in lieu of a few clock items. * The second pass seems to fix it. */ for (GeneColumn iterator = mMapGenerator.CurrentChunkHead; iterator != mMapGenerator.CurrentChunkTail.Next; iterator = iterator.Next) { for (int j = 0; j > -mMapGenerator.MaxHeight; j--) // Height is inverted { char cellCode = iterator.CellAtY(j); if (cellCode == 'C') { ClockItem clock = (ClockItem)clockScene.Instance(); clock.GlobalPosition = MapToWorld(new Vector2(iterator.GlobalX, j)) + (new Vector2(32F, 32F)); clock.ExtraTime = iterator.ClockExtraTime; clock.SourceGeneColumn = iterator; AddChild(clock); iterator.ClockPlaced = true; break; // Not necessary to proceed } else { SetCell(iterator.GlobalX, j, tileFromCode(cellCode)); } } if (iterator.GlobalX % 10 == 0 && !placedXLabels.Contains(iterator.GlobalX)) { // Place a Global X Label CellXLabel xlabel = (CellXLabel)cellXLabelScene.Instance(); xlabel.GlobalX = iterator.GlobalX; xlabel.GlobalPosition = MapToWorld(new Vector2(iterator.GlobalX, -9)) + (new Vector2(32F, 32F)); AddChild(xlabel); } } } }
public async Task <IActionResult> DeleteDepartment(int id) { int userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); ClockItem clockItemFromRepo = await _repo.GetSingleClockItem(userId, id); _repo.Delete(clockItemFromRepo); if (await _repo.SaveAll()) { return(Ok("Clock item was deleted!")); } throw new Exception("Deleting clock item failed on save"); }
public async Task <IActionResult> UpdateDepartment(int id, ClockItemForCreationDto clockItemForCreationDto) { int userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); ClockItem clockItemFromRepo = await _repo.GetSingleClockItem(userId, id); _mapper.Map(clockItemForCreationDto, clockItemFromRepo); if (await _repo.SaveAll()) { var clockItemToReturn = _mapper.Map <ClockItemForReturnDto>(clockItemFromRepo); return(CreatedAtRoute("GetClockItem", new { id = clockItemFromRepo.Id }, clockItemToReturn)); } throw new Exception("Updating clock item failed on save"); }
public IActionResult SaveSettingsScreen(string slideTime, bool clockSlideActive, int clockSlideInterval, bool weatherSlideActive, int weatherSlideInterval, string weatherSlideLocation) { ClockItem clock = _data.GetSingle <ClockItem>(); WeatherItem weather = _data.GetSingle <WeatherItem>(); clock.Active = clockSlideActive; clock.DisplayTime = clockSlideInterval; weather.Active = weatherSlideActive; weather.DisplayTime = weatherSlideInterval; _data.Edit(clock); _data.Edit(weather); _data.SetSettingByName("WeatherLocation", weatherSlideLocation); _data.SetSettingByName("DefaultDisplayTime", slideTime); _data.Commit(); return(Success()); }
protected override async Task ExecuteAsync(CancellationToken cancellationToken) { _logger.LogInformation("Screen Background Service is starting."); using (var scope = _scopeFactory.CreateScope()) { _data = scope.ServiceProvider.GetRequiredService <IVolatileDataService>(); IEnumerable <Item> activeCustomItems = _data.GetAllActive().Where(i => !(i is RSSItem || i is ClockItem || i is WeatherItem)); IEnumerable <Item> activeRSSItems = _data.GetAllActive().Where(i => i is RSSItem); activeCustomItems.ToList().Shuffle(); activeRSSItems.ToList().Shuffle(); Item currentItem = activeCustomItems.FirstOrDefault(); Item screenItem = currentItem; Item currentRssItem = null; bool showClock = true; while (!cancellationToken.IsCancellationRequested) { activeCustomItems = _data.GetAllActive() .Where(i => !(i is RSSItem || i is ClockItem || i is WeatherItem)); activeRSSItems = _data.GetAllActive().Where(i => i is RSSItem); try { if (screenItem != null) { // Send item to clients via websockets _logger.LogInformation($"Send item: {(screenItem.Title)}."); //SEND TO CLIENTS await _hubContext.Clients.All.BroadcastSlide(new ScreenItemViewModel(screenItem)); await Task.Delay(TimeSpan.FromSeconds(screenItem.DisplayTime)); } else { await Task.Delay(TimeSpan.FromSeconds(3)); } // Obtain new item Random r = new Random(); ClockItem clock = _data.GetSingle <ClockItem>(); WeatherItem weather = _data.GetSingle <WeatherItem>(); // bool checkIfRSSFeedActive = _data.AnyRssFeedActive(); // bool checkIfRssItemsExist = activeRSSItems.ToList().Count > 0; // bool checkIfRssShow = r.NextBool(25); if (_data.AnyRssFeedActive() && activeRSSItems.ToList().Count > 0 && r.NextBool(25)) { // Toon RSS Item als er actieve RSS feeds zijn en met een (pseudo) kans van 25% currentRssItem = GetNextItem(currentRssItem, activeRSSItems); screenItem = currentRssItem ?? screenItem; } else if (!(screenItem is ClockItem || screenItem is WeatherItem) && r.NextBool(35) && ((showClock && clock.Active) || (!showClock && weather.Active))) { screenItem = showClock ? (Item)clock : weather; showClock = !showClock; } else { currentItem = GetNextItem(currentItem, activeCustomItems); screenItem = currentItem ?? screenItem; } } catch (Exception ex) { _logger.LogError(ex, $"An unexpected error occurred in ScreenBackgroundController."); } } } _logger.LogInformation("Screen Background Service is stopping."); }
void addItem(String line) { String[] split = line.Split(','); IObject item; float x = ((Int32.Parse(split[1]) - 1) * blockBaseDimension * blockSizeMod) + screenX + (2 * blockBaseDimension * blockSizeMod); float y = ((Int32.Parse(split[2]) - 1) * blockBaseDimension * blockSizeMod) + screenY + (2 * blockBaseDimension * blockSizeMod); switch (split[0]) { case "bomb": item = new BombItem(sprites["itemset"], new Vector2(x, y)); break; case "boomerang": item = new BoomerangItem(sprites["itemset"], new Vector2(x, y)); break; case "bow": item = new BowItem(sprites["itemset"], new Vector2(x, y)); break; case "clock": item = new ClockItem(sprites["itemset"], new Vector2(x, y)); break; case "compass": item = new CompassItem(sprites["itemset"], new Vector2(x, y)); break; case "fairy": item = new FairyItem(sprites["itemset"], new Vector2(x, y)); break; case "heart": item = new HeartItem(sprites["itemset"], new Vector2(x, y)); break; case "key": item = new KeyItem(sprites["itemset"], new Vector2(x, y)); break; case "map": item = new MapItem(sprites["itemset"], new Vector2(x, y)); break; case "permanentheart": item = new PermanentHeartItem(sprites["itemset"], new Vector2(x, y)); break; case "rupee": item = new RupeeItem(sprites["itemset"], new Vector2(x, y)); break; case "triforce": item = new TriforceItem(sprites["itemset"], new Vector2(x + 24, y + 8)); break; default: item = null; break; } Items.Add(item); }
public void BuildBlocks(string input) { if (Room.Id == 13) { buildblocks13(input); return; } switch (input) { //BLOCKS case "TILE": IBlock tile = new FloorBlock(Position); Room.blocks.Add(tile); break; case "BLOK": IBlock blok = new RegularBlock(Position); Room.blocks.Add(blok); break; case "RFSH": IBlock rfsh = new Face1Block(Position); Room.blocks.Add(rfsh); break; case "LFSH": IBlock lfsh = new Face2Block(Position); Room.blocks.Add(lfsh); break; case "SPOT": IBlock spot = new SpottedBlock(Position); Room.blocks.Add(spot); break; case "BLCK": IBlock blck = new BlackBlock(Position); Room.blocks.Add(blck); break; case "BRIK": IBlock brik = new BrickBlock(Position); Room.blocks.Add(brik); break; case "DARK": IBlock dark = new DarkBlueBlock(Position); Room.blocks.Add(dark); break; case "STAR": IBlock star = new StairsBlock(Position); Room.blocks.Add(star); break; case "STIP": IBlock stip = new StripeBlock(Position); Room.blocks.Add(stip); break; case "MVBK": IBlock mvbk = new MovingVertBlock(Position); Room.blocks.Add(mvbk); break; case "MLBK": IBlock mlbk = new MovingLeftBlock(Position); Room.blocks.Add(mlbk); break; //ENEMIES case "BBAT": IEntity bat = new BlueBatEnemy(Position); Room.enemies.Add(enemyID, bat); enemyID++; break; case "SKLN": IEntity skel = new SkeletonEnemy(Position); Room.enemies.Add(enemyID, skel); enemyID++; break; case "BOSS": IAttack up = new FireAttack(1); IAttack center = new FireAttack(0); IAttack down = new FireAttack(2); Room.enemies.Add(enemyID, up); enemyID++; Room.enemies.Add(enemyID, down); enemyID++; Room.enemies.Add(enemyID, center); enemyID++; Room.enemies.Add(enemyID, new FinalBossEnemy(Position, up, center, down)); enemyID++; break; case "FIRE": IEntity fire = new FireEnemy(Position); Room.enemies.Add(enemyID, fire); enemyID++; break; case "GELY": IEntity gel = new GelEnemy(Position); gel.X = gel.Position.X + FOUR * Global.Var.SCALE; gel.Y = gel.Position.Y + FOUR * Global.Var.SCALE; Room.enemies.Add(enemyID, gel); enemyID++; break; case "GORY": IBoomerang goriyaBoomerang = new BoomerangItem(); IEntity goriya = new GoriyaEnemy(goriyaBoomerang, Position); Room.enemyProj.Add(goriyaBoomerang); Room.enemies.Add(enemyID, goriya); enemyID++; break; case "HAND": IEntity hand = new HandEnemy(Position); Room.enemies.Add(enemyID, hand); enemyID++; break; case "OLDM": IEntity man = new OldManNPC(Position); man.X = man.Position.X + EIGHT * Global.Var.SCALE; Room.enemies.Add(enemyID, man); enemyID++; break; case "MNFR": IEntity fire1 = new FireEnemy(Position); IEntity fire2 = new FireEnemy(Position); Room.enemies.Add(enemyID, fire1); enemyID++; Room.enemies.Add(enemyID, fire2); enemyID++; IEntity manAndFire = new OldMan_FireEnemy(Position, fire1, fire2); manAndFire.X = manAndFire.Position.X + EIGHT * Global.Var.SCALE; Room.enemies.Add(enemyID, manAndFire); enemyID++; break; case "SPKE": IEntity spike = new SpikeEnemy(Position, spikeNum); Room.enemies.Add(enemyID, spike); enemyID++; spikeNum++; if (spikeNum > 4) { spikeNum = 1; } break; //ITEMS // Probably could use a static bomb and boomerang object now that I think of it. case "KEYI": IItem key = new KeyItem(Position); key.X = key.Position.X + FOUR * Global.Var.SCALE; Room.items.Add(key); break; case "BOWI": IItem bow = new BowItem(Position); Room.items.Add(bow); break; case "CLCK": IItem clock = new ClockItem(Position); Room.items.Add(clock); break; case "CMPS": IItem compass = new CompassItem(Position); compass.X = compass.Position.X + TWO * Global.Var.SCALE; compass.Y = compass.Position.Y + TWO * Global.Var.SCALE; Room.items.Add(compass); break; case "FARY": IItem fairy = new FairyItem(Position); Room.items.Add(fairy); break; case "HCON": IItem hcont = new HeartContainerItem(Position); hcont.X = hcont.Position.X + ONE * Global.Var.SCALE; hcont.Y = hcont.Position.Y + ONE * Global.Var.SCALE; Room.items.Add(hcont); break; case "HART": IItem heart = new HeartItem(Position); Room.items.Add(heart); break; case "MAPI": IItem map = new MapItem(Position); map.X = map.Position.X + FOUR * Global.Var.SCALE; Room.items.Add(map); break; case "RUPE": IItem rupee = new RupeeItem(Position); Room.items.Add(rupee); break; case "BOMB": IItem bomb = new BombStaticItem(Position); Room.items.Add(bomb); break; case "BMRG": IItem boom = new BoomerangStaticItem(Position); boom.X = boom.Position.X + BMRG_X_OFFSET * Global.Var.SCALE; boom.Y = boom.Position.Y + BMRG_Y_OFFSET * Global.Var.SCALE; Room.items.Add(boom); break; case "BRUP": IItem brup = new BlueRupeeItem(Position); Room.items.Add(brup); break; case "TRIF": IItem triforce = new TriforceItem(Position); triforce.X = triforce.Position.X + ELEVEN * Global.Var.SCALE; triforce.Y = triforce.Position.Y + ELEVEN * Global.Var.SCALE; Room.items.Add(triforce); break; } }