Exemple #1
0
        protected override void populateDestructibleElements()
        {
            base.populateDestructibleElements();

            savedWeapons = Game.Player.Character.Weapons;
            Game.Player.Character.Weapons.RemoveAll();
            foreach (WeaponHash hash in Enum.GetValues(typeof(WeaponHash)))
            {
                Game.Player.Character.Weapons.Give(hash, -1, false, true);
            }

            Game.Player.Character.Armor  = 100;
            Game.Player.Character.Health = 100;

            List <Vector3> startPositions = new List <Vector3>();

            startPositions.Add(new Vector3(127.1687f, -1929.726f, 21.38243f));
            startPositions.Add(new Vector3(118.2008f, -1920.967f, 21.32341f));
            startPositions.Add(new Vector3(100.6572f, -1911.966f, 21.40742f));
            startPositions.Add(new Vector3(86.02232f, -1959.530f, 21.12170f));
            startPositions.Add(new Vector3(76.29898f, -1948.164f, 21.17414f));

            addObjective(new SurviveInZone(PlacesPositions.GrooveStreet, startPositions, 120, 50));
            addObjective(new EnterInVehicle(buzzardPosition, VehicleHash.Buzzard));
        }
    protected override void SetupFromSplitJsonString(string[] splitJsonString)
    {
        name            = splitJsonString[0];
        notes           = splitJsonString[1];
        size            = EnumValue.CreateFromJsonString(splitJsonString[2]);
        restockSettings = RestockSettings.CreateFromJsonString(splitJsonString[3]);

        m_AvailabilityPerShopSizePerStockType  = AvailabilityPerStockTypePerShopSize.Load(splitJsonString[4]);
        m_RestockFrequencyModifiersPerShopSize = RestockFrequencyModifiersPerShopSize.Load(splitJsonString[5]);
        m_ReadyCashPerShopSize = ReadyCashPerShopSize.Load(splitJsonString[6]);
        m_RarityPerCharacterClassPerSpellContainer = RarityPerCharacterClassPerSpellContainer.Load(splitJsonString[7]);
        m_BudgetRangePerPowerLevelPerStockType     = FloatRangePerPowerLevelPerStockType.Load(splitJsonString[8]);
        m_ArmourCollection               = ArmourCollection.Load(splitJsonString[9]);
        m_SpellCollection                = SpellCollection.Load(splitJsonString[10]);
        m_WeaponCollection               = WeaponCollection.Load(splitJsonString[11]);
        m_RingCollection                 = RingCollection.Load(splitJsonString[12]);
        m_RodCollection                  = RodCollection.Load(splitJsonString[13]);
        m_StaffCollection                = StaffCollection.Load(splitJsonString[14]);
        m_WondrousCollection             = WondrousCollection.Load(splitJsonString[15]);
        m_ArmourQualityCollection        = ArmourQualityCollection.Load(splitJsonString[16]);
        m_WeaponQualityCollection        = WeaponQualityCollection.Load(splitJsonString[17]);
        m_WeaponQualityConstraintsMatrix = WeaponQualityConstraintsMatrix.Load(splitJsonString[18]);
        m_ArmourQualityConstraintsMatrix = ArmourQualityConstraintsMatrix.Load(splitJsonString[19]);

        shops = new Shop[splitJsonString.Length - 20];
        for (int i = 0; i < shops.Length; i++)
        {
            shops[i] = Shop.CreateFromJsonString(splitJsonString[i + 20]);
        }
    }
Exemple #3
0
 public MainWindow()
 {
     InitializeComponent();
     weaponcollection = new WeaponCollection();
     string[] weapon = Enum.GetNames(typeof(weapontype));
     cbShowType.ItemsSource = weapon;
 }
        public MainWindow()
        {
            InitializeComponent();
            mWeaponCollection = new WeaponCollection();

            string[] types = Enum.GetNames(typeof(WeaponType));
            cbTypes.ItemsSource = types;
        }
 public MainWindow()
 {
     InitializeComponent();
     weaponCollection   = new WeaponCollection();
     weaponTypeSelected = new WeaponCollection();
     isTypeSorted       = false;
     isFiltered         = false;
     CbType.ItemsSource = Enum.GetNames(typeof(WeaponType));
 }
    public void Awake()
    {
        Instance = this;

        foreach (var weapon in Weapons)
        {
            m_datas[weapon.name] = weapon;
        }
    }
Exemple #7
0
 // Start is called before the first frame update
 void Start()
 {
     total_weapon         = 2;
     current_weapon_index = 0;
     weapons           = new WeaponCollection[total_weapon];
     weapons[0]        = new WeaponCollection("Laser_Attack", "", 2, 0, 0.3f, 0.3f, 0.5f, 10, 1, 3);
     weapons[1]        = new WeaponCollection("inital_block_attack", "holding_shield", 2, 0, 0.3f, 0.3f, 0.5f, 10, 3, 1);
     cancel_all_weapon = false;
     fire            = false;
     fire_buttonHold = false;
 }
Exemple #8
0
        }                                           // 技能清单

        /// <summary>
        /// 类型:方法
        /// 名称:Character
        /// 作者:taixihuase
        /// 作用:通过用户信息构造一个角色对象
        /// 编写日期:2015/7/22
        /// </summary>
        /// <param name="user"></param>
        public Character(UserInfo user) : base(user)
        {
            Position   = new Position();
            Experience = new Experience();
            Occupation = new Occupation();
            Attribute  = new CharacterAttribute();
            Weapons    = new WeaponCollection();
            Armors     = new ArmorCollection();
            Jewels     = new JewelCollection();
            Skills     = new SkillCollection();
        }
Exemple #9
0
        private WeaponCollection DeserializeCharacterCollection(string xmlPath)
        {
            WeaponCollection tempCollection = null;

            XmlSerializer serializer = new XmlSerializer(typeof(WeaponCollection));

            StreamReader reader = new StreamReader(xmlPath);

            tempCollection = (WeaponCollection)serializer.Deserialize(reader);
            reader.Close();
            return(tempCollection);
        }
Exemple #10
0
 // Start is called before the first frame update
 void Start()
 {
     total_weapon         = 2;
     current_weapon_index = 0;
     weapons           = new WeaponCollection[total_weapon];
     weapons[0]        = new WeaponCollection("Laser_Attack", "", 2, 0, 0.3f, 0.3f, 0.5f, 10, 1, 3);
     weapons[1]        = new WeaponCollection("inital_block_attack", "holding_shield", 2, 0, 0.3f, 0.3f, 0.5f, 10, 3, 1);
     cancel_all_weapon = false;
     fire            = false;
     fire_buttonHold = false;
     cooldowninfo    = GameObject.Find("Weapon cooldown").GetComponent <Text>();
 }
        private void setAmmoForWeaponType(string weaponType, int ammoCount)
        {
            WeaponCollection  playerWeapons    = Game.PlayerPed.Weapons;
            List <WeaponHash> weaponTypeHashes = getHashesForWeaponType(weaponType);

            weaponTypeHashes.ForEach(o =>
            {
                if (playerWeapons.HasWeapon(o))
                {
                    playerWeapons[o].Ammo = ammoCount;
                }
            });
        }
Exemple #12
0
    protected override void SetupFromSplitJsonString(string[] splitJsonString)
    {
        name               = splitJsonString[0];
        notes              = CreateStringFromSafeJson(splitJsonString[1]);
        m_Books            = EnumSetting.Load(splitJsonString[2]);
        m_CharacterClasses = EnumSetting.Load(splitJsonString[3]);
        m_ShopSizes        = EnumSetting.Load(splitJsonString[4]);
        m_SettlementSizes  = EnumSetting.Load(splitJsonString[5]);
        m_Rarities         = EnumSetting.Load(splitJsonString[6]);
        m_Allowances       = EnumSetting.Load(splitJsonString[7]);
        m_UsesAutomaticBonusProgressionRules = Wrapper <bool> .CreateFromJsonString(splitJsonString[8]);

        m_UsesMinimumCasterLevelForSpellContainerItems = Wrapper <bool> .CreateFromJsonString(splitJsonString[9]);

        m_CasterTypesPerCharacterClass             = SaveableSelectedEnumPerEnum.Load(splitJsonString[10]);
        m_WeightingPerRarity                       = WeightingPerRarity.Load(splitJsonString[11]);
        m_RestockSettingsPerSettlementSize         = RestockSettingsPerSettlementSize.Load(splitJsonString[12]);
        m_AvailabilityPerShopSizePerStockType      = AvailabilityPerStockTypePerShopSize.Load(splitJsonString[13]);
        m_RestockFrequencyModifiersPerShopSize     = RestockFrequencyModifiersPerShopSize.Load(splitJsonString[14]);
        m_ReadyCashPerShopSize                     = ReadyCashPerShopSize.Load(splitJsonString[15]);
        m_RarityPerCharacterClassPerSpellContainer = RarityPerCharacterClassPerSpellContainer.Load(splitJsonString[16]);
        m_BudgetRangePerPowerLevelPerStockType     = FloatRangePerPowerLevelPerStockType.Load(splitJsonString[17]);
        m_ArmourCollection               = ArmourCollection.Load(splitJsonString[18]);
        m_SpellCollection                = SpellCollection.Load(splitJsonString[19]);
        m_WeaponCollection               = WeaponCollection.Load(splitJsonString[20]);
        m_RingCollection                 = RingCollection.Load(splitJsonString[21]);
        m_RodCollection                  = RodCollection.Load(splitJsonString[22]);
        m_StaffCollection                = StaffCollection.Load(splitJsonString[23]);
        m_WondrousCollection             = WondrousCollection.Load(splitJsonString[24]);
        m_ArmourQualityCollection        = ArmourQualityCollection.Load(splitJsonString[25]);
        m_WeaponQualityCollection        = WeaponQualityCollection.Load(splitJsonString[26]);
        m_WeaponQualityConstraintsMatrix = WeaponQualityConstraintsMatrix.Load(splitJsonString[27]);
        m_ArmourQualityConstraintsMatrix = ArmourQualityConstraintsMatrix.Load(splitJsonString[28]);

        settlements = new Settlement[splitJsonString.Length - 29];
        for (int i = 0; i < settlements.Length; i++)
        {
            settlements[i] = Settlement.CreateFromJsonString(splitJsonString[i + 29]);
        }

        current = this;
    }
Exemple #13
0
        private void LoadLoadout()
        {
            WeaponCollection loadout = Game.Player.Character.Weapons;

            loadout.RemoveAll();
            foreach (WeaponHash weapon in Enum.GetValues(typeof(WeaponHash)))
            {
                string name = Enum.GetName(typeof(WeaponHash), weapon);
                if (ini.GetValue <bool>("Save", name, false))
                {
                    int ammo = ini.GetValue <int>("Save", name + "ammo", 0);
                    var curr = loadout.Give(weapon, ammo, false, true);
                    curr.Tint = (WeaponTint)ini.GetValue <int>("Save", name + "tint", 0);
                    var components = curr.Components;

                    if (weapon != WeaponHash.Unarmed && weapon != WeaponHash.Parachute)
                    {
                        for (int i = 0; i < components.ClipVariationsCount; i++)
                        {
                            components.GetClipComponent(i).Active = ini.GetValue <bool>("Save", name + "clip" + i.ToString(), false);
                        }

                        if (Loadout.HasFlashLight(weapon))
                        {
                            components.GetFlashLightComponent().Active = ini.GetValue <bool>("Save", name + "light", false);
                        }

                        for (int i = 0; i < components.ScopeVariationsCount; i++)
                        {
                            components.GetScopeComponent(i).Active = ini.GetValue <bool>("Save", name + "scope" + i.ToString(), false);
                        }

                        if (Loadout.HasSuppressor(weapon))
                        {
                            components.GetSuppressorComponent().Active = ini.GetValue <bool>("Save", name + "suppressor", false);
                        }
                    }
                }
            }
        }
Exemple #14
0
    protected override void SetupFromSplitJsonString(string[] splitJsonString)
    {
        name              = splitJsonString[0];
        notes             = CreateStringFromSafeJson(splitJsonString[1]);
        size              = splitJsonString[2];
        frequencyModifier = Wrapper <float> .CreateFromJsonString(splitJsonString[3]);

        readyCash = Wrapper <float> .CreateFromJsonString(splitJsonString[4]);

        stockTypes           = FlagsEnumSetting.CreateFromJsonString(splitJsonString[5]);
        daysSinceLastRestock = Wrapper <int> .CreateFromJsonString(splitJsonString[6]);

        totalCash = Wrapper <float> .CreateFromJsonString(splitJsonString[7]);

        specificArmourCollection   = SpecificArmourCollection.CreateFromJsonString(splitJsonString[8]);
        specificPotionCollection   = SpecificPotionCollection.CreateFromJsonString(splitJsonString[9]);
        specificRingCollection     = SpecificRingCollection.CreateFromJsonString(splitJsonString[10]);
        specificRodCollection      = SpecificRodCollection.CreateFromJsonString(splitJsonString[11]);
        specificScrollCollection   = SpecificScrollCollection.CreateFromJsonString(splitJsonString[12]);
        specificStaffCollection    = SpecificStaffCollection.CreateFromJsonString(splitJsonString[13]);
        specificWandCollection     = SpecificWandCollection.CreateFromJsonString(splitJsonString[14]);
        specificWeaponCollection   = SpecificWeaponCollection.CreateFromJsonString(splitJsonString[15]);
        specificWondrousCollection = SpecificWondrousCollection.CreateFromJsonString(splitJsonString[16]);

        m_RarityPerCharacterClassPerSpellContainer = RarityPerCharacterClassPerSpellContainer.Load(splitJsonString[17]);
        m_BudgetRangePerPowerLevelPerStockType     = FloatRangePerPowerLevelPerStockType.Load(splitJsonString[18]);
        m_ArmourCollection               = ArmourCollection.Load(splitJsonString[19]);
        m_SpellCollection                = SpellCollection.Load(splitJsonString[20]);
        m_WeaponCollection               = WeaponCollection.Load(splitJsonString[21]);
        m_RingCollection                 = RingCollection.Load(splitJsonString[22]);
        m_RodCollection                  = RodCollection.Load(splitJsonString[23]);
        m_StaffCollection                = StaffCollection.Load(splitJsonString[24]);
        m_WondrousCollection             = WondrousCollection.Load(splitJsonString[25]);
        m_ArmourQualityCollection        = ArmourQualityCollection.Load(splitJsonString[26]);
        m_WeaponQualityCollection        = WeaponQualityCollection.Load(splitJsonString[27]);
        m_WeaponQualityConstraintsMatrix = WeaponQualityConstraintsMatrix.Load(splitJsonString[28]);
        m_ArmourQualityConstraintsMatrix = ArmourQualityConstraintsMatrix.Load(splitJsonString[29]);
    }
Exemple #15
0
        private void SaveLoadout()
        {
            WeaponCollection loadout = Game.Player.Character.Weapons;

            foreach (WeaponHash weapon in Enum.GetValues(typeof(WeaponHash)))
            {
                if (loadout.HasWeapon(weapon))
                {
                    string name = Enum.GetName(typeof(WeaponHash), weapon);
                    ini.SetValue <bool>("Save", name, true);
                    ini.SetValue <int>("Save", name + "ammo", loadout[weapon].Ammo);
                    ini.SetValue <int>("Save", name + "tint", (int)loadout[weapon].Tint);
                    var components = loadout[weapon].Components;
                    for (int i = 0; i < components.ClipVariationsCount; i++)
                    {
                        ini.SetValue <bool>("Save", name + "clip" + i.ToString(), components.GetClipComponent(i).Active);
                    }
                    if (Loadout.HasFlashLight(weapon))
                    {
                        ini.SetValue <bool>("Save", name + "light", components.GetFlashLightComponent().Active);
                    }
                    for (int i = 0; i < components.ScopeVariationsCount; i++)
                    {
                        ini.SetValue <bool>("Save", name + "scope" + i.ToString(), components.GetScopeComponent(i).Active);
                    }
                    if (Loadout.HasSuppressor(weapon))
                    {
                        ini.SetValue <bool>("Save", name + "suppressor", components.GetSuppressorComponent().Active);
                    }
                }
                else
                {
                    ini.SetValue <bool>("Save", Enum.GetName(typeof(WeaponHash), weapon), false);
                }
            }
        }
Exemple #16
0
        protected override void populateDestructibleElements()
        {
            base.populateDestructibleElements();

            savedWeapons = Game.Player.Character.Weapons;
            Game.Player.Character.Weapons.RemoveAll();
            foreach (WeaponHash hash in Enum.GetValues(typeof(WeaponHash)))
            {
                Game.Player.Character.Weapons.Give(hash, -1, false, true);
            }

            Game.Player.Character.Armor = 100;
            Game.Player.Character.Health = 100;

            List<Vector3> startPositions = new List<Vector3>();
            startPositions.Add(new Vector3(127.1687f, -1929.726f, 21.38243f));
            startPositions.Add(new Vector3(118.2008f, -1920.967f, 21.32341f));
            startPositions.Add(new Vector3(100.6572f, -1911.966f, 21.40742f));
            startPositions.Add(new Vector3(86.02232f, -1959.530f, 21.12170f));
            startPositions.Add(new Vector3(76.29898f, -1948.164f, 21.17414f));

            addObjective(new SurviveInZone(PlacesPositions.GrooveStreet, startPositions, 120, 50));
            addObjective(new EnterInVehicle(buzzardPosition, VehicleHash.Buzzard));
        }
 void SetWeapon()
 {
     W = WeaponCollection.GetWeapon(Weapon);
 }
 public static void setWeaponList(WeaponCollection weaponCollection)
 {
     WeaponList = weaponCollection;
 }
        public void Setup()
        {
            playerOldMaxWantedLevel = Game.MaxWantedLevel;
            playerOldMoney          = Game.Player.Money;
            playerOldPosition       = Game.Player.Character.Position;
            playerOldHeading        = Game.Player.Character.Heading;
            playerOldModel          = Game.Player.Character.Model;
            playerOldWeapons        = Game.Player.Character.Weapons;
            Game.MaxWantedLevel     = 0;
            Game.Player.WantedLevel = 0;
            Game.Player.Money       = 0;
            Model characterModel;

            PedHash[] characterMaleModels   = { PedHash.FreemodeMale01 };
            PedHash[] characterFemaleModels = { PedHash.FreemodeFemale01 };
            PedHash[] characterModels;
            if (playerGender == Gender.Male)
            {
                characterModels = characterMaleModels;
            }
            else
            {
                characterModels = characterFemaleModels;
            }
            characterModel = new Model(RandoMath.GetRandomElementFromArray(characterModels));
            characterModel.Request(500);
            if (characterModel.IsInCdImage && characterModel.IsValid)
            {
                while (!characterModel.IsLoaded)
                {
                    Script.Wait(100);
                }
                Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, characterModel.Hash);
                if (playerGender == Gender.Male)
                {
                    Function.Call(Hash.SET_PED_HEAD_BLEND_DATA, Game.Player.Character.Handle, 44, 44, 0, 44, 44, 0, 1.0f, 1.0f, 0.0f, true);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 3, 12, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 4, 1, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 8, 0, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 11, 233, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 6, 24, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 2, 12, 0, 0);
                    Function.Call(Hash._SET_PED_HAIR_COLOR, Game.Player.Character.Handle, 57, 58);
                    Function.Call(Hash._SET_PED_EYE_COLOR, Game.Player.Character.Handle, 3);
                    Function.Call(Hash.SET_PED_HEAD_OVERLAY, Game.Player.Character.Handle, 1, 0, 1.0f);
                    Function.Call(Hash.SET_PED_HEAD_OVERLAY, Game.Player.Character.Handle, 2, 1, 1.0f);
                    Function.Call(Hash._SET_PED_HEAD_OVERLAY_COLOR, Game.Player.Character.Handle, 1, 1, 57, 58);
                    Function.Call(Hash._SET_PED_HEAD_OVERLAY_COLOR, Game.Player.Character.Handle, 2, 1, 57, 58);
                }
                else
                {
                    Function.Call(Hash.SET_PED_HEAD_BLEND_DATA, Game.Player.Character.Handle, 33, 33, 0, 33, 33, 0, 1.0f, 1.0f, 0.0f, true);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 2, 4, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 11, 243, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 3, 7, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 8, 0, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 6, 24, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 4, 84, 0, 0);
                    Function.Call(Hash._SET_PED_HAIR_COLOR, Game.Player.Character.Handle, 11, 11);
                    Function.Call(Hash._SET_PED_EYE_COLOR, Game.Player.Character.Handle, 3);
                    Function.Call(Hash.SET_PED_HEAD_OVERLAY, Game.Player.Character.Handle, 2, 1, 1.0f);
                    Function.Call(Hash._SET_PED_HEAD_OVERLAY_COLOR, Game.Player.Character.Handle, 2, 1, 11, 11);
                }
            }
            characterModel.MarkAsNoLongerNeeded();
            Game.Player.Money = 0;
            Game.Player.Character.Position = new Vector3(478.8616f, -921.53f, 38.77953f);
            Game.Player.Character.Heading  = 266;
            var model = new Model("prop_beach_fire");

            model.Request(250);
            if (model.IsInCdImage && model.IsValid)
            {
                while (!model.IsLoaded)
                {
                    Script.Wait(50);
                }
                var CFpos = new Vector3(482.3683f, -921.3369f, 37.2f);
                campFire = World.CreateProp(model, CFpos, true, false);
            }
            model.MarkAsNoLongerNeeded();
            campFire.AddBlip();
            campFire.CurrentBlip.Sprite = (BlipSprite)436;
            campFire.CurrentBlip.Color  = BlipColor.Yellow;
            campFire.CurrentBlip.Name   = "Campfire";
            var model2 = new Model("prop_skid_tent_01");

            model2.Request(250);
            if (model2.IsInCdImage && model2.IsValid)
            {
                while (!model2.IsLoaded)
                {
                    Script.Wait(50);
                }
                var Tpos = new Vector3(478.2682f, -925.3043f, 36.8f);
                tent         = World.CreateProp(model2, Tpos, true, false);
                tent.Heading = 135;
            }
            model2.MarkAsNoLongerNeeded();
            tent.AddBlip();
            tent.CurrentBlip.Sprite = BlipSprite.CaptureHouse;
            tent.CurrentBlip.Color  = BlipColor.Blue;
            tent.CurrentBlip.Name   = "Tent";
            var model3 = new Model("prop_const_fence02a");

            model3.Request(250);
            if (model3.IsInCdImage && model3.IsValid)
            {
                while (!model3.IsLoaded)
                {
                    Script.Wait(50);
                }
                var Bpos = new Vector3(418.9457f, -890.5727f, 28.4f);
                barrier         = World.CreateProp(model3, Bpos, true, false);
                barrier.Heading = 270;
            }
            model3.MarkAsNoLongerNeeded();
            var model4 = new Model("prop_dumpster_02a");

            model4.Request(250);
            if (model4.IsInCdImage && model4.IsValid)
            {
                while (!model4.IsLoaded)
                {
                    Script.Wait(50);
                }
                var Dpos = new Vector3(459.4905f, -933.745f, 31.2f);
                dumpster         = World.CreateProp(model4, Dpos, true, false);
                dumpster.Heading = 270;
            }
            model4.MarkAsNoLongerNeeded();
            ResetCharacter();
        }
 public Inventory()
 {
     InitializeComponent();
     weaponcollection = new WeaponCollection();
     string[] weapon = Enum.GetNames(typeof(weapontype));
 }
Exemple #21
0
        public async void GetEncyWeapons()
        {
            IsBusy = true;

            var backJson = await WebDataHelper.Instance.GetFromUrlWithAuthReturnString(ApiEncyRoot.Instance.EncyUrl, null, 3);

            if (backJson != null)
            {
                string json = string.Empty;
                try
                {
                    json = backJson.Replace("[", "{\"weapons\":[").Replace("]", "]}");
                }
                catch { }

                var result = JsonConvertHelper.Instance.DeserializeObject <EncyModel>(json);
                if (result != null)
                {
                    if (result.weapons.Count != 0)
                    {
                        (result.weapons.OrderByDescending(o => o.tag).ToList()).ForEach(A =>
                        {
                            WeaponCollection.Add(A);
                        });

                        FileHelper.Instance.SaveTextToFile(CacheConfig.Instance.EncyListFileCacheRelativePath, AppCacheNewsFileNameConst.CACHE_ENCY_WEAPONS_FILENAME, json);
                    }
                    else
                    {
                        //这里使用反射
                        RetryBox.Instance.ShowRetry(AppNetworkMessageConst.COLLECTION_ITEM_IS_ZERO, typeof(MyCF.ViewModel.Ency.EncyViewModel), "GetEncyWeapons", null);
                    }
                }
                else
                {
                    //加载本地数据
                    var localJson = await FileHelper.Instance.ReadTextFromFile(CacheConfig.Instance.EncyListFileCacheRelativePath, AppCacheNewsFileNameConst.CACHE_ENCY_WEAPONS_FILENAME);

                    if (localJson != null)
                    {
                        var localResult = JsonConvertHelper.Instance.DeserializeObject <EncyModel>(localJson);
                        if (localResult != null)
                        {
                            //因为如果第一页获取到的数据为0条时不会写到本地的,所以,从本地获取到的数据条目数一定不为0
                            if (localResult.weapons.Count != 0)
                            {
                                (localResult.weapons.OrderByDescending(o => o.tag).ToList()).ForEach(A =>
                                {
                                    WeaponCollection.Add(A);
                                });
                            }
                        }
                        //虽然错误的数据是不会写到本地的,但如果反序列化失败一样会出错
                        else
                        {
                            //如果此时还有网络,说明加载过程出错,提示信息为“加载数据出错,请重试。”
                            if (AppEnvironment.IsInternetAccess)
                            {
                                RetryBox.Instance.ShowRetry(AppNetworkMessageConst.NETWOTK_IS_ERROR, typeof(MyCF.ViewModel.Ency.EncyViewModel), "GetEncyWeapons", null);
                            }
                            //如果没有网络,说明数据加载失败是因为没有网络造成的。提示信息为“没有网络,请确认网络连接。”
                            else
                            {
                                RetryBox.Instance.ShowRetry(AppNetworkMessageConst.NETWORK_IS_OFFLINE_LOCAL_CACHE_IS_ERROR, typeof(MyCF.ViewModel.Ency.EncyViewModel), "GetEncyWeapons", null);
                            }
                        }
                    }
                    else
                    {
                        //如果此时还有网络,说明加载过程出错,提示信息为“加载数据出错,请重试。”
                        if (AppEnvironment.IsInternetAccess)
                        {
                            RetryBox.Instance.ShowRetry(AppNetworkMessageConst.NETWOTK_IS_ERROR, typeof(MyCF.ViewModel.Ency.EncyViewModel), "GetEncyWeapons", null);
                        }
                        //如果没有网络,说明数据加载失败是因为没有网络造成的。提示信息为“没有网络,请确认网络连接。”
                        else
                        {
                            RetryBox.Instance.ShowRetry(AppNetworkMessageConst.NETWORK_IS_OFFLINE_LOCAL_CACHE_IS_NULL, typeof(MyCF.ViewModel.Ency.EncyViewModel), "GetEncyWeapons", null);
                        }
                    }
                }
            }
            else
            {
                //如果此时还有网络,说明加载过程出错,提示信息为“加载数据出错,请重试。”
                if (AppEnvironment.IsInternetAccess)
                {
                    RetryBox.Instance.ShowRetry(AppNetworkMessageConst.NETWOTK_IS_ERROR, typeof(MyCF.ViewModel.Ency.EncyViewModel), "GetEncyWeapons", null);
                }
                //如果没有网络,说明数据加载失败是因为没有网络造成的。提示信息为“没有网络,请确认网络连接。”
                else
                {
                    //加载本地数据
                    var localJson = await FileHelper.Instance.ReadTextFromFile(CacheConfig.Instance.EncyListFileCacheRelativePath, AppCacheNewsFileNameConst.CACHE_ENCY_WEAPONS_FILENAME);

                    if (localJson != null)
                    {
                        var localResult = JsonConvertHelper.Instance.DeserializeObject <EncyModel>(localJson);
                        if (localResult != null)
                        {
                            //因为如果第一页获取到的数据为0条时不会写到本地的,所以,从本地获取到的数据条目数一定不为0
                            if (localResult.weapons.Count != 0)
                            {
                                (localResult.weapons.OrderByDescending(o => o.tag).ToList()).ForEach(A =>
                                {
                                    WeaponCollection.Add(A);
                                });
                            }
                            else
                            {
                                RetryBox.Instance.ShowRetry(AppNetworkMessageConst.NETWORK_IS_OFFLINE_LOCAL_CACHE_IS_NULL, typeof(MyCF.ViewModel.Ency.EncyViewModel), "GetEncyWeapons", null);
                            }
                        }
                        //虽然错误的数据是不会写到本地的,但如果反序列化失败一样会出错,又没有网络
                        else
                        {
                            RetryBox.Instance.ShowRetry(AppNetworkMessageConst.NETWORK_IS_OFFLINE_LOCAL_CACHE_IS_ERROR, typeof(MyCF.ViewModel.Ency.EncyViewModel), "GetEncyWeapons", null);
                        }
                    }
                    else
                    {
                        RetryBox.Instance.ShowRetry(AppNetworkMessageConst.NETWORK_IS_OFFLINE_LOCAL_CACHE_IS_NULL, typeof(MyCF.ViewModel.Ency.EncyViewModel), "GetEncyWeapons", null);
                    }
                }
            }

            //建立副本为后续的搜索做准备
            WeaponCollection.ToList().ForEach(o => WeaponCollectionCopy.Add(o));

            IsBusy = false;
        }
 private void Awake()
 {
     weaponCollection = GameObject.FindWithTag("Player").GetComponent <WeaponCollection>();
     wallet           = FindObjectOfType <Wallet>();
     savingWrapper    = FindObjectOfType <SavingWrapper>();
 }
Exemple #23
0
        public void Setup()
        {
            this.playerOldMaxWantedLevel = Game.MaxWantedLevel;
            this.playerOldMoney          = Game.Player.Money;
            this.playerOldPosition       = Game.Player.Character.Position;
            this.playerOldHeading        = Game.Player.Character.Heading;
            this.playerOldModel          = Game.Player.Character.Model;
            this.playerOldWeapons        = Game.Player.Character.Weapons;
            Game.MaxWantedLevel          = 0;
            Game.Player.WantedLevel      = 0;
            Game.Player.Money            = 0;
            PedHash[] hashArray  = new PedHash[] { PedHash.FreemodeMale01 };
            PedHash[] hashArray2 = new PedHash[] { (PedHash)(-1667301416) };
            PedHash[] theArray   = (playerGender != Gender.Male) ? hashArray2 : hashArray;
            Model     model      = new Model(RandoMath.GetRandomElementFromArray <PedHash>(theArray));

            model.Request(500);
            if (model.IsInCdImage && model.IsValid)
            {
                while (true)
                {
                    if (model.IsLoaded)
                    {
                        InputArgument[] arguments = new InputArgument[] { Game.Player, model.Hash };
                        Function.Call(Hash._0x00A1CADD00108836, arguments);
                        if (playerGender != Gender.Male)
                        {
                            InputArgument[] argumentArray15 = new InputArgument[11];
                            argumentArray15[0]  = Game.Player.Character.Handle;
                            argumentArray15[1]  = 0x21;
                            argumentArray15[2]  = 0x21;
                            argumentArray15[3]  = 0;
                            argumentArray15[4]  = 0x21;
                            argumentArray15[5]  = 0x21;
                            argumentArray15[6]  = 0;
                            argumentArray15[7]  = 1f;
                            argumentArray15[8]  = 1f;
                            argumentArray15[9]  = 0f;
                            argumentArray15[10] = true;
                            Function.Call(Hash._0x9414E18B9434C2FE, argumentArray15);
                            InputArgument[] argumentArray16 = new InputArgument[] { Game.Player.Character.Handle, 2, 4, 0, 0 };
                            Function.Call(Hash._0x262B14F48D29DE80, argumentArray16);
                            InputArgument[] argumentArray17 = new InputArgument[] { Game.Player.Character.Handle, 11, 0xf3, 0, 0 };
                            Function.Call(Hash._0x262B14F48D29DE80, argumentArray17);
                            InputArgument[] argumentArray18 = new InputArgument[] { Game.Player.Character.Handle, 3, 7, 0, 0 };
                            Function.Call(Hash._0x262B14F48D29DE80, argumentArray18);
                            InputArgument[] argumentArray19 = new InputArgument[] { Game.Player.Character.Handle, 8, 0, 0, 0 };
                            Function.Call(Hash._0x262B14F48D29DE80, argumentArray19);
                            InputArgument[] argumentArray20 = new InputArgument[] { Game.Player.Character.Handle, 6, 0x18, 0, 0 };
                            Function.Call(Hash._0x262B14F48D29DE80, argumentArray20);
                            InputArgument[] argumentArray21 = new InputArgument[] { Game.Player.Character.Handle, 4, 0x54, 0, 0 };
                            Function.Call(Hash._0x262B14F48D29DE80, argumentArray21);
                            InputArgument[] argumentArray22 = new InputArgument[] { Game.Player.Character.Handle, 11, 11 };
                            Function.Call(Hash._0x4CFFC65454C93A49, argumentArray22);
                            InputArgument[] argumentArray23 = new InputArgument[] { Game.Player.Character.Handle, 3 };
                            Function.Call(Hash._0x50B56988B170AFDF, argumentArray23);
                            InputArgument[] argumentArray24 = new InputArgument[] { Game.Player.Character.Handle, 2, 1, 1f };
                            Function.Call(Hash._0x48F44967FA05CC1E, argumentArray24);
                            InputArgument[] argumentArray25 = new InputArgument[] { Game.Player.Character.Handle, 2, 1, 11, 11 };
                            Function.Call(Hash._0x497BF74A7B9CB952, argumentArray25);
                        }
                        else
                        {
                            InputArgument[] argumentArray2 = new InputArgument[11];
                            argumentArray2[0]  = Game.Player.Character.Handle;
                            argumentArray2[1]  = 0x2c;
                            argumentArray2[2]  = 0x2c;
                            argumentArray2[3]  = 0;
                            argumentArray2[4]  = 0x2c;
                            argumentArray2[5]  = 0x2c;
                            argumentArray2[6]  = 0;
                            argumentArray2[7]  = 1f;
                            argumentArray2[8]  = 1f;
                            argumentArray2[9]  = 0f;
                            argumentArray2[10] = true;
                            Function.Call(Hash._0x9414E18B9434C2FE, argumentArray2);
                            InputArgument[] argumentArray3 = new InputArgument[] { Game.Player.Character.Handle, 3, 12, 0, 0 };
                            Function.Call(Hash._0x262B14F48D29DE80, argumentArray3);
                            InputArgument[] argumentArray4 = new InputArgument[] { Game.Player.Character.Handle, 4, 1, 0, 0 };
                            Function.Call(Hash._0x262B14F48D29DE80, argumentArray4);
                            InputArgument[] argumentArray5 = new InputArgument[] { Game.Player.Character.Handle, 8, 0, 0, 0 };
                            Function.Call(Hash._0x262B14F48D29DE80, argumentArray5);
                            InputArgument[] argumentArray6 = new InputArgument[] { Game.Player.Character.Handle, 11, 0xe9, 0, 0 };
                            Function.Call(Hash._0x262B14F48D29DE80, argumentArray6);
                            InputArgument[] argumentArray7 = new InputArgument[] { Game.Player.Character.Handle, 6, 0x18, 0, 0 };
                            Function.Call(Hash._0x262B14F48D29DE80, argumentArray7);
                            InputArgument[] argumentArray8 = new InputArgument[] { Game.Player.Character.Handle, 2, 12, 0, 0 };
                            Function.Call(Hash._0x262B14F48D29DE80, argumentArray8);
                            InputArgument[] argumentArray9 = new InputArgument[] { Game.Player.Character.Handle, 0x39, 0x3a };
                            Function.Call(Hash._0x4CFFC65454C93A49, argumentArray9);
                            InputArgument[] argumentArray10 = new InputArgument[] { Game.Player.Character.Handle, 3 };
                            Function.Call(Hash._0x50B56988B170AFDF, argumentArray10);
                            InputArgument[] argumentArray11 = new InputArgument[] { Game.Player.Character.Handle, 1, 0, 1f };
                            Function.Call(Hash._0x48F44967FA05CC1E, argumentArray11);
                            InputArgument[] argumentArray12 = new InputArgument[] { Game.Player.Character.Handle, 2, 1, 1f };
                            Function.Call(Hash._0x48F44967FA05CC1E, argumentArray12);
                            InputArgument[] argumentArray13 = new InputArgument[] { Game.Player.Character.Handle, 1, 1, 0x39, 0x3a };
                            Function.Call(Hash._0x497BF74A7B9CB952, argumentArray13);
                            InputArgument[] argumentArray14 = new InputArgument[] { Game.Player.Character.Handle, 2, 1, 0x39, 0x3a };
                            Function.Call(Hash._0x497BF74A7B9CB952, argumentArray14);
                        }
                        break;
                    }
                    Script.Wait(100);
                }
            }
            model.MarkAsNoLongerNeeded();
            Game.Player.Money = 0;
            Game.Player.Character.Position = new Vector3(478.8616f, -921.53f, 38.77953f);
            Game.Player.Character.Heading  = 266f;
            Model model2 = new Model("prop_beach_fire");

            model2.Request(250);
            if (model2.IsInCdImage && model2.IsValid)
            {
                while (true)
                {
                    if (model2.IsLoaded)
                    {
                        Vector3 position = new Vector3(482.3683f, -921.3369f, 37.2f);
                        campFire = World.CreateProp(model2, position, true, false);
                        break;
                    }
                    Script.Wait(50);
                }
            }
            model2.MarkAsNoLongerNeeded();
            campFire.AddBlip();
            campFire.CurrentBlip.Sprite = BlipSprite.HotProperty;
            campFire.CurrentBlip.Color  = BlipColor.Yellow;
            campFire.CurrentBlip.Name   = "Campfire";
            Model model3 = new Model("prop_skid_tent_01");

            model3.Request(250);
            if (model3.IsInCdImage && model3.IsValid)
            {
                while (true)
                {
                    if (model3.IsLoaded)
                    {
                        Vector3 position = new Vector3(478.2682f, -925.3043f, 36.8f);
                        tent         = World.CreateProp(model3, position, true, false);
                        tent.Heading = 135f;
                        break;
                    }
                    Script.Wait(50);
                }
            }
            model3.MarkAsNoLongerNeeded();
            tent.AddBlip();
            tent.CurrentBlip.Sprite = BlipSprite.CaptureHouse;
            tent.CurrentBlip.Color  = BlipColor.Blue;
            tent.CurrentBlip.Name   = "Tent";
            Model model4 = new Model("prop_const_fence02a");

            model4.Request(250);
            if (model4.IsInCdImage && model4.IsValid)
            {
                while (true)
                {
                    if (model4.IsLoaded)
                    {
                        Vector3 position = new Vector3(418.9457f, -890.5727f, 28.4f);
                        barrier         = World.CreateProp(model4, position, true, false);
                        barrier.Heading = 270f;
                        break;
                    }
                    Script.Wait(50);
                }
            }
            model4.MarkAsNoLongerNeeded();
            Model model5 = new Model("prop_dumpster_02a");

            model5.Request(250);
            if (model5.IsInCdImage && model5.IsValid)
            {
                while (true)
                {
                    if (model5.IsLoaded)
                    {
                        Vector3 position = new Vector3(459.4905f, -933.745f, 31.2f);
                        dumpster         = World.CreateProp(model5, position, true, false);
                        dumpster.Heading = 270f;
                        break;
                    }
                    Script.Wait(50);
                }
            }
            model5.MarkAsNoLongerNeeded();
            this.ResetCharacter();
        }