public void Update(GameWindow Window, GameTime gameTime) { if (HP <= 0) { State = 3; Animate(gameTime); } if (State != 3) { KeyboardState kbState = Keyboard.GetState(); //Нажата кнопка ВЛЕВО if (kbState.IsKeyDown(Keys.A)) { if (Rectangle.X > 0 && Main.ThisGame.CanRunLeft) { if (!onJump) { State = 1; } Rotate = true; Position.X -= Speed; Animate(gameTime); } else if (State == 1) { State = 0; CurrentTime = 0; CurrentFrame = 0; } } //Нажата кнопка ВПРАВО else if (kbState.IsKeyDown(Keys.D)) { if (Rectangle.X < Window.ClientBounds.Width - FrameWidth && Main.ThisGame.CanRunRight) { if (!onJump) { State = 1; } Rotate = false; Position.X += Speed; Animate(gameTime); } else if (State == 1) { State = 0; CurrentTime = 0; CurrentFrame = 0; } } else if (kbState.IsKeyDown(Keys.Space)) { if (State != 2) { CurrentTime = 0; CurrentFrame = 0; } State = 2; } //Ничего не нажато else { if (State != 0 && State != 3) { State = 0; CurrentTime = 0; CurrentFrame = 0; } } //Нажат ПРОБЕЛ if (kbState.IsKeyDown(Keys.W)) { if (Rectangle.X <= Window.ClientBounds.Width - FrameWidth) { State = 4; onJump = true; } } } }
public SkillWindow(Skill[] nSkill, GameWindow Window) { SkillPoint = 1; MarginX = 20; MarginY = 20; SelectRadius = 3; Skill = nSkill; SavedPosition = new Rectangle[Skill.Length]; LocalPosition = new Rectangle[Skill.Length]; for (int i = 0; i < Skill.Length; i++) { SavedPosition[i] = Skill[i].Button.Rectangle; Skill[i].Button.Rectangle = new Rectangle( MarginX + (MarginX + Skill[i].Button.Rectangle.Width) * i, MarginY, Skill[i].Button.Rectangle.Width, Skill[i].Button.Rectangle.Height ); LocalPosition[i] = Skill[i].Button.Rectangle; } Bg = Main.ThisGame.Content.Load <Texture2D>("img/Windows/Start/Bg"); Select = Main.ThisGame.Content.Load <Texture2D>("img/Windows/Skill/Select"); SkillPointPanel = Main.ThisGame.Content.Load <Texture2D>("img/Windows/Skill/SkillPoint"); ButtonLearn = new Button( new Rectangle( (Window.ClientBounds.Width - 400) / 2, 280, 400, 50 ), Main.ThisGame.Content.Load <Texture2D>("img/Windows/Skill/Learn"), true ); ButtonStart = new Button( new Rectangle( (Window.ClientBounds.Width - 400) / 2, 580, 400, 50 ), Main.ThisGame.Content.Load <Texture2D>("img/Windows/Start/Start"), true ); ButtonReturn = new Button( new Rectangle( (Window.ClientBounds.Width - 400) / 2, 650, 400, 50 ), Main.ThisGame.Content.Load <Texture2D>("img/Windows/Skill/Back"), true ); ActiveSkill = 0; Description = new Label( Main.ThisGame.Content.Load <SpriteFont>("fonts/Stat"), new Vector2(20, 150), ""); SkillPointLabel = new Label( Main.ThisGame.Content.Load <SpriteFont>("fonts/Stat"), new Vector2(1200, 27), ""); BuySkill = Main.ThisGame.Content.Load <SoundEffect>("sound/BuySkill"); }