示例#1
0
        /// <summary>
        /// Processes the information of the squad member.
        /// </summary>
        public override void Process()
        {
            // Update the player ped if required
            if (updatePlayerPed && Game.Player.Character != Ped)
            {
                Ped = Game.Player.Character;
            }

            // Everyone knows that I'm against calculations every tick, but this is for the player health
            // It is important to keep the player health up to date

            // Get the health percentage
            float percentage = (Ped.HealthFloat - 100) / (Ped.MaxHealthFloat - 100);

            // Make sure that is not under 0, over 1 or NaN
            if (percentage < 0)
            {
                percentage = 0;
            }
            else if (percentage > 1)
            {
                percentage = 1;
            }
            else if (float.IsNaN(percentage))
            {
                percentage = 0;
            }
            // Set the correct color based on the current health percentage
            if (percentage < 0.25f)
            {
                health.Color = colorHealthLow;
            }
            else if (percentage < 0.5f)
            {
                health.Color = colorHealthDanger;
            }
            else
            {
                health.Color = colorHealthNormal;
            }
            // Set the correct texture
            Icon.Texture = percentage == 0 ? "icon_dead" : "icon_alive";
            // And set the size of the health bar
            health.Size = new SizeF(((showBigHealth ? big : small) - healthOffset) * percentage, 4);

            // Then, just draw everything else
            base.Process();
            Icon?.Draw();
            infoBackground.Draw();
            name.Draw();
            foreach (ScaledRectangle separator in separators)
            {
                separator.Draw();
            }
            health.Draw();
        }
示例#2
0
 internal static void Fiber()
 {
     GameFiber.Yield();
     if (NativeFunction.Natives.THEFEED_IS_PAUSED <bool>() && Game.IsControlJustPressed(0, GameControl.CharacterWheel))
     {
         Hud.HideComponentThisFrame(HudComponent.Cash);
         Hud.HideComponentThisFrame(HudComponent.CashChange);
         UpdateMoneyRender();
         moneyText.Draw();
     }
 }
示例#3
0
文件: Weapon.cs 项目: justalemon/GGOV
        /// <summary>
        /// Draws the current weapon being used by the player.
        /// </summary>
        public override void Process()
        {
            // If the last hash is not the same as the current one, update the position of the weapon and texture
            WeaponHash currentHash = Hash;
            WeaponType currentType = Tools.GetWeaponType(currentHash);

            if (lastHash != currentHash)
            {
                weapon.Texture = ((int)currentHash).ToString();

                switch (Tools.GetWeaponType(currentHash))
                {
                case WeaponType.Primary:
                case WeaponType.Secondary:
                    ShiftImage(false);
                    break;

                case WeaponType.Melee:
                    ShiftImage(true);
                    break;
                }

                lastHash = currentHash;
                lastType = currentType;
            }

            // Update the current ammo count
            ammo.Text = AmmoCount.ToString();
            // And set the correct font size
            if (AmmoCount < 1000)
            {
                ammo.Scale = 0.55f;
            }
            else
            {
                ammo.Scale = 0.4f;
            }
            // And draw all of the elements
            base.Process();
            infoBackground.Draw();
            if (lastType == WeaponType.Primary || lastType == WeaponType.Secondary || lastType == WeaponType.Melee)
            {
                if (lastType == WeaponType.Melee || lastHash == WeaponHash.StunGun)
                {
                    noneAmmo.Draw();
                }
                else
                {
                    ammo.Draw();
                }

                weaponBackground.Draw();
                Icon?.Draw();
                weapon.Draw();
            }
            else
            {
                noneIcon.Draw();
                noneAmmo.Draw();
            }
        }
示例#4
0
        /// <summary>
        /// Processes the inventory.
        /// </summary>
        public void Process()
        {
            // If the inventory is disabled, return
            if (!GGO.menu.Inventory.Checked)
            {
                return;
            }

            // If the last ped is not the same as the current one, update the player gender
            if (lastPlayerPed != Game.Player.Character)
            {
                switch (Game.Player.Character.Gender)
                {
                case Gender.Male:
                    playerGender.Texture = "gender_m";
                    break;

                case Gender.Female:
                    playerGender.Texture = "gender_f";
                    break;

                default:
                    playerGender.Texture = "gender_u";
                    break;
                }
                lastPlayerPed = Game.Player.Character;
            }

            // If is not visible, return
            if (!Visible)
            {
                return;
            }

            // Show the cursor during this frame
            Function.Call(Hash._SET_MOUSE_CURSOR_ACTIVE_THIS_FRAME);

            // Disable the firing controls
            Game.DisableControlThisFrame(Control.Attack);
            Game.DisableControlThisFrame(Control.Aim);
            Game.DisableControlThisFrame(Control.Attack2);
            Game.DisableControlThisFrame(Control.NextWeapon);
            Game.DisableControlThisFrame(Control.PrevWeapon);
            Game.DisableControlThisFrame(Control.VehicleSelectNextWeapon);
            Game.DisableControlThisFrame(Control.VehicleSelectPrevWeapon);
            Game.DisableControlThisFrame(Control.VehicleFlySelectNextWeapon);
            Game.DisableControlThisFrame(Control.WeaponWheelNext);
            Game.DisableControlThisFrame(Control.WeaponWheelPrev);
            Game.DisableControlThisFrame(Control.SelectNextWeapon);
            Game.DisableControlThisFrame(Control.SelectPrevWeapon);
            Game.DisableControlThisFrame(Control.SelectWeapon);
            // And the HUD Reticle
            Hud.HideComponentThisFrame(HudComponent.Reticle);

            // Update the value of the health bar
            float percentage = (Game.Player.Character.HealthFloat - 100) / (Game.Player.Character.MaxHealthFloat - 100);

            if (percentage < 0)
            {
                percentage = 0;
            }
            else if (percentage > 1)
            {
                percentage = 1;
            }
            else if (float.IsNaN(percentage))
            {
                percentage = 0;
            }
            healthBar.Size = new SizeF(healthWidth * percentage, healthHeight);

            // Make sure that the weapon images are up to date
            bool weaponUpdateRequired = false;

            foreach (WeaponHash weaponHash in weaponsEquippable)
            {
                // Check if the player has the weapon
                bool has = Function.Call <bool>(Hash.HAS_PED_GOT_WEAPON, Game.Player.Character, weaponHash, false);

                // If the player does not has the weapon and is on the list, or he does but it is, remove it
                if ((!has && weaponImages.ContainsKey(weaponHash)) || (has && !weaponImages.ContainsKey(weaponHash)))
                {
                    weaponUpdateRequired = true;
                    break;
                }
            }
            // If they are not, update them
            if (weaponUpdateRequired)
            {
                UpdateWeapons();
            }

            // Draw the UI Elements
            background.Draw();
            top.Draw();
            playerBackground.Draw();
            playerName.Draw();
            playerGender.Draw();
            statusText.Draw();
            statusCurrent.Draw();
            settingsIcon.Draw();
            healthText.Draw();
            healthCornerTop.Draw();
            healthCornerBottom.Draw();
            healthCornerLeft.Draw();
            healthCornerRight.Draw();
            healthBar.Draw();

            // Make sure that all of the required items are present
            bool itemUpdateRequired = false;

            foreach (ItemPair pair in itemsVisible)
            {
                if (pair.Item is StackableItem stackable && stackable.Count == 0)
                {
                    itemUpdateRequired = true;
                    break;
                }
            }
            foreach (KeyValuePair <WeaponHash, AmmoCount> throwable in itemsThrowable)
            {
                if (throwable.Value.Count > 0 && !itemsActive.Where(x => x.Item == throwable.Value).Any()) // TODO: Look for a better solution
                {
                    itemUpdateRequired = true;
                    break;
                }
            }
            foreach (KeyValuePair <WeaponHash, AmmoCount> ammo in itemsAmmo)
            {
                if (ammo.Value.Count > 0 && !itemsActive.Where(x => x.Item == ammo.Value).Any()) // TODO: Look for a better solution
                {
                    itemUpdateRequired = true;
                    break;
                }
            }
            if (itemUpdateRequired)
            {
                UpdateItems();
            }

            itemsText.Draw();
            foreach (CornerSet corners in itemsCorners)
            {
                corners.Top.Draw();
                corners.Bottom.Draw();
                corners.Left.Draw();
                corners.Right.Draw();
                corners.Extra.Draw();
            }
            foreach (ItemPair pair in itemsVisible)
            {
                pair.Draw();
            }

            // Corners of the weapon spaces
            weaponText.Draw();
            foreach (CornerSet corners in weaponCorners)
            {
                corners.Top.Draw();
                corners.Bottom.Draw();
                corners.Left.Draw();
                corners.Right.Draw();
            }
            // And the weapon images themselves
            foreach (KeyValuePair <WeaponHash, ScaledTexture> weapon in weaponVisible)
            {
                weapon.Value.Draw();
            }

            // Iterate over the visible weapons
            foreach (KeyValuePair <WeaponHash, ScaledTexture> weapon in weaponVisible)
            {
                // If the user clicked in the weapon
                if (Game.IsControlJustPressed(Control.CursorAccept) && Screen.IsCursorInArea(weapon.Value.Position, weapon.Value.Size))
                {
                    // If the Equip Weapons feature is enabled
                    if (GGO.menu.EquipWeapons.Checked)
                    {
                        // Get the type of it
                        WeaponType type = Tools.GetWeaponType(weapon.Key);

                        // If the weapon is primary or secondary, set it
                        WeaponHash previous;
                        if (type == WeaponType.Primary)
                        {
                            previous          = GGO.weaponPrimary;
                            GGO.weaponPrimary = weapon.Key;
                        }
                        else if (type == WeaponType.Secondary || type == WeaponType.Melee)
                        {
                            previous            = GGO.weaponSecondary;
                            GGO.weaponSecondary = weapon.Key;
                        }
                        // If the weapon is not primary or secondary, warn the player
                        else
                        {
                            Notification.Show("~r~Error~s~: The weapon is not Primary nor Secondary. Please check your GGO Settings and try again.");
                            return;
                        }

                        // If the player has the previous weapon equiped or is unarmed, set the weapon as active
                        if (Game.Player.Character.Weapons.Current.Hash == previous || previous == WeaponHash.Unarmed || previous == 0)
                        {
                            Function.Call(Hash.SET_CURRENT_PED_WEAPON, Game.Player.Character, weapon.Key, true);
                        }
                    }
                    // If is not
                    else
                    {
                        // Just set the weapon as active
                        Function.Call(Hash.SET_CURRENT_PED_WEAPON, Game.Player.Character, weapon.Key, true);
                    }
                    // Update the weapons shown on the inventory and on the screen and break the iterator
                    UpdateWeapons();
                    break;
                }
            }

            // Iterate over the list of items and trigger those hovered
            for (int i = 0; i < itemsVisible.Count; i++)
            {
                PointF start = itemsCorners[i].Top.Position;
                if (Game.IsControlJustPressed(Control.CursorAccept) && Screen.IsCursorInArea(start.X, start.Y, itemWidth, genericHeight))
                {
                    itemsVisible[i].Item.Use();
                    break;
                }
            }

            // If the player moved the mouse wheel up or down when the weapons are selected, move
            bool upPressed        = Game.IsControlJustPressed(Control.PhoneScrollBackward);
            bool downPressed      = Game.IsControlJustPressed(Control.PhoneScrollForward);
            bool isMouseOnItems   = Screen.IsCursorInArea(itemsCorners[0].Top.Position, itemsAreaSize);
            bool isMouseOnWeapons = Screen.IsCursorInArea(weaponCorners[0].Top.Position, weaponAreaSize);

            if (downPressed && isMouseOnItems)
            {
                itemsIndex += 3;
                UpdateVisibleItems();
            }
            else if (upPressed && isMouseOnItems)
            {
                itemsIndex -= 3;
                UpdateVisibleItems();
            }
            if (downPressed && isMouseOnWeapons)
            {
                weaponIndex++;
                UpdateVisibleWeapons();
            }
            else if (upPressed && isMouseOnWeapons)
            {
                weaponIndex--;
                UpdateVisibleWeapons();
            }

            // If the settings button was pressed, open the settings menu
            if (Game.IsControlJustPressed(Control.CursorAccept) && Screen.IsCursorInArea(settingsIcon.Position, settingsIcon.Size))
            {
                GGO.menu.Open();
            }
        }