public void SpawnEnemiesOnTileLocation(Tile tile, TileType tileType)
    {
        if (_sceneController.GetActiveSceneIndex() == (int)SceneIndex.Village)
        {
            //Debug.Log("Looks like enemies spawning is not supported yet on the village map");
        }
        else
        {
            if (tileType == TileType.enemySpawner)
            {
                Vector3 position = new Vector3(tile.PositionInMap.x, tile.PositionInMap.y, 0);

                Enemy enemy;

                if (RoomBuilder.CurrentLoadedReadingMap.RoomType == RoomType.Boss)
                {
                    enemy = _enemyFactory.CreateEnemy(position, GameManager, EnemyType.Boss);
                }
                else
                {
                    enemy = _enemyFactory.CreateEnemy(position, GameManager, EnemyType.Regular);
                }

                TrashController.EnemiesInTheRoom.Add(enemy.gameObject);
            }
        }
    }
Пример #2
0
        private void Inject()
        {
            // Services
            ImpactService impactService = new ImpactService();

            // Groupal controller
            PortalsController  portalsController = new PortalsController();
            PortalUICollection portalUIList      = new PortalUICollection();

            portalsController.SetPortalRemoveListener(portalUIList);

            // Factories
            PlayerFactory playerFactory = new PlayerFactory(portalsController, portalsController, impactService, portalUIList);
            EnemyFactory  enemyFactory  = new EnemyFactory(impactService);
            PortalFactory portalFactory = new PortalFactory(portalsController, portalUIList);

            // References
            PlayerUI playerUI  = GameObject.Find("/Player").GetComponent <PlayerUI>();
            EnemyUI  enemyUI1  = GameObject.Find("/Enemies/Enemy1").GetComponent <EnemyUI>();
            EnemyUI  enemyUI2  = GameObject.Find("/Enemies/Enemy2").GetComponent <EnemyUI>();
            PortalUI portalUI1 = GameObject.Find("/Portals/Portal1").GetComponent <PortalUI>();
            PortalUI portalUI2 = GameObject.Find("/Portals/Portal2").GetComponent <PortalUI>();
            PortalUI portalUI3 = GameObject.Find("/Portals/Portal3").GetComponent <PortalUI>();

            // Injection
            playerFactory.CreatePlayer(playerUI);
            enemyFactory.CreateEnemy(enemyUI1);
            enemyFactory.CreateEnemy(enemyUI2);
            portalFactory.CreatePortal(portalUI1);
            portalFactory.CreatePortal(portalUI2);
            portalFactory.CreatePortal(portalUI3);
        }
Пример #3
0
        public void Start()
        {
            var gameState = new GameState();

            gameState.Player = _playerFactory.CreatePlayer("Bungus", new GamePosition(5, 5, 1, Layer.Blocking));

            var level = _levelFactory.GenerateLevel(1);

            level.AddLevelElement(gameState.Player);

            var testItem1 = _itemFactory.CreateItem("katana", new GamePosition(7, 7, 1, Layer.OnFloor));
            var testItem2 = _itemFactory.CreateItem("katana", new GamePosition(4, 9, 1, Layer.OnFloor));

            level.AddLevelElement(testItem1, Level.AddStyle.Stack);
            level.AddLevelElement(testItem2, Level.AddStyle.Stack);

            var enemy = _enemyFactory.CreateEnemy("Mook", new GamePosition(10, 7, 1, Layer.Blocking), gameState);

            level.AddLevelElement(enemy);

            gameState.Levels[1]    = level;
            gameState.CurrentLevel = level;

            var mainScreen = _screenFactory.GetMainScreen(gameState);

            gameState.CurrentScreen = mainScreen;

            _renderController.Initialise(gameState);

            _eventBus.RegisterEvent("WELCOME");

            Loop(gameState);
        }
Пример #4
0
        public void Execute()
        {
            var enemy  = EnemyFactory.CreateEnemy(player);
            var battle = new Battle(player, enemy);

            battle.BeginBattle();
        }
Пример #5
0
    private static Data D4()
    {
        // 場所替えで敵と位置を入れ替わって階段に向かう
        const string map = @"
...~...~...
...~...~...
...~...~...
...~...~...
...~...~...
";

        var fobjs     = new List <FieldObject>();
        var stairsLoc = new Loc(2, 10);

        var playerLoc = new Loc(2, 1);

        var fitems = new List <FieldItem>();

        // 場所替えの杖
        fitems.Add(FieldItemFactory.CreateWand(new Loc(2, 2), 0));

        var enemies = new List <Enemy>();

        enemies.Add(EnemyFactory.CreateEnemy(new Loc(2, 4)));
        enemies.Add(EnemyFactory.CreateEnemy(new Loc(2, 8)));

        foreach (var e in enemies)
        {
            e.ChangeDir(Dir.W);
        }
        return(new Data(map, stairsLoc, playerLoc, fobjs, fitems, enemies));
    }
Пример #6
0
    // ------ フロアデータ

    private static Data D1_0()
    {
        const string map = TestMap;

        var stairsLoc = new Loc(4, 3);
        var playerLoc = new Loc(5, 3);

        var fobjs = new List <FieldObject>();

        fobjs.Add(FieldObjectFactory.CreateTrapHeal(new Loc(6, 6)));

        var fitems = new List <FieldItem>();

        fitems.Add(FieldItemFactory.CreateMagic(new Loc(6, 3), 4));  // 水がれ
        fitems.Add(FieldItemFactory.CreateMagic(new Loc(12, 3), 4)); // 水がれ
        fitems.Add(FieldItemFactory.CreateHerb(new Loc(6, 4), 1));   // 睡眠草
        fitems.Add(FieldItemFactory.CreateHerb(new Loc(6, 5), 4));   // 目薬草


        var enemies = new List <Enemy>();

        enemies.Add(EnemyFactory.CreateEnemy(new Loc(5, 5)));
        enemies.Last().AddStatus(StatusType.Sleep);

        return(new Data(map, stairsLoc, playerLoc, fobjs, fitems, enemies));
    }
Пример #7
0
        public void LoadEnemies(string map)
        {
            var enemyFactory = new EnemyFactory();
            this.enemyList = new List<Enemy>();
            StreamReader reader = new StreamReader(@"..\..\Resources\Maps\ShadowMountains\EnemiesLocation\" + map + ".txt");
            string[] enemySprites = new string[3];
            enemySprites[0] = "None";
            enemySprites[1] = "Bandit";
            enemySprites[2] = "Gargoyle";

            int y = 0;

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();

                for (int x = 0; x < line.Length; x++)
                {
                    int lineX = line[x] - '0';
                    Enemy enemy = enemyFactory.CreateEnemy(enemySprites[lineX], new Position(x*40,y*40));
                    if(enemy != null)
                    {
                        this.enemyList.Add(enemy);
                    }
                }

                y++;
            }

            reader.Close();
        }
Пример #8
0
    private void HandleLife()
    {
        bool allEnemiesOutsidePlayerVision = true;

        for (int i = enemies.Count - 1; i >= 0; --i)
        {
            if (enemies[i] != null)
            {
                //IF VISIBLE BY PLAYER
                if (Vector2.Distance(enemies[i].transform.position, player.transform.position) < MapLoader.grassAppearRadius)
                {
                    isAreaActive = true;
                    allEnemiesOutsidePlayerVision = false;
                }

                //IF OUTSIDE SPAWN RADIUS
                if (Vector2.Distance(enemies[i].transform.position, transform.position) > spawnRadius)
                {
                    //change direction of ones that are outside area range
                    if (enemies[i].activity == AEnemy.E_ACTIVITY.IDLE)
                    {
                        enemies[i].moveDir = (transform.position - enemies[i].transform.position).normalized;
                        //rotate only ones that need to be rotated
                        if (enemies[i].canBeRotated)
                        {
                            float rotationAngle = Global.GetAngle(Vector2.right, enemies[i].moveDir);
                            enemies[i].transform.eulerAngles = new Vector3(0, 0, rotationAngle);
                        }
                    }
                }
            }

            //remove death ones or one that are dying(dying ones will not bbe part of the area anymore)
            if (enemies[i] == null || enemies[i].isDying)
            {
                enemies.Remove(enemies[i]);
            }
        }

        //Disable area if all enemies are inside spawn range and if they're not visible by player
        if (allEnemiesOutsidePlayerVision && Vector2.Distance(transform.position, player.transform.position) > spawnPlusExtraRadius)
        {
            isAreaActive = false;
            if (ChangeAreaOpacity(4f) <= 0)
            {
                MapLoader.refrence.DisableEnemyArea(gameObject);
            }
        }

        //if far enough, spawn new ones
        if (Vector2.Distance(transform.position, player.transform.position) > spawnPlusExtraRadius)
        {
            while (enemies.Count < numOfEnemies)
            {
                //create new enemy
                Vector2 startPos = new Vector2(transform.position.x + Random.Range(-spawnRadius, spawnRadius), transform.position.y + Random.Range(-spawnRadius, spawnRadius));
                enemies.Add(EnemyFactory.CreateEnemy(id, startPos).GetComponent <AEnemy>());
            }
        }
    }
Пример #9
0
    private static Data D5()
    {
        // かなしばりで敵の進行をふさぐ
        const string map = @"
.......
.~~.~~.
.~...~.
.~...~.
.~~~~~.
.......
";

        var fobjs     = new List <FieldObject>();
        var stairsLoc = new Loc(0, 3);

        var playerLoc = new Loc(5, 3);

        var fitems = new List <FieldItem>();

        // かなしばりの杖
        fitems.Add(FieldItemFactory.CreateWand(new Loc(5, 5), 4));

        var enemies = new List <Enemy>();

        enemies.Add(EnemyFactory.CreateEnemy(new Loc(3, 2)));
        enemies.Add(EnemyFactory.CreateEnemy(new Loc(3, 3)));
        enemies.Add(EnemyFactory.CreateEnemy(new Loc(3, 4)));
        return(new Data(map, stairsLoc, playerLoc, fobjs, fitems, enemies));
    }
Пример #10
0
/*
 *  private static Data D9() {
 *      // ふきとばし。場所替え
 *      const string map = @"
 * .....
 * .....
 * ..~..
 * .....
 * .....
 * .....
 +
 +    ......
 +++++......
 +     ......
 + ";
 +
 +      var stairsLoc = new Loc(4, 14);
 +      var playerLoc = new Loc(1, 2);
 +
 +      var fobjs = new List<FieldObject>();
 +
 +      var fitems = new List<FieldItem>();
 +      //fitems.Add(FieldItemFactory.CreateHerb(new Loc(5, 4), 4));
 +
 +      var enemies = new List<Enemy>();
 +      enemies.Add(EnemyFactory.CreateEnemy(new Loc(4, 2)));
 +
 +
 +      return new Data(map, stairsLoc, playerLoc, fobjs, fitems, enemies);
 +  }
 */

    private static Data D9()
    {
        // TODO: 上下左右いずれの方向に進んでも全ての敵が回りにくるロジック
        // ふきとばし。場所替え
        // とびつきで
        const string map = @"
........
........
........
.~~~~~~.
.~....~.
.~....~.
.~....~.
.~~~~~~.
........
";

        var stairsLoc = new Loc(5, 4);
        var playerLoc = new Loc(0, 3);

        var fobjs = new List <FieldObject>();

        fobjs.Add(FieldObjectFactory.CreateNoticeBoard(new Loc(5, 3), "ゲームクリアです!! \n\n階段を降りると\n1Fに戻ります。"));

        var fitems = new List <FieldItem>();

        fitems.Add(FieldItemFactory.CreateWand(new Loc(2, 3), 1));
        fitems.Add(FieldItemFactory.CreateWand(new Loc(2, 4), 2));

        var enemies = new List <Enemy>();

        enemies.Add(EnemyFactory.CreateEnemy(new Loc(6, 5)));

        return(new Data(map, stairsLoc, playerLoc, fobjs, fitems, enemies));
    }
Пример #11
0
    private static Data D3()
    {
        // いかずちの杖を振って敵を倒す。
        // 2 体いる。使用回数は 1 回
        const string map = @"
....~...
....~.~.
....~.~.
....~.~~
........
";

        var fobjs     = new List <FieldObject>();
        var stairsLoc = new Loc(2, 7);

        var playerLoc = new Loc(2, 1);

        var fitems = new List <FieldItem>();

        // いかずちの杖
        fitems.Add(FieldItemFactory.CreateWand(new Loc(3, 1), 3));

        var enemies = new List <Enemy>();

        enemies.Add(EnemyFactory.CreateEnemy(new Loc(2, 5)));
        enemies.Add(EnemyFactory.CreateEnemy(new Loc(1, 1)));

        return(new Data(map, stairsLoc, playerLoc, fobjs, fitems, enemies));
    }
Пример #12
0
        public void LoadEnemies(string map)
        {
            var enemyFactory = new EnemyFactory();

            this.enemyList = new List <Enemy>();
            StreamReader reader = new StreamReader(@"..\..\Resources\Maps\ShadowMountains\EnemiesLocation\" + map + ".txt");

            string[] enemySprites = new string[3];
            enemySprites[0] = "None";
            enemySprites[1] = "Bandit";
            enemySprites[2] = "Gargoyle";

            int y = 0;

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();

                for (int x = 0; x < line.Length; x++)
                {
                    int   lineX = line[x] - '0';
                    Enemy enemy = enemyFactory.CreateEnemy(enemySprites[lineX], new Position(x * 40, y * 40));
                    if (enemy != null)
                    {
                        this.enemyList.Add(enemy);
                    }
                }

                y++;
            }

            reader.Close();
        }
Пример #13
0
        public Enemy GetEnemy()
        {
            // If the list is empty return null
            if (!EnemiesHere.Any())
            {
                return(null);
            }

            // Add up encounter chance of every enemy in the locations
            int totalChance = EnemiesHere.Sum(e => e.EncounterChance);

            // Select random number from 1 to total encounter chance based off all enemies in location
            int random = RNG.Generator(1, totalChance);

            int runningTotal = 0;

            // Get to understand this more...
            foreach (EnemyEncounter enemyEncounter in EnemiesHere)
            {
                runningTotal += enemyEncounter.EncounterChance;
                if (random <= runningTotal)
                {
                    return(EnemyFactory.CreateEnemy(enemyEncounter.EnemyID));
                }
            }

            // If ID couldn't be found, return the last correct ID
            return(EnemyFactory.CreateEnemy(EnemiesHere.Last().EnemyID));
        }
Пример #14
0
    public void Spawn(GameObject enemy)
    {
        transformNumber = Random.Range(0, TransformList.Length - 1);
        GameObject SpawnEnemy = Factory.CreateEnemy();

        SpawnEnemy.transform.position = TransformList[transformNumber].transform.position;
        EnemyList.Add(SpawnEnemy);
    }
Пример #15
0
 private void InitializeLevel()
 {
     aliveEnemies.ForEach(enemy => enemyFactory.Remove(enemy));
     aliveEnemies.Clear();
     for (int i = 0; i < horizontalAmount; i++)
     {
         for (int j = 0; j < enemyToFloor.Count; j++)
         {
             string              enemyTypeOnLevel = enemyToFloor.Find(floorSetting => floorSetting.level == j).enemyName;
             Vector2             position         = gameStateManager.PositionForEnemy(i, j);
             EnemyShipController enemyShip        = enemyFactory.CreateEnemy(enemyTypeOnLevel, position);
             enemyShip.RegisterObserver(this);
             aliveEnemies.Add(enemyShip);
         }
     }
     currentDirection = 1;
     InvokeRepeating("SpawnSpecialEnemy", timeToSpecialEnemyAppears, timeToSpecialEnemyAppears);
 }
Пример #16
0
        private void AddSpawn(int id, float spawnDelay)
        {
            Enemy en = SpawnFactory.CreateEnemy(id, spawnDelay);

            Spawns.AddEnemy(en);

            UpdateEnemyList();
            UpdateTextboxesValues();
        }
Пример #17
0
        public void ShouldCreateNormalEnemy_SimpleExample()
        {
            var sut = new EnemyFactory();

            object enemy = sut.CreateEnemy(false);

            NormalEnemy normalEnemy = Assert.IsType <NormalEnemy>(enemy);

            Assert.Equal(10, normalEnemy.Power);
        }
Пример #18
0
 private void SpawnEnemies()
 {
     for (int i = 0; i < numOfEnemies; ++i)
     {
         Vector2 startPos = new Vector2(transform.position.x + Random.Range(-spawnRadius, spawnRadius), transform.position.y + Random.Range(-spawnRadius, spawnRadius));
         AEnemy  newEnemy = EnemyFactory.CreateEnemy(id, startPos).GetComponent <AEnemy>();
         newEnemy.transform.SetParent(gameObject.transform);
         enemies.Add(newEnemy);
     }
 }
Пример #19
0
    private Enemy MakeEnemy(Loc loc, int sleepDepth)
    {
        var e = EnemyFactory.CreateEnemy(loc);

        if (sleepDepth > 0)
        {
            e.AddStatus(StatusType.Sleep, sleepDepth);
        }
        return(e);
    }
Пример #20
0
    public IEnumerator Summon(Loc loc)
    {
        // TODO: assert(loc に敵がいない)
        var e = EnemyFactory.CreateEnemy(loc);

        _enemies.Add(e);

        yield return(Anim.Par(this,
                              () => e.FadeIn(),
                              () => EffectAnim.Aura2(e.Position)));
    }
        private void InitializeEnemies()
        {
            IList <Type> enemiesAssembly = Assembly.GetAssembly(typeof(Enemy)).GetTypes()
                                           .Where(t => t.Namespace == QuestReaderConstants.EnemiesNamespace && !t.IsAbstract)
                                           .ToList();

            for (int i = 0; i < enemiesAssembly.Count; i++)
            {
                Enemies enemyEnumType = (Enemies)Enum.Parse(typeof(Enemies), enemiesAssembly[i].Name);
                this.enemies.Add(EnemyFactory.CreateEnemy(enemyEnumType, i + 1));
            }
        }
Пример #22
0
 private void Update()
 {
     time -= Time.deltaTime;
     if (time < 0)
     {
         random = Random.Range(0, 5);
         if (enemy[random].activeSelf == false)
         {
             create.CreateEnemy(enemy[random]);
         }
         time = 2.0f;
     }
 }
Пример #23
0
        protected void SpawnNextWave()
        {
            CurrentWave++;
            (from enemySpawnData in EnemySpawns.Dequeue() select EnemyFactory.CreateEnemy(enemySpawnData, -1, CurrentRegion)).ToList().ForEach(enemy =>
            {
                Enemies.Add(enemy);
            });

            AllEnemiesCount = (uint)Enemies.Count;
            if (AllEnemiesCount == 0 && EnemySpawns.Count == 0 && ActivityStatus != ActivityStatus.Completed)
            {
                ChangeStatus(ActivityStatus.Completed);
            }
        }
    // Update is called once per frame
    void Update()
    {
        enemiesInGame = GameObject.FindGameObjectsWithTag("Enemy");

        if (Time.time > nextFire && enemiesInGame.Length <= 5)
        {
            Debug.Log("exp");
            nextFire = Time.time + firerate;
            type     = "ExplodingEnemy";
            enemy    = factory.CreateEnemy(type);

            enemy.transform.position = transform.position;
        }

        if (Time.time > nextFire && enemiesInGame.Length <= 5)
        {
            Debug.Log("heavy");
            nextFire = Time.time + firerate;
            type     = "HeavyEnemy";
            enemy    = factory.CreateEnemy(type);

            enemy.transform.position = transform.position;
        }
    }
Пример #25
0
    public void InitializeBattle(EnemyFactory.EnemyType typ)
    {
        GameObject playerObj = (GameObject)Instantiate(Resources.Load("Prefabs/BattleSprite"));

        playerObj.transform.parent        = playerCharaCenter.transform;
        playerObj.transform.localPosition = new Vector3(1, 0, 0);
        player = new Battler(playerObj, "Player");
        PlayerData pd = GameObject.Find("Player").GetComponent <PlayerData>();

        player.hp    = pd.stats.hp;
        player.maxhp = pd.stats.maxhp;
        player.en    = pd.stats.en;
        player.maxen = pd.stats.maxen;
        player.att   = pd.stats.off;
        player.def   = pd.stats.def;
        player.spd   = pd.stats.spd;
        player.isPlayerControlled = true;
        registeredBattlers.Add(player);

        GameObject enemyObj = (GameObject)Instantiate(Resources.Load("Prefabs/BattleSprite"));

        enemyObj.transform.parent        = enemyCharaCenter.transform;
        enemyObj.transform.localPosition = new Vector3(-1, 0, 0);
        enemy = new Battler(enemyObj, ef.CreateEnemy(typ));
        string path = enemy.GetAnimationControllerPath();

        if (path != "")
        {
            enemyObj.GetComponent <Animator>().runtimeAnimatorController = (RuntimeAnimatorController)Resources.Load(path);
        }
        battlerQueue.Add(player);
        battlerQueue.Add(enemy);
        currstate = states.turnstart;
        enemies.Add(enemy);
        registeredBattlers.Add(enemy);
    }
Пример #26
0
        public GameSpawningWave(ObjectPool enemyPool, GameStateData stateData, WaveSettings waveSettings)
        {
            this.stateData    = stateData;
            this.waveSettings = waveSettings;
            enemyFactory      = new EnemyFactory(waveSettings.Seed, enemyPool, waveSettings.ConversionRates);
            archetypes        = new GameObject[waveSettings.WaveCount];

            var parent = new GameObject("WaveArchetypes").transform;

            for (int i = 0; i < waveSettings.WaveCount; i++)
            {
                archetypes[i]      = enemyFactory.CreateEnemy(waveSettings.EnemyPower[i]);
                archetypes[i].name = $"Wave {i}";
                archetypes[i].transform.SetParent(parent);
            }
        }
Пример #27
0
    private static Data D8()
    {
        // TODO: 上下左右いずれの方向に進んでも全ての敵が回りにくるロジック
        const string map = @"
.........
.........
..~...~..
.........    ...
.........++++...
.........    ...
..~...~..
.........
.........
";

        var stairsLoc = new Loc(4, 14);
        var playerLoc = new Loc(4, 4);

        var fobjs = new List <FieldObject>();

        // 地雷のワナ
        fobjs.Add(FieldObjectFactory.CreateTrapLandmine(new Loc(4, 4)));

        var fitems = new List <FieldItem>();

        // めぐすり草
        fitems.Add(FieldItemFactory.CreateHerb(new Loc(5, 4), 4));

        var enemies = new List <Enemy>();

        enemies.Add(EnemyFactory.CreateEnemy(new Loc(4, 8)));
        enemies.Add(EnemyFactory.CreateEnemy(new Loc(4, 0)));
        enemies.Add(EnemyFactory.CreateEnemy(new Loc(1, 1)));
        enemies.Add(EnemyFactory.CreateEnemy(new Loc(1, 7)));
        enemies.Add(EnemyFactory.CreateEnemy(new Loc(7, 1)));
        enemies.Add(EnemyFactory.CreateEnemy(new Loc(7, 7)));
        enemies.Add(EnemyFactory.CreateEnemy(new Loc(0, 4)));
        enemies.Add(EnemyFactory.CreateEnemy(new Loc(8, 4)));

        return(new Data(map, stairsLoc, playerLoc, fobjs, fitems, enemies));
    }
Пример #28
0
    // フロアに敵を配置する
    private void SetupFloorEnemy(int n, GameObject layer)
    {
        Assert.IsTrue(_enemies.Count == 0);
        if (DebugConfig.NoEnemy)
        {
            return;
        }

        Room[] rooms = _floor.GetRooms();
        for (int i = 0; i < n; i++)
        {
            const int tryCount = 10;
            for (int j = 0; j < tryCount; j++)
            {
                var loc = Utils.RandomRoomLoc(rooms.Choice());

                // TODO:敵を配置可能か調べるメソッド
                if (_floor.ExistsObstacle(loc))
                {
                    continue;
                }
                if (_floor.IsWater(loc))
                {
                    continue;
                }

                if (_enemies.Any(e => e.Loc == loc))
                {
                    continue;
                }
                if (_player.Loc == loc)
                {
                    continue;
                }

                _enemies.Add(EnemyFactory.CreateEnemy(loc));
                break;
            }
        }
    }
Пример #29
0
        private static LevelInfo Level1()
        {
            var levelInfo = new LevelInfo();

            levelInfo.BigWaveStartTimes = new List <float>
            {
                15f
            };

            levelInfo.EstimatedMaxEnemiesOnScreen = new Dictionary <EnemyType, int>
            {
                { EnemyType.SmallSlime, 14 }
            };

            levelInfo.AddEnemySpawnInfo(3f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));

            levelInfo.AddEnemySpawnInfo(6f, SpawnPoint.C, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(6f, SpawnPoint.E, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));

            levelInfo.AddEnemySpawnInfo(9f, SpawnPoint.A, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(9f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(9f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));

            levelInfo.AddEnemySpawnInfo(11f, SpawnPoint.B, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(11f, SpawnPoint.F, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));

            levelInfo.AddEnemySpawnInfo(15f, SpawnPoint.A, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(15f, SpawnPoint.B, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(15f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(15f, SpawnPoint.F, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(15f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));

            levelInfo.Reward      = 100;
            levelInfo.LevelNumber = 1;

            return(levelInfo);
        }
        private void LoadEnemies()
        {
            XDocument regionFile = XDocument.Load(RegionPathGenerator.GetRegionPath(Coords));

            if (regionFile.Root.Element("spawns") != null && regionFile.Root.Element("spawns").Descendants("enemy") != null)
            {
                Enemies = new HashSet <Enemy>(from enemy in regionFile.Root.Element("spawns").Descendants("enemy")
                                              select EnemyFactory.CreateEnemy(
                                                  new Vector2i((Coords.X * FieldsInLine) + int.Parse(enemy.Element("x").Value), (Coords.Y * FieldsInLine) + int.Parse(enemy.Element("y").Value)),
                                                  enemy.Element("type").Value,
                                                  enemy.Element("aimc").Value,
                                                  enemy.Element("path") != null && enemy.Element("path").Descendants("point") != null
                            ? new List <Vector2i>(from point in enemy.Element("path").Descendants("point") select new Vector2i((Coords.X * FieldsInLine) + int.Parse(point.Element("x").Value), (Coords.Y * FieldsInLine) + int.Parse(point.Element("y").Value)))
                            : null,
                                                  enemy.Element("health") != null
                            ? int.Parse(enemy.Element("health").Value)
                            : -1,
                                                  this));
            }
            else
            {
                Enemies = new HashSet <Enemy>();
            }
        }
Пример #31
0
    private static Data D7()
    {
        // 矢をうってくる敵
        const string map = @"
...........
..~........
...........
..#........
...........
";

        var stairsLoc = new Loc(2, 10);
        var playerLoc = new Loc(2, 1);

        var fobjs  = new List <FieldObject>();
        var fitems = new List <FieldItem>();

        var enemies = new List <Enemy>();

        enemies.Add(EnemyFactory.CreateEnemy(new Loc(2, 4)));
        enemies.Last().CanLongDistanceAttack = true;

        return(new Data(map, stairsLoc, playerLoc, fobjs, fitems, enemies));
    }