예제 #1
0
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        if (!phase1Init)
        {
            CmdFetchPlayerInfo();
            phase1Init = true;
            return;
        }

        if (!phase2Init)
        {
            if (info == null)
            {
                return;
            }

            beltUI = GameObject.FindGameObjectWithTag("ItemBar").GetComponent <BeltInventoryUI> ();
            beltUI.loadInventory(info.belt);


            backpackUI = GameObject.FindGameObjectWithTag("BackpackUI").GetComponent <BackpackInventoryUI> ();
            equipUI    = GameObject.FindGameObjectWithTag("EquipUI").GetComponent <EquipMenuUI> ();
            if (info.backpack != null)
            {
                backpackUI.loadInventory(info.backpack.inventory);
            }

            equipUI.updateUI(info);

            phase2Init = true;
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            int  slotNum = beltUI.getSelectedSlotNumber();
            Item item    = info.belt.getSlots() [slotNum].getItem();
            if (item != null)
            {
                CmdUseItem(slotNum, MessageUtil.ToArray(item));
            }
        }
    }
예제 #2
0
    public static bool PerformOperationWithBackpackUIUpdate(Player player, EquipmentOperation operation, BackpackInventoryUI invUI)
    {
        Item item = assertGoodItem(operation.itemData);

        if (item == null)
        {
            return(false);
        }

        switch (operation.op)
        {
        case Operation.SetHelmet:
            if (item is HelmetItem)
            {
                player.info.helmet = item as HelmetItem;
                return(true);
            }
            else
            {
                return(false);
            }

        case Operation.SetUpperBody:
            if (item is UpperBodyItem)
            {
                player.info.upperBody = item as UpperBodyItem;
                return(true);
            }
            else
            {
                return(false);
            }

        case Operation.SetLowerBody:
            if (item is LowerBodyItem)
            {
                player.info.lowerBody = item as LowerBodyItem;
                return(true);
            }
            else
            {
                return(false);
            }

        case Operation.SetBoots:
            if (item is BootsItem)
            {
                player.info.boots = item as BootsItem;
                return(true);
            }
            else
            {
                return(false);
            }

        case Operation.SetLeftClaw:
            if (item is ClawItem)
            {
                player.info.leftClaw = item as ClawItem;
                return(true);
            }
            else
            {
                return(false);
            }

        case Operation.SetRightClaw:
            if (item is ClawItem)
            {
                player.info.rightClaw = item as ClawItem;
                return(true);
            }
            else
            {
                return(false);
            }

        case Operation.SetBackpack:
            if (item is BackpackItem)
            {
                player.info.backpack = item as BackpackItem;
                if (invUI != null)
                {
                    invUI.loadInventory(player.info.backpack.inventory);
                }


                return(true);
            }
            else
            {
                return(false);
            }

        case Operation.SmartSet:
            return(smartEquip(item, player.info, invUI));

        default:
            Debug.Log("Unhandled EquipmentOperation case");
            return(false);
        }
    }
예제 #3
0
    private static bool smartEquip(Item equip, PlayerInfo info, BackpackInventoryUI invUI)
    {
        if (equip is BackpackItem)
        {
            BackpackItem backpack = equip as BackpackItem;
            if (info.backpack == null)
            {
                info.backpack = backpack;
                if (invUI != null)
                {
                    invUI.loadInventory(info.backpack.inventory);
                }
                return(true);
            }
            return(false);
        }
        else if (equip is HelmetItem)
        {
            HelmetItem helmet = equip as HelmetItem;
            if (info.helmet == null)
            {
                info.helmet = helmet;
                return(true);
            }
            return(false);
        }
        else if (equip is UpperBodyItem)
        {
            UpperBodyItem upperBody = equip as UpperBodyItem;
            if (info.upperBody == null)
            {
                info.upperBody = upperBody;
                return(true);
            }
            return(false);
        }
        else if (equip is LowerBodyItem)
        {
            LowerBodyItem lowerBody = equip as LowerBodyItem;
            if (info.lowerBody == null)
            {
                info.lowerBody = lowerBody;
                return(true);
            }
            return(false);
        }
        else if (equip is BootsItem)
        {
            BootsItem boots = equip as BootsItem;
            if (info.boots == null)
            {
                info.boots = boots;
                return(true);
            }
            return(false);
        }
        else if (equip is ClawItem)
        {
            ClawItem claw = equip as ClawItem;
            if (info.rightClaw == null)
            {
                info.rightClaw = claw;
                return(true);
            }
            else if (info.leftClaw == null)
            {
                info.leftClaw = claw;
            }
            else
            {
                return(false);
            }
        }

        return(false);
    }