Exemplo n.º 1
0
    public void AddBuilding(BuildingInfo bi)
    {
        if (bi.type == 0)
        {
            dfButton button     = (dfButton)Instantiate(prefabBuildingButton);
            dfButton helpButton = (dfButton)Instantiate(prefabHelpButton);

            button.Text = bi.ButtonText();

            BuildingInfoContainer container = button.GetComponent <BuildingInfoContainer>();
            container.bi = bi;

            buildingBackButton.ZOrder = 0;
            button.ZOrder             = -1;
            buildButtonPanel.AddControl(button);
            button.AddControl(helpButton);



            HelpButton helpScript = helpButton.GetComponent <HelpButton>();
            helpScript.bi = bi;

            helpButton.RelativePosition = new Vector3(button.Width - helpButton.Width - 8, button.Height - helpButton.Height - 2, 0);
            helpButton.BringToFront();
        }
    }
Exemplo n.º 2
0
 protected override void OnGUI()
 {
     base.OnGUI();
     if (showGui)
     {
         int count = 1;
         foreach (DictionaryEntry e in state.availableBuildings)
         {
             BuildingInfo bi = (BuildingInfo)e.Value;
             if (bi.type == 1)
             {  //if this is a launch facility buidling
                 if (GUI.Button(new Rect(menuX, menuY - count * buttonHeight * 2, buttonWidth, buttonHeight * 2), bi.ButtonText()))
                 {
                     if (state.HasEnoughEnergyFor(bi.cost))
                     {
                         state.AddEnergy(-bi.cost);
                         Vector3    launchVector = transform.position;
                         GameObject launchObject = (GameObject)Instantiate(Resources.Load("Prefabs/buildings/" + bi.className), launchVector, transform.rotation);
                         launchObject.transform.parent = state.planet.transform;
                         SpaceBuilding b = launchObject.GetComponent <SpaceBuilding>();
                         b.supplyFacility = this;
                         state.planet.placedBuildings.Add(b);
                         showGui = false;
                     }
                 }
                 count++;
             }
         }
     }
 }
Exemplo n.º 3
0
    public void AddBuilding(BuildingInfo bi)
    {
        if (bi.type == 0)
        {
            dfButton button = (dfButton)Instantiate(prefabBuildingButton);
            dfButton helpButton = (dfButton)Instantiate(prefabHelpButton);

            button.Text = bi.ButtonText();

            BuildingInfoContainer container = button.GetComponent<BuildingInfoContainer>();
            container.bi = bi;

            buildingBackButton.ZOrder = 0;
            button.ZOrder = -1;
            buildButtonPanel.AddControl(button);
            button.AddControl(helpButton);

            HelpButton helpScript = helpButton.GetComponent<HelpButton>();
            helpScript.bi = bi;

            helpButton.RelativePosition = new Vector3(button.Width - helpButton.Width - 8, button.Height - helpButton.Height - 2, 0);
            helpButton.BringToFront();

        }
    }