public void Update() { foreach (var tile in tiles) { tile.shape.OutlineColor = Color.Black; } if (MathModule.CorrectVector(Controller.NormalizedMousePosition)) { activeTile = tiles[Controller.NormalizedMousePosition.X, Controller.NormalizedMousePosition.Y]; activeTile.shape.OutlineColor = Color.White; } if (Model.TowerListChanged) { Model.TowerListChanged = false; Towers.Clear(); if (Model.Towers.Count != 0) { foreach (var tower in Model.Towers) { Towers.Add(new RectangleShape() { Size = new Vector2f(100, 100), Origin = new Vector2f(50, 50), Position = MathModule.ViewTransform((Vector2f)tower.position) + Config.PositionShift, Texture = tower.configs.texture }); } } Towers.Sort(CompareSpriteDepth); } Mobs.Clear(); if (Model.Wave.Count != 0) { foreach (var mob in Model.Wave) { /*Mobs.Add(new CircleShape() * { * Radius = 10, * Origin = new Vector2f(10, -10), * Position = MathModule.ViewTransform(mob.position) + mob.shift + Config.PositionShift, * FillColor = Color.Black, * OutlineColor = Color.Black, * OutlineThickness = 2 * });*/ Mobs.Add(new RectangleShape() { Size = new Vector2f(40, 50), Origin = new Vector2f(20, 20), Position = MathModule.ViewTransform((Vector2f)mob.position) + Config.PositionShift, Texture = mob.configs.texture }); } } Mobs.Sort(CompareSpriteDepth); }
public static void Update() { if (Model.HomeHP <= 0) { Program.currentState = 2; return; } if (MouseClicks.Count > 0) { var click = MouseClicks.Dequeue(); if (Keyboard.IsKeyPressed(Keyboard.Key.N)) { var clickOnBoard = GetRectangleCoordinates(click); if (MathModule.CorrectVector(clickOnBoard)) { Model.AddTower(clickOnBoard); } } } if (pressM == false) { if (Keyboard.IsKeyPressed(Keyboard.Key.M)) { pressM = true; Model.NewWave(0); } } else if (!Keyboard.IsKeyPressed(Keyboard.Key.M)) { pressM = false; } MousePosition = (Vector2f)Mouse.GetPosition(); NormalizedMousePosition = GetRectangleCoordinates(MousePosition); }