Beispiel #1
0
        private void SetWeaponInSlot(WeaponItem weapon, EquipmentSlotEnum equipmentSlotID)
        {
            switch (equipmentSlotID)
            {
            case EquipmentSlotEnum.RightHandSlot01:
                weaponsInRightHandSlots[0] = weapon;
                break;

            case EquipmentSlotEnum.RightHandSlot02:
                weaponsInRightHandSlots[1] = weapon;
                break;

            case EquipmentSlotEnum.RightHandSlot03:
                weaponsInRightHandSlots[2] = weapon;
                break;

            case EquipmentSlotEnum.LeftHandSlot01:
                weaponsInLeftHandSlots[0] = weapon;
                break;

            case EquipmentSlotEnum.LeftHandSlot02:
                weaponsInLeftHandSlots[1] = weapon;
                break;

            case EquipmentSlotEnum.LeftHandSlot03:
                weaponsInLeftHandSlots[2] = weapon;
                break;
            }

            if (weapon != null)
            {
                weaponsInInventory.Remove(weapon);
            }
        }
Beispiel #2
0
 private void UpdateWeaponSlots()
 {
     leftWeapon  = weaponsInLeftHandSlots[currentLeftWeaponIndex] != null ? weaponsInLeftHandSlots[currentLeftWeaponIndex] : unarmedWeapon;
     rightWeapon = weaponsInRightHandSlots[currentRightWeaponIndex] != null ? weaponsInRightHandSlots[currentRightWeaponIndex] : unarmedWeapon;
     weaponSlotManager.LoadWeaponOnSlot(rightWeapon, WeaponSlotID.RightHandSlot);
     weaponSlotManager.LoadWeaponOnSlot(leftWeapon, WeaponSlotID.LeftHandSlot);
 }
Beispiel #3
0
        public void UpdateWeaponQuickSlotsUI(bool isLeft, WeaponItem weapon)
        {
            Image quickSlotImage = isLeft ? leftWeaponIcon : rightWeaponIcon;

            quickSlotImage.sprite  = weapon.icon;
            quickSlotImage.enabled = weapon.icon != null;
        }
Beispiel #4
0
        public void EquipWeapon(WeaponItem weapon, EquipmentSlotEnum equipmentSlotID)
        {
            MoveWeaponBackToInventory(equipmentSlotID);
            SetWeaponInSlot(weapon, equipmentSlotID);

            UpdateWeaponSlots();
        }
Beispiel #5
0
        private void Start()
        {
            rightWeapon = weaponsInRightHandSlots[0] == null ? unarmedWeapon : weaponsInRightHandSlots[0];
            leftWeapon  = weaponsInLeftHandSlots[0] == null ? unarmedWeapon : weaponsInLeftHandSlots[0];

            weaponSlotManager.LoadWeaponOnSlot(rightWeapon, WeaponSlotID.RightHandSlot);
            weaponSlotManager.LoadWeaponOnSlot(leftWeapon, WeaponSlotID.LeftHandSlot);
        }
Beispiel #6
0
 public void SetColliderDamageAbsorbtion(WeaponItem weapon)
 {
     if (weapon != null)
     {
         blockingPhysicalDamageAbsorbtion = weapon.physicalDamageAbsorbtion;
         stability = weapon.stability;
     }
 }
Beispiel #7
0
        private void MoveWeaponBackToInventory(EquipmentSlotEnum equipmentSlotID)
        {
            WeaponItem equippedWeapon = GetEquippedWeapon(equipmentSlotID);

            if (equippedWeapon != null)
            {
                weaponsInInventory.Add(equippedWeapon);
            }
        }
Beispiel #8
0
 private void SelectNextLeftWeapon()
 {
     currentLeftWeaponIndex++;
     if (currentLeftWeaponIndex > weaponsInLeftHandSlots.Length - 1)
     {
         currentLeftWeaponIndex = 0;
     }
     leftWeapon = weaponsInLeftHandSlots[currentLeftWeaponIndex] != null ?
                  weaponsInLeftHandSlots[currentLeftWeaponIndex] : unarmedWeapon;
 }
Beispiel #9
0
 private void LoadWeapons()
 {
     foreach (HandEquipmentSlot slot in handEquipmentSlots)
     {
         WeaponItem weapon = playerInventory.GetEquippedWeapon(slot.equipmentSlotID);
         if (weapon != playerInventory.unarmedWeapon)
         {
             slot.AddItem(weapon);
         }
     }
 }
Beispiel #10
0
        public void AddItem(WeaponItem newWeapon)
        {
            if (newWeapon == null)
            {
                return;
            }

            weapon       = newWeapon;
            icon.sprite  = weapon.icon;
            icon.enabled = true;
        }
Beispiel #11
0
        public void HandleBlock(WeaponItem weapon)
        {
            if (playerManager.isBlocking || playerManager.isInteracting)
            {
                return;
            }

            animatorHandler.PlayTargetAnimation("Block_Idle", false, true);
            EnableBlockingCollider(weapon);
            playerManager.isBlocking = true;
        }
Beispiel #12
0
        public void LoadWeaponModel(WeaponItem weaponItem)
        {
            UnloadItemModelAndDestroy();

            if (weaponItem == null)
            {
                UnloadItemModel();
                return;
            }

            LoadItemModel(weaponItem);
        }
Beispiel #13
0
 private void PerformAttack(WeaponItem weapon, PlayerAttackAction attack)
 {
     if (playerStats.currentStamina <= 0)
     {
         return;
     }
     if (attack.actionAnimation == string.Empty)
     {
         throw new Exception("Attack with missing animation called: " + attack);
     }
     weaponSlotManager.attackingWeapon = weapon;
     animatorHandler.PlayTargetAnimation(attack.actionAnimation, true, true);
     lastAttack = attack;
 }
Beispiel #14
0
 public void LoadWeaponOnSlot(WeaponItem weapon, bool isLeft)
 {
     if (isLeft)
     {
         leftHandSlot.currentWeapon = weapon;
         leftHandSlot.LoadWeaponModel(weapon);
         LoadWeaponDamageCollider(true);
     }
     else
     {
         rightHandSlot.currentWeapon = weapon;
         rightHandSlot.LoadWeaponModel(weapon);
         LoadWeaponDamageCollider(false);
     }
 }
Beispiel #15
0
        public void LoadWeaponOnSlot(WeaponItem weaponItem, WeaponSlotID slotID)
        {
            WeaponHolderSlot slot = GetWeaponHolderSlot(slotID);
            if (slot.slotID == WeaponSlotID.LeftHandSlot)
            {
                leftHandSlot.currentWeapon = weaponItem;
                leftHandSlot.LoadWeaponModel(weaponItem);
                LoadLeftWeaponDamageCollider();
                quickSlotsUI.UpdateWeaponQuickSlotsUI(true, weaponItem);

                if (weaponItem != null && weaponItem.Left_Hand_Idle != null)
                {
                    animator.CrossFade(weaponItem.Left_Hand_Idle, 0.2f);
                }
                else
                {
                    animator.CrossFade("Left Arm Empty", 0.2f);
                }
            }
            else
            {
                if (InputHandler.twoHandFlag)
                {
                    backSlot.LoadWeaponModel(leftHandSlot.currentWeapon);
                    leftHandSlot.UnloadItemModelAndDestroy();
                    animator.CrossFade(weaponItem.Two_Hand_Idle, 0.2f);
                }
                else
                {
                    backSlot.UnloadItemModelAndDestroy();
                    animator.CrossFade("Both Arms Empty", 0.2f);
                    if (weaponItem != null && weaponItem.Right_Hand_Idle != null)
                    {
                        animator.CrossFade(weaponItem.Right_Hand_Idle, 0.2f);
                    }
                    else
                    {
                        animator.CrossFade("Right Arm Empty", 0.2f);
                    }
                }

                rightHandSlot.currentWeapon = weaponItem;
                rightHandSlot.LoadWeaponModel(weaponItem);
                LoadRightWeaponDamageCollider();
                quickSlotsUI.UpdateWeaponQuickSlotsUI(false, weaponItem);
            }
        }
Beispiel #16
0
 public void HandleWeaponCombo(WeaponItem weapon)
 {
     animatorHandler.anim.SetBool("canDoCombo", false);
     if (lastAttack == weapon.OH_Light_Attack_1 || lastAttack == weapon.TH_Light_Attack_1)
     {
         LightAttack2(weapon);
     }
     else if (lastAttack == weapon.OH_Light_Attack_2 || lastAttack == weapon.TH_Light_Attack_2)
     {
         LightAttack1(weapon);
     }
     else if (lastAttack == weapon.OH_Heavy_Attack_1 || lastAttack == weapon.TH_Heavy_Attack_1)
     {
         HeavyAttack2(weapon);
     }
     else if (lastAttack == weapon.OH_Heavy_Attack_2 || lastAttack == weapon.TH_Heavy_Attack_2)
     {
         HeavyAttack1(weapon);
     }
 }
Beispiel #17
0
        private void HandleAttackInput()
        {
            if (rhLightAttack_Input || rhStrongAttack_Input)
            {
                animatorHandler.anim.SetBool("isUsingRightHand", true);
                if (playerManager.canDoCombo)
                {
                    playerAttacker.HandleWeaponCombo(playerInventory.rightWeapon);
                }
                else
                {
                    if (playerManager.isInteracting)
                    {
                        return;
                    }
                    if (rhStrongAttack_Input)
                    {
                        playerAttacker.HandleHeavyAttack(playerInventory.rightWeapon);
                    }
                    else
                    {
                        playerAttacker.HandleLightAttack(playerInventory.rightWeapon);
                    }
                }
            }

            lhLightAttack_Input = inputActions.PlayerActions.LeftAttack1.phase == UnityEngine.InputSystem.InputActionPhase.Started;
            if (lhLightAttack_Input)
            {
                WeaponItem blockingWeapon = twoHandFlag ? playerInventory.rightWeapon : playerInventory.leftWeapon;
                playerAttacker.HandleBlock(blockingWeapon);
            }
            else
            {
                playerManager.isBlocking = false;
                playerAttacker.DisableBlockingCollider();
            }
        }
Beispiel #18
0
        private void HeavyAttack1(WeaponItem weapon)
        {
            PlayerAttackAction attack = inputHandler.twoHandFlag ? weapon.TH_Heavy_Attack_1 : weapon.OH_Heavy_Attack_1;

            PerformAttack(weapon, attack);
        }
Beispiel #19
0
        private void LightAttack2(WeaponItem weapon)
        {
            PlayerAttackAction attack = inputHandler.twoHandFlag ? weapon.TH_Light_Attack_2 : weapon.OH_Light_Attack_2;

            PerformAttack(weapon, attack);
        }
Beispiel #20
0
 public void HandleHeavyAttack(WeaponItem weapon)
 {
     HeavyAttack1(weapon);
 }
Beispiel #21
0
 public void HandleLightAttack(WeaponItem weapon)
 {
     LightAttack1(weapon);
 }
Beispiel #22
0
 private void EnableBlockingCollider(WeaponItem weapon)
 {
     blockingCollider.SetColliderDamageAbsorbtion(weapon);
     blockingCollider.EnableCollider();
 }
Beispiel #23
0
 public override void UnequipItem()
 {
     weapon = null;
     base.UnequipItem();
 }
Beispiel #24
0
 public override void ClearInventorySlot()
 {
     weapon = null;
     base.ClearInventorySlot();
 }
Beispiel #25
0
 public void AddItem(WeaponItem newItem)
 {
     weapon = newItem;
     base.AddItem(newItem);
 }