コード例 #1
0
    public void TryBuyEquipment(EquipmentSlot equipmentSlot)
    {
        ShipEquipment equipmentToBuy = equipmentSlot.GetPlacedEquipment;

        if (inventoryManager.GetPlayerInventoryEquipments.Count < IntersceneManager.intersceneManager.GetPlayerDatas.GetPlayerInventoryCapacity)
        {
            if (IntersceneManager.intersceneManager.GetPlayerDatas.GetPlayerGoldAmount >= equipmentToBuy.PriceToBuy)
            {
                IntersceneManager.intersceneManager.GetPlayerDatas.SpendMoney(equipmentToBuy.PriceToBuy);

                if (docksInterface.SellerInventoryOpened)
                {
                    sellerManager.RemoveEquipmentFromSellerShop(equipmentToBuy);
                    docksInterface.OpenSellerInventoryPanel(sellerManager.GetBuyableEquipments);
                }
                else if (docksInterface.SellerRebuyInventoryOpened)
                {
                    sellerManager.RemoveSoldEquipmentToSellerShop(equipmentToBuy);
                    docksInterface.OpenSellerRebuyInventoryPanel(sellerManager.GetSoldEquipments);
                }

                inventoryManager.AddNewEquipmentToInventory(equipmentToBuy);
                docksInterface.OpenPlayerInventoryPanel(inventoryManager.GetPlayerInventoryEquipments);

                mapManager.EquipmentsInfoManager.CloseInformationsPanel();

                inventoryManager.UpdatePlayerEquipmentValue();

                //docksInterface.OpenPlayerInventoryPanel(inventoryManager.GetPlayerInventoryEquipments);
                mapManager.SavePlayerDatas();

                docksInterface.UpdatePlayerGoldText();
            }
            else
            {
                Debug.Log("Not enough money, kid");
            }
        }
        else
        {
            Debug.Log("trop d'objets dans l'inventaire pour acheter");
        }
    }