Exemplo n.º 1
0
    void Default()
    {
        Debug.Log("building menu");

        menuItems = new List<MenuItem>();
        GameObject menuItemObject;
        MenuItem menuItem;
        //MenuAction menuAction;
        if (combatant.Stats.TurnStats.CanAttack()) {

            MenuAttackAction attackAction = new MenuAttackAction();
            attackAction.parentMenu = this;
            attackAction.combatant = combatant;

            menuItemObject = (GameObject)Instantiate(Resources.Load("MenuItem"));
            menuItemObject.transform.parent = this.gameObject.transform;
            menuItem = menuItemObject.GetComponent<MenuItem>();
            menuItem.SetText("Attack");
            menuItem.name = menuItem.menuItemText.text;
            menuItem.transform.localRotation = Quaternion.identity;
            menuItem.transform.localPosition = Vector3.zero;
            menuItem.transform.localScale = Vector3.one;
            menuItem.SetMenuAction(attackAction);
            menuItems.Add(menuItem);

        }

        if (combatant.Stats.TurnStats.CanMove()) {
            //menuAction = new MenuMoveAction();
            MenuMoveAction moveAction = new MenuMoveAction();
            moveAction.SetMenu(this);
            moveAction.combatant = combatant;

            menuItemObject = (GameObject)Instantiate(Resources.Load("MenuItem"));
            menuItemObject.transform.parent = this.gameObject.transform;
            menuItem = menuItemObject.GetComponent<MenuItem>();
            menuItem.SetText("Move");
            menuItem.name = menuItem.menuItemText.text;
            menuItem.transform.localRotation = Quaternion.identity;
            menuItem.transform.localPosition = Vector3.zero;
            menuItem.transform.localScale = Vector3.one;
            menuItem.SetMenuAction(moveAction);
            menuItems.Add(menuItem);
        }

        //menuAction = new MenuEndTurnAction();
        MenuEndTurnAction endTurnAction = new MenuEndTurnAction();
        endTurnAction.parentMenu = this;
        menuItemObject = (GameObject)Instantiate(Resources.Load("MenuItem"));
        menuItemObject.transform.parent = this.gameObject.transform;
        menuItem = menuItemObject.GetComponent<MenuItem>();
        menuItem.SetText("End Turn");
        menuItem.name = menuItem.menuItemText.text;
        menuItem.transform.localRotation = Quaternion.identity;
        menuItem.transform.localPosition = Vector3.zero;
        menuItem.transform.localScale = Vector3.one;
        menuItem.SetMenuAction(endTurnAction);
        menuItems.Add(menuItem);

        int i = 0;
        foreach(MenuItem item in menuItems) {
            Vector3 pos = item.transform.position;
            pos.y = pos.y - (item.menuItemText.fontSize * i);
            item.transform.position = pos;
            i = i + 1;
        }
        menuSelector.SetMenuItems(menuItems);
    }
Exemplo n.º 2
0
    void Default()
    {
        Debug.Log("building menu");

        menuItems = new List <MenuItem>();
        GameObject menuItemObject;
        MenuItem   menuItem;

        //MenuAction menuAction;
        if (combatant.Stats.TurnStats.CanAttack())
        {
            MenuAttackAction attackAction = new MenuAttackAction();
            attackAction.parentMenu = this;
            attackAction.combatant  = combatant;

            menuItemObject = (GameObject)Instantiate(Resources.Load("MenuItem"));
            menuItemObject.transform.parent = this.gameObject.transform;
            menuItem = menuItemObject.GetComponent <MenuItem>();
            menuItem.SetText("Attack");
            menuItem.name = menuItem.menuItemText.text;
            menuItem.transform.localRotation = Quaternion.identity;
            menuItem.transform.localPosition = Vector3.zero;
            menuItem.transform.localScale    = Vector3.one;
            menuItem.SetMenuAction(attackAction);
            menuItems.Add(menuItem);
        }

        if (combatant.Stats.TurnStats.CanMove())
        {
            //menuAction = new MenuMoveAction();
            MenuMoveAction moveAction = new MenuMoveAction();
            moveAction.SetMenu(this);
            moveAction.combatant = combatant;

            menuItemObject = (GameObject)Instantiate(Resources.Load("MenuItem"));
            menuItemObject.transform.parent = this.gameObject.transform;
            menuItem = menuItemObject.GetComponent <MenuItem>();
            menuItem.SetText("Move");
            menuItem.name = menuItem.menuItemText.text;
            menuItem.transform.localRotation = Quaternion.identity;
            menuItem.transform.localPosition = Vector3.zero;
            menuItem.transform.localScale    = Vector3.one;
            menuItem.SetMenuAction(moveAction);
            menuItems.Add(menuItem);
        }

        //menuAction = new MenuEndTurnAction();
        MenuEndTurnAction endTurnAction = new MenuEndTurnAction();

        endTurnAction.parentMenu        = this;
        menuItemObject                  = (GameObject)Instantiate(Resources.Load("MenuItem"));
        menuItemObject.transform.parent = this.gameObject.transform;
        menuItem = menuItemObject.GetComponent <MenuItem>();
        menuItem.SetText("End Turn");
        menuItem.name = menuItem.menuItemText.text;
        menuItem.transform.localRotation = Quaternion.identity;
        menuItem.transform.localPosition = Vector3.zero;
        menuItem.transform.localScale    = Vector3.one;
        menuItem.SetMenuAction(endTurnAction);
        menuItems.Add(menuItem);

        int i = 0;

        foreach (MenuItem item in menuItems)
        {
            Vector3 pos = item.transform.position;
            pos.y = pos.y - (item.menuItemText.fontSize * i);
            item.transform.position = pos;
            i = i + 1;
        }
        menuSelector.SetMenuItems(menuItems);
    }