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 MapGeneratorEngine( HexGrid mapManager, IEntityFactory entityFactory, PrefabsDictionary prefabsDictionary) { _mapManager = mapManager; //_entityFactory = entityFactory; //_prefabsDictionary = prefabsDictionary; GenerateMap(); }
private void BuildTurnEntity() { var prefabsDictionary = new PrefabsDictionary(); var currentTurn = prefabsDictionary.Instantiate("Current Turn"); var currentTurnImpl = currentTurn.GetComponent <TurnImpl>(); entityFactory.BuildEntity <TurnED>(currentTurn.GetInstanceID(), currentTurn.GetComponents <IImplementor>()); currentTurnImpl.PlayerColor = PlayerColor.BLACK; }
private void BuildTurnEntity() { var prefabsDictionary = new PrefabsDictionary(); var currentTurn = prefabsDictionary.Instantiate("Current Turn"); var currentTurnImpl = currentTurn.GetComponent <TurnImpl>(); entityFactory.BuildEntity <TurnED>(currentTurn.GetInstanceID(), currentTurn.GetComponents <IImplementor>()); currentTurnImpl.PlayerColor = PlayerColor.BLACK; currentTurnImpl.IsInitialArrangementInEffect = true; // TODO Later set based on reading from save game file or new game option }
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()); }
public HandPieceCreateService(IEntityFactory entityFactory) { this.entityFactory = entityFactory; prefabsDictionary = new PrefabsDictionary(); }
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); }