Пример #1
0
    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < EnemeyWorkers.Count; i++)
        {
            if (EnemeyWorkers[i].activeSelf == false)
            {
                EnemeyWorkers.RemoveAt(i);
            }
        }
        for (int i = 0; i < Archers.Count; i++)
        {
            if (Archers[i].activeSelf == false)
            {
                Archers.RemoveAt(i);
            }
        }

        for (int i = 0; i < Horseman.Count; i++)
        {
            if (Horseman[i].activeSelf == false)
            {
                Horseman.RemoveAt(i);
            }
        }
        for (int i = 0; i < Axemen.Count; i++)
        {
            if (Axemen[i].activeSelf == false)
            {
                Axemen.RemoveAt(i);
            }
        }

        if (archerbuilding == null || !archerbuilding.activeSelf)
        {
            archerbuilding = null;
        }

        if (tower == null || !tower.activeSelf)
        {
            tower = null;
        }
        if (stable == null || !stable.activeSelf)
        {
            stable = null;
        }

        if (workerbuilding == null || !workerbuilding.activeSelf)
        {
            workerbuilding = null;
        }

        sign_to_what_create = FirstOperationEnemy();

        if (sign_to_what_create == 1)
        {
            if (gold >= 40 && createworker)
            {
                gold = gold - 40;

                GameObject o          = GameObject.Find("enemy worker building(Clone)");
                GameObject copyworker = o.GetComponent <Flock>().CreateNewWorker(100, 100.0f / 60.0f);
                copyworker.SetActive(false);
                temp = copyworker;
                InvokeRepeating("timer1", 5f, 5f);
                createworker = false;
            }
        }
        else if (sign_to_what_create == 2)
        {
            if (gold >= 170 && !Inbuilding)
            {
                Inbuilding = true;
                this.gold  = this.gold - 170;
                GameObject start_building = Instantiate(Camera.main.transform.Find("first stage of the building").gameObject);
                GameObject o = GameObject.Find("characters").transform.Find("enemy soldiers").Find("buildings").gameObject;
                start_building.transform.SetParent(o.transform);
                start_building.transform.position = new Vector3(4, 4, 0);
                start_building.GetComponent <Build_Building>().Set_Name_Of_Building("enemy archer building");
                start_building.GetComponent <Build_Building>().Set_Name_Building_shai("archer building");
                start_building.GetComponent <Build_Building>().Set_Side_Of_Player(false);
                Debug.Log(start_building.GetComponent <Build_Building>());
                start_building.SetActive(true);
            }
        }
        else if (sign_to_what_create == 3)
        {
            if (gold >= 40 && createworker)
            {
                //GameObject o = GameObject.Find("enemy worker building(Clone)");
                GameObject o          = MainThreadOfGame.SearchBuildingInHirarchy(GameObject.Find("characters").transform.Find("colony soldiers").Find("buildings").gameObject, "enemy worker building");
                GameObject copyworker = o.GetComponent <Flock>().CreateNewWorker(100, 100.0f / 60.0f);
                copyworker.SetActive(false);
                temp = copyworker;
                InvokeRepeating("timer1", 5f, 5f);
                createworker = false;
            }
        }
        else if (sign_to_what_create == 4)
        {
            if (gold >= 50 && createarcher)
            {
                gold = gold - 50;
                //GameObject o = this.transform.Find("enemy archer building").gameObject;
                GameObject o          = MainThreadOfGame.SearchBuildingInHirarchy(GameObject.Find("characters").transform.Find("colony soldiers").Find("buildings").gameObject, "enemy archer building");
                GameObject copyarcher = o.GetComponent <Flock>().CreateNewSoldier(20f, 20f, 1f);
                copyarcher.SetActive(false);
                temp = copyarcher;
                Invoke("timer3", 5f);
                createarcher = false;
            }
        }
        else if (sign_to_what_create == 5)
        {
            if (gold >= 40 && createworker)
            {
                //GameObject o = GameObject.Find("enemy worker building(Clone)");
                GameObject o          = MainThreadOfGame.SearchBuildingInHirarchy(GameObject.Find("characters").transform.Find("colony soldiers").Find("buildings").gameObject, "enemy worker building");
                GameObject copyworker = o.GetComponent <Flock>().CreateNewWorker(100, 100.0f / 60.0f);
                copyworker.SetActive(false);
                temp = copyworker;
                InvokeRepeating("timer1", 5f, 5f);
                createworker = false;
            }
        }
        else if (sign_to_what_create == 6)
        {
            if (gold >= 200 && !Inbuilding)
            {
                Inbuilding = true;
                this.gold  = this.gold - 200;
                GameObject start_building = Instantiate(Camera.main.transform.Find("first stage of the building").gameObject);
                GameObject o = GameObject.Find("characters").transform.Find("enemy soldiers").Find("buildings").gameObject;
                start_building.transform.SetParent(o.transform);
                start_building.transform.position = new Vector3(2, 2, 0);
                start_building.GetComponent <Build_Building>().Set_Name_Of_Building("enemy stable");
                start_building.GetComponent <Build_Building>().Set_Name_Building_shai("stable");
                start_building.GetComponent <Build_Building>().Set_Side_Of_Player(false);
                start_building.SetActive(true);
            }
        }
        else if (sign_to_what_create == 7)
        {
            if (gold >= 60 && createhorse)
            {
                gold = gold - 60;
                //GameObject o = GameObject.Find("enemy stable1").gameObject;
                GameObject o         = MainThreadOfGame.SearchBuildingInHirarchy(GameObject.Find("characters").transform.Find("colony soldiers").Find("buildings").gameObject, "enemy stable").gameObject;
                GameObject copyhorse = o.GetComponent <Flock>().CreateNewSoldier(20f, 20f, 1f);
                copyhorse.SetActive(false);
                temp = copyhorse;
                Invoke("timer4", 5f);
                createhorse = false;
            }
        }

        else if (sign_to_what_create == 8)
        {
            if (gold >= 120 && !Inbuilding)
            {
                Inbuilding = true;
                this.gold  = this.gold - 120;
                GameObject start_building = Instantiate(Camera.main.transform.Find("first stage of the building").gameObject);
                GameObject o = GameObject.Find("characters").transform.Find("enemy soldiers").Find("buildings").gameObject;
                start_building.transform.SetParent(o.transform);
                start_building.transform.position = new Vector3(3, 3, 0);
                start_building.GetComponent <Build_Building>().Set_Name_Of_Building("enemy protect tower");
                start_building.GetComponent <Build_Building>().Set_Name_Building_shai("protect tower");
                start_building.GetComponent <Build_Building>().Set_Side_Of_Player(false);
                start_building.SetActive(true);
            }
        }

        else if (sign_to_what_create == 9)
        {
            if (gold >= 40 && createworker)
            {
                //GameObject o = GameObject.Find("enemy worker building(Clone)");
                GameObject o          = MainThreadOfGame.SearchBuildingInHirarchy(GameObject.Find("characters").transform.Find("colony soldiers").Find("buildings").gameObject, "enemy worker building");
                GameObject copyworker = o.GetComponent <Flock>().CreateNewWorker(100, 100.0f / 60.0f);
                copyworker.SetActive(false);
                temp = copyworker;
                Invoke("timer1", 5f);
                createworker = false;
            }
        }

        else if (sign_to_what_create == 10)
        {
            if (gold >= 60 && createaxe)
            {
                gold = gold - 60;
                //GameObject o = GameObject.Find("enemy protect tower1").gameObject;
                GameObject o       = MainThreadOfGame.SearchBuildingInHirarchy(GameObject.Find("characters").transform.Find("colony soldiers").Find("buildings").gameObject, "enemy protect tower");
                GameObject copyaxe = o.GetComponent <Flock>().CreateNewSoldier(20f, 20f, 1f);
                copyaxe.SetActive(false);
                temp = copyaxe;
                Invoke("timer7", 5f);
                createaxe = false;
            }
        }
        else if (sign_to_what_create == 11)
        {
            float r = Random.Range(1f, 4f);
            if (r == 1)
            {
                if (gold >= 50 && createall)
                {
                    gold = gold - 50;
                    //GameObject o = GameObject.Find("enemy archer building1").gameObject;
                    GameObject o          = MainThreadOfGame.SearchBuildingInHirarchy(GameObject.Find("characters").transform.Find("colony soldiers").Find("buildings").gameObject, "enemy archer building").gameObject;
                    GameObject copyarcher = o.GetComponent <Flock>().CreateNewSoldier(20f, 20f, 1f);
                    copyarcher.SetActive(false);
                    temp = copyarcher;
                    Invoke("timer3", 5f);
                    createarcher = false;
                }
            }

            else if (r == 2)
            {
                if (gold >= 60 && createall)
                {
                    gold = gold - 60;
                    //GameObject o = GameObject.Find("enemy stable1").gameObject;
                    GameObject o         = MainThreadOfGame.SearchBuildingInHirarchy(GameObject.Find("characters").transform.Find("colony soldiers").Find("buildings").gameObject, "enemy stable").gameObject;
                    GameObject copyhorse = o.GetComponent <Flock>().CreateNewSoldier(20f, 20f, 1f);
                    copyhorse.SetActive(false);
                    temp = copyhorse;
                    Invoke("timer4", 5f);
                    createhorse = false;
                }
            }

            else if (r == 3)
            {
                if (gold >= 60 && createall)
                {
                    gold = gold - 60;
                    GameObject o       = MainThreadOfGame.SearchBuildingInHirarchy(GameObject.Find("characters").transform.Find("colony soldiers").Find("buildings").gameObject, "enemy protect tower").gameObject;
                    GameObject copyaxe = o.GetComponent <Flock>().CreateNewSoldier(20f, 20f, 1f);
                    copyaxe.SetActive(false);
                    temp = copyaxe;
                    Invoke("timer7", 5f);
                    createaxe = false;
                }
            }
        }
    }
Пример #2
0
    void Increase_Life_Building()
    {
        if (slide.value > 0 && slide.value < 100)
        {
            float hitPower = 5;


            slide.value = slide.value + hitPower;
            fill.color  = gradient.Evaluate(slide.normalizedValue);

            Set_Phase_Building();
        }
        else if (slide.value >= 100)
        {
            slide.value = 100;
            fill.color  = gradient.Evaluate(slide.normalizedValue);

            Debug.Log(Sturctue_Mine);
            CancelInvoke("Increase_Life_Building");
            this.gameObject.SetActive(false);
            if (Sturctue_Mine)
            {
                GameObject o = MainThreadOfGame.SearchBuildingInHirarchy(GameObject.Find("characters").transform.Find("colony soldiers").Find("buildings").gameObject, Name_Of_Building_Shai);
                Instantiate(o.gameObject);
                if (o.tag.Contains("colony"))
                {
                    MainThreadOfGame.IncNumColony();
                }
                else
                {
                    MainThreadOfGame.IncNumEnemy();
                }
                //GameObject o = Instantiate(this.transform.parent.Find(Name_Of_Building_Shai).gameObject);
                // GameObject r = GameObject.Find(Name_Of_Building);
                // o.transform.SetParent(r.transform);
                o.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z);
                o.SetActive(true);
            }
            else if (!Sturctue_Mine)
            {
                GameObject o = null;

                if (Name_Of_Building == "enemy archer building")
                {
                    o = GameObject.Find("enemy player").transform.Find(Name_Of_Building).gameObject;

                    o.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z);
                    GameObject enemyplayer = GameObject.Find("enemy player");
                    enemyplayer.GetComponent <Options_Enemy>().SetInbuilding(false);
                    enemyplayer.GetComponent <Options_Enemy>().timer2(o);
                    o.SetActive(true);
                }

                else if (Name_Of_Building == "enemy stable")
                {
                    o = GameObject.Find("enemy player").transform.Find(Name_Of_Building).gameObject;

                    o.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z);
                    GameObject enemyplayer = GameObject.Find("enemy player");
                    enemyplayer.GetComponent <Options_Enemy>().SetInbuilding(false);
                    enemyplayer.GetComponent <Options_Enemy>().timer5(o);
                    o.SetActive(true);
                }

                else if (Name_Of_Building == "enemy protect tower")
                {
                    o = GameObject.Find("enemy player").transform.Find(Name_Of_Building).gameObject;
                    o.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z);
                    GameObject enemyplayer = GameObject.Find("enemy player");
                    enemyplayer.GetComponent <Options_Enemy>().SetInbuilding(false);
                    enemyplayer.GetComponent <Options_Enemy>().timer6(o);
                    o.SetActive(true);
                }
            }
        }
    }