public override void Update(GameTime gameTime, Game1 game) { player.Update(gameTime); key.Update(gameTime); //Collision&CameraMovement foreach (CollisionTiles item in map.LevelCurrent.CollisionTiles) { player.Collision(item.Rectangle, map.LevelCurrent.Width, map.LevelCurrent.Height); camera.Update(player.Position, map.LevelCurrent.Width, map.LevelCurrent.Height); } //collision met fruit foreach (Fruit item in map.LevelCurrent.Fruits.ToArray()) { item.Update(gameTime); if (player.rectangle.Intersects(item.rectangle)) { int Collide = map.LevelCurrent.Fruits.IndexOf(item); map.LevelCurrent.Fruits.RemoveAt(Collide); item.hasTouched(); Sounds.ananasPickup.Play(); } } //Collision met key if (player.rectangle.Intersects(key.rectangle) && Fruit.fruitCount == 0 && currentLevel <= 2) { currentLevel++; map.setLevel(currentLevel); map.GenerateLevel(); Fruit.fruitCount = 4; Sounds.ananasPickup.Play(); } else if (currentLevel > 2) { game.MenuChange(Game1.gameState.End); } }
public void Update(GameTime gameTime) { GuiHelper.CurrentIMGUI = _ui; _ui.UpdateAll(gameTime); if (Triggers.RectDrag.Pressed(false)) { _ui.GrabFocus(null); } Sidebar.Put(isLeftSide: true); string gridSizeString = $"{_gridSize}"; string gridLockString = $"{(_gridLock ? 1 : 0)}"; Label.Put(""); Label.Put("Lock Grid"); Textbox.Put(ref gridLockString); if (Int32.TryParse(gridLockString, out int newGridLock)) { _gridLock = newGridLock == 0 ? false : true; } Label.Put("Grid Size"); if (_gridLock) { Label.Put(gridSizeString); } else { Textbox.Put(ref gridSizeString); if (float.TryParse(gridSizeString, out float newGridSize)) { _gridSize = newGridSize; _gridWorld = _gridSize * Camera.ScreenToWorldScale; _adaptiveGrid = MathF.Max(GetAdaptiveGrid(_gridSize, _gridWorld), _gridSize); } } Label.Put("Adaptive Size"); Label.Put($"{_adaptiveGrid}"); Label.Put("Focal length"); string fl = $"{Camera.FocalLength}"; Textbox.Put(ref fl); if (float.TryParse(fl, out float focalLength)) { var temp = Camera.Z / Camera.FocalLength; Camera.FocalLength = focalLength; Camera.Z = focalLength * temp; } Sidebar.Pop(); bool addModifier = false; bool removeModifier = false; bool skipEditModifier = false; if (!_edit.IsDragged) { addModifier = Triggers.AddModifier.Held(); removeModifier = Triggers.RemoveModifier.Held(); skipEditModifier = Triggers.SkipEditModifier.Held(); } Camera.UpdateInput(); Camera.Update(); if (Triggers.Redo.Pressed()) { _historyHandler.Redo(); ComputedSelectionBounds(); } if (Triggers.Undo.Pressed()) { _historyHandler.Undo(); ComputedSelectionBounds(); } bool isEditDone = false; if (!addModifier && !removeModifier && !skipEditModifier) { if (Triggers.AlignToGrid.Held()) { isEditDone = _edit.UpdateInput(Camera.MouseWorld, false, grid: new Vector2(_adaptiveGrid)); } else { isEditDone = _edit.UpdateInput(Camera.MouseWorld, false); } } var isSelectionDone = _selection.UpdateInput(Camera.MouseWorld); ApplyEdit(isEditDone); SingleHover(); if (Triggers.Create.Pressed()) { Create(); isSelectionDone = true; } if (Triggers.CreateStuff.Pressed()) { CreateStuff(); isSelectionDone = true; } if (Triggers.Paste.Pressed()) { Paste(Camera.MouseWorld); isSelectionDone = true; } if (isSelectionDone) { ApplySelection(addModifier, removeModifier); } if (Triggers.ResetOrder.Pressed()) { ResetOrder(); } if (Triggers.ResetResize.Pressed()) { ResetResize(); } if (Triggers.Remove.Pressed()) { Remove(); } if (Triggers.Cut.Pressed()) { Cut(); } if (Triggers.Copy.Pressed()) { Copy(); } if (Triggers.ToggleLilypads.Pressed()) { _activeLayers ^= World.LayerType.Lilypads; } if (Triggers.ToggleWoods.Pressed()) { _activeLayers ^= World.LayerType.Woods; } if (Triggers.ToggleClouds.Pressed()) { _activeLayers ^= World.LayerType.Clouds; } _pathEditor.UpdateInput(); }