示例#1
0
    private IEnumerable <ConstructionButton> allConstructionButtons()
    {
        int totalNumOfButtons            = this.buttonHolder.transform.childCount;
        List <ConstructionButton> result = new List <ConstructionButton>(totalNumOfButtons);

        for (int i = 0; i < totalNumOfButtons; i++)
        {
            ConstructionButton button = this.buttonHolder.transform.GetChild(i).GetComponent <ConstructionButton>();
            result.Add(button);
        }
        return(result);
    }
示例#2
0
    private static Tile tile;  // The tile that this Construction Controller is planning to build on

    // Start is called before the first frame update
    void Start()
    {
        this.gc = GameController.singleton;

        foreach (BuildingType bt in BuildingFactory.allBuildings)
        {
            // Make a button for each building type
            ConstructionButton newButton = Instantiate(buttonPrefab);
            newButton.Start();
            newButton.setBuildingType(bt);

            newButton.transform.SetParent(this.buttonHolder.transform);
        }



        // Constructions starts turned off
        this.turnOff();
    }
        public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null)
        {
            base.HandleMessage(message, netChannel, component);

            switch (message)
            {
            case PlayerAttachedMsg _:
                if (Button == null)
                {
                    Button       = new ConstructionButton();
                    Button.Owner = this;
                }
                Button.AddToScreen();
                break;

            case PlayerDetachedMsg _:
                Button.RemoveFromScreen();
                break;

            case AckStructureConstructionMessage ackMsg:
                ClearGhost(ackMsg.Ack);
                break;
            }
        }