Esempio n. 1
0
    public void loadMap()
    {
        for (int x = 0; x < 20; x++)
        {
            for (int z = 0; z < 20; z++)
            {
                gridInfo[x, z]      = 0;
                placeItemInfo[x, z] = 0;
            }
        }

        Vector2 prev = gridTurningPoints[0];

        for (int i = 1; i < gridTurningPoints.Count; i++)
        {
            loadRoute(prev, gridTurningPoints[i]);
            prev = gridTurningPoints[i];
        }

        //Detect the palce of all turbines, pumps and transformers that already in the scene

        GameObject[] allTurbines               = GameObject.FindGameObjectsWithTag("turbine");
        GameObject[] allPumps                  = GameObject.FindGameObjectsWithTag("waterTower");
        GameObject[] allTransformers           = GameObject.FindGameObjectsWithTag("transformer");
        GameObject[] allTransformerForTurbines = GameObject.FindGameObjectsWithTag("transformerForTurbine");

        for (int i = 0; i < allTurbines.Length; i++)
        {
            Transform   currentTransform = allTurbines[i].transform;
            Vector2     gridPlace        = TerrainInfo.TransformToGrid(currentTransform.position);
            TurbineInfo currentTurbine   = allTurbines[i].transform.GetComponent <TurbineInfo>();
            currentTurbine.x = (int)gridPlace.x;
            currentTurbine.z = (int)gridPlace.y;
            placeItemInfo[(int)gridPlace.x, (int)gridPlace.y] = 1;
        }

        for (int i = 0; i < allPumps.Length; i++)
        {
            Transform currentTransform = allPumps[i].transform;
            Vector2   gridPlace        = TerrainInfo.TransformToGrid(currentTransform.position);
            PumpInfo  currentPump      = allPumps[i].transform.GetComponent <PumpInfo>();
            currentPump.x = (int)gridPlace.x;
            currentPump.z = (int)gridPlace.y;
            placeItemInfo[(int)gridPlace.x, (int)gridPlace.y] = 1;
        }

        for (int i = 0; i < allTransformers.Length; i++)
        {
            Transform       currentTransform   = allTransformers[i].transform;
            Vector2         gridPlace          = TerrainInfo.TransformToGrid(currentTransform.position);
            TransformerInfo currentTransformer = allTransformers[i].transform.GetComponent <TransformerInfo>();
            currentTransformer.x = (int)gridPlace.x;
            currentTransformer.z = (int)gridPlace.y;
            placeItemInfo[(int)gridPlace.x, (int)gridPlace.y] = 1;
        }

        for (int i = 0; i < allTransformerForTurbines.Length; i++)
        {
            Transform currentTransform = allTransformerForTurbines[i].transform;
            Vector2   gridPlace        = TerrainInfo.TransformToGrid(currentTransform.position);
            TransformerForTurbineInfo currentTransformerForTurbine = allTransformerForTurbines[i].transform.GetComponent <TransformerForTurbineInfo>();
            currentTransformerForTurbine.x = (int)gridPlace.x;
            currentTransformerForTurbine.z = (int)gridPlace.y;
            placeItemInfo[(int)gridPlace.x, (int)gridPlace.y] = 1;
        }
    }
 // Methods
 public void Add(TransformerInfo transformerInfo)
 {
 }
 // Methods
 public void Add(TransformerInfo transformerInfo)
 {
 }