Пример #1
0
    private void OnPickupWeapon()
    {
        timeShooting        = 0;
        lastEnemy           = null;
        gunCollider         = currWeapon.GetComponent <BoxCollider2D>();
        gunCollider.enabled = false;
        info         = currWeapon.GetComponent <weaponInfo>();
        maxBullets   = info.maxBullets;
        bulletsLeft  = maxBullets;
        reloadTime   = info.reloadTime;
        bulletSpread = info.bulletSpread;
        bulletDamage = info.bulletDamage;
        fireRate     = info.fireRateInSeconds;
        bulletPrefab = info.bullet;
        if (bulletPrefab == null)
        {
            lineRend         = currWeapon.GetComponent <LineRenderer>();
            lineRend.enabled = false;
        }

        shootingPoint         = info.shootingPoint;
        ammoText.text         = maxBullets + "/" + maxBullets;
        weaponTarget          = info.targetPrefab;
        shotAudio             = info.bulletSound;
        bulletExplosionRadius = info.explosionRadius;
        bulletShow            = info.bulletsStay;
        if (weaponTarget != null)
        {
            weaponTarget.transform.parent = null;
        }
    }
Пример #2
0
 void UpdateWeaponInfo()
 {
     curWeapon    = transform.Find("weapon").GetChild(0); //first child should be using weapon, if want to vaild, we can use CompareTag as well
     weaponAnim   = curWeapon.GetComponent <Animator>();
     weaponScript = curWeapon.GetComponent <weaponInfo>();
     float[] delay = weaponScript.GetDelay(), time = weaponScript.GetTime(), force = weaponScript.GetForce();
     normalAttackDelay = delay[0]; defenseDelay = delay[1]; counterDelay = delay[2]; dashDelay = delay[3]; specialAttackDelay = delay[4];
     normalAttackTime  = time[0] * slowFactor; defenseTime = time[1] * slowFactor; counterTime = time[2] * slowFactor; dashTime = time[3] * slowFactor; specialAttackTime = time[4] * slowFactor;
     normalAttackForce = force[0]; defenseForce = force[1]; counterForce = force[2]; dashForce = force[3]; specialAttackForce = force[4];
 }
Пример #3
0
    weaponInfo [] ReadWeaponFile()
    {
        try{
            StreamReader weapFile = new StreamReader(weapFileName);

            weaponInfo [] myWeaponAry = new weaponInfo[numOfWeapons];
            string        curString;

            for (int i = 0; i < numOfWeapons; i++)
            {
                curString = weapFile.ReadLine().Split(",");
            }
        }
        catch (FileNotFoundException e) {
        }
    }
Пример #4
0
    // Use this for initialization
    void Start()
    {
        useClip = firingPoint.GetComponent <weaponInfo>();
        useClip = firingPoint.GetComponent <weaponInfo>();

        fireDirection = new Vector2(0, 1); // weapon will shoot up

        spreadHits = new RaycastHit2D[3];

        spreadDirections    = new Vector2[3];
        spreadDirections[0] = new Vector2(-.5f, ((Mathf.Sqrt(3) / 2)));
        spreadDirections[1] = new Vector2(0, 1);
        spreadDirections[2] = new Vector2(.5f, ((Mathf.Sqrt(3)) / 2));

        firemode = 0;

        // lineRenderers = new LineRenderer[3];
        SetupRenderer(lineRenderers[0]);
        SetupRenderer(lineRenderers[1]);
        SetupRenderer(lineRenderers[2]);
    }
Пример #5
0
 private void OnEnable()
 {
     if (this.activeBool && !this.mainTrigger && !this.remotePlayer)
     {
         if (this.mainTriggerScript)
         {
             this.mainTriggerScript.currentWeaponScript = base.transform.GetComponent<weaponInfo>();
             this.mainTriggerScript.weaponAudio = base.transform;
             this.setupMainTrigger();
             if (this.canDoGroundAxeChop)
             {
                 this.mainTriggerScript.enableSpecialWeaponVars();
             }
         }
         base.Invoke("cleanUpSpearedFish", 0.2f);
         if (this.animator)
         {
             this.checkBurnableCloth();
         }
         this.animSpeed = this.weaponSpeed / 20f;
         this.animSpeed += 0.5f;
         this.animTiredSpeed = this.tiredSpeed / 10f * (this.animSpeed - 0.5f);
         this.animTiredSpeed += 0.5f;
         if (!this.setup)
         {
             return;
         }
         if (this.setup.pmStamina)
         {
             if (this.animControl.tiredCheck)
             {
                 this.animControl.tempTired = this.animSpeed;
                 this.setup.pmStamina.FsmVariables.GetFsmFloat("notTiredSpeed").Value = this.animSpeed / 1f;
             }
             else
             {
                 this.setup.pmStamina.FsmVariables.GetFsmFloat("notTiredSpeed").Value = this.animSpeed;
             }
         }
         if (this.setup && this.setup.pmStamina)
         {
             this.setup.pmStamina.FsmVariables.GetFsmFloat("tiredSpeed").Value = this.animTiredSpeed;
         }
         if (this.setup && this.setup.pmControl)
         {
             this.setup.pmControl.FsmVariables.GetFsmFloat("staminaDrain").Value = this.staminaDrain * -1f;
         }
         if (this.setup && this.setup.pmControl)
         {
             this.setup.pmControl.FsmVariables.GetFsmFloat("blockStaminaDrain").Value = this.blockStaminaDrain * -1f;
         }
         if (LocalPlayer.Stats)
         {
             LocalPlayer.Stats.blockDamagePercent = this.blockDamagePercent;
         }
         this.damageAmount = (int)this.WeaponDamage;
         if (this.setup && this.setup.pmStamina)
         {
             this.setup.pmStamina.SendEvent("toSetStats");
         }
     }
 }
Пример #6
0
 private void Start()
 {
     if (!this.setup && base.GetComponent<EmptyObjectIdentifier>())
     {
         UnityEngine.Object.Destroy(base.gameObject);
         return;
     }
     if (this.setup.pmControl)
     {
         this.fsmJumpAttackBool = this.setup.pmControl.FsmVariables.GetFsmBool("doingJumpAttack");
         this.fsmHeavyAttackBool = this.setup.pmControl.FsmVariables.GetFsmBool("heavyAttackBool");
     }
     if (this.soundDetectGo)
     {
         this.soundCollider = this.soundDetectGo.GetComponent<SphereCollider>();
         this.soundDetectRangeInit = this.soundCollider.radius;
     }
     if (this.spear)
     {
         if (base.transform && base.transform.parent && base.transform.parent.FindChild("SpearTip"))
         {
             this.SpearTip = base.transform.parent.FindChild("SpearTip").transform;
         }
         if (base.transform && base.transform.parent && base.transform.parent.FindChild("SpearTip2"))
         {
             this.SpearTip2 = base.transform.parent.FindChild("SpearTip2").transform;
         }
     }
     this.weaponAudio = base.transform;
     this.currentWeaponScript = base.transform.GetComponent<weaponInfo>();
 }
Пример #7
0
        public bool ApplyWeaponStatsUpgrades(int productItemId, int ingredientItemId, WeaponStatUpgrade[] bonuses, bool batched, int upgradeCount, WeaponStatUpgrade.Types lastIngredientActiveBonus = (WeaponStatUpgrade.Types)(-2))
        {
            bool       result         = false;
            Type       typeFromHandle = typeof(weaponInfo);
            weaponInfo heldWeaponInfo = this._itemViewsCache[productItemId]._heldWeaponInfo;
            int        i = 0;

            while (i < bonuses.Length)
            {
                switch (bonuses[i]._type)
                {
                case WeaponStatUpgrade.Types.BurningWeapon:
                {
                    BurnableCloth componentInChildren = this._itemViewsCache[productItemId]._held.GetComponentInChildren <BurnableCloth>();
                    if (componentInChildren)
                    {
                        this._itemViewsCache[productItemId].ActiveBonus = WeaponStatUpgrade.Types.BurningWeapon;
                        componentInChildren.EnableBurnableCloth();
                    }
                    result = true;
                    break;
                }

                case WeaponStatUpgrade.Types.StickyProjectile:
                    this._itemViewsCache[productItemId].ActiveBonus = WeaponStatUpgrade.Types.StickyProjectile;
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.WalkmanTrack:
                    WalkmanControler.LoadCassette(ingredientItemId);
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.BurningAmmo:
                    if (batched && this._itemViewsCache[productItemId]._allowMultiView)
                    {
                        this._itemViewsCache[productItemId].SetMultiviewsBonus(WeaponStatUpgrade.Types.BurningAmmo);
                    }
                    else
                    {
                        this._itemViewsCache[productItemId].ActiveBonus = WeaponStatUpgrade.Types.BurningAmmo;
                    }
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.Paint_Green:
                {
                    EquipmentPainting componentInChildren2 = this._itemViewsCache[productItemId]._held.GetComponentInChildren <EquipmentPainting>();
                    if (componentInChildren2)
                    {
                        componentInChildren2.PaintInGreen();
                    }
                    result = true;
                    break;
                }

                case WeaponStatUpgrade.Types.Paint_Orange:
                {
                    EquipmentPainting componentInChildren3 = this._itemViewsCache[productItemId]._held.GetComponentInChildren <EquipmentPainting>();
                    if (componentInChildren3)
                    {
                        componentInChildren3.PaintInOrange();
                    }
                    result = true;
                    break;
                }

                case WeaponStatUpgrade.Types.DirtyWater:
                case WeaponStatUpgrade.Types.CleanWater:
                case WeaponStatUpgrade.Types.Cooked:
                case WeaponStatUpgrade.Types.blockStaminaDrain:
                    goto IL_3DD;

                case WeaponStatUpgrade.Types.ItemPart:
                {
                    IItemPartInventoryView itemPartInventoryView = (IItemPartInventoryView)this._itemViewsCache[productItemId];
                    itemPartInventoryView.AddPiece(Mathf.RoundToInt(bonuses[i]._amount));
                    result = true;
                    break;
                }

                case WeaponStatUpgrade.Types.BatteryCharge:
                    LocalPlayer.Stats.BatteryCharge = Mathf.Clamp(LocalPlayer.Stats.BatteryCharge + bonuses[i]._amount, 0f, 100f);
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.FlareGunAmmo:
                    LocalPlayer.Inventory.AddItem(ItemDatabase.ItemByName("FlareGunAmmo")._id, Mathf.RoundToInt(bonuses[i]._amount * (float)upgradeCount), false, false, (WeaponStatUpgrade.Types)(-2));
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.SetWeaponAmmoBonus:
                    this._itemViewsCache[productItemId].ActiveBonus = ((lastIngredientActiveBonus != (WeaponStatUpgrade.Types)(-2)) ? lastIngredientActiveBonus : this._itemViewsCache[ingredientItemId].ActiveBonus);
                    LocalPlayer.Inventory.SortInventoryViewsByBonus(LocalPlayer.Inventory.InventoryItemViewsCache[ingredientItemId][0], this._itemViewsCache[productItemId].ActiveBonus, false);
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.AddMaxAmountBonus:
                    LocalPlayer.Inventory.AddMaxAmountBonus(ingredientItemId, Mathf.RoundToInt(bonuses[i]._amount));
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.SetMaxAmountBonus:
                    LocalPlayer.Inventory.AddMaxAmountBonus(ingredientItemId, Mathf.RoundToInt(bonuses[i]._amount));
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.PoisonnedAmmo:
                    if (batched && this._itemViewsCache[productItemId]._allowMultiView)
                    {
                        this._itemViewsCache[productItemId].SetMultiviewsBonus(WeaponStatUpgrade.Types.PoisonnedAmmo);
                    }
                    else
                    {
                        this._itemViewsCache[productItemId].ActiveBonus = WeaponStatUpgrade.Types.PoisonnedAmmo;
                    }
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.SetArrowMaxAmountBonus:
                    LocalPlayer.Inventory.AddMaxAmountBonus(ItemDatabase.ItemByName("Arrows")._id, Mathf.RoundToInt(bonuses[i]._amount));
                    result = true;
                    break;

                case WeaponStatUpgrade.Types.BurningWeaponExtra:
                {
                    BurnableCloth componentInChildren4 = this._itemViewsCache[productItemId]._held.GetComponentInChildren <BurnableCloth>();
                    if (componentInChildren4 && this._itemViewsCache[productItemId].ActiveBonus == WeaponStatUpgrade.Types.BurningWeapon)
                    {
                        this._itemViewsCache[productItemId].ActiveBonus = WeaponStatUpgrade.Types.BurningWeaponExtra;
                        componentInChildren4.EnableBurnableClothExtra();
                    }
                    result = true;
                    break;
                }

                case WeaponStatUpgrade.Types.Incendiary:
                    this._itemViewsCache[productItemId].ActiveBonus = WeaponStatUpgrade.Types.Incendiary;
                    result = true;
                    break;

                default:
                    goto IL_3DD;
                }
IL_4C5:
                i++;
                continue;
IL_3DD:
                if (heldWeaponInfo)
                {
                    FieldInfo field = typeFromHandle.GetField(bonuses[i]._type.ToString(), BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                    float     upgradeBonusAmount = this.GetUpgradeBonusAmount(productItemId, ingredientItemId, bonuses[i], upgradeCount);
                    if (field.FieldType == typeof(float))
                    {
                        field.SetValue(heldWeaponInfo, (float)field.GetValue(heldWeaponInfo) + upgradeBonusAmount);
                    }
                    else if (field.FieldType == typeof(int))
                    {
                        field.SetValue(heldWeaponInfo, (int)field.GetValue(heldWeaponInfo) + Mathf.RoundToInt(upgradeBonusAmount));
                    }
                    result = true;
                    GameStats.UpgradesAdded.Invoke(upgradeCount);
                }
                else
                {
                    Debug.LogError("Attempting to upgrade " + this._itemViewsCache[productItemId].ItemCache._name + " which doesn't reference its weaponInfo component.");
                }
                goto IL_4C5;
            }
            return(result);
        }
Пример #8
0
    private weaponInfo useClip;             //the weapon info script to access variables

    // Use this for initialization
    void Start()
    {
        useClip = firingPoint.GetComponent <weaponInfo>();
    }