Esempio n. 1
0
    public void ADDBuilding(GameObject buildingsObj, Vector3 position)
    {
        //BuildObjectScript buildtoadd = Instantiate(buildings, position, Quaternion.identity);
        //buildObjectScript[(int)position.x, (int)position.z] = buildtoadd;



        GameObject InstanBuildingObj =
            Instantiate(buildingsObj, position, Quaternion.identity);


        InstanBuildingObj.transform.SetParent(GameManager.instance.GetBuildingParentTransform());



        BuildObjectScript buildToAdd = InstanBuildingObj.GetComponent <BuildObjectScript>();

        if (PlayerManagerScript.instance.Woods >= buildToAdd.Cost)
        {
            buildToAdd.transform.position = new Vector3(position.x, buildToAdd.GetYPos(), position.z);


            GameManager.instance.buildObjectListScript.Add(buildToAdd);



            buildObjectScript[(int)position.x, (int)position.z] = buildToAdd;


            PlayerManagerScript.instance.Woods -= buildToAdd.Cost;
        }
        else if (PlayerManagerScript.instance.Woods
                 < buildToAdd.Cost)
        {
            Destroy(InstanBuildingObj);
        }


        UIManager.instance.UpdateCrtResourceTypeFunction
            (PlayerManagerScript.instance.foods,
            PlayerManagerScript.instance.fruitCollecterCost,
            PlayerManagerScript.instance.Woods,
            PlayerManagerScript.instance.Gold);
    }
Esempio n. 2
0
    //Function : InstanResourseAreaFunction
    //Method : This is the Function used For Instan Resourse Area Function
    public void InstanResourseAreaFunction()
    {
        #region  InstanGoldObjectRegions


        InstanResourceAreaScript[] instanResourceAreaScript = FindObjectsOfType <InstanResourceAreaScript>();

        BuildObjectScript buildObjectScript = GoldenObj.GetComponent <BuildObjectScript>();



        for (int i = 0; i < instanResourceAreaScript.Length; i++)
        {
            Transform[] trans = instanResourceAreaScript[i].GetTransformListToArrayFunction();

            if (instanResourceAreaScript[i].GetIsInstanGoldArea())
            {
                for (int j = GoldResourceCollectiveScript.Count; j < trans.Length; j++)
                {
                    GameObject InstanGoldObject = Instantiate(GoldenObj, new Vector3(trans[j].position.x, buildObjectScript.GetYPos(), trans[j].position.z), Quaternion.identity);

                    InstanGoldObject.transform.SetParent(SpawnResourceTransformArea);



                    ResourceCollectiveScript INSTANGOLDOBJAREA = InstanGoldObject.GetComponent <ResourceCollectiveScript>();


                    GoldResourceCollectiveScript.Add(INSTANGOLDOBJAREA);
                }
            }


            if (instanResourceAreaScript[i].GetisInstanWoodsArea())
            {
                for (int j = 0; j < trans.Length; j++)
                {
                    GameObject InstanWoodsObj = Instantiate(WoodsObj, new Vector3(trans[j].position.x, buildObjectScript.GetYPos(), trans[j].position.z), instanResourceAreaScript[i].transform.rotation);

                    InstanWoodsObj.transform.SetParent(SpawnResourceTransformArea);



                    ResourceCollectiveScript InstanWoodsArea = InstanWoodsObj.GetComponent <ResourceCollectiveScript>();


                    WoodsResourceCollectiveScript.Add(InstanWoodsArea);
                }
            }
        }

        #endregion
    }