Пример #1
0
    //반응키로 눌렀을때
    public void ClickAction()
    {
        if (player == null)
        {
            return;
        }
        if (itemBase == null)
        {
            return;
        }

        if (player.isInventoryFull() == true &&
            //가방 , 아머일때는 인벤토리 크기 상관 x
            (itemBase.itemType != ItemType.Bag && itemBase.itemType != ItemType.Armor))
        {
            if (Language.Instance.NowLanguage == LanguageType.English)
            {
                MessageBar.Instance.ShowInfoBar("Inventory Is Full", Color.red);
            }
            else
            {
                MessageBar.Instance.ShowInfoBar("가방이 가득 찼어요", Color.red);
            }
            SoundManager.Instance.PlaySoundEffect("error");
            return;
        }

        if (isSalesItem == true)
        {
            if (player.Coin < price)
            {
                if (Language.Instance.NowLanguage == LanguageType.English)
                {
                    MessageBar.Instance.ShowInfoBar("Not enough money", Color.red);
                }
                else
                {
                    MessageBar.Instance.ShowInfoBar("돈이 부족합니다.", Color.red);
                }
                return;
            }
            else
            {
                if (player.isInventoryFull() == true)
                {
                    return;
                }
                player.UseCoin(price);
                SoundManager.Instance.PlaySoundEffect("ItemBuy");
                isSoldOut = true;
            }
        }

        switch (itemBase.itemType)
        {
        case ItemType.Weapon:
        {
            Type type = Type.GetType("weapon." + itemBase.weapontype.ToString());
            if (type == null)
            {
                break;
            }
            Weapon instance = Activator.CreateInstance(type) as Weapon;
            if (instance == null)
            {
                break;
            }
            player.AddWeapon(instance);
            itemBase = null;
        }
        break;

        case ItemType.Bag:
        {
            Item_Bag bag = itemBase as Item_Bag;
            if (bag == null)
            {
                return;
            }

            if (bag != null)
            {
                player.GetBag(bag.ItemLevel, bag.Value);
            }
            //해제
            itemBase = null;
        }
        break;

        case ItemType.Armor:
        {
            player.SetArmor(itemBase.Value);
        }
        break;

        default:
        {
            player.AddItem(itemBase);
        }
        break;
        }
        Destroy(this.gameObject);
    }