private void GiveHeavyWeapons(Ped ped)
        {
            WeaponAsset weapon;

            switch (RandomNumber(1, 5))
            {
            case 1:
                weapon = new WeaponAsset((uint)WeaponHash.Minigun);
                break;

            case 2:
                weapon = new WeaponAsset((uint)WeaponHash.AssaultShotgun);
                break;

            case 3:
                weapon = new WeaponAsset((uint)WeaponHash.CombatMG);
                break;

            default:
                weapon = new WeaponAsset((uint)WeaponHash.AssaultRifle);
                break;
            }
            var gun1 = new Weapon(weapon, SpawnPoint, 500);

            gun1.GiveTo(ped);
            ped.MaxHealth = RandomNumber(200, 751);
            ped.Armor     = RandomNumber(150, 401);
            Game.LogTrivial($"Armor: {ped.Armor}; Health: {ped.MaxHealth}");
        }
        private void GiveHeavyWeapons(List <Ped> pedList)
        {
            if (pedList.Count < 1)
            {
                return;
            }

            foreach (var ped in pedList)
            {
                WeaponAsset weapon;
                switch (RandomNumber(1, 5))
                {
                case 1:
                    weapon = new WeaponAsset((uint)WeaponHash.APPistol);
                    break;

                case 2:
                    weapon = new WeaponAsset((uint)WeaponHash.AssaultShotgun);
                    break;

                case 3:
                    weapon = new WeaponAsset((uint)WeaponHash.CombatMG);
                    break;

                default:
                    weapon = new WeaponAsset((uint)WeaponHash.AssaultRifle);
                    break;
                }
                var gun1 = new Weapon(weapon, SpawnPoint, 500);
                gun1.GiveTo(ped);
                ped.Armor = RandomNumber(50, 101);
                Game.LogTrivial($"Armor: {ped.Armor}; Health: {ped.MaxHealth}");
            }
        }
Exemplo n.º 3
0
        private void GiveKnifeOrWeapon(IEnumerable <Ped> pedList)
        {
            var enumerable = pedList as Ped[] ?? pedList.ToArray();

            if (enumerable.Length < 1)
            {
                return;
            }

            foreach (var ped in enumerable)
            {
                WeaponAsset weapon;
                switch (Fiskey111Common.Rand.RandomNumber(1, 5))
                {
                case 1:
                    weapon = new WeaponAsset((uint)WeaponHash.Pistol);
                    break;

                case 2:
                    weapon = new WeaponAsset((uint)WeaponHash.SawnOffShotgun);
                    break;

                case 3:
                    weapon = new WeaponAsset((uint)WeaponHash.APPistol);
                    break;

                default:
                    weapon = new WeaponAsset((uint)WeaponHash.Knife);
                    break;
                }

                var gun1 = new Weapon(weapon, SpawnPoint, 100);
                gun1.GiveTo(ped);
            }
        }
Exemplo n.º 4
0
    public void OnChangedWeapon(WeaponAsset wa)
    {
        currentWeapon = wa;

        controller.weaponCooldown = currentWeapon.primaryWeapon.cooldown;
        controller.weaponDamage   = currentWeapon.primaryWeapon.damage;
        controller.weaponDistance = currentWeapon.primaryWeapon.range;
    }
Exemplo n.º 5
0
        /// <summary>
        /// Sets the information on the information panel based on the information set on both the info and assets.
        /// </summary>
        public void SetInfoPanel(WeaponType type, string universalID)
        {
            WeaponAsset asset = GameManager.Instance.weaponSettings.RetrieveFromSettings(type, universalID);

            informationPanel.SetActive(true);
            InformationPanel infoPanel = informationPanel.GetComponent <InformationPanel>();

            infoPanel.SetPanelInfo(asset.name, asset.description, null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Sets the information on the information panel based on the information set on both the info and assets.
        /// </summary>
        public void SetInfoPanel(string equipmentID)
        {
            WeaponInfo  info  = weaponServicer.GetWeaponItem(equipmentID);
            WeaponAsset asset = GameManager.Instance.weaponSettings.RetrieveFromSettings(info.weaponType, info.globalID);

            informationPanel.SetActive(true);
            InformationPanel infoPanel = informationPanel.GetComponent <InformationPanel>();

            infoPanel.SetPanelInfo(info.name, asset.description, asset.spriteThumbnail);
        }
Exemplo n.º 7
0
    void SpawnEnemy(WeaponAsset weapon, GameObject spawnPoint)
    {
        int enemyPrefab = Random.Range(0, m_EnemyPrefabs.Length);

        var enemyGO = Instantiate(m_EnemyPrefabs[enemyPrefab], spawnPoint.transform.position, spawnPoint.transform.rotation, m_EnemySpawnParent.transform);

        enemyGO.GetComponent <ActorWeapon>().EquipWeapon(weapon);
        enemyGO.GetComponent <ActorHealth>().OnDeath.AddListener(OnEnemyDeath);
        enemyGO.GetComponent <ActorAI>().Player = m_Player;
        enemyGO.GetComponent <ActorAI>().Agent  = weapon.AIAgent;
    }
Exemplo n.º 8
0
        private IWeapon InitialiseWeapon(WeaponAsset weaponAsset, WeaponInfo info)
        {
            //Spawn and Initialise Weapon
            weapon = Instantiate(weaponAsset.weaponPrefab, transform);
            IWeapon weaponInterface = weapon.GetComponent <IWeapon>();

            weaponInterface.InitialiseWeapon(info, transform.root.gameObject.GetComponent <IEntitySpeed>());
            weaponInterface.ConfigureWeaponPositioning(loadoutType);

            return(weaponInterface);
        }
Exemplo n.º 9
0
    void OnGUI()
    {
        GUILayout.Label ("Select pickup and DB", EditorStyles.boldLabel);
        UID = EditorGUILayout.IntField("UID: ",UID);
        WP = (WeaponPickup)EditorGUILayout.ObjectField("Pickup:",WP, typeof(WeaponPickup), true);
        WA = (WeaponAsset)EditorGUILayout.ObjectField("Asset List:",WA, typeof(WeaponAsset), true);

        if (GUILayout.Button("Add weapon to DB")) {
            UID = WeaponHandler.saveWeapon(WP.thisGun);
        }
    }
Exemplo n.º 10
0
        /// <summary>
        ///  Responsible for creating template shop cells to be populated by weapon asset.
        /// </summary>
        private void CreateCell(WeaponAsset asset, GameObject cellPrefab, GameObject spawnedCell)
        {
            spawnedCell = Instantiate(cellPrefab, shopPanel.transform);

            IShopEquipmentCell cellInserter = spawnedCell.GetComponent <IShopEquipmentCell>();

            cellInserter.InitialiseCell(asset.globalID, asset);
            cellInserter.PassInterfaces(informationPanel, this);
            cellInserter.SetColor(GetWeaponCellColor(asset.defaultData.weaponType));

            shopCells.Add(spawnedCell);
        }
Exemplo n.º 11
0
    void OnGUI()
    {
        GUILayout.Label("Select pickup and DB", EditorStyles.boldLabel);
        UID = EditorGUILayout.IntField("UID: ", UID);
        WP  = (WeaponPickup)EditorGUILayout.ObjectField("Pickup:", WP, typeof(WeaponPickup), true);
        WA  = (WeaponAsset)EditorGUILayout.ObjectField("Asset List:", WA, typeof(WeaponAsset), true);

        if (GUILayout.Button("Add weapon to DB"))
        {
            UID = WeaponHandler.saveWeapon(WP.thisGun);
        }
    }
Exemplo n.º 12
0
        /// <summary>
        /// Is given a loadout configuration which then loads the weapon.
        /// </summary>
        public IWeapon SetWeapon(string weaponID)
        {
            // Grab asset from the scriptable object
            WeaponInfo  info        = SessionData.instance.weaponServicer.GetWeaponItem(weaponID);
            WeaponAsset weaponAsset = GameManager.Instance.weaponSettings.RetrieveFromSettings(info.weaponType, info.globalID);

            if (weaponAsset == null)
            {
                return(null);
            }

            return(InitialiseWeapon(weaponAsset, info));
        }
Exemplo n.º 13
0
        public void InitialiseCell(string itemID, WeaponAsset weaponAsset)
        {
            weaponServicer = SessionData.instance.weaponServicer.GetComponent <IWeaponServicer>();

            this.instanceID = itemID;
            this.type       = weaponAsset.defaultData.weaponType;
            this.price      = weaponAsset.price;

            cellTitle.text      = weaponAsset.name;
            itemPrice.text      = "$" + price;
            availableCount.text = "Inventory: " + weaponServicer.GetAvailableWeaponOccuranceCount(itemID);
            cellImage.sprite    = weaponAsset.weaponPrefab.GetComponent <IImageExtract>().ExtractImage();
        }
Exemplo n.º 14
0
        private void SpawnWeapon()
        {
            int    wpnIndex = weaponsList.Index;
            string wpnName  = weaponsList.IndexToItem(weaponsList.Index);

            WeaponAsset wa = l.WeaponModels[wpnIndex];

            inventory.GiveNewWeapon(wa, (short)Ammo.max, true);

            if (cbSpawnWithAttachments.Checked)
            {
                AddAttachmentsToWeapon(wa);
            }
        }
Exemplo n.º 15
0
    public static int saveWeapon(Weapon weapon)
    {
        WeaponAsset WA = getWeapons()[0];

        if (WA.weapons.Contains(weapon))
        {
            return(weapon.UID = WA.weapons.IndexOf(weapon));
        }
        else
        {
            weapon.UID = WA.weapons.Count;
            WA.weapons.Add(weapon);
            return(WA.weapons.Count - 1);
        }
    }
Exemplo n.º 16
0
        public void OnGUI()
        {
            EditorStyles.textField.wordWrap = true;
            TabBar();
            GUILayout.BeginHorizontal();
            switch (tabState)
            {
            case TabState.WEAPONS:
                Weapons();
                break;

            case TabState.CONSUMABLES:
                Consumables();
                break;

            case TabState.QUEST_ITEMS:
                QuestItems();
                break;

            default:
                About();
                break;
            }

            GUILayout.EndHorizontal();
            StatusBar();
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Create Weapon", EditorStyles.toolbarButton))
            {
                var newAsset = new WeaponAsset(WeaponDatabase.Instance.GetNextId());
                WeaponDatabase.Instance.Add(newAsset);
            }
            if (GUILayout.Button("Create Consumable", EditorStyles.toolbarButton))
            {
                var newAsset = new ConsumableAsset(ConsumableDatabase.Instance.GetNextId());
                ConsumableDatabase.Instance.Add(newAsset);
            }
            if (GUILayout.Button("Create Quest Item", EditorStyles.toolbarButton))
            {
                var newAsset = new QuestAsset(QuestDatabase.Instance.GetNextId());
                QuestDatabase.Instance.Add(newAsset);
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Processes purchases made in the shop.
        /// </summary>
        public void MakePurchase(string globalID, WeaponType type, int purchaseCost)
        {
            UserStatus userStatus = SessionData.instance.userStatus;

            if (userStatus.credits < purchaseCost)
            {
                purchaseErrorPanel.SetActive(true);
                return;
            }

            userStatus.credits -= purchaseCost;
            WeaponAsset asset = GameManager.Instance.weaponSettings.RetrieveFromSettings(type, globalID);

            SessionData.instance.weaponServicer.AddWeaponInstance(asset);
            SessionData.instance.OnUserTransaction.Invoke();

            UpdateShopList();
        }
Exemplo n.º 18
0
        /// <summary>
        /// Suicides this Rage.Ped instance with a weapon
        /// </summary>
        /// <param name="ped"></param>
        /// <param name="weapon">Weapon to use</param>
        public static void SuicideWeapon(this Ped ped, WeaponAsset weapon)
        {
            ped.Inventory.GiveNewWeapon(weapon, 10, true);

            ped.Tasks.PlayAnimation("mp_suicide", "pistol", 8.0f, AnimationFlags.None);

            GameFiber.Wait(700);

            if (ped.IsPlayingAnimation("mp_suicide", "pistol"))
            {
                NativeFunction.CallByName <uint>("SET_PED_SHOOTS_AT_COORD", ped, 0.0f, 0.0f, 0.0f, 0);

                WildernessCallouts.Common.StartParticleFxNonLoopedOnEntity("scr_solomon3", "scr_trev4_747_blood_impact", (Entity)ped, new Vector3(0.0f, 0.0f, 0.6f), new Rotator(90.0f, 0.0f, 0.0f), 0.25f);

                GameFiber.Wait(1000);

                ped.Kill();
            }
        }
Exemplo n.º 19
0
    public void Damage(int damage, Vector3 hitbackDir)
    {
        SetHitback(hitbackDir);
        health -= damage;

        if (weaponManager.updateUI)
        {
            hudController.PlayerHealth = health;
        }

        if (health < 0)
        {
            WeaponAsset equipped = weaponManager.GetEquippedWeapon();
            if (equipped)
            {
                Instantiate(equipped.pickupPrefab, transform.position, equipped.pickupPrefab.rotation);
            }
            Destroy(this.gameObject);
        }
    }
Exemplo n.º 20
0
    public void EquipWeapon(WeaponAsset weapon)
    {
        // Remove old weapon
        foreach (Transform child in m_WeaponEquipParent.transform)
        {
            Destroy(child.gameObject);
        }

        m_Weapon = weapon;

        // Instantiate if this has a weapon model.
        if (m_Weapon.WeaponPrefab)
        {
            Instantiate(m_Weapon.WeaponPrefab, m_WeaponEquipParent, false);
        }

        // Instantiate if this has a weapon hit area (ranged weapons don't)
        if (m_Weapon.HitAreaPrefab)
        {
            m_WeaponHitArea.SetHitArea(Instantiate(m_Weapon.HitAreaPrefab));
        }
    }
Exemplo n.º 21
0
        public void OnKeyUp()
        {
            Ped player = Game.Player.Character;

            if (Game.IsControlJustPressed(GTA.Control.Attack) && Enabled && player.Weapons.Current == config.weapon && !player.IsReloading)
            {
                int ammo = player.Weapons.Current.Ammo;

                WeaponAsset bullet = config.bullet;

                if (ammo > 0)
                {
                    Vector3 target = player.Position + player.ForwardVector * 45;

                    World.ShootBullet(player.Weapons.CurrentWeaponObject.Position, target, player, bullet, 0, config.bulletspeed);

                    Game.Player.Character.Weapons.Current.Ammo = 0;

                    Game.Player.Character.Weapons.Current.Ammo = ammo - 1;
                }
            }
        }
Exemplo n.º 22
0
 private void AddAttachmentsToWeapon(WeaponAsset e)
 {
     if (e.Hash == (uint)(WeaponHash.Pistol))
     {
         NativeFunction.CallByName <uint>("GIVE_WEAPON_COMPONENT_TO_PED", character, 0x1B06D571, 0x359B7AAE); //Pistol Flashlight
         NativeFunction.CallByName <uint>("GIVE_WEAPON_COMPONENT_TO_PED", character, 0x1B06D571, 0xED265A1C); //Pistol Extended Clip
     }
     if (e.Hash == (uint)(WeaponHash.CombatPistol))
     {
         NativeFunction.CallByName <uint>("GIVE_WEAPON_COMPONENT_TO_PED", character, 0x5EF9FEC4, 0x359B7AAE); //Combat Pistol Flashlight
         NativeFunction.CallByName <uint>("GIVE_WEAPON_COMPONENT_TO_PED", character, 0x5EF9FEC4, 0xD67B4F2D); //Combat Pistol Extended Clip
     }
     if (e.Hash == (uint)(WeaponHash.CarbineRifle))
     {
         NativeFunction.CallByName <uint>("GIVE_WEAPON_COMPONENT_TO_PED", character, 0x83BF0278, 0x91109691); //Carbine Rifle Extended Clip
         NativeFunction.CallByName <uint>("GIVE_WEAPON_COMPONENT_TO_PED", character, 0x83BF0278, 0xC164F53);  //Carbine Rifle Grip
         NativeFunction.CallByName <uint>("GIVE_WEAPON_COMPONENT_TO_PED", character, 0x83BF0278, 0x7BC4CDDC); //Carbine Rifle Flashlight
     }
     if (e.Hash == (uint)(WeaponHash.PumpShotgun))
     {
         NativeFunction.CallByName <uint>("GIVE_WEAPON_COMPONENT_TO_PED", character, 0x1D073A89, 0x7BC4CDDC); //Pump Shotgun Flashlight
     }
 }
Exemplo n.º 23
0
        private void DoMagic()
        {
            Player player = Game.LocalPlayer;
            Ped    pc     = player.Character;

            if (CleanPlayer)
            {
                pc.ClearBlood();
            }
            if (FillHealth)
            {
                pc.Health = pc.MaxHealth;
            }
            if (FillArmour)
            {
                pc.Armor = 100;
            }

            if ((!OnlyRepairPoliceVehicles && pc.IsInAnyVehicle(false)) || (OnlyRepairPoliceVehicles && pc.IsInAnyPoliceVehicle))
            {
                if (RepairVehicle)
                {
                    pc.CurrentVehicle.Repair();
                }
                if (CleanVehicle)
                {
                    pc.CurrentVehicle.DirtLevel = 0f;
                }
            }

            // Add weapons

            pc.Inventory.Weapons.Clear();
            if (GiveFlashlight)
            {
                pc.Inventory.GiveFlashlight();
            }

            foreach (string s in WeaponPool.Split(','))
            {
                WeaponAsset wep        = new WeaponAsset();
                string[]    weaponData = s.Split('|');
                for (int x = 0; x < weaponData.Length; x++)
                {
                    string w = weaponData[x];

                    /*
                     * WEAPON_UNARMED WEAPON_ANIMAL WEAPON_COUGAR WEAPON_KNIFE WEAPON_NIGHTSTICK WEAPON_HAMMER WEAPON_BAT WEAPON_GOLFCLUB WEAPON_CROWBAR WEAPON_PISTOL WEAPON_COMBATPISTOL WEAPON_APPISTOL WEAPON_PISTOL50
                     * WEAPON_MICROSMG WEAPON_SMG WEAPON_ASSAULTSMG WEAPON_ASSAULTRIFLE WEAPON_CARBINERIFLE WEAPON_ADVANCEDRIFLE WEAPON_MG WEAPON_COMBATMG WEAPON_PUMPSHOTGUN WEAPON_SAWNOFFSHOTGUN WEAPON_ASSAULTSHOTGUN
                     * WEAPON_BULLPUPSHOTGUN WEAPON_STUNGUN WEAPON_SNIPERRIFLE WEAPON_HEAVYSNIPER WEAPON_REMOTESNIPER WEAPON_GRENADELAUNCHER WEAPON_GRENADELAUNCHER_SMOKE WEAPON_RPG WEAPON_PASSENGER_ROCKET
                     * WEAPON_AIRSTRIKE_ROCKET WEAPON_STINGER WEAPON_MINIGUN WEAPON_GRENADE WEAPON_STICKYBOMB WEAPON_SMOKEGRENADE WEAPON_BZGAS WEAPON_MOLOTOV WEAPON_FIREEXTINGUISHER WEAPON_PETROLCAN WEAPON_DIGISCANNER
                     * WEAPON_BRIEFCASE WEAPON_BRIEFCASE_02 WEAPON_BALL WEAPON_FLARE WEAPON_VEHICLE_ROCKET WEAPON_BARBED_WIRE WEAPON_DROWNING WEAPON_DROWNING_IN_VEHICLE WEAPON_BLEEDING WEAPON_ELECTRIC_FENCE
                     * WEAPON_EXPLOSION WEAPON_FALL WEAPON_EXHAUSTION WEAPON_HIT_BY_WATER_CANNON WEAPON_RAMMED_BY_CAR WEAPON_RUN_OVER_BY_CAR WEAPON_HELI_CRASH WEAPON_FIRE WEAPON_ANIMAL_RETRIEVER WEAPON_SMALL_DOG
                     * WEAPON_TIGER_SHARK WEAPON_HAMMERHEAD_SHARK WEAPON_KILLER_WHALE WEAPON_BOAR WEAPON_PIG WEAPON_COYOTE WEAPON_DEER WEAPON_HEN WEAPON_RABBIT WEAPON_CAT WEAPON_COW WEAPON_BIRD_CRAP
                     */
                    if (x == 0)
                    {
                        Game.Console.Print($"Attempting to add weapon {w} to player");
                        wep = new WeaponAsset(w);
#if DEBUG
                        Game.Console.Print($"{wep.Hash} // {wep.IsValid} // {wep.IsLoaded}");
#endif
                        if (!wep.IsValid)
                        {
                            continue;
                        }
                        if (!wep.IsLoaded)
                        {
                            wep.LoadAndWait();
                        }
                        WeaponDescriptor wd = new WeaponDescriptor(wep);
                        pc.Inventory.GiveNewWeapon(wep, (InfiniteAmmo ? short.MaxValue : /*(short)(wd.MagazineSize * (short)15)*/ AmmoCount), false);
                        continue;
                    }
                    Game.Console.Print($"Attempting to add component {w} to weapon");
                    pc.Inventory.AddComponentToWeapon(wep, w);
                }
            }

            Game.DisplayNotification("AlfredoRedux has completed tasks.");
        }
Exemplo n.º 24
0
    public static Weapon getWeapon(int index)
    {
        WeaponAsset WA = getWeapons()[0];         // This is the hard part...

        return(WA.weapons[(index >= WA.weapons.Count ? 0 : index)]);
    }
Exemplo n.º 25
0
        private void Update()
        {
            moveDirection = target.position - transform.position;

            WeaponAsset currentWeapon = (weaponManager.equippedWeapon ? weaponManager.equippedWeapon : weaponManager.unequippedWeapon);

            if (currentWeapon.weaponType == WeaponAsset.WeaponType.Melee)
            {
                MeleeWeapon weapon = currentWeapon as MeleeWeapon;

                float dist = Vector3.Distance(target.position, transform.position);

                Collider col = weaponManager.meleeHitbox.checkStatus();
                // if hit this frame reset reaction
                if (controller.hit)
                {
                    reactionTimer = 0;
                }

                if (col && col.tag == "Enemy")
                {
                    moveDirection = Vector3.Reflect(moveDirection, animationController.flip ? transform.right : -transform.right);
                }

                if (col && col.tag == "Player")
                {
                    inRange        = true;
                    reactionTimer += Time.deltaTime;
                }
                else
                {
                    inRange       = false;
                    reactionTimer = 0;
                }


                if (!hasHit && inRange && reactionTimer > reactionTime)
                {
                    moveDirection = moveDirection * 0.1f;
                    hasHit        = true;
                    hitButton     = true;
                    tellEffects.gameObject.SetActive(false);
                }

                if (hasHit)
                {
                    hitTimer += Time.deltaTime;
                }

                if (hitTimer > hitTimeout)
                {
                    hitTimer = 0;
                    hasHit   = false;
                }

                if (hitTimer > hitTimeout / 2)
                {
                    tellEffects.gameObject.SetActive(true);
                }
            }
        }
Exemplo n.º 26
0
 /// <summary>
 /// Adds weapon instance into hangar
 /// </summary>
 public void AddWeaponInstance(WeaponAsset asset)
 {
     hangarWeapons.Add(asset.ConvertToWeaponInfo());
 }
Exemplo n.º 27
0
        public void Weapons()
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);

            for (int i = 0; i < WeaponDatabase.GetAssetCount(); i++)
            {
                WeaponAsset asset = WeaponDatabase.GetAt(i);
                if (asset != null)
                {
                    GUILayout.BeginHorizontal(EditorStyles.toolbar);
                    GUILayout.Label(string.Format("ID: {0}", asset.ID.ToString("D3")), GUILayout.Width(60));

                    bool clicked = GUILayout.Toggle(asset.ID == activeID, asset.Name, ToggleButtonStyle);

                    if (clicked != (asset.ID == activeID))
                    {
                        if (clicked)
                        {
                            activeID = asset.ID;
                            GUI.FocusControl(null);
                        }
                        else
                        {
                            activeID = -1;
                        }
                    }

                    if (GUILayout.Button("x", EditorStyles.toolbarButton, GUILayout.Width(30)) && EditorUtility.DisplayDialog("Delete Stat Type", "Are you sure you want to delete " + asset.Name + " Weapon?", "Delete", "Cancel"))
                    {
                        WeaponDatabase.Instance.RemoveAt(i);
                    }

                    GUILayout.EndHorizontal();

                    if (activeID == asset.ID)
                    {
                        EditorGUI.BeginChangeCheck();

                        GUILayout.BeginVertical("Box");

                        GUILayout.BeginHorizontal();
                        //ITEM SPRITE
                        GUILayout.BeginVertical(GUILayout.Width(75)); //begin vertical
                        asset.Icon = (Sprite)EditorGUILayout.ObjectField(asset.Icon, typeof(Sprite), false, GUILayout.Width(72), GUILayout.Height(72));
                        GUILayout.Label("Item Sprite", GUILayout.Width(72));
                        GUILayout.EndVertical();   //end vertical

                        //ITEM CLASS
                        GUILayout.BeginVertical(); //begin vertical
                        GUILayout.Label("Item Class: " + asset.IType.ToString(), EditorStyles.boldLabel);

                        //NAME
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Name", GUILayout.Width(80));
                        asset.Name = EditorGUILayout.TextField(asset.Name);
                        GUILayout.EndHorizontal();

                        //DESCRIPTION
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Description", GUILayout.Width(80));
                        asset.Description = EditorGUILayout.TextArea(asset.Description, GUILayout.MinHeight(30));
                        GUILayout.EndHorizontal();

                        //COST
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Cost", GUILayout.Width(80));
                        asset.Cost = EditorGUILayout.IntField(asset.Cost);
                        GUILayout.EndHorizontal();

                        //STACKABLE
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Stackable", GUILayout.Width(80));
                        GUILayout.BeginVertical();
                        asset.Stackable = EditorGUILayout.BeginToggleGroup("Enabled", asset.Stackable);
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Stack Size", GUILayout.Width(80));
                        asset.StackSize = EditorGUILayout.IntSlider(asset.StackSize, 2, 64);
                        GUILayout.EndHorizontal();
                        GUILayout.EndVertical();
                        GUILayout.EndHorizontal();
                        EditorGUILayout.EndToggleGroup();

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Level", GUILayout.Width(80));
                        asset.Level = EditorGUILayout.IntSlider(asset.Level, 1, 99);
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Weight", GUILayout.Width(80));
                        asset.Weight = EditorGUILayout.IntSlider(asset.Weight, 0, 99);
                        GUILayout.EndHorizontal();

                        GUILayout.Label("Weapon Variables", EditorStyles.boldLabel);

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Weap Type", GUILayout.Width(80));
                        asset.WType = (WeaponType)EditorGUILayout.EnumPopup(asset.WType);
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Durability", GUILayout.Width(80));
                        asset.Durability = EditorGUILayout.IntField(asset.Durability);
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Attack Range", GUILayout.Width(80));
                        asset.AttackRange = EditorGUILayout.IntSlider(asset.AttackRange, 1, 20);
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Weap Dmg", GUILayout.Width(80));
                        asset.WeaponDamage = EditorGUILayout.IntSlider(asset.WeaponDamage, 0, 99);
                        GUILayout.EndHorizontal();

                        GUILayout.EndVertical();

                        GUILayout.EndHorizontal();

                        GUILayout.EndVertical();
                        if (EditorGUI.EndChangeCheck())
                        {
                            EditorUtility.SetDirty(WeaponDatabase.Instance);
                        }
                    }
                }
            }
            GUILayout.EndScrollView();
        }
Exemplo n.º 28
0
        public IEnumerator Init(MVersion versions)
        {
            CScene             scene = SceneManager.CurrentScene;
            SUser              sUser = Global.SUser;
            List <IEnumerator> list  = new List <IEnumerator>();

            list.Add(sUser.Download(PromptMessageAsset.Url, versions.prompt_message, (AssetBundle assetbundle) => {
                Debug.Log("CLogo assetbundle=" + assetbundle);
                PromptMessageAsset.assetbundle = assetbundle;
            }));
            list.Add(sUser.Download(LanguageAsset.WORD_URL, versions.word, (AssetBundle assetbundle) => {
                LanguageAsset.assetbundle = assetbundle;
                Language.Reset(LanguageAsset.Data.words);
                LanguageAsset.Clear();
            }));
            list.Add(sUser.Download(ImageAssetBundleManager.horseUrl, versions.horse_img, (AssetBundle assetbundle) => {
                AvatarSpriteAsset.assetbundle = assetbundle;
                ImageAssetBundleManager.horse = AvatarSpriteAsset.Data.meshs;
            }));
            list.Add(sUser.Download(ImageAssetBundleManager.headUrl, versions.head_img, (AssetBundle assetbundle) => {
                AvatarSpriteAsset.assetbundle = assetbundle;
                ImageAssetBundleManager.head  = AvatarSpriteAsset.Data.meshs;
            }));
            list.Add(sUser.Download(ImageAssetBundleManager.clothesUrl, versions.clothes_img, (AssetBundle assetbundle) => {
                AvatarSpriteAsset.assetbundle   = assetbundle;
                ImageAssetBundleManager.clothes = AvatarSpriteAsset.Data.meshs;
            }));
            list.Add(sUser.Download(ImageAssetBundleManager.weaponUrl, versions.weapon_img, (AssetBundle assetbundle) => {
                AvatarSpriteAsset.assetbundle  = assetbundle;
                ImageAssetBundleManager.weapon = AvatarSpriteAsset.Data.meshs;
            }));
            list.Add(sUser.Download(WorldAsset.Url, versions.world, (AssetBundle assetbundle) => {
                WorldAsset.assetbundle = assetbundle;
                Global.worlds          = WorldAsset.Data.worlds;
            }));
            list.Add(sUser.Download(ConstantAsset.Url, versions.constant, (AssetBundle assetbundle) => {
                ConstantAsset.assetbundle = assetbundle;
                Global.Constant           = ConstantAsset.Data.constant;
            }));
            list.Add(sUser.Download(NpcAsset.Url, versions.npc, (AssetBundle assetbundle) => {
                NpcAsset.assetbundle = assetbundle;
                NpcCacher.Instance.Reset(NpcAsset.Data.npcs);
                NpcAsset.Clear();
            }));
            list.Add(sUser.Download(NpcEquipmentAsset.Url, versions.npc_equipment, (AssetBundle assetbundle) => {
                NpcEquipmentAsset.assetbundle = assetbundle;
                NpcEquipmentCacher.Instance.Reset(NpcEquipmentAsset.Data.npc_equipments);
                NpcEquipmentAsset.Clear();
            }));
            list.Add(sUser.Download(CharacterStarAsset.Url, versions.characterstar, (AssetBundle assetbundle) => {
                CharacterStarAsset.assetbundle = assetbundle;
                CharacterStarCacher.Instance.Reset(CharacterStarAsset.Data.characterStars);
                CharacterStarAsset.Clear();
            }));

            /*list.Add(sUser.Download(AreaAsset.Url, versions.area, (AssetBundle assetbundle)=>{
             *  AreaAsset.assetbundle = assetbundle;
             *  AreaCacher.Instance.Reset(AreaAsset.Data.areas);
             *  AreaAsset.Clear();
             * }));*/
            list.Add(sUser.Download(ItemAsset.Url, versions.item, (AssetBundle assetbundle) => {
                ItemAsset.assetbundle = assetbundle;
                ItemCacher.Instance.Reset(ItemAsset.Data.items);
                ItemAsset.Clear();
            }));

            /*list.Add(sUser.Download(MissionAsset.Url, versions.mission, (AssetBundle assetbundle)=>{
             *  MissionAsset.assetbundle = assetbundle;
             *  MissionCacher.Instance.Reset(MissionAsset.Data.missions);
             *  MissionAsset.Clear();
             * }));*/
            list.Add(sUser.Download(SkillAsset.Url, versions.skill, (AssetBundle assetbundle) => {
                SkillAsset.assetbundle = assetbundle;
                SkillCacher.Instance.Reset(SkillAsset.Data.skills);
                SkillAsset.Clear();
            }));
            list.Add(sUser.Download(StrategyAsset.Url, versions.strategy, (AssetBundle assetbundle) => {
                StrategyAsset.assetbundle = assetbundle;
                StrategyCacher.Instance.Reset(StrategyAsset.Data.strategys);
                StrategyAsset.Clear();
            }));
            list.Add(sUser.Download(ExpAsset.Url, versions.exp, (AssetBundle assetbundle) => {
                ExpAsset.assetbundle = assetbundle;
                ExpCacher.Instance.Reset(ExpAsset.Data.exps);
                ExpAsset.Clear();
            }));
            list.Add(sUser.Download(BattlefieldAsset.Url, versions.battlefield, (AssetBundle assetbundle) => {
                BattlefieldAsset.assetbundle = assetbundle;
                BattlefieldCacher.Instance.Reset(BattlefieldAsset.Data.battlefields);
                BattlefieldAsset.Clear();
            }));
            list.Add(sUser.Download(BuildingAsset.Url, versions.building, (AssetBundle assetbundle) => {
                BuildingAsset.assetbundle = assetbundle;
                BuildingCacher.Instance.Reset(BuildingAsset.Data.buildings);
                BuildingAsset.Clear();
            }));
            list.Add(sUser.Download(BaseMapAsset.Url, versions.top_map, (AssetBundle assetbundle) => {
                BaseMapAsset.assetbundle = assetbundle;
                BaseMapCacher.Instance.Reset(BaseMapAsset.Data.baseMaps);
                BaseMapAsset.Clear();
            }));
            list.Add(sUser.Download(CharacterAsset.Url, versions.character, (AssetBundle assetbundle) => {
                CharacterAsset.assetbundle = assetbundle;
                CharacterCacher.Instance.Reset(CharacterAsset.Data.characters);
                CharacterAsset.Clear();
            }));
            list.Add(sUser.Download(TileAsset.Url, versions.tile, (AssetBundle assetbundle) => {
                TileAsset.assetbundle = assetbundle;
                TileCacher.Instance.Reset(TileAsset.Data.tiles);
                TileAsset.Clear();
            }));
            list.Add(sUser.Download(LoginBonusAsset.Url, versions.loginbonus, (AssetBundle assetbundle) => {
                LoginBonusAsset.assetbundle = assetbundle;
                LoginBonusCacher.Instance.Reset(LoginBonusAsset.Data.loginbonuses);
                LoginBonusAsset.Clear();
            }));
            list.Add(sUser.Download(ImageAssetBundleManager.mapUrl, versions.map, (AssetBundle assetbundle) => {
                ImageAssetBundleManager.map = assetbundle;
            }, false));
            list.Add(sUser.Download(ImageAssetBundleManager.equipmentIconUrl, versions.equipmenticon_icon, (AssetBundle assetbundle) => {
                ImageAssetBundleManager.equipmentIcon = assetbundle;
            }, false));
            list.Add(sUser.Download(ImageAssetBundleManager.itemIconUrl, versions.item_icon, (AssetBundle assetbundle) => {
                ImageAssetBundleManager.itemIcon = assetbundle;
            }, false));
            list.Add(sUser.Download(ImageAssetBundleManager.skillIconUrl, versions.skill_icon, (AssetBundle assetbundle) => {
                ImageAssetBundleManager.skillIcon = assetbundle;
            }, false));
            list.Add(sUser.Download(HorseAsset.Url, versions.horse, (AssetBundle assetbundle) => {
                HorseAsset.assetbundle = assetbundle;
                EquipmentCacher.Instance.ResetHorse(HorseAsset.Data.equipments);
                HorseAsset.Clear();
            }));
            list.Add(sUser.Download(WeaponAsset.Url, versions.weapon, (AssetBundle assetbundle) => {
                WeaponAsset.assetbundle = assetbundle;
                EquipmentCacher.Instance.ResetWeapon(WeaponAsset.Data.equipments);
                WeaponAsset.Clear();
            }));
            list.Add(sUser.Download(ClothesAsset.Url, versions.clothes, (AssetBundle assetbundle) => {
                ClothesAsset.assetbundle = assetbundle;
                EquipmentCacher.Instance.ResetClothes(ClothesAsset.Data.equipments);
                ClothesAsset.Clear();
            }));
            list.Add(sUser.Download(StoryProgressAsset.Url, versions.character, (AssetBundle assetbundle) => {
                StoryProgressAsset.assetbundle = assetbundle;
                foreach (string key in StoryProgressAsset.Data.keys)
                {
                    App.Util.LSharp.LSharpVarlable.SetVarlable(key, "0");
                }
                StoryProgressAsset.Clear();
            }));
            if (App.Util.Global.SUser.self != null)
            {
                list.Add(sUser.RequestGet());
            }
            float step = 100f / list.Count;

            for (int i = 0; i < list.Count; i++)
            {
                CLoadingDialog.SetNextProgress((i + 1) * step);
                yield return(scene.StartCoroutine(list[i]));
            }
            yield return(0);
        }
Exemplo n.º 29
0
        public static IEnumerator LoadAssetbundle(MVersion versions)
        {
            SUser sUser             = Global.SUser;
            List <IEnumerator> list = new List <IEnumerator>();

            list.Add(sUser.Download(ImageAssetBundleManager.horseUrl, versions.horse_img, (AssetBundle assetbundle) => {
                AvatarSpriteAsset.assetbundle = assetbundle;
                ImageAssetBundleManager.horse = AvatarSpriteAsset.Data.meshs;
            }));
            list.Add(sUser.Download(ImageAssetBundleManager.headUrl, versions.head_img, (AssetBundle assetbundle) => {
                AvatarSpriteAsset.assetbundle = assetbundle;
                ImageAssetBundleManager.head  = AvatarSpriteAsset.Data.meshs;
            }));
            list.Add(sUser.Download(ImageAssetBundleManager.clothesUrl, versions.clothes_img, (AssetBundle assetbundle) => {
                AvatarSpriteAsset.assetbundle   = assetbundle;
                ImageAssetBundleManager.clothes = AvatarSpriteAsset.Data.meshs;
            }));
            list.Add(sUser.Download(ImageAssetBundleManager.weaponUrl, versions.weapon_img, (AssetBundle assetbundle) => {
                AvatarSpriteAsset.assetbundle  = assetbundle;
                ImageAssetBundleManager.weapon = AvatarSpriteAsset.Data.meshs;
            }));
            list.Add(sUser.Download(ImageAssetBundleManager.equipmentIconUrl, versions.equipmenticon_icon, (AssetBundle assetbundle) => {
                ImageAssetBundleManager.equipmentIcon = assetbundle;
            }, false));
            list.Add(sUser.Download(CharacterAsset.Url, versions.character, (AssetBundle assetbundle) => {
                CharacterAsset.assetbundle = assetbundle;
                CharacterCacher.Instance.Reset(CharacterAsset.Data.characters);
                CharacterAsset.Clear();
            }));
            list.Add(sUser.Download(BattlefieldAsset.Url, versions.battlefield, (AssetBundle assetbundle) => {
                BattlefieldAsset.assetbundle = assetbundle;
                BattlefieldCacher.Instance.Reset(BattlefieldAsset.Data.battlefields);
                BattlefieldAsset.Clear();
            }));
            list.Add(sUser.Download(SkillAsset.Url, versions.skill, (AssetBundle assetbundle) => {
                SkillAsset.assetbundle = assetbundle;
                SkillCacher.Instance.Reset(SkillAsset.Data.skills);
                SkillAsset.Clear();
            }));
            list.Add(sUser.Download(NpcAsset.Url, versions.npc, (AssetBundle assetbundle) => {
                NpcAsset.assetbundle = assetbundle;
                NpcCacher.Instance.Reset(NpcAsset.Data.npcs);
                NpcAsset.Clear();
            }));
            list.Add(sUser.Download(TileAsset.Url, versions.tile, (AssetBundle assetbundle) => {
                TileAsset.assetbundle = assetbundle;
                TileCacher.Instance.Reset(TileAsset.Data.tiles);
                TileAsset.Clear();
            }));
            list.Add(sUser.Download(HorseAsset.Url, versions.horse, (AssetBundle assetbundle) => {
                HorseAsset.assetbundle = assetbundle;
                EquipmentCacher.Instance.ResetHorse(HorseAsset.Data.equipments);
                HorseAsset.Clear();
            }));
            list.Add(sUser.Download(WeaponAsset.Url, versions.weapon, (AssetBundle assetbundle) => {
                WeaponAsset.assetbundle = assetbundle;
                EquipmentCacher.Instance.ResetWeapon(WeaponAsset.Data.equipments);
                WeaponAsset.Clear();
            }));
            list.Add(sUser.Download(ClothesAsset.Url, versions.clothes, (AssetBundle assetbundle) => {
                ClothesAsset.assetbundle = assetbundle;
                EquipmentCacher.Instance.ResetClothes(ClothesAsset.Data.equipments);
                ClothesAsset.Clear();
            }));
            list.Add(sUser.Download(ConstantAsset.Url, versions.constant, (AssetBundle assetbundle) => {
                ConstantAsset.assetbundle = assetbundle;
                Global.Constant           = ConstantAsset.Data.constant;
            }));
            float step = 100f / list.Count;

            for (int i = 0; i < list.Count; i++)
            {
                //CLoadingDialog.SetNextProgress((i + 1) * step);
                yield return(AppManager.CurrentScene.StartCoroutine(list[i]));
            }
            yield return(0);
        }
Exemplo n.º 30
0
        private void DeliverWeapons()
        {
            int carModelSelection = new Random().Next(c.CarModelsList().Count);

            Game.LogTrivial("index=" + carModelSelection);
            Game.LogTrivial("size=" + c.CarModelsList().Count);
            Model policeCarModel    = c.CarModelsList()[carModelSelection];
            int   pedModelSelection = new Random().Next(c.CharacterModelsList().Count);

            Game.LogTrivial("index=" + pedModelSelection);
            Game.LogTrivial("size=" + c.CharacterModelsList().Count);
            Model   pedModel   = c.CharacterModelsList()[pedModelSelection];
            Vector3 spawnPoint = World.GetNextPositionOnStreet(character.Position.Around(250f, 750f));
            Vector3 playerAroundPos;
            Vector3 playerFrontPos;

            //Start of main code
            IsWeaponDeliveryInProcess = true;
            if (character.IsInAnyVehicle(false))
            {
                if (player.LastVehicle.Speed != 0f)
                {
                    Game.DisplayNotification("Bring your vehicle to a complete stop to start the process...");
                }
                while (true)
                {
                    GameFiber.Yield();

                    if (player.LastVehicle.Speed == 0f)
                    {
                        character.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion();
                        character.Tasks.FollowNavigationMeshToPosition(player.LastVehicle.GetOffsetPositionRight(-5f), 0f, 2f).WaitForCompletion();
                        break;
                    }
                }
            }

            GameFiber weaponThread = new GameFiber(new ThreadStart(WeaponMenuThread), "LSPDE Thread");

            weaponThread.Start();

            character.IsPositionFrozen = true;
            playerAroundPos            = World.GetNextPositionOnStreet(character.Position.Around(10f, 15f));
            playerFrontPos             = character.GetOffsetPositionFront(2f);
            policeVehicle = new Vehicle(policeCarModel, spawnPoint);
            officer       = new Ped(pedModel, policeVehicle.GetOffsetPositionFront(5f), 0f);
            officer.WarpIntoVehicle(policeVehicle, -1);
            officerBlip = officer.AttachBlip();

            officerBlip.IsFriendly     = true;
            officerBlip.IsRouteEnabled = true;

            officer.IsPersistent         = true;
            officer.BlockPermanentEvents = true;
            policeVehicle.IsPersistent   = true;

            policeVehicle.IsSirenOn = true;
            officer.Tasks.DriveToPosition(playerAroundPos, 20f, VehicleDrivingFlags.Emergency).WaitForCompletion();

            if (IsNothingQueued())
            {
                CancelDelivery(CancelType.WeaponDelivery);
                Game.DisplayNotification("Weapon Delivery Canceled because no weapons were queued");
            }

            if (officer.Exists() && policeVehicle.Exists())
            {
                do
                {
                    officer.Tasks.LeaveVehicle(policeVehicle, LeaveVehicleFlags.None);

                    #region weaponDeliveryWeapon
                    officer.Tasks.FollowNavigationMeshToPosition(playerFrontPos, character.Heading + 180f, 2f).WaitForCompletion();

                    for (int i = 0; i < weaponQueue.Count; i++)
                    {
                        WeaponAsset wp = weaponQueue[i];
                        officer.Inventory.GiveNewWeapon(wp, (short)Ammo.min, true);
                        GameFiber.Sleep(1000);
                        NativeFunction.CallByName <uint>("REMOVE_ALL_PED_WEAPONS", officer, true);
                        inventory.GiveNewWeapon(wp, (short)Ammo.max, true);
                        int index = l.WeaponModels.IndexOf(wp.Hash);
                        Game.DisplaySubtitle(string.Format("~y~Officer~w~: Here is your {0} sir", l.WeaponNames[index]));
                        if (cbSpawnWithAttachments.Checked)
                        {
                            AddAttachmentsToWeapon(wp);
                        }
                        GameFiber.Sleep(1000);
                    }

                    break;
                    #endregion
                } while (officer.Exists());
            }
            IsWeaponDeliveryInProcess  = false;
            character.IsPositionFrozen = false;
            WeaponMenuThreadEnabled    = false;

            RemoveAllWeaponsFromQueue();

            if (policeVehicle.Exists() && officer.Exists())
            {
                officer.Tasks.EnterVehicle(policeVehicle, -1).WaitForCompletion();
                officer.Tasks.DriveToPosition(World.GetNextPositionOnStreet(character.Position.Around(250f, 750f)), 20f, VehicleDrivingFlags.FollowTraffic);
                policeVehicle.IsSirenOn      = false;
                officer.IsPersistent         = false;
                officer.BlockPermanentEvents = false;
                policeVehicle.IsPersistent   = false;
            }

            if (officerBlip.Exists())
            {
                officerBlip.Delete();
            }
        }