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); }
public void DecreaseAmmo(AmmoType ammoType) { AmmoSlot ammoSlot = GetAmmoSlot(ammoType); if (ammoSlot != null) { ammoSlot.ammoAmmount--; } }
public void IncreaseAmmo(AmmoType ammoType, int ammount) { AmmoSlot ammoSlot = GetAmmoSlot(ammoType); if (ammoSlot != null) { ammoSlot.ammoAmmount += ammount; } }
public void ReduceCurrentAmmo(AmmoType ammoType) { AmmoSlot ammoSlot = GetAmmoSlot(ammoType); if (ammoSlot != null) { ammoSlot.ammoAmount--; } }
public int GetAmmoAmount(AmmoType ammoType) { AmmoSlot ammoSlot = GetAmmoSlot(ammoType); if (ammoSlot == null) { return(0); } return(ammoSlot.ammoAmount); }
// 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; }
public int GetAmmo(AmmoType ammoType) { AmmoSlot ammoSlot = GetAmmoSlot(ammoType); if (ammoSlot != null) { return(ammoSlot.ammoAmmount); } else { return(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); } }
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); }
public void IncreaseCurrentAmmo(AmmoType ammoType, int ammoAmount) { AmmoSlot currentSlot = GetAmmoSlot(ammoType); currentSlot.ammoAmount += ammoAmount; }
public void ReduceCurrentAmmo(AmmoType ammoType) { AmmoSlot currentSlot = GetAmmoSlot(ammoType); currentSlot.ammoAmount--; }
public int GetCurrentAmmo(AmmoType ammoType) { AmmoSlot currentSlot = GetAmmoSlot(ammoType); return(currentSlot.ammoAmount); }
public void addAmmoForSpecificType(int amount, int slotNumber) { AmmoSlot a = ammoSlots[slotNumber]; a.ammoAmount += amount; }
// 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; }