/// <summary>
 /// Doeses the eixst.
 /// </summary>
 private void DoesEixst()
 {
     if (GunTypes.Exists(_databasePath, _gunTypeName, out _errOut))
     {
         GunTypes.Delete(_databasePath, _gunTypeName, out _errOut);
     }
 }
 /// <summary>
 /// Doesnes the exist.
 /// </summary>
 private void DoesneExist()
 {
     if (!GunTypes.Exists(_databasePath, _gunTypeName, out _errOut))
     {
         GunTypes.Add(_databasePath, _gunTypeName, out _errOut);
     }
 }
示例#3
0
        public static void SetPedGunPermitType(Ped p, GunTypes guntype, bool Concealed)
        {
            switch (guntype)
            {
            case GunTypes.Handguns:
                p.Metadata.gunLicense = "Handguns";
                break;

            case GunTypes.Long_Guns:
                p.Metadata.gunLicense = "Long guns";
                break;

            case GunTypes.Both:
                p.Metadata.gunLicense = "Handguns and long guns";
                break;
            }

            if (Concealed)
            {
                p.Metadata.gunPermit = "Concealed";
            }
            else
            {
                p.Metadata.gunPermit = "Public";
            }
        }
        public void ExistsTest()
        {
            DoesneExist();
            bool value = GunTypes.Exists(_databasePath, _gunTypeName, out _errOut);

            TestContext.WriteLine(value ? $"{_gunTypeName} exists!" : $"{_gunTypeName} does not exist");
            General.HasTrueValue(value, _errOut);
        }
        public void GetIdTest()
        {
            DoesneExist();
            int value = GunTypes.GetId(_databasePath, _gunTypeName, out _errOut);

            TestContext.WriteLine($"{_gunTypeName} id is {value}!");
            General.HasTrueValue(value > 0, _errOut);
        }
示例#6
0
 /// <summary>
 /// Creates new drop from buffer.
 /// </summary>
 /// <param name="type">Gun type to create.</param>
 /// <param name="position">Position to insert drop.</param>
 public void CreateNewDrop(GunTypes type, Vector3 position)
 {
     if (type == GunTypes.None)
     {
         return;
     }
     networkLayer.CreateNewDrop(type, position);
 }
        public void DeleteByNameTest()
        {
            DoesneExist();
            bool value = GunTypes.Delete(_databasePath, _gunTypeName, out _errOut);

            TestContext.WriteLine(value ? $"{_gunTypeName} was delete!" : $"{_gunTypeName} was not deleted");
            General.HasTrueValue(value, _errOut);
        }
        public void UpdateGunTypeTest()
        {
            DoesEixst();

            bool value = GunTypes.UpdateGunType(_databasePath, _gunTypeName, out _errOut);

            General.HasTrueValue(value, _errOut);
        }
示例#9
0
 public ArmSprite(Player player)
 {
     _player        = player;
     _position      = player.Position + new Vector2(8, 31);
     muzzlePosition = _position + new Vector2(22, 0);
     pivot          = new Vector2(0, 2.5f);
     _damageValue   = 1;
     currentGun     = GunTypes.Single;
 }
        public void GetListAllTest()
        {
            DoesneExist();

            List <Types.GunTypes> value = GunTypes.GetList(_databasePath, out _errOut);

            PrintList(value);
            General.HasTrueValue(value.Count > 0, _errOut);
        }
        public void GetListByIdTest()
        {
            DoesneExist();
            int id = GunTypes.GetId(_databasePath, _gunTypeName, out _errOut);
            List <Types.GunTypes> value = GunTypes.GetList(_databasePath, id, out _errOut);

            PrintList(value);
            General.HasTrueValue(value.Count > 0, _errOut);
        }
        public void UpdateTest()
        {
            DoesneExist();
            int  id    = GunTypes.GetId(_databasePath, _gunTypeName, out _errOut);
            bool value = GunTypes.Update(_databasePath, id, $"{_gunTypeName} NEW", out _errOut);

            TestContext.WriteLine(value ? $"{_gunTypeName} was updated to {_gunTypeName} NEW!" : $"{_gunTypeName} was not updated to {_gunTypeName} NEW");
            General.HasTrueValue(value, _errOut);
        }
        public void AddTest()
        {
            DoesEixst();
            bool   value  = GunTypes.Add(_databasePath, _gunTypeName, out _errOut);
            string result = value ? "Was" : "Was not";

            result += $" able to add gun type {_gunTypeName} to database";
            TestContext.WriteLine(result);
            General.HasTrueValue(value, _errOut);
        }
示例#14
0
 void SetWeapon(string statusText, GunTypes gunType, Sprite sprite, int maxAmmo)
 {
     GameObject.FindGameObjectWithTag("StatusText").GetComponent <Text>().text = statusText;
     GameObject.FindGameObjectWithTag("StatusText").transform.localScale       = Vector3.one;
     weaponUnlocked = Time.time;
     CurrentWeapon  = gunType;
     Weapon.GetComponent <SpriteRenderer>().sprite = sprite;
     Joystick.MaxAmmo   = maxAmmo;
     Joystick.AmmoCount = maxAmmo;
 }
示例#15
0
 /// <summary>
 /// Set a new alternative gun for the player, if available.
 /// </summary>
 /// <param name="newGun">New gun type.</param>
 public void SetAlternativeGun(GunTypes newGun)
 {
     for (int i = 1; i < myGuns.Length; i++)
     {
         if (myGuns[i] == GunTypes.None)
         {
             myGuns[i] = newGun;
             return;
         }
     }
 }
示例#16
0
 /// <summary>
 /// Receives data from network, to create new gun drop.
 /// </summary>
 /// <param name="type">Gun type to create.</param>
 /// <param name="position">Position to insert drop.</param>
 public void OnNetworkCreateNewDrop(GunTypes type, Vector3 position)
 {
     for (int i = 0; i < buffer.Length; i++)
     {
         if (!buffer[i].gameObject.activeSelf)
         {
             buffer[i].gameObject.SetActive(true);
             buffer[i].Initialize(type, position);
             return;
         }
     }
 }
 /// <summary>
 /// Receives data from network, to create new gun drop.
 /// </summary>
 /// <param name="type">Gun type to create.</param>
 /// <param name="position">Position to insert drop.</param>
 public void OnNetworkCreateNewDrop(GunTypes type, Vector3 position)
 {
     for (int i = 0; i < buffer.Length; i++)
     {
         if (!buffer[i].gameObject.activeSelf)
         {
             buffer[i].gameObject.SetActive(true);
             buffer[i].Initialize(type,position);
             return;
         }
     }
 }
示例#18
0
文件: Gun.cs 项目: Adomet/Gunner
 public void UpgradeGun()
 {
     if (GunTypeindex < GunTypes.Length - 1)
     {
         GunTypeindex++;
         MyGunType = GunTypes[GunTypeindex];
         if (GunMesh != null)
         {
             GunMesh.SetActive(false);
         }
         GunMesh = Instantiate(MyGunType.Gun, transform.position, transform.rotation, transform);
         GetGun();
     }
 }
示例#19
0
 public void SetGunModel(int bodyType, int scopeType, int clipType, int underBarrelType, int stockType,
                         GunTypes type, WeaponType weaponType, ElementalEffect typeOfEffect, int mtypeOfAbility, bool mHasAbility)
 {
     body          = bodyType;
     scope         = scopeType;
     clip          = clipType;
     underBarrel   = underBarrelType;
     barrel        = stockType;
     WeaponSlot    = type;
     typeOfWeapon  = weaponType;
     effect        = typeOfEffect;
     Ability       = mHasAbility;
     typeOfAbility = mtypeOfAbility;
 }
示例#20
0
文件: Gun.cs 项目: Adomet/Gunner
    private void OnEnable()
    {
        MyGunType = GunTypes[GunTypeindex];

        AudioSource = GetComponent <AudioSource>();
        GetGun();

        animator = GetComponent <Animator>();



        Pooler              = FindObjectOfType <ObjectPooler>();
        MyPlayer            = transform.root.GetComponent <Player>();
        tmprecoiltime       = recoiltime;
        currentBulletAmount = Magcount;
        GunMesh             = Instantiate(MyGunType.Gun, transform.position, transform.rotation, transform);
    }
示例#21
0
    public void ToggleGunType()
    {
        //Swap gun type and set to matching material
        //Yeah I know. This code is pretty quick and dirty.
        //But this isn't the important part!

        if (defaultGunType == GunTypes.Automatic)
        {
            defaultGunType = GunTypes.SingleShot;
        }
        else
        {
            defaultGunType = GunTypes.Automatic;
        }

        if ((int)defaultGunType < gunTypeMaterials.Length)
        {
            for (int i = 0; i < gunMeshRenderers.Length; i++)
            {
                gunMeshRenderers[i].material = gunTypeMaterials[(int)defaultGunType];
            }
        }
    }
示例#22
0
 /// <summary>
 /// "Bridge" method. Used to tell ShooterManager that the player caught a new weapon.
 /// </summary>
 /// <param name="newGun">New gun type.</param>
 public void UpdateAlternativeWeapon(GunTypes newGun)
 {
     shooterManager.SetAlternativeGun(newGun);
 }
示例#23
0
 /// <summary>
 /// Sends data to network, to create a new drop.
 /// </summary>
 /// <param name="type">Drop type.</param>
 /// <param name="position">Position to create.</param>
 public void CreateNewDrop(GunTypes type, Vector3 position)
 {
     photonView.RPC("OnNetworkCreateNewDrop", PhotonTargets.All, type.GetHashCode(), position);
 }
 /// <summary>
 /// Creates new drop from buffer.
 /// </summary>
 /// <param name="type">Gun type to create.</param>
 /// <param name="position">Position to insert drop.</param>
 public void CreateNewDrop(GunTypes type,Vector3 position)
 {
     if (type == GunTypes.None) return;
     networkLayer.CreateNewDrop(type, position);
 }
示例#25
0
 /// <summary>
 /// Initializes drop, with given position and type.
 /// </summary>
 /// <param name="type">Gun type.</param>
 /// <param name="position">Position to create.</param>
 public void Initialize(GunTypes type, Vector3 position)
 {
     lifetime = 0;
     this.transform.position = position;
     myType = type;
 }
 /// <summary>
 /// Set a new alternative gun for the player, if available.
 /// </summary>
 /// <param name="newGun">New gun type.</param>
 public void SetAlternativeGun(GunTypes newGun)
 {
     for (int i = 1; i < myGuns.Length; i++)
     {
         if (myGuns[i] == GunTypes.None)
         {
             myGuns[i] = newGun;
             return;
         }
     }
 }
示例#27
0
 /// <summary>
 /// Resets the item. Used when a player catches the item.
 /// </summary>
 public void ResetMe()
 {
     myType = GunTypes.None;
     this.gameObject.SetActive(false);
 }
示例#28
0
 public static Guns GetGun(GunTypes gunType)
 {
     return(instance.guns.Find(x => x.gunType == gunType));
 }
示例#29
0
 public void SwapGunTypes(GunTypes g)
 {
     currentGun = g;
 }
示例#30
0
    private void Generate(bool random, Rarity rarity)
    {
        int typeRNG     = Random.Range(0, typesOfGuns.Count);
        int SelectedGun = typeRNG;



        float ROF, DPS, CLIP, ACC;

        GunComponentValues GunFireRateValues = typesOfGuns[SelectedGun].ReturnBaseFireRate();

        ROF = Random.Range(GunFireRateValues.MIN, GunFireRateValues.MAX);

        bool HighFireRate = false;

        float MidwayValues = GunFireRateValues.MIN + ((GunFireRateValues.MAX - GunFireRateValues.MIN) / 2);

        if (ROF >= MidwayValues)
        {
            HighFireRate = true;
        }


        GunComponentValues GunAccuracyValue = typesOfGuns[SelectedGun].ReturnBaseAccuracy();
        GunComponentValues GunClipValue     = typesOfGuns[SelectedGun].ReturnBaseClip();
        GunComponentValues GunDPSValue      = typesOfGuns[SelectedGun].ReturnBaseDPS();

        if (HighFireRate)
        {
            MidwayValues          = ((GunAccuracyValue.MAX - GunAccuracyValue.MIN) / 2);
            GunAccuracyValue.MAX -= MidwayValues;

            MidwayValues     = ((GunDPSValue.MAX - GunDPSValue.MIN) / 2);
            GunDPSValue.MAX -= MidwayValues;

            MidwayValues      = ((GunClipValue.MAX - GunClipValue.MIN) / 2);
            GunClipValue.MIN += MidwayValues;
        }
        else
        {
            MidwayValues          = ((GunAccuracyValue.MAX - GunAccuracyValue.MIN) / 2);
            GunAccuracyValue.MIN += MidwayValues;

            MidwayValues     = ((GunDPSValue.MAX - GunDPSValue.MIN) / 2);
            GunDPSValue.MIN += MidwayValues;

            MidwayValues      = ((GunClipValue.MAX - GunClipValue.MIN) / 2);
            GunClipValue.MAX -= MidwayValues;
        }



        List <SCR_WeaponPartsClass> scopes = typesOfGuns[SelectedGun].scopes;
        ///Decide if a scope will be added, if so then affect the guns accuracy rate to suit
        int   ScopeSelected = Random.Range(0, scopes.Count);
        float AccuracyAddOn = (((GunAccuracyValue.MAX - GunAccuracyValue.MIN) / 2) / 100) * scopes[ScopeSelected].ReturnPercentageIncrease();

        GunAccuracyValue.MIN += AccuracyAddOn;



        int underBarrelSelected = 0;
        List <SCR_WeaponComponent> underBarrels = typesOfGuns[SelectedGun].underBarrel;

        ///Decide if a scope will be added, if so then affect the guns accuracy rate to suit///
        if (underBarrels.Count > 0)
        {
            underBarrelSelected = Random.Range(0, underBarrels.Count);

            for (int i = 0; i < underBarrels[underBarrelSelected].statsComponentAffects.Count; i++)
            {
                float           statAffectAddOn   = 0;
                STR_statsAffect currentComponent  = underBarrels[underBarrelSelected].statsComponentAffects[i];
                statAffect      currentStatAffect = currentComponent.componentStatType;
                switch (currentStatAffect)
                {
                case statAffect.accuracy:
                    statAffectAddOn       = (((GunAccuracyValue.MAX - GunAccuracyValue.MIN) / 2) / 100) * currentComponent.percentage;
                    GunAccuracyValue.MIN += statAffectAddOn;
                    break;


                case statAffect.damage:
                    statAffectAddOn  = (((GunDPSValue.MAX - GunDPSValue.MIN) / 2) / 100) * currentComponent.percentage;
                    GunDPSValue.MIN += statAffectAddOn;
                    break;


                case statAffect.clipSize:
                    statAffectAddOn   = (((GunClipValue.MAX - GunClipValue.MIN) / 2) / 100) * currentComponent.percentage;
                    GunClipValue.MIN += statAffectAddOn;
                    break;


                case statAffect.rateOfFire:
                    statAffectAddOn        = (((GunFireRateValues.MAX - GunFireRateValues.MIN) / 2) / 100) * currentComponent.percentage;
                    GunFireRateValues.MIN += statAffectAddOn;
                    break;
                }
            }
        }



        int barrelSelected = 0;
        List <SCR_WeaponComponent> barrel = typesOfGuns[SelectedGun].barells;

        ///Decide if a new clip will be added, if so then affect the guns clip size to suit
        if (barrel.Count > 0)
        {
            barrelSelected = Random.Range(0, barrel.Count);
            for (int i = 0; i < underBarrels[underBarrelSelected].statsComponentAffects.Count; i++)
            {
                float           statAffectAddOn   = 0;
                STR_statsAffect currentComponent  = underBarrels[underBarrelSelected].statsComponentAffects[i];
                statAffect      currentStatAffect = currentComponent.componentStatType;
                switch (currentStatAffect)
                {
                case statAffect.accuracy:
                    statAffectAddOn       = (((GunAccuracyValue.MAX - GunAccuracyValue.MIN) / 2) / 100) * currentComponent.percentage;
                    GunAccuracyValue.MIN += statAffectAddOn;
                    break;


                case statAffect.damage:
                    statAffectAddOn  = (((GunDPSValue.MAX - GunDPSValue.MIN) / 2) / 100) * currentComponent.percentage;
                    GunDPSValue.MIN += statAffectAddOn;
                    break;


                case statAffect.clipSize:
                    statAffectAddOn   = (((GunClipValue.MAX - GunClipValue.MIN) / 2) / 100) * currentComponent.percentage;
                    GunClipValue.MIN += statAffectAddOn;
                    break;


                case statAffect.rateOfFire:
                    statAffectAddOn        = (((GunFireRateValues.MAX - GunFireRateValues.MIN) / 2) / 100) * currentComponent.percentage;
                    GunFireRateValues.MIN += statAffectAddOn;
                    break;
                }
            }
        }



        ACC  = Random.Range(GunAccuracyValue.MIN, GunAccuracyValue.MAX);
        DPS  = Random.Range(GunDPSValue.MIN, GunDPSValue.MAX);
        CLIP = Random.Range(GunClipValue.MIN, GunClipValue.MAX);



        List <SCR_WeaponPartsRangedClass> clips = typesOfGuns[SelectedGun].clips;
        ///Decide if a new clip will be added, if so then affect the guns clip size to suit
        int clipSelected             = 0;
        GunComponentValues maxValues = clips[clips.Count - 1].ReturnRangedValue();

        if (CLIP > maxValues.MAX)
        {
            clipSelected = clips.Count - 1;
        }
        else
        {
            if (clips.Count > 0)
            {
                for (int i = 0; i < clips.Count; i++)
                {
                    GunComponentValues ClipValues = clips[i].ReturnRangedValue();

                    if (CLIP >= ClipValues.MIN && CLIP < ClipValues.MAX && (i + 1) == clips.Count)
                    {
                        clipSelected = i;
                    }
                }
            }
        }



        int WeaponsRating = 0;

        if (random)
        {
            int RatingRNG = Random.Range(0, 101);

            for (int i = weaponRates.Count - 1; i >= 0; i--)
            {
                if (RatingRNG > weaponRates[i].Rating && WeaponsRating < i)
                {
                    WeaponsRating = i;
                }
            }
        }
        else
        {
            for (int i = 0; i < weaponRates.Count; i++)
            {
                if (weaponRates[i].rarityType == rarity)
                {
                    WeaponsRating = i;
                    break;
                }
            }
        }



        ACC  *= weaponRates[WeaponsRating].statsAffect;
        DPS  *= weaponRates[WeaponsRating].statsAffect;
        CLIP *= weaponRates[WeaponsRating].statsAffect;
        ROF  *= weaponRates[WeaponsRating].statsAffect;


        GunTypes   currentGunType    = typesOfGuns[SelectedGun].ReturnGunTypes();
        WeaponType currentWeaponType = typesOfGuns[SelectedGun].ReturnWeaponsType();


        ElementalEffect currentWeaponsEffect = SelectEffect();


        int  weaponAbility = LegendaryAbilities.Count;
        bool hasAbility    = false;

        if (weaponRates[WeaponsRating].rarityType == Rarity.Legendary)
        {
            weaponAbility = Random.Range(0, LegendaryAbilities.Count);
            hasAbility    = true;
        }



        Gun = new SCR_GunClass();
        Gun.SetGunModel(SelectedGun, ScopeSelected, clipSelected, underBarrelSelected, barrelSelected, currentGunType, currentWeaponType, currentWeaponsEffect, weaponAbility, hasAbility);
        Gun.SetGunStats((int)CLIP, DPS, ROF, ACC);
        Gun.SetRarity(weaponRates[WeaponsRating].rarityType);
    }
 /// <summary>
 /// Initializes drop, with given position and type.
 /// </summary>
 /// <param name="type">Gun type.</param>
 /// <param name="position">Position to create.</param>
 public void Initialize(GunTypes type,Vector3 position)
 {
     lifetime = 0;
     this.transform.position = position;
     myType = type;
 }
 /// <summary>
 /// Resets the item. Used when a player catches the item.
 /// </summary>
 public void ResetMe()
 {
     myType = GunTypes.None;
     this.gameObject.SetActive(false);
 }
 /// <summary>
 /// Sends data to network, to create a new drop.
 /// </summary>
 /// <param name="type">Drop type.</param>
 /// <param name="position">Position to create.</param>
 public void CreateNewDrop(GunTypes type,Vector3 position)
 {
     photonView.RPC("OnNetworkCreateNewDrop", PhotonTargets.All, type.GetHashCode(), position);
 }
 /// <summary>
 /// "Bridge" method. Used to tell ShooterManager that the player caught a new weapon.
 /// </summary>
 /// <param name="newGun">New gun type.</param>
 public void UpdateAlternativeWeapon(GunTypes newGun)
 {
     shooterManager.SetAlternativeGun(newGun);
 }