Пример #1
0
 private void OnUnitSpawn(NetworkManager.UnitSpawnData spawnData)
 {
     Debug.Log("Spawning unit from controller");
     CheckInitialized();
     Debug.Log("passed init");
     unitSpawner.SpawnUnit(spawnData);
 }
Пример #2
0
    public void Spawn(EnemyData enemyData, Vector3 position)
    {
        GameObject enemyObject = new GameObject(enemyData.Name);

        enemyObject.transform.position = position;
        enemyObject.layer = LayerMask.NameToLayer("Enemy");

        UnitData unitData = new UnitData(Main.StaticData.Game.Races.GetValue(enemyData.RaceId).BaseStats);

        foreach (var item in enemyData.Items)
        {
            //Debug.Log("Equipping " + item.DisplayName);
            unitData.Inventory.Equip(item);
        }

        Unit unit = UnitSpawner.SpawnUnit(enemyObject, unitData);

        switch (enemyData.AiParams.AiType)
        {
        case AiType.Rush:
            RushAI rushAI = enemyObject.AddComponent <RushAI>();
            //Debug.Log("assigning attacks..." + enemyData.AiParams.AttackIds.ToString());
            rushAI.Attacks = unit.Skills;
            break;
        }

        Enemy enemy = new Enemy
        {
            gameObject = enemyObject,
            enemyData  = enemyData,
            indicator  = null
        };

        enemies.Add(enemy);
    }
 protected override void UnitDeath()
 {
     if (UnitTracker.GetActiveEnemyCount() == 0 && !bossSpawned)
     {
         UnitSpawner.SpawnUnit(UnitReferences.EnemyBattleship, new Vector3(0, 100, 200));
         bossSpawned = true;
     }
 }
Пример #4
0
 void Start()
 {
     if (Config != null)
     {
         UnitSpawner spawner = gameObject.AddComponent <UnitSpawner>();
         spawner.SpawnUnit(Config, new M_Math.R_Range(1, 5), 0, true);
     }
 }
Пример #5
0
    // Use this for initialization
    void Awake()
    {
        instance = this;

        UnitTracker.Clear();
        ProjectileTracker.Clear();

        UnitSpawner.SpawnUnit(GameSettings.CurrentPlayerShip, currentLevelController.CurrentPlayerSpawn.transform.position, RotationCalculator.RotationTowardLocation(currentLevelController.CurrentPlayerSpawn.transform.position, currentLevelController.PositionPlayerLooksAtSpawn));
    }
    /// <returns>Returns true on successful spawn.</returns>
    public bool SpawnUnit(int unitIndex)
    {
        if (unitIndex >= 4)
        {
            return(SpawnMinerUnit());
        }

        int cost = unitSpawner.SpawnUnit(unitIndex, ActiveLine, faction, factionMaterial, goldController.GetBalance());

        goldController.RemoveBalance(cost);

        return(cost != 0);
    }
    // Use this for initialization
    void Start()
    {
        PoolController.Instance.SetInitialPoolSize(ProjectileReferences.SmallLaser, 400);
        PoolController.Instance.SetInitialPoolSize(ProjectileReferences.LargeLaser, 5);
        PoolController.Instance.SetInitialPoolSize(ProjectileReferences.GuidedMissile, 5);
        PoolController.Instance.Initialize();

        UnitSpawner.SpawnUnit(UnitReferences.EnemyCruiserLight1, new Vector3(-100, 50, 100));
        UnitSpawner.SpawnUnit(UnitReferences.EnemyCruiserLight1, new Vector3(0, 50, 100));
        UnitSpawner.SpawnUnit(UnitReferences.EnemyCruiserLight1, new Vector3(100, 50, 100));
        UnitSpawner.SpawnUnit(UnitReferences.AlliedCruiserHeavy1, new Vector3(0, 50, -200), Quaternion.Euler(0, 0, 0));

        UnitSpawner.SpawnUnitsInArea(UnitReferences.EnemyFighter1, 75, enemySpawns[0]);
        UnitSpawner.SpawnUnitsInArea(UnitReferences.AlliedFighter1, 15, allySpawns[0]);
    }
Пример #8
0
    // Use this for initialization
    void Start()
    {
        cruiser = UnitSpawner.SpawnUnit(UnitReferences.AlliedCruiserHeavy1, Vector3.zero);
        cruiser.GetComponent <CruiserAIController>().goToPoints = goToPoints;

        priority = GetComponent <PriorityTarget>();
        if (priority)
        {
            priority.setEnemyPriority(cruiser);
        }
        else
        {
            Debug.LogError("PriorityTarget component not found.");
        }
    }
Пример #9
0
    public static GameObject Spawn(GameObject parentObject)
    {
        //Common
        HeroData heroData = Main.GameState.CurrentHeroData;

        if (heroData == null)
        {
            return(null);
        }

        var playerObject = new GameObject("Player");

        playerObject.transform.localPosition = Vector3.zero;
        playerObject.transform.parent        = parentObject.transform;
        playerObject.tag   = "Player";
        playerObject.layer = 9;

        UnitData unitData = new UnitData(heroData.UnitData);
        //unitData.Inventory.Add(MainData.Game.GetItem("Dagger"));
        //unitData.Inventory.Equip("Dagger");
        Unit unit = UnitSpawner.SpawnUnit(playerObject, unitData);

        //Components to be initialized
        PlayerController controller = playerObject.GetComponent <PlayerController>();
        XpComponent      xp         = playerObject.GetComponent <XpComponent>();

        if (controller == null)
        {
            controller = playerObject.AddComponent <PlayerController>();
        }
        controller.MainAttack = unit.Skills[0];
        unit.ActiveController = controller;

        if (xp == null)
        {
            xp = playerObject.AddComponent <XpComponent>();
        }

        playerObject.AddComponent <PlayerWorldUI>();

        return(playerObject);
    }
Пример #10
0
    void SpawnGroup(UnitSpawnGroupConfig group, List <int> spawnerIDs)
    {
        if (group == null)
        {
            Debug.LogWarning("No Group");
            return;
        }

        globalGroupCounter++;

        List <UnitSpawner> spawnersForGroup = GetSpawnerForGroup(spawnerIDs, group);

        if (spawnersForGroup == null || spawnersForGroup.Count == 0)
        {
            Debug.LogWarning("NO SPAWNERS FOR GROUP");
            return;
        }

        List <WeightedUnit> unitConfigs = RegionLoader.GetUnitsForGroupPower(group);

        if (unitConfigs.Count > spawnersForGroup.Count)
        {
            Debug.LogWarning("Not enough spawners for my group :(   spawners:" + spawnersForGroup.Count + "  units:" + unitConfigs.Count);
            //  return;
        }

        // MDebug.Log(spawnersForGroup.Count+ "   "+unitConfigs.Count);
        while (spawnersForGroup.Count > 0 && unitConfigs.Count > 0)
        {
            // MDebug.Log("SPAWN");
            WeightedUnit unit    = unitConfigs.GetRandom();
            UnitSpawner  spawner = spawnersForGroup.GetRandom();

            unitConfigs.Remove(unit);
            spawnersForGroup.Remove(spawner);

            spawner.SpawnUnit(unit.UnitConfig, unit.TurnTimeOnSpawn, globalGroupCounter, unit.HidePlayerUnit);
        }
    }