Initial Commit
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
||||
using ModestTree;
|
||||
|
||||
namespace Zenject.Asteroids
|
||||
{
|
||||
public enum ShipStates
|
||||
{
|
||||
Moving,
|
||||
Dead,
|
||||
WaitingToStart,
|
||||
Count
|
||||
}
|
||||
|
||||
public class ShipStateFactory
|
||||
{
|
||||
readonly ShipStateWaitingToStart.Factory _waitingFactory;
|
||||
readonly ShipStateMoving.Factory _movingFactory;
|
||||
readonly ShipStateDead.Factory _deadFactory;
|
||||
|
||||
public ShipStateFactory(
|
||||
ShipStateDead.Factory deadFactory,
|
||||
ShipStateMoving.Factory movingFactory,
|
||||
ShipStateWaitingToStart.Factory waitingFactory)
|
||||
{
|
||||
_waitingFactory = waitingFactory;
|
||||
_movingFactory = movingFactory;
|
||||
_deadFactory = deadFactory;
|
||||
}
|
||||
|
||||
public ShipState CreateState(ShipStates state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case ShipStates.Dead:
|
||||
{
|
||||
return _deadFactory.Create();
|
||||
}
|
||||
case ShipStates.WaitingToStart:
|
||||
{
|
||||
return _waitingFactory.Create();
|
||||
}
|
||||
case ShipStates.Moving:
|
||||
{
|
||||
return _movingFactory.Create();
|
||||
}
|
||||
}
|
||||
|
||||
throw Assert.CreateException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user