Exemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            PlayerIndex index     = PlayerIndex.One;
            int         i         = 0;
            string      attribute = "";

            if (Xin.CheckKeyReleased(Keys.Down))
            {
                selected++;
                if (selected >= attributes.Count)
                {
                    selected = attributes.Count - 1;
                }
            }
            else if (Xin.CheckKeyReleased(Keys.Up))
            {
                selected--;
                if (selected < 0)
                {
                    selected = 0;
                }
            }
            if (Xin.CheckKeyReleased(Keys.Space) || Xin.CheckKeyReleased(Keys.Enter))
            {
                if (selected == 4 && points == 0)
                {
                    foreach (string s in assignedTo.Keys)
                    {
                        player.AssignPoint(s, assignedTo[s]);
                    }
                    manager.PopState();
                    manager.PopState();
                    manager.PopState();
                    return;
                }
            }
            int increment = 1;

            if (Xin.CheckKeyReleased(Keys.Right) && points > 0)
            {
                foreach (string s in assignedTo.Keys)
                {
                    if (s == "Done")
                    {
                        return;
                    }
                    if (i == selected)
                    {
                        attribute = s;
                        break;
                    }
                    i++;
                }
                if (attribute == "Health")
                {
                    increment *= 5;
                }
                points--;
                assignedTo[attribute] += increment;
                if (points == 0)
                {
                    selected = 4;
                }
            }
            else if (Xin.CheckKeyReleased(Keys.Left) && points <= 3)
            {
                foreach (string s in assignedTo.Keys)
                {
                    if (s == "Done")
                    {
                        return;
                    }
                    if (i == selected)
                    {
                        attribute = s;
                        break;
                    }
                    i++;
                }
                if (assignedTo[attribute] != attributes[attribute])
                {
                    if (attribute == "Health")
                    {
                        increment *= 5;
                    }
                    points++;
                    assignedTo[attribute] -= increment;
                }
            }
            base.Update(gameTime);
        }