public static void AssignTurtleToSeat(TurtleModel turtleModel, SeatModel seatModel) { if (turtleModel != null && seatModel != null) { SeatModel oldSeat = turtleModel.TargetSeat; if (oldSeat != null) { oldSeat.Taken = false; } turtleModel.TargetSeat = seatModel; seatModel.Taken = true; } }
public override void Update(float deltaTime) { timeSinceLastSpawn += deltaTime; if (timeSinceLastSpawn > SPAWN_INTERVAL_SECONDS) { timeSinceLastSpawn -= SPAWN_INTERVAL_SECONDS; SeatModel assignedSeat = GetFreeQueueSeat(); if (assignedSeat != null) { // Spawn turtle TurtleModel newTurtle = new TurtleModel() { StaticData = ObjectDatabaseModel.Instance["turtle_1_no_materials"] }; Turtles.Add(newTurtle); TurtleModel.AssignTurtleToSeat(newTurtle, assignedSeat); } } }
public override void Update(float deltaTime) { SeatModel clickedSeat = null; foreach (SeatModel seat in SeatModels) { // Clicked? if (MouseInputModel.JustClicked && MouseInputModel.Intersects(seat)) { clickedSeat = seat; } } if (clickedSeat != null) { foreach (SeatModel seat in SeatModels) { if (!clickedSeat.Equals(seat)) { seat.Selected = false; } } clickedSeat.Selected = !clickedSeat.Selected; } }
public void Reset() { Subject = null; Target = null; }