Exemplo n.º 1
0
        private void Spawn(MonsterStats monster)
        {
            //int spawnNumPerTime = Random.Range(1, 4);

            //for (int s = 0; s < spawnNumPerTime; s++) {
            //    //Pick monster type
            //    MonsterStats randomMonster = _monsterUnits[Random.Range(0, monsterLength)];

            //Pick start position
            int      randomX        = Random.Range(0, _entranceComponent.fullSize.x);
            TileNode randomTileNode = _entranceComponent.tilemapReader.nodes[randomX, _entranceComponent.fullSize.y - 1];

            GameObject monsterObject = PoolManager.instance.ReuseObject(VariableFlag.Pooling.MonsterID);

            if (monsterObject != null)
            {
                BaseStrategy strategy = _strategyMapper.GetStrategy(monster.strategy);

                MonsterUnit unit = monsterObject.GetComponent <MonsterUnit>();
                unit.transform.position = randomTileNode.WorldSpace;
                unit.SetUp(monster, strategy, _mapGrid, _mapHolder, _gameUnitManager.gameDamageManager);
                _gameUnitManager.AddUnit(unit);
            }
            //}
        }
Exemplo n.º 2
0
    private void GenerateMonster(TileNode tileNode)
    {
        if (_monsterStats == null || _monsterStats.Count <= 0)
        {
            return;
        }

        MonsterStats monsterStats = _monsterStats[0];

        GameObject monsterObject = Pooling.PoolManager.instance.ReuseObject(VariableFlag.Pooling.MonsterID);

        if (monsterObject != null)
        {
            monsterObject.transform.position = tileNode.WorldSpace;
            BaseStrategy strategy = _strategyMapper.GetStrategy(monsterStats.strategy);

            MonsterUnit dummyUnit = monsterObject.GetComponent <MonsterUnit>();
            dummyUnit.SetUp(monsterStats, strategy, _mapGrid, _mapHolder, _gameUnitManager.gameDamageManager);

            _gameUnitManager.AddUnit(dummyUnit);
        }
    }