Esempio n. 1
0
 public PlayerObject(Size panel_size, GameObjects NPC) : base(panel_size) //берём у нпс все параметры
 {
     this.center = NPC.GetCenter();
     this.radius = NPC.GetRadius();
     this.color  = NPC.GetColor();
     this.step   = NPC.GetStep();
     key         = new KeyPlayer(ClassGame.GetDlinaKey()); // создали новый пустой ключ для игрока 256 переделать на значения комбобокса!!!!!!!!!!!!!!!!!!
     key.AddBitArray(NPC.GetKey().GetKeyArray());          // ключь нпс переделываем в ключ игрока
 }
        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            Player    player    = Main.LocalPlayer;
            KeyPlayer keyPlayer = player.GetModPlayer <KeyPlayer>();

            if ((ModContent.GetInstance <KeyClientConfig>().AlwaysShowMP || (player.HeldItem.modItem is Keybrand && player.HeldItem.modItem.AltFunctionUse(player)) || player.HeldItem.type == ModContent.ItemType <Items.Other.Cure.CureSpell>() || player.HeldItem.type == ModContent.ItemType <Items.Other.Cure.CuraSpell>() || player.HeldItem.type == ModContent.ItemType <Items.Other.Cure.CuragaSpell>()) && !player.dead && !Main.playerInventory)
            {
                int index = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Ruler"));
                LegacyGameInterfaceLayer mpBar = new LegacyGameInterfaceLayer("KeybrandsPlus: MP Gauge",
                                                                              delegate
                {
                    DrawMPGauge(Main.spriteBatch);
                    return(true);
                },
                                                                              InterfaceScaleType.UI);
                layers.Insert(index, mpBar);
            }
        }
Esempio n. 3
0
        public void verify_password_mode_works()
        {
            //arrange
            var passwordInterceptKeyEventArgs = new InterceptKeyEventArgs(Keys.A, KeyDirection.Down, false, false, false);
            var passwordInterceptKeyEventArgs2 = new InterceptKeyEventArgs(Keys.B, KeyDirection.Down, false, false, false);
            var player = new KeyPlayer { passwordInterceptKeyEventArgs, passwordInterceptKeyEventArgs2 };

            var passwordService = Substitute.For<IPasswordModeService>();
            passwordService.CheckPasswordMode(Arg.Is(passwordInterceptKeyEventArgs)).Returns(true);

            var provider = new KeyProvider(player, passwordService);

            //act
            var processedKeys = ToEnumerable(provider, player);

            //assert
            Assert.Equal(1, processedKeys.Count());
        }
Esempio n. 4
0
        private IEnumerable<KeyPress> ToEnumerable(KeyProvider provider, KeyPlayer player)
        {
            var keys = new List<KeyPress>();

            provider.Subscribe(keys.Add);
            player.Play();

            return keys;
        }
        public void DrawMPGauge(SpriteBatch spriteBatch)
        {
            Player    player    = Main.LocalPlayer;
            KeyPlayer keyPlayer = player.GetModPlayer <KeyPlayer>();

            Texture2D gaugeLeft        = Instance.GetTexture("UI/MPBarEnd");
            Texture2D gaugeRight       = Instance.GetTexture("UI/MPBarText");
            Texture2D gaugeMid         = Instance.GetTexture("UI/MPBarSection");
            Texture2D gaugeFill        = Instance.GetTexture("UI/MPBarFill");
            Texture2D gaugeDelta       = Instance.GetTexture("UI/DeltaBarFill");
            float     maxMP            = keyPlayer.maxMP;
            float     currMP           = keyPlayer.currentMP;
            float     maxDelta         = keyPlayer.maxDelta;
            float     currDelta        = keyPlayer.currentDelta;
            float     toastTimer       = keyPlayer.rechargeMPToastTimer;
            float     rechargeTimer    = keyPlayer.rechargeMPTimer;
            float     maxRechargeTimer = keyPlayer.maxRechargeMPTimer;
            float     rechargeRate     = keyPlayer.rechargeMPRate;

            float midFrame  = 0;
            float fillFrame = 0;

            if (keyPlayer.rechargeMP)
            {
                midFrame  = 1;
                fillFrame = 1;

                if (Main.GameUpdateCount % 60 <= 30)
                {
                    fillFrame = 2;
                }
            }

            Rectangle midRect   = new Rectangle(0, (int)(gaugeMid.Height / 2 * midFrame), gaugeMid.Width, gaugeMid.Height / 2);
            Rectangle rightRect = new Rectangle(0, (int)(gaugeRight.Height / 2 * midFrame), gaugeRight.Width, gaugeRight.Height / 2);
            Rectangle fillRect  = new Rectangle(0, (int)(gaugeFill.Height / 3 * fillFrame), gaugeFill.Width, gaugeFill.Height / 3);

            Vector2 drawPos = new Vector2(50, 200);

            if (toastTimer > 0)
            {
                drawPos.X = MathHelper.Lerp(-200 - maxMP, 50, 1f - toastTimer / 40);
            }

            Rectangle mpBar = new Rectangle((int)drawPos.X, (int)drawPos.Y, (int)(50 + maxMP) + 16, 26 + 8);

            mpBar.X -= 8;
            mpBar.Y -= 4;

            spriteBatch.Draw(gaugeLeft, drawPos, null, Color.White, 0f, new Vector2(0, 0), 1f, SpriteEffects.None, 0f);
            drawPos.X += gaugeLeft.Width;

            for (int i = 0; i < maxMP; i++)
            {
                spriteBatch.Draw(gaugeMid, drawPos + new Vector2(i, 0f), midRect, Color.White, 0f, new Vector2(0, 0), 1f, SpriteEffects.None, 0f);
            }
            drawPos.X += maxMP;

            Vector2 Offset = new Vector2(drawPos.X - currMP, drawPos.Y);

            for (int i = 0; i < currMP; i++)
            {
                spriteBatch.Draw(gaugeFill, Offset + new Vector2(i, 4f), fillRect, Color.White, 0f, new Vector2(0, 0), 1f, SpriteEffects.None, 0f);
            }
            if (currDelta > maxDelta)
            {
                currDelta = maxDelta;
            }
            Offset = new Vector2(drawPos.X - currDelta / 2, drawPos.Y);
            for (int i = 0; i < currDelta / 2; i++)
            {
                spriteBatch.Draw(gaugeDelta, Offset + new Vector2(i, 20f), null, Color.White, 0f, new Vector2(0, 0), 1f, SpriteEffects.None, 0f);
            }

            spriteBatch.Draw(gaugeRight, drawPos, rightRect, Color.White, 0f, new Vector2(0, 0), 1f, SpriteEffects.None, 0f);

            if (mpBar.Contains(new Point(Main.mouseX, Main.mouseY)))
            {
                if (keyPlayer.rechargeMP)
                {
                    Main.spriteBatch.DrawString(Main.fontMouseText, (rechargeRate > 0 ? "Recharging: " + Math.Ceiling(rechargeTimer / rechargeRate / 60f) + "s" : "No Recharge!") + " (Delta: " + currDelta + "/" + maxDelta + ")", new Vector2(Main.mouseX + 20, Main.mouseY + 8), Color.White);
                }
                else
                {
                    Main.spriteBatch.DrawString(Main.fontMouseText, currMP + "/" + maxMP + " (Delta: " + currDelta + "/" + maxDelta + ")", new Vector2(Main.mouseX + 20, Main.mouseY + 8), Color.White);
                }
            }

            //int timerProgress = (int)(gaugeFill.Width * (maxMP - keyPlayer.asthralBlockCooldown) / maxMP);
            //Vector2 drawPos = player.Center + new Vector2(0, -32) - Main.screenPosition;
            //spriteBatch.Draw(gaugeMid, drawPos, null, Color.White, 0f, gaugeMid.Size() / 2f, 1f, SpriteEffects.None, 0f);
            //spriteBatch.Draw(gaugeFill, drawPos, new Rectangle?(new Rectangle(0, 0, timerProgress, gaugeFill.Height)), Color.White, 0f, gaugeFill.Size() / 2f, 1f, SpriteEffects.None, 0f);
        }