-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStrategyStateManager.cs
52 lines (44 loc) · 1.97 KB
/
StrategyStateManager.cs
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
using System;
using System.Collections.Generic;
namespace Com.CodeGame.CodeWizards2016.DevKit.CSharpCgdk.Model
{
public static class StrategyStateManager
{
private enum StrategyStates
{
None,
Prepare,
Game
}
private static Dictionary<StrategyStates, IStrategyState> strategyStates = new Dictionary<StrategyStates, IStrategyState>(5)
{
{ StrategyStates.None, new StrategyState() },
{ StrategyStates.Prepare, new StrategyStatePrepare() },
{ StrategyStates.Game, new StrategyStateGame() },
};
public static IStrategyState GetState(World world, Wizard self)
{
/* Основная логика игры */
StrategyStates strategyState = StrategyStates.Game;
if (self.Life == 0)
{
/* Жизней 0 - мертв */
strategyState = StrategyStates.None;
}
else if (StrategyStorage.prepareTick < StrategyStorage.waitTimer)
{
strategyState = StrategyStates.Prepare;
}
else if (StrategyStorage.prevLife == 0 && self.Life > 0)
{
StrategyHelper.Log(String.Format("RESPAWN, tick {0}", world.TickIndex));
int enemyCount = StrategyHelper.CountEnemyInCastRange(world, self);
StrategyStorage.priorityLane = null;
strategyState = enemyCount == 0 ? StrategyStates.Prepare : StrategyStates.Game;
StrategyHelper.Log(String.Format("\tEnemyCount: {0}, work strategy: {1}", Enum.GetName(typeof(StrategyStates), strategyState)));
}
StrategyHelper.Log(String.Format("strategy {0}, tick: {1}", Enum.GetName(typeof(StrategyStates), strategyState).ToUpper(), world.TickIndex));
return StrategyStateManager.strategyStates[strategyState];
}
}
}