示例#1
0
    public void EquipWeapon(Weapon _weaponToEquip)
    {
        if (currentlyEquippedWeapon == null)
        {
            if (_weaponToEquip.weaponData.equipmentType == EquipmentType.MeleeWeapon)
            {
                MeleeWeaponData meleeData = _weaponToEquip.weaponData as MeleeWeaponData;
                playerMgmt.playerStats.attackDamage_Stat.AddModifer(meleeData.weaponDamage);
            }

            if (_weaponToEquip.weaponData.equipmentType == EquipmentType.RangedWeapon)
            {
                playerMgmt.inputMgmt.combatContextEventStarted   -= playerMgmt.combatMgmt.BlockPerformed;
                playerMgmt.inputMgmt.combatContextEventCancelled -= playerMgmt.combatMgmt.BlockReleased;

                playerMgmt.inputMgmt.combatContextEventStarted   += playerMgmt.combatMgmt.AimPerformed;
                playerMgmt.inputMgmt.combatContextEventCancelled += playerMgmt.combatMgmt.AimReleased;
            }

            currentlyEquippedWeapon       = _weaponToEquip;
            _weaponToEquip.wieldingEntity = this.gameObject;
            _weaponToEquip.gameObject.SetActive(true);

            _weaponToEquip.transform.SetParent(weaponEquipPos);
            _weaponToEquip.transform.localPosition = Vector3.zero;
            _weaponToEquip.transform.localRotation = Quaternion.Euler(Vector3.zero);

            playerMgmt.animMgmt.SetAnimation(_weaponToEquip.weaponData.animationSet);
        }
    }
    /// <summary>
    /// Called by an Animation Event from the player checks an int
    /// to determine the means of the attack
    /// </summary>
    /// <param name="handInt"></param>
    public virtual void ActivateImpact(int impactID)
    {
        // If the attack is a Heavy Attack
        if (attackId > 1)
        {
            // If the attacker has a weapon equipped
            if (weaponMgmt.currentlyEquippedWeapon != null)
            {
                MeleeWeaponData meleeData = weaponMgmt.currentlyEquippedWeapon.weaponData as MeleeWeaponData;
                charStats.DamageStamina(meleeData.staminaCost);
            }
            // If the attacker is unarmed
            else
            {
                //Debug.Log("FIX THIS: DETERMINE HEAVY OR LIGHT ATTACK STAMINA COST!");
                charStats.DamageStamina(20f);
                switch (impactID)
                {
                case 1:
                    CreateImpactCollider(leftHand);
                    break;

                case 2:
                    CreateImpactCollider(rightHand);
                    break;

                case 3:
                    Debug.Log("Kick");
                    break;
                }
            }
        }
        // If the attack is a Light Attack
        else
        {
            if (weaponMgmt.currentlyEquippedWeapon == null)
            {
                switch (impactID)
                {
                case 1:
                    CreateImpactCollider(leftHand);
                    break;

                case 2:
                    CreateImpactCollider(rightHand);
                    break;

                case 3:
                    Debug.Log("Kick");
                    break;
                }
            }
        }

        attackId        = 0;
        impactActivated = true;
    }
 protected MeleeWeapon(MeleeWeaponData data, PhysicalUnit owner)
     : base(data, owner, data.Name)
 {
     _damage = data.Damage;
     _force = data.Impact;
     _recoil = data.Recoil;
     _hitArc = data.HitArc;
     _range = data.Range;
     _attackParticleEffect = (data.AttackParticleEffect == null) ?
         null : new ParticleEffect(data.AttackParticleEffect);
     _hitParticleEffect = (data.HitParticleEffect == null) ?
         null : new ParticleEffect(data.HitParticleEffect);
 }
示例#4
0
 protected MeleeWeapon(MeleeWeaponData data, PhysicalUnit owner)
     : base(TimeSpan.FromSeconds(1.0 / data.FireRate), owner)
 {
     _damage = data.Damage;
     _force = data.Impact;
     _recoil = data.Recoil;
     _hitArc = data.HitArc;
     _range = data.Range;
     _attackParticleEffect = (data.AttackParticleEffect == null) ?
         null : new ParticleEffect(data.AttackParticleEffect);
     _hitParticleEffect = (data.HitParticleEffect == null) ?
         null : new ParticleEffect(data.HitParticleEffect);
 }
示例#5
0
 protected MeleeWeapon(MeleeWeaponData data, PhysicalUnit owner)
     : base(TimeSpan.FromSeconds(1.0 / data.FireRate), owner)
 {
     _damage = data.Damage;
     _force  = data.Impact;
     _recoil = data.Recoil;
     _hitArc = data.HitArc;
     _range  = data.Range;
     _attackParticleEffect = (data.AttackParticleEffect == null) ?
                             null : new ParticleEffect(data.AttackParticleEffect);
     _hitParticleEffect = (data.HitParticleEffect == null) ?
                          null : new ParticleEffect(data.HitParticleEffect);
 }
示例#6
0
        private void SetWeapons(MeleeWeaponData meleeData, RangeWeaponData rangeData)
        {
            _meleeWeapon = Instantiate(meleeData.WeaponModel);
            _meleeWeapon.transform.SetParent(meleeWeaponSlot, false);
            _meleeWeapon.GetComponent <ActivateMelee>().SetWeapon(meleeData);
            _weaponTrail = _meleeWeapon.transform.GetChild(1).GetComponent <ParticleSystem>();

            GetComponent <Animator>().SetFloat(_attackSpeed, meleeData.WeaponAttackSpeed);
            var rangeWeapon = Instantiate(rangeData.WeaponModel);

            rangeWeapon.transform.SetParent(rangeWeaponSlot, false);
            rangeWeaponSlot.GetComponent <ProjectileLauncher>().WeaponData = rangeData;
            rangeWeaponSlot.gameObject.SetActive(false);
        }
示例#7
0
    public void DropWeapon()
    {
        if (currentlyEquippedWeapon != null)
        {
            weaponToDrop = currentlyEquippedWeapon;
        }

        if (weaponToDrop.weaponData.equipmentType == EquipmentType.MeleeWeapon)
        {
            MeleeWeaponData meleeData = weaponToDrop.weaponData as MeleeWeaponData;
            playerMgmt.playerStats.attackDamage_Stat.RemoveModifier(meleeData.weaponDamage);
            mainWeapon = null;
        }
        if (weaponToDrop.weaponData.equipmentType == EquipmentType.RangedWeapon)
        {
            playerMgmt.inputMgmt.combatContextEventStarted   -= playerMgmt.combatMgmt.AimPerformed;
            playerMgmt.inputMgmt.combatContextEventCancelled -= playerMgmt.combatMgmt.AimReleased;

            playerMgmt.inputMgmt.combatContextEventStarted   += playerMgmt.combatMgmt.BlockPerformed;
            playerMgmt.inputMgmt.combatContextEventCancelled += playerMgmt.combatMgmt.BlockReleased;
            secondaryWeapon = null;
        }

        gameObject.GetComponentInChildren <EquipmentPanel>().RemoveItem(weaponToDrop.GetComponent <Weapon>().weaponData);

        playerMgmt.animMgmt.ResetAnimation();
        currentlyEquippedWeapon = null;

        weaponToDrop.transform.SetParent(null);
        weaponToDrop.transform.position = dropPos.position;
        weaponToDrop.GetComponent <CapsuleCollider>().enabled = true;
        Rigidbody weaponRb = weaponToDrop.GetComponent <Rigidbody>();

        weaponToDrop.GetComponent <BoxCollider>().enabled = true;
        weaponRb.isKinematic = false;
        weaponRb.AddForce(transform.forward * 1f, ForceMode.Impulse);
        float random = Random.Range(-1f, 1f);

        weaponRb.AddTorque(new Vector3(random, random, random) * 10f);
    }
示例#8
0
    void UnequipWeapon(Weapon _weaponToUnequip)
    {
        if (_weaponToUnequip.weaponData.equipmentType == EquipmentType.RangedWeapon)
        {
            playerMgmt.inputMgmt.combatContextEventStarted   -= playerMgmt.combatMgmt.AimPerformed;
            playerMgmt.inputMgmt.combatContextEventCancelled -= playerMgmt.combatMgmt.AimReleased;

            playerMgmt.inputMgmt.combatContextEventStarted   += playerMgmt.combatMgmt.BlockPerformed;
            playerMgmt.inputMgmt.combatContextEventCancelled += playerMgmt.combatMgmt.BlockReleased;
        }

        // Deactivate currently equipped weapon
        _weaponToUnequip.gameObject.SetActive(false);
        // Clear modifiers
        if (_weaponToUnequip.weaponData.equipmentType == EquipmentType.MeleeWeapon)
        {
            MeleeWeaponData meleeData = _weaponToUnequip.weaponData as MeleeWeaponData;
            playerMgmt.playerStats.attackDamage_Stat.RemoveModifier(meleeData.weaponDamage);
        }
        // Reset animation set
        playerMgmt.animMgmt.ResetAnimation();
        // Clear any added bonuses from weapon
        currentlyEquippedWeapon = null;
    }
示例#9
0
 public void SetWeapon(MeleeWeaponData data)
 {
     _weaponData = data;
 }
示例#10
0
    public void LightAttackPerformed()
    {
        // If the player is interacting with a contextual object, exit.
        if (playerMgmt.isInteracting)
        {
            return;
        }
        if (playerMgmt.playerMovement.isSprinting)
        {
            return;
        }
        if (!canRecieveAttackInput)
        {
            return;
        }

        attackId           = 1;
        inCombat           = true;
        currentCombatTimer = combatTimer;

        if (canRecieveAttackInput)
        {
            attackInputHeld = true;
            lightAttack     = true;

            // If you have a weapon equipped
            if (playerMgmt.weaponMgmt.currentlyEquippedWeapon != null)
            {
                // If current weapon is a melee type...
                if (playerMgmt.weaponMgmt.currentlyEquippedWeapon.weaponData.equipmentType == EquipmentType.MeleeWeapon)
                {
                    MeleeWeaponData meleeData = playerMgmt.weaponMgmt.currentlyEquippedWeapon.weaponData as MeleeWeaponData;
                    // Checks if the entity has enough stamina to do an attack...
                    if ((playerMgmt.playerStats.GetCurrentStamina() - meleeData.staminaCost) > 0)
                    {
                        attackAnim = "attackLight";
                        playerMgmt.animMgmt.HandleMeleeAttackAnimation(attackInputHeld);
                    }
                }
                // else if the weapon is a ranged type...
                else if (playerMgmt.weaponMgmt.currentlyEquippedWeapon.weaponData.equipmentType == EquipmentType.RangedWeapon)
                {
                    // IF THE PLAYER ISN'T AIMING DO A PUSH/BASH ATTACK
                    // IF THE PLAYER IS AIMING THEN CALL SHOOTING LOGIC
                    // DO I CALL SHOOTING LOGIC ON THE WEAPON ITSELF???

                    attackAnim = "attackLight";
                    playerMgmt.animMgmt.HandleRangedAttackAnimation(attackInputHeld);
                }
            }
            // If you have no equipped weapon, you're unarmed
            else
            {
                print("test");

                if (playerMgmt.playerStats.GetCurrentStamina() - 10f > 0)
                {
                    attackAnim = "attackLight";
                    playerMgmt.animMgmt.HandleMeleeAttackAnimation(attackInputHeld);
                }
            }
        }
    }
示例#11
0
    public void HeavyAttackPerformed()
    {
        //if (!playerMgmt.weaponMgmt.currentlyEquippedWeapon.weaponData.isChargeable) { return; }
        // If the player is interacting with a contextual object, exit.
        if (playerMgmt.isInteracting)
        {
            return;
        }
        if (playerMgmt.playerMovement.isSprinting)
        {
            return;
        }
        if (!canRecieveAttackInput)
        {
            return;
        }

        attackId           = 2;
        inCombat           = true;
        currentCombatTimer = combatTimer;

        if (canRecieveAttackInput)
        {
            attackInputHeld = true;
            heavyAttack     = true;

            //TEST============>// IF THE PLAYER IS IN THE AIR AND LOOKING DOWNWARDS!!!
            if (!playerMgmt.playerMovement.isGrounded)
            {
                if (Vector3.Dot(playerMgmt.cameraCtrl.myCamera.transform.forward, Vector3.up) <= -0.65f)
                {
                    playerMgmt.myRb.AddForce(playerMgmt.cameraCtrl.myCamera.transform.forward * 75f, ForceMode.Impulse);
                }
            }

            // If you have a weapon equipped
            if (playerMgmt.weaponMgmt.currentlyEquippedWeapon != null)
            {
                // If current weapon is a melee type...
                if (playerMgmt.weaponMgmt.currentlyEquippedWeapon.weaponData.equipmentType == EquipmentType.MeleeWeapon)
                {
                    MeleeWeaponData meleeData = playerMgmt.weaponMgmt.currentlyEquippedWeapon.weaponData as MeleeWeaponData;
                    // Checks if the entity has enough stamina to do an attack...
                    if ((playerMgmt.playerStats.GetCurrentStamina() - meleeData.staminaCost) > 0)
                    {
                        attackAnim = "attackHeavy";
                        playerMgmt.animMgmt.HandleMeleeAttackAnimation(attackInputHeld);
                    }
                }
                // else if the weapon is a ranged type...
            }
            // If you have no equipped weapon, you're unarmed
            else
            {
                if (playerMgmt.playerStats.GetCurrentStamina() - 10f > 0)
                {
                    attackAnim = "attackHeavy";
                    playerMgmt.animMgmt.HandleMeleeAttackAnimation(attackInputHeld);
                }
            }
        }
    }