private void FixedUpdate() { deltaTime += Time.deltaTime; if (reloading != null && reloading.GetActualUseState() >= 0.99) { reloading.usingChar.ik.DisableLeftHand = !reloading.getConsumableStats().DisableLeftHand; reloading.usingChar.ik.DisableRightHand = !reloading.getConsumableStats().DisableRightHands; reloading = null; } }
public bool Stack(ItemController item) { if (item is ConsumableItem) { ConsumableItem consumable = (item as ConsumableItem); ItemController itContrl = GetItemByName(consumable.Stats.ItemName); if (itContrl != null && itContrl is ConsumableItem) { ConsumableItem alreadyInInventary = (itContrl as ConsumableItem); int max = alreadyInInventary.getConsumableStats().MaxUnits; if (max == alreadyInInventary.Units) { return(true); } int totalUnits = alreadyInInventary.Units + consumable.Units; int difference = (totalUnits - max); alreadyInInventary.Units = (difference > 0 ? max : totalUnits); consumable.Units = (difference > 0 ? difference : 0); if (consumable.Units <= 0) { ConsumableItem.Destroy(consumable.gameObject); return(true); } } } return(false); }
private void FixedUpdate() { if (invItem != null) { if (invItem is ConsumableItem) { ConsumableItem it = (invItem as ConsumableItem); if (Text != null) { Text.text = it.Units + "/" + it.getConsumableStats().MaxUnits; } countDown.fillAmount = it.GetActualUseState(); } else if (invItem is GunController) { GunController it = (invItem as GunController); if (Text != null) { Text.text = it.FireState.mode + "\n" + it.ActualAmmo + "/" + it.getGunStats().maxClip; } } } }
public override void Use(CharController character) { InventaryGroup g = character.inventary.GetGroup("Ammo"); if (g != null) { ItemController it = g.GetItemByName(getGunStats().ammoName); if (it != null && it is ConsumableItem) { ConsumableItem consumable = (it as ConsumableItem); int lack = (this.getGunStats().maxClip - ActualAmmo); if (lack <= 0) { return; } else { int getUnits = (consumable.Units < lack ? consumable.Units : lack); reloading = consumable; consumable.Use(character); consumable.Units -= getUnits; ActualAmmo += getUnits; int index = character.anim.GetLayerIndex(Stats.animLayer); character.anim.Play(Stats.animation, index); character.anim.SetLayerWeight(index, 1); character.ik.DisableLeftHand = consumable.getConsumableStats().DisableLeftHand; character.ik.DisableRightHand = consumable.getConsumableStats().DisableRightHands; Debug.Log(Stats.animation); Debug.Log(index); } } } base.Use(character); }