Beispiel #1
0
    public void setData(GameBattleUnit u, GameBattleUnitActionItemMode m)
    {
        unit      = u;
        mode      = m;
        selection = 0;

        for (int i = 0; i < GameDefine.MAX_SLOT; i++)
        {
            slots[i].clear();

            if (unit.Items[i] == GameDefine.INVALID_ID)
            {
                continue;
            }

            GameItem item = GameItemData.instance.getData(unit.Items[i]);

            slots[i].setData(item);
            slots[i].enable(true);

            switch (m)
            {
            case GameBattleUnitActionItemMode.Use:
            {
                if (!u.canUseItem(item))
                {
                    slots[i].enable(false);
                }
            }
            break;

            case GameBattleUnitActionItemMode.Give:
                break;

            case GameBattleUnitActionItemMode.Equip:
            {
                if (!u.canEquipItem(item))
                {
                    slots[i].enable(false);
                }
            }
            break;

            case GameBattleUnitActionItemMode.Drop:
                break;
            }
        }

        switch (m)
        {
        case GameBattleUnitActionItemMode.Give:
        case GameBattleUnitActionItemMode.Drop:
        {
            enableWeapon(false);
            enableArmor(false);
            enableAccessory(false);
        }
        break;

        case GameBattleUnitActionItemMode.Equip:
        {
            enableWeapon(false);
            enableArmor(false);
        }
        break;
        }

        int WeaponSlot    = unit.WeaponSlot;
        int ArmorSlot     = unit.ArmorSlot;
        int AccessorySlot = unit.AccessorySlot;

        if (WeaponSlot != GameDefine.INVALID_ID)
        {
            slots[WeaponSlot].setEquip(true);
        }
        if (ArmorSlot != GameDefine.INVALID_ID)
        {
            slots[ArmorSlot].setEquip(true);
        }
        if (AccessorySlot != GameDefine.INVALID_ID)
        {
            slots[AccessorySlot].setEquip(true);
        }

        for (int i = 0; i < GameDefine.MAX_SLOT; i++)
        {
            if (slots[i].Enabled)
            {
                select(i);
                return;
            }
        }

        select(selection);
    }