Ejemplo n.º 1
0
    //Shows the submenu actions for the actor
    public void showSubMenu(GameObject actor, string subMenu)
    {
        hideActionMenu();

        int children = actionMenuCommands.transform.childCount;

        for (int i = 0; i < children - 1; i++)
        {
            Destroy(actionMenuCommands.transform.GetChild(i));
        }
        Debug.Log("Removed old menu");

        bf.turnStage       = TurnStage.SELECTING_ACTION_SUBMENU;
        bf.cameFromSubMenu = true;
        bf.curSkill        = null;
        bf.curTargetType   = TargetType.NULL;
        bf.lastSubMenu     = subMenu;

        if (subMenu.ToLower().Trim() != "items")
        {
            List <Skill> skillsMenu = null;
            if (subMenu.ToLower().Trim() == "skill")
            {
                skillsMenu = subMenuSkills;
            }
            else if (subMenu.ToLower().Trim() == "blackmagic")
            {
                skillsMenu = subMenuBlackMagic;
            }
            else if (subMenu.ToLower().Trim() == "whitemagic")
            {
                skillsMenu = subMenuWhiteMagic;
            }

            foreach (Skill s in skillsMenu)
            {
                Debug.Log("Adding skill: " + s.name);
                GameObject so = Instantiate <GameObject>(_gm._battle.actionButtonPrefab);
                so.transform.SetParent(actionMenuCommands.transform);
                BattleComandButton bcb = so.GetComponent <BattleComandButton>();
                bcb.myButton.onClick.AddListener(() => { bcb.buttonClicked(); });
                if (s.cost != 0)
                {
                    bcb.myText.text = s.name + "   " + s.cost;
                }
                else
                {
                    bcb.myText.text = s.name;
                }
                bcb.actorOwner    = actor;
                bcb.myLinkedSkill = s;
                bcb.myLinkedMenu  = -1;
                bcb.myIcon        = s.icon;
                bcb.bf            = bf;
            }
            Debug.Log("Added skills for loaded sub-menu: " + subMenu + " for actor: " + actor.GetComponent <ActorBase>().name);

            showActionMenu();
        }
        else
        {
            //Get list of usuable in combat items from inventory
            //Use a larger scroll rect of multiple columns with numbers of items
            //Use same setup for targetting as skills for items and use the turnstage to keep the navigation working

            Debug.Log("Loaded usuable item inventory for actor: " + actor.GetComponent <ActorBase>().name);
        }
    }
Ejemplo n.º 2
0
    //Shows the base level actions for that actor, also recieves skills for other menus
    public void showBaseMenu(GameObject actor)
    {
        hideActionMenu();

        List <Skill> mySkills    = _gm._battle.getSkillsFor(actor);
        List <Skill> skillsToAdd = new List <Skill>();

        showActionMenu();

        //Reset values of script's saved skills
        subMenuSkills     = new List <Skill>();
        subMenuBlackMagic = new List <Skill>();
        subMenuWhiteMagic = new List <Skill>();

        foreach (Skill s in mySkills)
        {
            //Add to list
            if (s.skillType == SkillType.NONE)
            {
                skillsToAdd.Add(s);
            }
            else
            {
                //Player has skill for a sub-menu
                if (s.skillType == SkillType.Skill)
                {
                    Debug.Log("Added a skill to skill submenu: " + s.name);
                    subMenuSkills.Add(s);
                }
                else if (s.skillType == SkillType.Black_Magic)
                {
                    Debug.Log("Added a skill to black magic submenu: " + s.name);
                    subMenuBlackMagic.Add(s);
                }
                else if (s.skillType == SkillType.White_Magic)
                {
                    Debug.Log("Added a skill to white magic submenu: " + s.name);
                    subMenuWhiteMagic.Add(s);
                }
            }
        }
        Debug.Log("SM Skills: " + subMenuWhiteMagic.Count + ", BM Skills: " + subMenuBlackMagic.Count + ", Other Skills: " + subMenuSkills.Count);

        //Create button for each base menu skill
        foreach (Skill s in skillsToAdd)
        {
            GameObject so = Instantiate <GameObject>(_gm._battle.actionButtonPrefab);
            so.transform.SetParent(actionMenuCommands.transform);
            BattleComandButton sbcb = so.GetComponent <BattleComandButton>();
            sbcb.myButton = so.GetComponent <Button>();
            sbcb.myButton.onClick.AddListener(delegate() { sbcb.buttonClicked(); });
            if (s.cost != 0)
            {
                sbcb.myText.text = s.name + "   " + s.cost;
            }
            else
            {
                sbcb.myText.text = s.name;
            }
            sbcb.actorOwner    = actor;
            sbcb.myLinkedSkill = s;
            sbcb.myLinkedMenu  = -1;
            sbcb.bf            = bf;
            if (actor.GetComponent <ActorBase>().curMana < s.cost)
            {
                //Turn owner cannot afford cost of this skill currently.
                so.GetComponent <Button>().image.color = Color.gray;
            }
            Debug.Log("Created command for skill: " + s.name);
        }

        //Add buttons for the submenus
        //SKILLS
        if (subMenuSkills.Count > 0)
        {
            GameObject suo = Instantiate <GameObject>(_gm._battle.actionButtonPrefab);
            suo.transform.SetParent(actionMenuCommands.transform);
            BattleComandButton subbcb = suo.GetComponent <BattleComandButton>();
            subbcb.myButton = subbcb.GetComponent <Button>();
            subbcb.myButton.onClick.AddListener(delegate() { subbcb.buttonClicked(); });
            subbcb.myText.text   = "Skills";
            subbcb.actorOwner    = actor;
            subbcb.myLinkedSkill = null;
            subbcb.myLinkedMenu  = 0;
            subbcb.bf            = bf;
            Debug.Log("Created skills submenu button!");
        }
        //BLACK MAGIC
        if (subMenuBlackMagic.Count > 0)
        {
            GameObject suo = Instantiate <GameObject>(_gm._battle.actionButtonPrefab);
            suo.transform.SetParent(actionMenuCommands.transform);
            BattleComandButton subbcb = suo.GetComponent <BattleComandButton>();
            subbcb.myButton = subbcb.GetComponent <Button>();
            subbcb.myButton.onClick.AddListener(delegate() { subbcb.buttonClicked(); });
            subbcb.myText.text   = "Black Magic";
            subbcb.actorOwner    = actor;
            subbcb.myLinkedSkill = null;
            subbcb.myLinkedMenu  = 1;
            subbcb.bf            = bf;
            Debug.Log("Created black magic submenu button!");
        }
        //WHITE MAGIC
        if (subMenuWhiteMagic.Count > 0)
        {
            GameObject suo = Instantiate <GameObject>(_gm._battle.actionButtonPrefab);
            suo.transform.SetParent(actionMenuCommands.transform);
            BattleComandButton subbcb = suo.GetComponent <BattleComandButton>();
            subbcb.myButton = subbcb.GetComponent <Button>();
            subbcb.myButton.onClick.AddListener(delegate() { subbcb.buttonClicked(); });
            subbcb.myText.text   = "White Magic";
            subbcb.actorOwner    = actor;
            subbcb.myLinkedSkill = null;
            subbcb.myLinkedMenu  = 2;
            subbcb.bf            = bf;
            Debug.Log("Created white magic submenu button!");
        }

        Debug.Log("Adding required Items button!");
        GameObject io = Instantiate <GameObject>(_gm._battle.actionButtonPrefab);

        io.transform.SetParent(actionMenuCommands.transform);
        BattleComandButton bcb = io.GetComponent <BattleComandButton>();

        bcb.myButton = io.GetComponent <Button>();
        bcb.myButton.onClick.AddListener(delegate() { bcb.buttonClicked(); });
        bcb.myText.text   = "Items";
        bcb.actorOwner    = actor;
        bcb.myLinkedSkill = null;
        bcb.myLinkedMenu  = 3;
        bcb.bf            = bf;
        Debug.Log("Created Items submenu button!");

        bf.turnStage       = TurnStage.SELECTING_ACTION;
        bf.curSkill        = null;
        bf.curTargetType   = TargetType.NULL;
        bf.cameFromSubMenu = false;

        Debug.Log("Added base menu skills for actor: " + actor.GetComponent <Actor>().name);
    }