public UnitSpawnerEngine(PrefabsDictionary prefabsDictionary, IEntityFactory entityFactory, HexGrid mapManager) { _prefabsDictionary = prefabsDictionary; _entityFactory = entityFactory; _mapManager = mapManager; var cells = _mapManager.GetCells(); for (int i = 0; i < 2; i++) { int random; do { random = Random.Range(0, cells.Count); } while (cells[random].IsUnderwater); var coord = cells[random].coordinates; var go = _prefabsDictionary.Istantiate("testUnit"); var implementors = new List <IImplementor>(); go.GetComponentsInChildren(implementors); implementors.Add(new UnitCoordinatesImplementor(coord.X, coord.Z)); _entityFactory.BuildEntityInGroup <PlayerEntityDescriptor>( go.GetInstanceID(), 1, implementors.ToArray()); BuildAbilities("FireBolt", go.GetInstanceID()); if (i == 1) { BuildAbilities("IcePunch", go.GetInstanceID()); } } }
public BattleInitEngine(IEntityFunctions entityFunctions, PrefabsDictionary prefabsDictionary, IEntityFactory entityFactory) { _entityFunctions = entityFunctions; _prefabsDictionary = prefabsDictionary; _entityFactory = entityFactory; var go = _prefabsDictionary.Istantiate("BattleEntity"); var implementors = new List <IImplementor> { new BattleImplementor() }; _entityFactory.BuildEntity <BattleEntityDescriptor>( go.GetInstanceID(), implementors.ToArray()); }
void SetupEnginesAndEntities() { _enginesRoot = new EnginesRoot(new UnitySumbmissionEntityViewScheduler()); _entityFactory = _enginesRoot.GenerateEntityFactory(); _prefabsDictionary = new PrefabsDictionary(Application.persistentDataPath + "/prefabs.json"); var entityFunctions = _enginesRoot.GenerateEntityFunctions(); //GameObjectFactory factory = new GameObjectFactory(); _mapManager = GameObject.FindGameObjectWithTag("HexGrid").GetComponent <HexGrid>(); _uiService = _prefabsDictionary.Istantiate("UI Service").GetComponent <UIService>(); Sequencer battleTurnSequence = new Sequencer(); Sequencer abilityUsedSequence = new Sequencer(); ITime time = new Time(); MapGeneratorEngine mapGeneratorEngine = new MapGeneratorEngine(_mapManager, _entityFactory, _prefabsDictionary); UnitSpawnerEngine unitSpawnerEngine = new UnitSpawnerEngine(_prefabsDictionary, _entityFactory, _mapManager); PlayerInputEngine playerInputEngine = new PlayerInputEngine(_mapManager); BattleInitEngine battleInitEngine = new BattleInitEngine(entityFunctions, _prefabsDictionary, _entityFactory); TurnOrderEngine turnOrderEngine = new TurnOrderEngine(battleTurnSequence, _uiService); UnitTurnActionEngine unitTurnActionEngine = new UnitTurnActionEngine(battleTurnSequence); UnitMovementEngine unitMovementEngine = new UnitMovementEngine(_mapManager); UnitHighlightEngine unitHighlightEngine = new UnitHighlightEngine(_mapManager); BattleHudEngine battleHudEngine = new BattleHudEngine(_uiService); HealthEngine healthEngine = new HealthEngine(); AbilitySelectionEngine abilitySelectionEngine = new AbilitySelectionEngine(_uiService, abilityUsedSequence, _mapManager); AbilityTargetEngine abilityTargetEngine = new AbilityTargetEngine(); battleTurnSequence.SetSequence( new Steps { { turnOrderEngine, new To { unitTurnActionEngine, } }, { unitTurnActionEngine, new To { { TurnCondition.starting, new IStep[] { playerInputEngine, battleHudEngine } }, { TurnCondition.ending, new IStep[] { playerInputEngine, battleHudEngine, turnOrderEngine } } } }, } ); abilityUsedSequence.SetSequence( new Steps { { abilitySelectionEngine, new To { { new IStep[] { abilityTargetEngine } }, } } } ); AddEngine(mapGeneratorEngine); AddEngine(unitSpawnerEngine); AddEngine(playerInputEngine); AddEngine(battleInitEngine); AddEngine(turnOrderEngine); AddEngine(unitTurnActionEngine); AddEngine(unitMovementEngine); AddEngine(unitHighlightEngine); AddEngine(new CameraFollowTargetEngine(time)); AddEngine(battleHudEngine); AddEngine(healthEngine); AddEngine(abilitySelectionEngine); AddEngine(abilityTargetEngine); }