2 using System.Collections.Generic;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Graphics;
8 namespace SuperPolarity
10 class NameChooserWidget : Widget
17 public NameChooserWidget(SuperPolarity game, Vector2 position)
18 : base(game, position)
20 AppendChild(new LetterChooseWidget(game, new Vector2(position.X, position.Y)));
21 AppendChild(new LetterChooseWidget(game, new Vector2(position.X + 32, position.Y)));
22 AppendChild(new LetterChooseWidget(game, new Vector2(position.X + 64, position.Y)));
24 Children[CurrentIndex].Activate();
28 InputController.Bind("moveX", HandleMovement);
31 public override void Update(GameTime gameTime)
33 base.Update(gameTime);
35 CurrentTime = CurrentTime + gameTime.ElapsedGameTime.Milliseconds;
36 if (CurrentTime > LockRate)
42 foreach (LetterChooseWidget widget in Children)
44 widget.Update(gameTime);
48 public void HandleMovement(float value)
50 if (value > 0.8 && !Lock)
52 Children[CurrentIndex].Deactivate();
53 CurrentIndex = CurrentIndex + 1;
55 if (CurrentIndex > Children.Count - 1)
63 if (value < -0.8 && !Lock)
65 Children[CurrentIndex].Deactivate();
66 CurrentIndex = CurrentIndex - 1;
70 CurrentIndex = Children.Count - 1;
76 Children[CurrentIndex].Activate();
83 foreach (LetterChooseWidget letter in Children)
85 name = name + letter.Value();
91 public override void Draw(SpriteBatch spriteBatch)
93 foreach (LetterChooseWidget widget in Children)
95 widget.Draw(spriteBatch);