Dynamic Events

How to: get and print a list of event names

using GW2NET;
var service = GW2.V1.EventNames.ForDefaultCulture();
var dynamicEvents = service.FindAll();
foreach (var dynamicEvent in dynamicEvents.Values)
{
	Console.WriteLine("Event ID: {0}", dynamicEvent.EventId);
	Console.WriteLine("Event Name: {0}", dynamicEvent.Name);
}

How to: get and print a list of event details

using GW2NET;
using GW2NET.DynamicEvents;
var service = GW2.V1.Events.ForDefaultCulture();
var dynamicEvents = service.FindAll();
foreach (var dynamicEvent in dynamicEvents.Values)
{
	Console.WriteLine("Event ID: {0}", dynamicEvent.EventId);
	Console.WriteLine("Event Name: {0}", dynamicEvent.Name);
	Console.WriteLine("Event Level: {0}", dynamicEvent.Level);
	Console.WriteLine("Event Map ID: {0}", dynamicEvent.MapId);
	Console.WriteLine("Event Flags: {0}", dynamicEvent.Flags);
	Console.WriteLine("Event Location Center: {0}", dynamicEvent.Location.Center);

	if (dynamicEvent.Location is SphereLocation)
	{
		var sphereLocation = (SphereLocation)dynamicEvent.Location;
		Console.WriteLine("Event Location Radius: {0}", sphereLocation.Radius);
		Console.WriteLine("Event Location Rotation: {0}", sphereLocation.Rotation);
	}
	else if (dynamicEvent.Location is CylinderLocation)
	{
		var cylinderLocation = (CylinderLocation)dynamicEvent.Location;
		Console.WriteLine("Event Location Height: {0}", cylinderLocation.Height);
		Console.WriteLine("Event Location Radius: {0}", cylinderLocation.Radius);
		Console.WriteLine("Event Location Rotation: {0}", cylinderLocation.Rotation);
	}
	else if (dynamicEvent.Location is PolygonLocation)
	{
		var polygonLocation = (PolygonLocation)dynamicEvent.Location;
		Console.WriteLine("Event Location Z-Range: {0}", polygonLocation.ZRange);
		Console.WriteLine("Event Location Points: {0}", polygonLocation.Points);
	}
}

How to: get and print a list of world boss rotations

Rotations grouped by event

using GW2NET;
var service = GW2.Local.EventRotations;
var rotations = service.GetDynamicEventRotations();
foreach (var rotation in rotations.Values)
{
	Console.WriteLine(rotation.EventId);
	foreach (var shift in rotation.Shifts)
	{
		Console.WriteLine("{0,20}", shift.LocalDateTime.TimeOfDay);
	}
}

Rotations grouped by start time

using GW2NET;
var service = GW2.Local.EventRotations;
var rotations = service.GetDynamicEventRotations();
var rotationsByStartTime = from rotation in rotations.Values
                            from shift in rotation.Shifts
                            group rotation by shift into rotationsByShift
                            orderby rotationsByShift.Key.LocalDateTime
                            select rotationsByShift;
foreach (var rotation in rotationsByStartTime)
{
    Console.WriteLine(rotation.Key.LocalDateTime.TimeOfDay);
    foreach (var dynamicEvent in rotation)
    {
        Console.WriteLine("{0,40}", dynamicEvent.EventId);
    }
}

Last edited Feb 7, 2015 at 10:55 AM by StevenLiekens, version 7