Пример #1
0
    public bool DecreaseAmmo(AmmoType ammoType, int ammoDec)
    {
        AmmoSlot ammoSlot = GetAmmoSlot(ammoType);

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

        if (ammoSlot.ammoAmount <= 0)
        {
            return(false);
        }

        ammoSlot.ammoAmount -= ammoDec;
        if (ammoSlot.ammoAmount < 0)
        {
            ammoSlot.ammoAmount = 0;
        }

        if (ammoSlot.ammoType == AmmoType.Unlimited)
        {
            ammoSlot.ammoAmount = ammoSlot.maxAmount;
        }

        return(true);
    }
Пример #2
0
    public void DecreaseAmmo(AmmoType ammoType)
    {
        AmmoSlot ammoSlot = GetAmmoSlot(ammoType);

        if (ammoSlot != null)
        {
            ammoSlot.ammoAmmount--;
        }
    }
Пример #3
0
    public void IncreaseAmmo(AmmoType ammoType, int ammount)
    {
        AmmoSlot ammoSlot = GetAmmoSlot(ammoType);

        if (ammoSlot != null)
        {
            ammoSlot.ammoAmmount += ammount;
        }
    }
Пример #4
0
    public void ReduceCurrentAmmo(AmmoType ammoType)
    {
        AmmoSlot ammoSlot = GetAmmoSlot(ammoType);

        if (ammoSlot != null)
        {
            ammoSlot.ammoAmount--;
        }
    }
Пример #5
0
    public int GetAmmoAmount(AmmoType ammoType)
    {
        AmmoSlot ammoSlot = GetAmmoSlot(ammoType);

        if (ammoSlot == null)
        {
            return(0);
        }
        return(ammoSlot.ammoAmount);
    }
Пример #6
0
 // Start is called before the first frame update
 void Start()
 {
     results        = new Collider2D[24];
     hashCodes      = AnimationPropertiesPool.Instance.animationDictionary[animationPropertyIndex].animationHashCodes;
     animator       = GetComponent <Animator>();
     currentState   = hashCodes[0];
     target         = null;
     angleDivider   = 360.0f / hashCodes.Length;
     ammoInventory  = GetComponent <AmmoSlot>();
     animator.speed = 0;
 }
Пример #7
0
    public int GetAmmo(AmmoType ammoType)
    {
        AmmoSlot ammoSlot = GetAmmoSlot(ammoType);

        if (ammoSlot != null)
        {
            return(ammoSlot.ammoAmmount);
        }
        else
        {
            return(0);
        }
    }
Пример #8
0
    void OnClickInventorySlot(GameObject inventorySlot)
    {
        AmmoSlot ammoInv = inventory as AmmoSlot;

        if (ammoInv != null)
        {
            ammoInv.TransferMouse(mouseInventory, inventorySlot.GetComponent <InventorySlot>().slotID);
        }
        else
        {
            inventory.TransferMouse(mouseInventory, inventorySlot.GetComponent <InventorySlot>().slotID);
        }
    }
Пример #9
0
    public bool IncreaseAmmo(AmmoType ammoType, int ammoAdd)
    {
        AmmoSlot ammoSlot = GetAmmoSlot(ammoType);

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

        if (ammoSlot.ammoAmount >= ammoSlot.maxAmount)
        {
            return(false);
        }

        ammoSlot.ammoAmount += ammoAdd;

        if (ammoSlot.ammoAmount > ammoSlot.maxAmount)
        {
            ammoSlot.ammoAmount = ammoSlot.maxAmount;
        }

        return(true);
    }
Пример #10
0
    public void IncreaseCurrentAmmo(AmmoType ammoType, int ammoAmount)
    {
        AmmoSlot currentSlot = GetAmmoSlot(ammoType);

        currentSlot.ammoAmount += ammoAmount;
    }
Пример #11
0
    public void ReduceCurrentAmmo(AmmoType ammoType)
    {
        AmmoSlot currentSlot = GetAmmoSlot(ammoType);

        currentSlot.ammoAmount--;
    }
Пример #12
0
    public int GetCurrentAmmo(AmmoType ammoType)
    {
        AmmoSlot currentSlot = GetAmmoSlot(ammoType);

        return(currentSlot.ammoAmount);
    }
Пример #13
0
    public void addAmmoForSpecificType(int amount, int slotNumber)
    {
        AmmoSlot a = ammoSlots[slotNumber];

        a.ammoAmount += amount;
    }
Пример #14
0
    // Start is called before the first frame update
    void Start()
    {
        filterMining = new ContactFilter2D();
        filterMining.useLayerMask = true;
        filterMining.layerMask    = layerMaskMining;
        filterMining.useTriggers  = true;

        filter = new ContactFilter2D();
        filter.useLayerMask = true;
        filter.layerMask    = layerMask;
        filter.useTriggers  = false;

        placeSprite = Instantiate(placeSpritePrefab, Vector3.zero, Quaternion.identity);
        Inventory[] inventories = GetComponents <Inventory>();
        for (int i = 0; i < inventories.Length; i++)
        {
            if (inventories[i] is AmmoSlot)
            {
                ammoInventory = inventories[i] as AmmoSlot;
            }
            else
            {
                playerInventory = inventories[i];
            }
        }

        playerInventory     = GetComponent <Inventory>();
        placeSpriteRenderer = placeSprite.GetComponent <SpriteRenderer>();
        Camera.main.GetComponent <CameraFollow>().SetCameraTarget(this.gameObject);

        placeGrid            = GameObject.FindGameObjectWithTag("Grid").GetComponent <Grid>();
        canvas               = GameObject.Find("Canvas");
        machinePanelInteract = Instantiate(machinePanelInteractPrefab, canvas.transform);
        inventoryInteract    = Instantiate(inventoryPanelInteractPrefab, canvas.transform);
        inventoryPanel       = Instantiate(inventoryPanelPrefab, canvas.transform);
        craftingPanel        = Instantiate(craftingPanelPrefab, canvas.transform);
        inventoryAmmo        = Instantiate(ammoInventoryPrefab, canvas.transform);
        mouseInventoryUI     = Instantiate(mouseInventoryPrefab, canvas.transform);
        tooltip              = Instantiate(tooltipPanelPrefab, canvas.transform);
        filterItemPanel      = Instantiate(filterItemPanelPrefab, canvas.transform);

        mouseInventoryUI.GetComponent <InventoryMouse>().SetInventory(mouseInventory);
        machineUI           = machinePanelInteract.GetComponentInChildren <MachineUI>();
        inventoryInteractUI = inventoryInteract.GetComponentInChildren <InventoryUI>();
        inventoryUI         = inventoryPanel.GetComponentInChildren <InventoryUI>();
        craftingUI          = craftingPanel.GetComponentInChildren <CraftingUI>();
        inventoryAmmoUI     = inventoryAmmo.GetComponentInChildren <InventoryUI>();
        ammoSlotSelected    = inventoryAmmo.GetComponentInChildren <HighlightSlotUI>();
        filterItemUI        = filterItemPanel.GetComponent <UIFilterItem>();

        inventoryAmmoUI.SetViewedInventory(ammoInventory);
        inventoryAmmoUI.SetMouseInventory(mouseInventory);
        inventoryUI.SetViewedInventory(playerInventory);
        inventoryUI.SetMouseInventory(mouseInventory);
        inventoryInteractUI.SetMouseInventory(mouseInventory);
        craftingUI.SetLinkedInventory(playerInventory);
        machineUI.SetMouseInventory(mouseInventory);



        characterAlliance = AllianceDefinitions.Instance.GetAlliance("Character");
        this.gameObject.GetComponent <Health>().alliance = characterAlliance.allianceCode;
    }