Example #1
0
    public void AutoNaturalClear()
    {
        StopAllCoroutines();

        GameObject[] build       = GameObject.FindGameObjectsWithTag("Building");       //всі будівлі
        GameObject[] ObjectsZone = GameObject.FindGameObjectsWithTag("GameController"); //зона

        for (int i = 0; i < ObjectsZone.Length; i++)
        {
            Destroy(ObjectsZone[i]);
        }
        foreach (GameObject BuildInfo in build)
        {
            ClearZone(BuildInfo.GetComponent <BuildRayCast>().ThisNotacces);

            //Виклик ітераційного методу в  потоці та надання йому параметрів
            BuildInfo.GetComponent <BuildRayCast>().StartCoroutine(BuildInfo.GetComponent <BuildRayCast>().ContaminationIterationAuto((float)BuildInfo.GetComponent <BuildRayCast>().rad,
                                                                                                                                      (float)BuildInfo.GetComponent <BuildRayCast>().rad * 2,
                                                                                                                                      BuildInfo.GetComponent <BuildRayCast>().CenterXY[0], BuildInfo.GetComponent <BuildRayCast>().CenterXY[1],
                                                                                                                                      BuildInfo.GetComponent <BuildRayCast>().iterat, BuildInfo.GetComponent <Buildings>().Upgrade));
            // iteration.Add(new Iteration() { ID = BuildInfo.GetComponent<BuildRayCast>().iter, IDMap = 1, Build = BuildInfo.name, RadiusContamination1 = BuildInfo.GetComponent<BuildRayCast>().CenterXY[0], RadiusContamination2 = BuildInfo.GetComponent<BuildRayCast>().CenterXY[1] });

            if (BuildInfo.GetComponent <BuildRayCast>().iterat <= 20)            //Якщо ітерація для будівлі менше 20 то інкрементуємо
            {
                BuildInfo.GetComponent <BuildRayCast>().iterat++;
            }
        }
    }
Example #2
0
 //Показ зони
 public void ClickMatrix()
 {
     Dest();
     GameObject[] build      = GameObject.FindGameObjectsWithTag("Building");        //всі будівлі
     GameObject[] Clearbuild = GameObject.FindGameObjectsWithTag("ClearBuild");      //всі очисні будівлі
     //int[,] clea = new int[96, 96];
     foreach (GameObject BuildInfo in build)
     {
         for (int i = 0; i < SizeMatrix; i++)
         {
             for (int j = 0; j < SizeMatrix; j++)
             {
                 Board[i, j] = BuildInfo.GetComponent <BuildRayCast>().ThisNotacces[i, j];
                 //clea[i, j] = clear.GetComponent<ClearBuild>().ThisNotacces[i, j];
                 foreach (GameObject item in Clearbuild)
                 {
                     if (item.GetComponent <ClearBuild>().ThisNotacces[i, j] == 3)
                     {
                         Board[i, j] = 3;
                     }
                 }
                 if (Board[i, j] == 1 && Board[i, j] != 3)
                 {
                     SpawnObject(2, i, j);
                 }
                 if (Board[i, j] == 2 && Board[i, j] != 3)
                 {
                     SpawnObject(3, i, j);
                 }
             }
         }
     }
 }
Example #3
0
 //Зупинка всіх потоків
 public void StopCoroutines()
 {
     GameObject[] build = GameObject.FindGameObjectsWithTag("Building");             //всі будівлі
     foreach (GameObject BuildInfo in build)
     {
         BuildInfo.GetComponent <BuildRayCast>().StopAllCoroutines();
     }
 }
Example #4
0
    //Одиничний ітераційний метод
    public void OneIteration()
    {
        StopCoroutines();
        FakeClear();
        GameObject[] build       = GameObject.FindGameObjectsWithTag("Building");       //всі будівлі
        GameObject[] ObjectsZone = GameObject.FindGameObjectsWithTag("GameController"); //зона

        for (int i = 0; i < ObjectsZone.Length; i++)
        {
            Destroy(ObjectsZone[i]);
        }
        foreach (GameObject BuildInfo in build)
        {
            Debug.Log("iter: " + BuildInfo.GetComponent <BuildRayCast>().iterat);
            //
            //Виклик ітераційного методу та надання йому параметрів
            BuildInfo.GetComponent <BuildRayCast>().ContaminationIteration((float)BuildInfo.GetComponent <BuildRayCast>().rad,
                                                                           (float)BuildInfo.GetComponent <BuildRayCast>().rad * 2,
                                                                           BuildInfo.GetComponent <BuildRayCast>().CenterXY[0], BuildInfo.GetComponent <BuildRayCast>().CenterXY[1],
                                                                           BuildInfo.GetComponent <BuildRayCast>().iterat, BuildInfo.GetComponent <Buildings>().Upgrade);

            // iteration.Add(new Iteration() { ID = BuildInfo.GetComponent<BuildRayCast>().iter, IDMap = 1, Build = BuildInfo.name, RadiusContamination1 = BuildInfo.GetComponent<BuildRayCast>().CenterXY[0], RadiusContamination2 = BuildInfo.GetComponent<BuildRayCast>().CenterXY[1] });
        }
    }