Esempio n. 1
0
    void OnceToCreateAround3(Enemy enemyprefab)
    {
        HexCoordinates[] edge;
        edge = new HexCoordinates[36];
        int count = 0;

        for (int i = 0; i < 12; i++)
        {
            for (int j = 0; j < 8; j++)
            {
                if (i == 0 || i == 11)
                {
                    edge[count++] = new HexCoordinates(i, j);
                }
                else if (j == 0 || j == 7)
                {
                    edge[count++] = new HexCoordinates(i, j);
                }
            }
        }

        HexCoordinates spawnCoordinates;

        for (int i = 0; i < 36; i += 2)
        {
            spawnCoordinates = edge[i];
            Vector3 spawnPosition = HexCoordinates.FromCoordinate(spawnCoordinates);
            Enemy   enemy         = enemyFactory.GetAroundEnemy(spawnPosition, enemyprefab);
            enemies.Add(enemy);
            SearchAndGo(enemy);
        }
    }
Esempio n. 2
0
 private void Start()
 {
     audio = GetComponent <AudioSource>();
     if (state == 0)
     {
         Vector3 position = HexCoordinates.FromCoordinate(cell.coordinates);
         Instantiate(buildEffect, position, Quaternion.identity);
     }
 }
Esempio n. 3
0
    void CreateTowerShape(int towerId, HexCell buildRegion, int initState, float healthFactor = 1)
    {
        TowerShape  instance = towerShapeFactory.Get(towerId, towerId);
        Transform   t        = instance.transform;
        TowerEntity e        = instance.gameObject.GetComponent <TowerEntity>();

        e.health = (int)(e.maxHealth * healthFactor);

        if (buildRegion == null)
        {
            Debug.LogError("No cell found?");
        }
        else
        {
            e.cell                = buildRegion;
            buildPosition         = HexCoordinates.FromCoordinate(buildRegion.coordinates);
            instance.coordinates  = buildRegion.coordinates;
            buildRegion.available = false;
        }

        //Care if move the root of prefabs to ground
        t.localPosition = buildPosition;
        if (t.localScale.y >= 6)
        {
            t.localScale /= data.factorScale;
        }

        //Create link if production tower
        //if(towerId == 2)
        //      mapManager.hexGrid.CreatePowerLinkToCell(
        //       instance.gameObject.GetComponent<ProductionTowerEntity>());

        towerShapes.Add(instance);
        TestPack.TowerNum(towerShapes);

        instance.GetComponent <TowerEntity>().state = initState;

        for (int i = 0; i < enemies.Count; i++)
        {
            SearchAndGo(enemies[i]);
        }
    }