Exemplo n.º 1
0
    private void DisplayStructures()
    {
        currentSelection.Clear();

        if (sm.currentSelection.Count == 1)
        {
            PopulateCurrentStructureQueue();
        }
        else
        {
            foreach (GameObject potentialStructure in sm.currentSelection)
            {
                if (potentialStructure.GetComponent <Structure>() != null)
                {
                    // Display to UI
                    Structure  myStructure = potentialStructure.GetComponent <Structure>();
                    GameObject go          = uiUtils.createTile(myStructure);

                    // Add to currently selected structures
                    currentSelection.Add(go);

                    // Add event handlers to button
                    go.GetComponent <Button>().onClick.AddListener(delegate() {
                        sm.currentSelection.Clear();
                        sm.currentSelection.Clear();
                        sm.currentSelection.Add(potentialStructure.gameObject);
                        updateUITiles();
                    });
                }
            }
        }
    }
Exemplo n.º 2
0
    public void DisplayUnitActions(Unit unit)
    {
        ClearActionsPanel();

        if (unit is IAttacking)
        {
            // Create tile
            Action newAction = new Action(
                "Attack",
                uiManager.GetComponent <UI_TileManager>().UI_Action_Attack
                );
            GameObject newProducableUnitTile = uiUtils.createTile(newAction);
            currentActionTiles.Add(newProducableUnitTile);

            // Button event
            newProducableUnitTile.GetComponent <Button>().onClick.AddListener(delegate() {
                // Action
                //unit.GetComponent<Unit_GroundRanged>().attack(unit.transform.position);
            });
        }
        if (unit is IMovable)
        {
            // MOVE:
            // Create tile
            Action newAction = new Action(
                "Move",
                uiManager.GetComponent <UI_TileManager>().UI_Action_Move
                );
            GameObject newProducableUnitTile = uiUtils.createTile(newAction);
            currentActionTiles.Add(newProducableUnitTile);

            // Button event
            newProducableUnitTile.GetComponent <Button>().onClick.AddListener(delegate()
            {
                // Move Player to next valid click or cancel
                print("Move unit clicked");
                Debug.Log("Move unit clicked");
                selectionManager.sendingMoveOrder = true;
            });

            // STOP:
            // Create tile
            newAction = new Action(
                "Stop",
                uiManager.GetComponent <UI_TileManager>().UI_Action_Stop
                );
            newProducableUnitTile = uiUtils.createTile(newAction);
            currentActionTiles.Add(newProducableUnitTile);

            // Button event
            newProducableUnitTile.GetComponent <Button>().onClick.AddListener(delegate()
            {
                // Action
                unit.movement.stopMoving();
            });
        }
        if (unit is IMovable && unit is IAttacking)
        {
            // Create tile
            Action newAction = new Action(
                "Attack Move",
                uiManager.GetComponent <UI_TileManager>().UI_Action_AttackMove
                );
            GameObject newProducableUnitTile = uiUtils.createTile(newAction);
            currentActionTiles.Add(newProducableUnitTile);

            // Button event
            newProducableUnitTile.GetComponent <Button>().onClick.AddListener(delegate()
            {
                // Action
                // ...
            });
        }
    }