Example #1
0
    public void Update()
    {
        gameObject.transform.position = Cursor._transform.position;

        if (Cursor._hit.collider != null && Cursor._hit.collider.gameObject.layer != 8)
        {
            GhostRenderer.enabled = true;
            if (Input.GetMouseButtonDown(0))
            {
                Gas            gas            = typeOfBuildForConstraction as Gas;
                minerals       minerals       = typeOfBuildForConstraction as minerals;
                gas_silos      gas_Silos      = typeOfBuildForConstraction as gas_silos;
                minerals_silos minerals_Silos = typeOfBuildForConstraction as minerals_silos;

                if (gas)
                {
                    Instantiate(buildings[0], gameObject.transform.position, Quaternion.identity);
                    _DestroyGhost();
                    Destroy(gameObject);
                }
                if (minerals)
                {
                    Instantiate(buildings[1], gameObject.transform.position, Quaternion.identity);
                    _DestroyGhost();
                    Destroy(gameObject);
                }

                if (gas_Silos)
                {
                    Instantiate(buildings[2], gameObject.transform.position, Quaternion.identity);
                    _DestroyGhost();
                    Destroy(gameObject);
                }

                if (minerals_Silos)
                {
                    Instantiate(buildings[3], gameObject.transform.position, Quaternion.identity);
                    _DestroyGhost();
                    Destroy(gameObject);
                }
            }
        }
        else
        {
            GhostRenderer.enabled = false;
        }
    }
Example #2
0
    void Resource_request(AbstractBuild build)
    {
        Gas            gas            = build as Gas;
        minerals       minerals       = build as minerals;
        gas_silos      gas_Silos      = build as gas_silos;
        minerals_silos minerals_Silos = build as minerals_silos;

        //проверка ресурсов в зависимости от типа постройки

        if (gas)
        {
            if (int.Parse(resourses._mineralsValue.text) >= int.Parse(ShopInfo.price.text) & !build_Panel.IsBuilding)//ресурсов достаточно
            {
                resourses.Set_Minerals(-int.Parse(ShopInfo.price.text));
                startBuild(Gas_.GetComponent <Image>(), ShopInfo.buildT, selectedBuild);
            }
            else if (!(int.Parse(resourses._mineralsValue.text) >= int.Parse(ShopInfo.price.text)))//если нет ресурсов
            {
                AlertText.fontSize = 18;
                AlertText.text     = "Not enough resources!!!";
                StartCoroutine("ShowAlert");
            }
            else if (build_Panel.IsBuilding)//если уже что то строится
            {
                AlertText.fontSize = 20;
                AlertText.text     = "Building Process...";
                StartCoroutine("ShowAlert");
            }
        }


        if (gas_Silos)
        {
            if (int.Parse(resourses._mineralsValue.text) >= int.Parse(ShopInfo.price.text) & build_Panel.IsBuilding != true)
            {
                resourses.Set_Minerals(-int.Parse(ShopInfo.price.text));
                startBuild(gasSilos_.GetComponent <Image>(), ShopInfo.buildT, selectedBuild);
            }
            else if (!(int.Parse(resourses._mineralsValue.text) >= int.Parse(ShopInfo.price.text)))
            {
                AlertText.fontSize = 18;
                AlertText.text     = "Not enough resources!!!";
                StartCoroutine("ShowAlert");
            }
            else if (build_Panel.IsBuilding)
            {
                AlertText.fontSize = 20;
                AlertText.text     = "Building Process...";
                StartCoroutine("ShowAlert");
            }
        }


        if (minerals)
        {
            if (int.Parse(resourses._gasValue.text) >= int.Parse(ShopInfo.price.text) & build_Panel.IsBuilding != true)
            {
                resourses.Set_Gas(-int.Parse(ShopInfo.price.text));
                startBuild(minShop.GetComponent <Image>(), ShopInfo.buildT, selectedBuild);
            }
            else if (!(int.Parse(resourses._gasValue.text) >= int.Parse(ShopInfo.price.text)))
            {
                AlertText.fontSize = 18;
                AlertText.text     = "Not enough resources!!!";
                StartCoroutine("ShowAlert");
            }
            else if (build_Panel.IsBuilding)
            {
                AlertText.fontSize = 20;
                AlertText.text     = "Building Process...";
                StartCoroutine("ShowAlert");
            }
        }

        if (minerals_Silos)
        {
            if (int.Parse(resourses._gasValue.text) >= int.Parse(ShopInfo.price.text) & !build_Panel.IsBuilding)
            {
                resourses.Set_Gas(-int.Parse(ShopInfo.price.text));
                startBuild(mineralsSilos_.GetComponent <Image>(), ShopInfo.buildT, selectedBuild);
            }
            else if (!(int.Parse(resourses._gasValue.text) >= int.Parse(ShopInfo.price.text)))
            {
                AlertText.fontSize = 18;
                AlertText.text     = "Not enough resources!!!";
                StartCoroutine("ShowAlert");
            }
            else if (build_Panel.IsBuilding)
            {
                AlertText.fontSize = 20;
                AlertText.text     = "Building Process...";
                StartCoroutine("ShowAlert");
            }
        }
    }