Exemplo n.º 1
0
        public override bool UseItem(Item item, Player player)
        {
            var mymod = (StaminaMod)this.mod;

            if (!mymod.Config.Enabled)
            {
                return(base.UseItem(item, player));
            }

            if (mymod.Config.ConsumableStars && item.type == ItemID.FallenStar && item.stack > 0)
            {
                if (StaminaItem.StarUseCooldown[player.whoAmI] == 0)
                {
                    StaminaPlayer myplayer = player.GetModPlayer <StaminaPlayer>();

                    if (myplayer.Logic.Stamina < myplayer.Logic.MaxStamina2)
                    {
                        myplayer.Logic.AddStamina(player, mymod.Config.StarStaminaHeal);

                        if (--item.stack <= 0)
                        {
                            ItemHelpers.DestroyItem(item);
                        }
                    }

                    StaminaItem.StarUseCooldown[player.whoAmI]++;
                }
                StaminaItem.StarUseCooldown[player.whoAmI]++;
            }

            return(base.UseItem(item, player));
        }
Exemplo n.º 2
0
        ////////////////

        /*public override bool UseItem( Item item, Player player ) {
         *      StaminaPlayer info = player.GetModPlayer<StaminaPlayer>(this.mod);
         *      info.AddDrainStamina( StaminaMod.Config.Data.ItemUseRate, "use item" );
         * Main.NewText("UseItem " + StaminaMod.Config.Data.ItemUseRate);
         *
         *      return base.UseItem( item, player );
         * }*/

        public override bool WingUpdate(int wings, Player player, bool inUse)
        {
            StaminaPlayer myplayer = player.GetModPlayer <StaminaPlayer>();

            myplayer.IsFlying         = inUse;
            myplayer.HasCheckedFlying = true;

            return(false);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        ////////////////

        private void PrintStaminaDrainers(SpriteBatch sb, StaminaPlayer myplayer)
        {
            var dict = myplayer.Logic.CurrentDrainTypes;
            int i    = 0;

            foreach (var kv in dict.ToList())
            {
                if (kv.Value == 0f)
                {
                    continue;
                }

                //string msg = kv.Key.ToString() + ":  " + kv.Value;
                //sb.DrawString( Main.fontMouseText, msg, new Vector2( 8, (Main.screenHeight - 32) - (i * 24) ), Color.White );
                DebugHelpers.Print(kv.Key.ToString(), "" + kv.Value, 30);

                dict[kv.Key] = 0f;
                i++;
            }
        }