Beispiel #1
0
    IEnumerator SelectWeaponToAttach(int attachmentIndexInInventory)
    {
        attachCoroutineRunning = true;
        player.GetComponent <PauseGame>().HideInventory();
        player.GetComponent <PauseGame>().ShowAttachmentMenu();
        weaponToAttachTo = -1;
        yield return(new WaitUntil(() => weaponToAttachTo != -1));

        player.GetComponent <PauseGame>().HideAttachmentMenu();
        player.GetComponent <PauseGame>().ShowInventory();
        attachmentUI.SetAttachment(null);
        Attachment returnedAttachment = null;

        currentWeapon      = weaponSwitch.hands.GetChild(weaponToAttachTo).GetComponent <Shoot>();
        returnedAttachment = currentWeapon.AddAttachment(tempAttachment);
        #region Adding Attachment Effects
        if (returnedAttachment != null && returnedAttachment.itemName == "N/A")
        {
        }
        else
        {
            for (int i = 0; i < tempAttachment.attachmentEffects.Length; i++)
            {
                switch (tempAttachment.attachmentEffects[i])
                {
                case Attachment.AttachmentEffect.AimingAngleDivider:
                    if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                    {
                        currentWeapon.aimingDivider += tempAttachment.attachmentEffectAmounts[i];
                    }
                    else
                    {
                        float tempAmount = (tempAttachment.attachmentEffectAmounts[i] / 100) * currentWeapon.aimingDivider;
                        currentWeapon.aimingDivider += tempAmount;
                    }
                    break;

                case Attachment.AttachmentEffect.BulletSpeed:
                    //if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                    //{
                    //    currentWeapon.IncreaseProjectileSpeed(tempAttachment.attachmentEffectAmounts[i]);
                    //}
                    //else
                    //{
                    //    float tempAmount = (tempAttachment.attachmentEffectAmounts[i] / 100) * currentWeapon.GetProjectileSpeed();
                    //    currentWeapon.IncreaseProjectileSpeed(tempAmount);
                    //}
                    break;

                case Attachment.AttachmentEffect.Damage:
                    if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                    {
                        currentWeapon.damage += tempAttachment.attachmentEffectAmounts[i];
                    }
                    else
                    {
                        float amountToIncrease = (tempAttachment.attachmentEffectAmounts[i] / 100) * currentWeapon.damage;
                        currentWeapon.damage += (amountToIncrease);
                    }
                    break;

                case Attachment.AttachmentEffect.DefaultAngle:
                    if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                    {
                        currentWeapon.defaultAngle += (tempAttachment.attachmentEffectAmounts[i]);
                    }
                    else
                    {
                        float tempAmount = (tempAttachment.attachmentEffectAmounts[i] / 100) * currentWeapon.defaultAngle;
                        currentWeapon.defaultAngle += (tempAmount);
                    }
                    break;

                case Attachment.AttachmentEffect.FireAmmo:
                    if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                    {
                    }
                    else
                    {
                    }
                    break;

                case Attachment.AttachmentEffect.FireRate:
                    if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                    {
                        currentWeapon.fireRate += (0 - tempAttachment.attachmentEffectAmounts[i]);
                    }
                    else
                    {
                        float amountToIncrease = (tempAttachment.attachmentEffectAmounts[i] / 100) * currentWeapon.fireRate;
                        currentWeapon.fireRate += (0 - amountToIncrease);
                    }
                    break;

                case Attachment.AttachmentEffect.IceAmmo:
                    if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                    {
                    }
                    else
                    {
                    }
                    break;

                case Attachment.AttachmentEffect.MagazineSize:
                    if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                    {
                        currentWeapon.magazineSize += (int)(tempAttachment.attachmentEffectAmounts[i]);
                    }
                    else
                    {
                        float amountToIncrease = (tempAttachment.attachmentEffectAmounts[i] / 100) * currentWeapon.magazineSize;
                        currentWeapon.magazineSize += (int)(amountToIncrease);
                    }
                    break;

                case Attachment.AttachmentEffect.Silence:
                    currentWeapon.isSilenced = true;
                    break;

                case Attachment.AttachmentEffect.ShotGunAccuracy:
                //if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                //{
                //    currentWeapon.IncreaseNumOfPellets(tempAttachment.attachmentEffectAmounts[i]);
                //}
                //else
                //{
                //    float tempAmount = (tempAttachment.attachmentEffectAmounts[i] / 100) * currentWeapon.GetNumOfPellets();
                //    currentWeapon.IncreaseNumOfPellets(tempAmount);
                //}
                //break;
                case Attachment.AttachmentEffect.CritHitMultiplier:
                    if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                    {
                        currentWeapon.critMultiplier += (tempAttachment.attachmentEffectAmounts[i]);
                    }
                    else
                    {
                        float tempAmount = (tempAttachment.attachmentEffectAmounts[i] / 100) * currentWeapon.critMultiplier;
                        currentWeapon.critMultiplier += (tempAmount);
                    }
                    break;

                case Attachment.AttachmentEffect.ReloadSpeed:
                    if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                    {
                        currentWeapon.reloadSpeedModifier += (tempAttachment.attachmentEffectAmounts[i]);
                    }
                    else
                    {
                        float tempAmount = (tempAttachment.attachmentEffectAmounts[i] / 100) * currentWeapon.reloadSpeedModifier;
                        currentWeapon.reloadSpeedModifier += (tempAmount);
                    }
                    break;

                case Attachment.AttachmentEffect.AimSpeed:
                    if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                    {
                        currentWeapon.aimSpeed += (tempAttachment.attachmentEffectAmounts[i]);
                    }
                    else
                    {
                        float tempAmount = (tempAttachment.attachmentEffectAmounts[i] / 100) * currentWeapon.aimSpeed;
                        currentWeapon.aimSpeed += (tempAmount);
                    }

                    break;

                case Attachment.AttachmentEffect.Kickback:
                    if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                    {
                        currentWeapon.kickBackAmount += (tempAttachment.attachmentEffectAmounts[i]);
                    }
                    else
                    {
                        float tempAmount = (tempAttachment.attachmentEffectAmounts[i] / 100) * currentWeapon.kickBackAmount;
                        currentWeapon.kickBackAmount += (tempAmount);
                    }
                    break;

                case Attachment.AttachmentEffect.ZoomAmount:
                    if (tempAttachment.attachmentEffectAmountTypes[i] == Attachment.AttachmentEffectNumberType.FlatNumber)
                    {
                        currentWeapon.zoomAmount = tempAttachment.attachmentEffectAmounts[i];
                    }
                    else
                    {
                        float tempAmount = (tempAttachment.attachmentEffectAmounts[i] / 100) * currentWeapon.zoomAmount;
                        currentWeapon.zoomAmount += (tempAmount);
                    }
                    break;
                }
            }
            playerInventory.RemoveItem(attachmentIndexInInventory);
            //if(returnedAttachment != null)
            //{
            //    RemoveAttachmentEffects(returnedAttachment, currentWeapon);
            //    playerInventory.AddAttachmentToInventory(returnedAttachment);
            //}
        }

        #endregion
    }