public void handleEvent(Waypoint w) { // begin riding vehicle // begin riding vehicle if (w.Type == Waypoint.WaypointType.Spinner) { if (BoundingRectangle.Intersects(w.BoundingRectangle)) { ridingVehicle = true; BoundingRectangle.Min = new Vector3(w.BoundingRectangle.Min.X, w.BoundingRectangle.Min.Y - 80, 0.0f); BoundingRectangle.Max = new Vector3(w.BoundingRectangle.Max.X, w.BoundingRectangle.Min.Y, 0.0f); texRect.Location = new Point((int)BoundingRectangle.Min.X, (int)BoundingRectangle.Min.Y); } } else if (w.Type == Waypoint.WaypointType.Lift) { if (BoundingRectangle.Intersects(w.BoundingRectangle)) { ridingVehicle = true; BoundingRectangle.Min = new Vector3(w.BoundingRectangle.Min.X, w.BoundingRectangle.Min.Y - 80, 0.0f); BoundingRectangle.Max = new Vector3(w.BoundingRectangle.Max.X, w.BoundingRectangle.Min.Y, 0.0f); texRect.Location = new Point((int)BoundingRectangle.Min.X, (int)BoundingRectangle.Min.Y); } } }
/// <summary> /// Handle all waypoint events, using the supplied waypoint data /// </summary> /// <param name="w">The waypoint that generated the event</param> public void handleEvent(Waypoint w) { if (w.Type == Waypoint.WaypointType.SavePoint) { if (player.BoundingRectangle.Intersects(w.BoundingRectangle)) { Point oldSpawn = spawn; Vector2 pos = new Vector2(((float)oldSpawn.X * 60.0f), (float)(oldSpawn.Y * 40.0f)); tiles[oldSpawn.X][oldSpawn.Y] = new Tile(pos, Tile.TileType.Air, 0.0f); spawn = new Point((int)w.TileCoords.X, (int)w.TileCoords.Y); // overwrite the waypoint with the player tile to set the new spawn point tiles[spawn.X / 60][spawn.Y / 40] = new Tile(new Vector2((float)spawn.X / 60.0f, (float)spawn.Y / 40.0f), Tile.TileType.Player, 0.0f); } } else if (w.Type == Waypoint.WaypointType.EndLevel) { if (player.BoundingRectangle.Intersects(w.BoundingRectangle)) nextLevel(); } }
public void handleEvent(Waypoint w) { if (w.Type == Waypoint.WaypointType.EndRide) { if (BoundingRectangle.Intersects(w.BoundingRectangle)) { if (player.ridingVehicle) { if (this.Type == VehicleType.Lift) { player.ridingVehicle = false; } else { player.ridingVehicle = false; player.BoundingRectangle.Min = new Vector3(w.TileCoords.X + 60, w.TileCoords.Y - 40, 0.0f); player.BoundingRectangle.Max = new Vector3(player.BoundingRectangle.Min.X + 60, player.BoundingRectangle.Min.Y + 80, 0.0f); player.texRect.Location = new Point((int)player.BoundingRectangle.Min.X, (int)player.BoundingRectangle.Min.Y); } } } } }