/// <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));
 }
Exemplo n.º 2
0
    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);
    }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
    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);
    }
Exemplo n.º 5
0
    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;
    }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
    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);
    }