/// <summary> /// Creates a new AiEntityManager from the provided WorldEntity and IMapManager instances. /// </summary> /// <param name="entity">The WorldEntity the created AiEntityManager will control.</param> /// <param name="mapManager">The MapManager for the map that the WorldEntity the AiEntityManager controls exists in.</param> /// <param name="mapBattleManager">The MapBattleManager for the map that the WorldEntity the AiEntityManager controls /// exists in.</param> /// <param name="spawnEntityData">An object containing spawn data for the type of WorldEntity the created manager controls.</param> /// <returns></returns> public AiEntityManager Create(WorldEntity entity, IMapManager mapManager, IMapBattleManager mapBattleManager, SpawnEntityData spawnEntityData) { return(new AiEntityManager(entity, mapManager, mapBattleManager, spawnEntityData)); }
public void CreateGrenade(Point startPos, Point target, List <Point> range) { var spawn = new SpawnEntityData(); spawn.PrefabName = "Grenade"; spawn.InitialComponents.Add(new ExplodableComponent(startPos, target, range)); Game.I.EntityManager.CreateEntity(spawn); }
/// <summary> /// Spawns a new WorldEntity and creates a new AiEntityManager to control it. Returns the AiEntityManager. /// </summary> /// <param name="spawnData">Contains data used to create the spawn WorldEntity.</param> /// <returns></returns> private AiEntityManager SpawnEntity(SpawnEntityData spawnData) { var spawnedEntity = _worldEntityFactory.Create(spawnData.FormationTemplate); var manager = _aiEntityManagerFactory.Create(spawnedEntity, _mapManager, _mapBattleManager, spawnData); manager.RemovedFromMap += OnEntityRemovedFromMap; _managers.Add(manager); return(manager); }
private SpawnEntityData CreateCover(Point point) { var spawn = new SpawnEntityData { PrefabName = "Cover" }; spawn.InitialComponents.Add(new MovementComponent(point, OnMapType.Cover)); spawn.InitialComponents.Add(new HealthComponent(1)); return(spawn); }
public void CreateEntity(SpawnEntityData data) { var playerPrefab = ResourceManager.Instance.GetEntity(data.PrefabName); var entity = Instantiate(playerPrefab, _parent); _entities.Add(_idCounter, entity); entity.Init(_idCounter); foreach (var comp in data.InitialComponents) { entity.AddComponent(comp); } ++_idCounter; }
public AiEntityManager(WorldEntity entity, IMapManager mapManager, IMapBattleManager mapBattleManager, SpawnEntityData spawnEntityData) { _entity = entity; _mapManager = mapManager; _mapBattleManager = mapBattleManager; _spawnEntityData = spawnEntityData; _rand = new Random(); _mapBattleManager.OnCreatedBattle += OnCreatedBattle; AddToMap(); }
private SpawnEntityData CreateCharacter(PlayerType owner, OperativeType operative, Weapon weapon, Point point) { var spawn = new SpawnEntityData(); var maxHealth = 1; var mapType = owner == PlayerType.Player1 ? OnMapType.Player1 : OnMapType.Player2; spawn.PrefabName = "CharacterBase"; spawn.InitialComponents.Add(new OperativeInfoComponent(owner, operative)); spawn.InitialComponents.Add(new MovementComponent(point, mapType)); spawn.InitialComponents.Add(new ShootComponent(weapon)); spawn.InitialComponents.Add(new HealthComponent(maxHealth)); spawn.InitialComponents.Add(new CharacterActionComponent()); spawn.InitialComponents.Add(new GrenadeThrowComponent()); return(spawn); }