Example #1
0
 public void spawnTower1()
 {
     if (castle.canPurchase(200))
     {
         Debug.Log("spawnTower1() triggered");
         currentTower = buildingPlacement.SetItem(buildings[0]);
         castle.makePurchase(200);
         lastPurchaseAmount = 200;
         initOnce           = false;
     }
     else
     {
         // TODO Produce an alert that says you cannot make that purchase
     }
 }
Example #2
0
 void OnGUI()
 {
     for (int i = 0; i < buildings.Length; i++)
     {
         if (GUI.Button(new Rect(Screen.width / 20, Screen.height / 20 + Screen.height / 10 * i, 100, 30), buildings[i].name))
         {
             buildingPlacement.SetItem(buildings[i]);
         }
     }
 }
Example #3
0
    public void TaskOnClick()
    {
        //buildingPlacement.currentBuilding = null;

        ObjectOnGrid ong = building.GetComponent <ObjectOnGrid>();

        if (rm.isEnough(ong.costWood, ong.costStone, 0))
        {
            buildingPlacement.SetItem(building);
        }
    }
Example #4
0
    private void OnGUI()
    {
        for (int i = 0; i < buildings.Length; i++)
        {
            if (GUI.Button(new Rect(20, 100 + i * 40, 100, 30), buildings[i].name))
            {
                ObjectOnGrid ong = buildings[i].GetComponent <ObjectOnGrid>();

                if (rm.isEnough(ong.costWood, ong.costStone, 0))
                {
                    buildingPlacement.SetItem(buildings[i]);
                }
            }
        }
    }
Example #5
0
 void Buildings()
 {
     for (int i = 0; i < buildings.Length; i++)
     {
         if (GUI.Button(new Rect(Screen.width / 20, Screen.height / 15 + Screen.height / 12 * i, 100, 30), buildings[i].name))
         {
             buildingPlacement.SetItem(buildings[i]);
         }
     }
     if (GUI.Button(new Rect(Screen.width / 20, Screen.height / 15 + Screen.height / 12 * 4, 100, 30), "Close"))
     {
         builds = false;
         menu   = true;
         Debug.Log("Close");
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Debug.Log(Input.mousePosition);

            var position = new Vector3(Input.mousePosition.x, Screen.height - Input.mousePosition.y);

            Debug.Log(position);
            for (int i = 0; i < buildings.Length; i++)
            {
                var rect = GetRect(i);

                Debug.Log(rect);
                if (rect.Contains(position))
                {
                    Debug.Log("button down");
                    buildingPlacement.SetItem(buildings[i]);
                    return;
                }
            }
        }
    }
Example #7
0
 public void PickBuilding(int number)
 {
     buildingPlacement.SetItem(buildings [number]);
 }
Example #8
0
 public void ConstruirEdificio(int n)
 {
     buildingPlacement.SetItem(buildings[n]);
 }
Example #9
0
 public void plantTree()
 {
     gameState.currentEvent = 1;
     buildingPlacement.SetItem(buildings[gameState.tree]);
 }
Example #10
0
 public void SpawnWall()
 {
     buildingPlacement.SetItem(buildings[0]);
 }
Example #11
0
    private void OnUpdateGUI()
    {
        //buildingsContainer.GetComponent<GridLayoutGroup>().cellSize =new Vector2(Screen.width/ 8, Screen.height / 5);

        foreach (Transform o in buildingsContainer.transform)
        {
            Destroy(o.gameObject);
        }
        // for(int i = 0; i < gameObjectsSystem.Buildings.Length; i++)
        foreach (GameObject o in gameObjectsSystem.Buildings)
        {
            GameObject newOpt = Instantiate(button);
            if (o.GetComponent <BuildingReqirements>() != null)
            {
                newOpt.transform.SetParent(buildingsContainer.transform, false);
            }
            newOpt.gameObject.GetComponent <Button>().onClick.AddListener(delegate(){ buldingPlacement.SetItem(o); });
            newOpt.gameObject.GetComponent <Button>().onClick.AddListener(closePanel);
            newOpt.gameObject.transform.Find("BuildingImage").GetComponent <Image>().sprite = o.transform.Find("Sprite").GetComponent <SpriteRenderer>().sprite;
            BuildingReqirements req = o.GetComponent <BuildingReqirements>();
            newOpt.gameObject.transform.Find("NameText").GetComponent <Text>().text        = o.name;
            newOpt.gameObject.transform.Find("DescriptionText").GetComponent <Text>().text = req.buildingStatiscics.Description;
            newOpt.gameObject.transform.Find("WoodInfo").Find("Text").GetComponent <TextMeshProUGUI>().text             = req.buildingStatiscics.woodReq.Value + "";
            newOpt.gameObject.transform.Find("GoldInfo").Find("Text").GetComponent <TextMeshProUGUI>().text             = req.buildingStatiscics.goldReq.Value + "";
            newOpt.gameObject.transform.Find("StoneInfo").Find("Text").GetComponent <TextMeshProUGUI>().text            = req.buildingStatiscics.stoneReq.Value + "";
            newOpt.gameObject.transform.Find("ConstructionTimeInfo").Find("Text").GetComponent <TextMeshProUGUI>().text = req.buildingStatiscics.constructionTime.Value + "";

            /* newOpt.transform.Find("Text").GetComponent<Text>().text = "" + o.name + "\n " + req.buildingStatiscics.goldReq.Value
             + "g+" + req.buildingStatiscics.woodReq.Value + "w+" + req.buildingStatiscics.stoneReq.Value + "s";*/
        }
    }
Example #12
0
 public void placeBase()
 {
     BasePool[BaseCount].SetActive(true);
     place.SetItem(BasePool[BaseCount]);
     BaseCount++;
 }