Esempio n. 1
0
    public void SpawnPlayerUnits()
    {
        int offsetX = (map.mapSizeX / 2) - (map.mapSizeX / 4);
        int offsetZ = 7;

        for (int i = 0; i < playerUnits.units.Count; i++)
        {
            if (playerUnits.isOnBattleField[i])
            {
                CreachureStats creachure = playerUnits.units[i];
                GameObject     spawned   = GameObject.Instantiate(Resources.Load("BattlePlayerUnit")) as GameObject;

                BattleUnit battleUnit = spawned.GetComponent <BattleUnit>();
                PlayerBattleList.Add(battleUnit);
                BattleOrder.Add(battleUnit);

                int tileX = playerUnits.BattleFieldIndex[i] / 6 + offsetX;
                int tileZ = playerUnits.BattleFieldIndex[i] % 6 + offsetZ;

                battleUnit.tileX       = tileX;
                battleUnit.tileZ       = tileZ;
                battleUnit.UnitStats   = creachure;
                battleUnit.visionRange = creachure.VisionRange;

                spawned.transform.position = BattleMap.ConvertTileCoordToWorld(battleUnit.tileX, battleUnit.tileZ);
                map.tiles[tileX, tileZ].mapObjects.Add(battleUnit);
                map.visibleObjects.Add(battleUnit);
            }
        }
    }
Esempio n. 2
0
    public void SpawnEnemyUnits()
    {
        //TEST
        int index = 0;

        int offsetX = (map.mapSizeX / 2) + (map.mapSizeX / 4);
        int x       = 0;
        int z       = 0;

        foreach (UnitPreset preset in GameSettings.instance.Enemies)
        {
            CreachureStats creachure = new CreachureStats(preset);
            GameObject     spawned   = GameObject.Instantiate(Resources.Load("EnemyBattle")) as GameObject;

            spawned.name = "Enemy " + index;
            index++;

            BattleUnit battleUnit = spawned.GetComponent <BattleUnit>();
            EnemyBattleList.Add(battleUnit);
            BattleOrder.Add(battleUnit);

            //UNDONE Check to melee go first
            int offsetZ = (z / 2);
            if (z % 2 != 0)
            {
                offsetZ++;
                offsetZ *= -1;
            }
            int tileZ = (map.mapSizeZ / 2) - 1 + offsetZ;
            int tileX = offsetX + x;
            z++;
            if (z == 8)
            {
                z = 0;
                x++;
            }

            battleUnit.tileX       = tileX;
            battleUnit.tileZ       = tileZ;
            battleUnit.UnitStats   = creachure;
            battleUnit.visionRange = creachure.VisionRange;

            spawned.transform.position = BattleMap.ConvertTileCoordToWorld(battleUnit.tileX, battleUnit.tileZ);
            map.tiles[tileX, tileZ].mapObjects.Add(battleUnit);
        }
    }