-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSuperheroTasks.cs
More file actions
53 lines (45 loc) · 1.5 KB
/
SuperheroTasks.cs
File metadata and controls
53 lines (45 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
namespace SuperheroPlugin;
public static class SuperheroTasks
{
public static void printLevelToAllPlayers(Dictionary<IntPtr, SuperheroPlayer> shPlayers)
{
foreach (var player in shPlayers)
{
if (player.Value == null) { continue; }
SuperheroTasks.printLevel(player.Value);
}
}
public static void activatePlayerOnRoundStartAbilities(Dictionary<IntPtr, SuperheroPlayer> shPlayers)
{
Task.Run(() =>
{
foreach (var shPlayer in shPlayers)
{
if (shPlayer.Value == null || shPlayer.Value.Player == null) { continue; }
shPlayer.Value.activateRoundStartAbilities();
}
});
}
public static void printLevel(SuperheroPlayer shPlayer, int firstDelay=2000)
{
if (shPlayer == null || shPlayer.Player == null) { return; }
Task.Run(async () =>
{
await Task.Delay(firstDelay);
var timer = new System.Timers.Timer();
timer.Start();
timer.Interval = 500;
timer.Elapsed += (sender, e) =>
{
shPlayer.Player.PrintToCenter(
StringResources.LevelStatsMessage(
shPlayer.currentLevel, shPlayer.currentXp,
shPlayer.levelUpXp, shPlayer.availableAbilityPoints)
);
};
await Task.Delay(12000);
timer.Stop();
timer.Dispose();
});
}
}