Ejemplo n.º 1
0
        private bool StaminaBarPlayerDraw()
        {
            Player player = Main.LocalPlayer;

            if (player.dead)
            {
                return(false);
            }

            StaminaPlayer myplayer = player.GetModPlayer <StaminaPlayer>();

            SpriteBatch sb = Main.spriteBatch;

            if (sb == null)
            {
                return(false);
            }

            try {
                if (myplayer.Logic == null)
                {
                    LogHelpers.WarnOnce("Player logic failed to load.");
                    return(false);
                }

                float alpha        = myplayer.Logic.DrainingFX ? 1f : 0.65f;
                int   stamina      = (int)myplayer.Logic.Stamina;
                int   maxStamina   = myplayer.Logic.MaxStamina2;
                float fatigue      = myplayer.Logic.Fatigue;
                bool  isExercising = myplayer.Logic.IsExercising;
                int   threshold    = fatigue > 0 ? myplayer.Logic.GetStaminaLossAmountNeededForExercise() : -1;

                if (this.Config.ShowMiniStaminaBar)
                {
                    int plrX = (int)(player.position.X - Main.screenPosition.X) + (player.width / 2);
                    int plrY = (int)(player.position.Y - Main.screenPosition.Y) + player.height;
                    plrX += this.Config.PlayerStaminaBarOffsetX;
                    plrY += this.Config.PlayerStaminaBarOffsetY;

                    StaminaUI.DrawShortStaminaBar(sb, plrX, plrY, stamina, maxStamina, (int)fatigue, threshold, isExercising, alpha, 1f);
                }
            } catch (Exception e) {
                LogHelpers.Warn(e.ToString());
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        ////////////////

        private bool StaminaBarUIDraw()
        {
            Player        player   = Main.LocalPlayer;
            StaminaPlayer myplayer = player.GetModPlayer <StaminaPlayer>();

            SpriteBatch sb = Main.spriteBatch;

            if (sb == null)
            {
                return(false);
            }

            try {
                int   scrX         = Main.screenWidth - 172;
                int   scrY         = 78;
                float alpha        = myplayer.Logic.DrainingFX ? 1f : 0.65f;
                int   stamina      = (int)myplayer.Logic.Stamina;
                int   maxStamina   = myplayer.Logic.MaxStamina2;
                float fatigue      = myplayer.Logic.Fatigue;
                bool  isExercising = myplayer.Logic.IsExercising;
                int   threshold    = fatigue > 0 ? myplayer.Logic.GetStaminaLossAmountNeededForExercise() : -1;

                if (this.Config.CustomStaminaBarPositionX >= 0)
                {
                    scrX = this.Config.CustomStaminaBarPositionX;
                }
                if (this.Config.CustomStaminaBarPositionY >= 0)
                {
                    scrY = this.Config.CustomStaminaBarPositionY;
                }

                StaminaUI.DrawLongStaminaBar(sb, scrX, scrY, stamina, maxStamina, (int)fatigue, threshold, isExercising, alpha, 1f);
            } catch (Exception e) {
                this.Logger.Info(e.ToString());
                return(false);
            }

            if (this.Config.DebugModeInfoDrainers)
            {
                this.PrintStaminaDrainers(sb, myplayer);
            }

            return(true);
        }