Exemplo n.º 1
0
    /// <summary>
    /// Take care of switching and moving through menus when the corresponding keys are pressed.
    /// </summary>
    protected void Update()
    {
        //Toggle the appropriate menu
        if (InputContextManager.isMAIN_MENU_PUSHED())
        {
            if (menuCode == tMenuStates.MENU_MAIN)
                menuCode = tMenuStates.MENU_NONE;
            else
                menuCode = tMenuStates.MENU_MAIN;
        }

        switch (menuCode)
        {
            case tMenuStates.MENU_MAIN:
                {
                    if (InputContextManager.isMENU_LEFT())
                        menuCode = tMenuStates.CRAFTING;
                    else if (InputContextManager.isMENU_UP())
                        menuCode = tMenuStates.INVENTORY;
                    else if (InputContextManager.isMENU_RIGHT())
                        menuCode = tMenuStates.ASSEMBLING;
                    else if (InputContextManager.isITEM_MENU_PUSHED())
                        menuCode = tMenuStates.MENU_NONE;
                    break;
                }

            //See which menu we're in and process movement. Handle switching between menus first
            case tMenuStates.INVENTORY:
                {
                    if (InputContextManager.isMENU_SWITCH_LEFT())
                    {
                        menuCode = tMenuStates.CRAFTING;
                        break;
                    }
                    else if (InputContextManager.isMENU_SWITCH_RIGHT())
                    {
                        menuCode = tMenuStates.ASSEMBLING;
                        break;
                    }

                    //Process menu movement inside the inventory
                    handleInventoryMovement();

                    break;
                }
            case tMenuStates.CRAFTING:
                {
                    if (InputContextManager.isMENU_SWITCH_LEFT())
                    {
                        menuCode = tMenuStates.ASSEMBLING;
                        break;
                    }
                    else if (InputContextManager.isMENU_SWITCH_RIGHT())
                    {
                        menuCode = tMenuStates.INVENTORY;
                        break;
                    }

                    handleCraftingMovement();
                    break;
                }
            case tMenuStates.ASSEMBLING:
                {
                    if (InputContextManager.isMENU_SWITCH_LEFT())
                    {
                        menuCode = tMenuStates.INVENTORY;
                        break;
                    }
                    else if (InputContextManager.isMENU_SWITCH_RIGHT())
                    {
                        menuCode = tMenuStates.CRAFTING;
                        break;
                    }
                    handleAssembleMovement();
                    break;
                }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// The initializer menu when this object is created.
    /// </summary>
    protected void Start()
    {
        //Start off outside of a menu
        menuCode = tMenuStates.MENU_NONE;

        //Initialize the player
        player = GameObject.FindGameObjectWithTag("Player").GetComponent<Unit>();

        //Initialize component data structures
        int intNumWeapons = Enum.GetNames(typeof(ItemWeapon.tWeaponType)).Length - ItemWeapon.getNonCraftingWeapons().Count;
        int intNumParts = Enum.GetNames(typeof(ItemComponent.tComponentPart)).Length;

        arrWepPartNames = new string[intNumWeapons * intNumParts];

        int intNumOres = Enum.GetNames(typeof(ItemComponent.tOreType)).Length;
        int intNumAtts = Enum.GetNames(typeof(ItemComponent.tAttributeType)).Length;

        //Find all the weapon categories and add them to an array
        arrComponentGrids = new ItemSlot[arrWepPartNames.Length][,];
        int intWepCategoryindex = 0;
        foreach (ItemWeapon.tWeaponType wepType in (ItemWeapon.tWeaponType[])Enum.GetValues(typeof(ItemWeapon.tWeaponType)))
        {
            if (ItemWeapon.getNonCraftingWeapons().Contains(wepType))
                continue;
            //Weapon categories are a combination of the Weapon type and the weapon part e.g. sword blade and staff arrow
            foreach (ItemComponent.tComponentPart partType in (ItemComponent.tComponentPart[])Enum.GetValues(typeof(ItemComponent.tComponentPart)))
            {
                string code = ItemComponent.getComponentCategoryCode(wepType, partType);
                string name = ItemComponent.getComponentName(code);

                arrWepPartNames[intWepCategoryindex] = name; //An array to store the names for the weapon parts

                //Get the craftable components based on which category we're in e.g. Lightened copper sword handle
                arrMakeableComps = new ItemSlot[intNumAtts, intNumOres - ItemBase.getNonCraftingOres().Count]; //Account for non-useable types
                int intAttIndex = 0;
                foreach (ItemComponent.tAttributeType attType in (ItemComponent.tAttributeType[])Enum.GetValues(typeof(ItemComponent.tAttributeType)))
                {
                    //Components will be a combination of the attribute, ore, weapon, and the part
                    int intOreIndex = 0;
                    foreach (ItemComponent.tOreType oreType in (ItemComponent.tOreType[])Enum.GetValues(typeof(ItemComponent.tOreType)))
                    {
                        //Ignore NOT_ORE & Stone types
                        if (ItemBase.getNonCraftingOres().Contains(oreType))
                            continue;

                        string newCompCode = ItemComponent.generateComponentCode(attType, oreType, wepType, partType);
                        ItemComponent newComponent = ItemFactory.createComponent(newCompCode);

                        ItemSlot slot = new ItemSlot();
                        slot.item = newComponent;

                        //TODO Ask Ari what exact quantities should be needed
                        slot.oreNeeded.oreType = oreType;
                        slot.oreNeeded.Quantity = 3;

                        slot.oreNeeded.neededPoints = (int)oreType;

                        //Unlock the very first tier of components
                        if (intOreIndex == 0)
                            slot.unlocked = true;
                        else
                            slot.unlocked = false;

                        arrMakeableComps[intAttIndex, intOreIndex] = slot;

                        intOreIndex++;
                    }
                    intAttIndex++;
                }

                arrComponentGrids[intWepCategoryindex] = arrMakeableComps;
                intWepCategoryindex++; //The weapon category index is needed since crafting is done by selecting category and then attribute+ore
            }
        }
    }