Ejemplo n.º 1
0
 public SkillTreeItem(SkillType type, string title, string description, int points, int row, int col, string file, SkillTreeItem parent = null, AbilityTypes ability = AbilityTypes.None)
 {
     Type        = type;
     Row         = row;
     Col         = col;
     Title       = title;
     MaxPoints   = points;
     Description = description;
     Texture     = TextureCacheFactory.GetOnce($"Icons/{file}");
     Children    = new List <SkillTreeItem>();
     Parent      = parent;
     parent?.Children.Add(this);
     Ability = ability;
 }
Ejemplo n.º 2
0
        public void Draw(Rectangle bounds)
        {
            Selected = Selected ?? Items.First();
            Items.ForEach(i => i.DrawDependencies(bounds));
            Items.ForEach(i =>
            {
                var available = PointsSpent >= i.Row * 5 && (i.Parent == null || i.Parent.PointsSpent == i.Parent.MaxPoints);
                i.Draw(bounds, Selected == i, available);
            });
            new Rectangle(bounds.X, bounds.Y + bounds.Height - InfoHeight, bounds.Width, InfoHeight).Draw(new Color(new Color(180, 180, 180), 0.75f));
            Selected.Title.Draw(new Vector2(bounds.X + bounds.Width / 2, bounds.Bottom - InfoHeight + 30), 24f, Color.Black);
            $"{Selected.PointsSpent} / {Selected.MaxPoints}".Draw(new Vector2(bounds.X + bounds.Width / 2, bounds.Bottom - InfoHeight + 80f), 20f);
            Selected.Description.Wrap(bounds.Width - Padding * 2, 16f).Draw(new Vector2(bounds.X + bounds.Width / 2, bounds.Bottom - InfoHeight + 180f), 16f);
            var skillPts = (Name == "Fire" ? _player.Skills.FireSkillTree.PointsAvailable : Name == "Frost" ? _player.Skills.FrostSkillTree.PointsAvailable : _player.Skills.ArcaneSkillTree.PointsAvailable);

            $"Pts Available: {skillPts} + {_player.FloatingSkillPoints} Floating".Draw(new Vector2(bounds.Center.X, bounds.Y + 30f), 15f, Color.White);
        }
Ejemplo n.º 3
0
        public void Update()
        {
            Selected = Selected ?? Items.First();

            if (InputService.InputDevices[_player.PlayerIndex].IsPressed(Buttons.A))
            {
                if ((PointsAvailable > 0 || _player.FloatingSkillPoints > 0) && Selected.PointsSpent < Selected.MaxPoints && PointsSpent >= Selected.Row * 5 &&
                    (Selected.Parent == null || Selected.Parent.PointsSpent == Selected.Parent.MaxPoints))
                {
                    _player.Zerd.Stats.SkillPointsSpent++;
                    Selected.PointsSpent++;
                    if (PointsAvailable > 0)
                    {
                        PointsAvailable--;
                    }
                    else
                    {
                        _player.FloatingSkillPoints--;
                    }
                    if (Selected.PointsSpent == Selected.MaxPoints)
                    {
                        switch (Selected.Ability)
                        {
                        case AbilityTypes.LavaBlast:
                            _player.Zerd.Abilities.Add(new LavaBlast(_player.Zerd));
                            break;

                        case AbilityTypes.FrostPound:
                            _player.Zerd.Abilities.Add(new FrostPound(_player.Zerd));
                            break;

                        case AbilityTypes.DragonsBreath:
                            _player.Zerd.Abilities.Add(new DragonBreath(_player.Zerd));
                            break;

                        case AbilityTypes.Icicle:
                            _player.Zerd.Abilities.Add(new Icicle(_player.Zerd));
                            break;

                        case AbilityTypes.Charm:
                            _player.Zerd.Abilities.Add(new Charm(_player.Zerd));
                            break;

                        case AbilityTypes.None:
                            break;

                        default:
                            throw new Exception("missing ability type");
                        }
                    }
                }
            }

            var origSelection = Selected;

            if (InputService.InputDevices[_player.PlayerIndex].IsPressed(Buttons.LeftThumbstickRight))
            {
                Selected = Items.Where(i => i.Row == Selected.Row && i.Col > Selected.Col).OrderBy(i => i.Col).FirstOrDefault() ?? Selected;
            }
            else if (InputService.InputDevices[_player.PlayerIndex].IsPressed(Buttons.LeftThumbstickLeft))
            {
                Selected = Items.Where(i => i.Row == Selected.Row && i.Col < Selected.Col).OrderByDescending(i => i.Col).FirstOrDefault() ?? Selected;
            }
            else if (InputService.InputDevices[_player.PlayerIndex].IsPressed(Buttons.LeftThumbstickDown))
            {
                Selected = Items.Where(i => i.Col == Selected.Col && i.Row > Selected.Row).OrderBy(i => i.Row).FirstOrDefault();
                if (Selected == null)
                {
                    Selected = Items.Where(i => i.Col == origSelection.Col - 1 && i.Row > origSelection.Row).OrderBy(i => i.Row).FirstOrDefault();
                }
                if (Selected == null)
                {
                    Selected = Items.Where(i => i.Col == origSelection.Col + 1 && i.Row > origSelection.Row).OrderBy(i => i.Row).FirstOrDefault();
                }
            }
            else if (InputService.InputDevices[_player.PlayerIndex].IsPressed(Buttons.LeftThumbstickUp))
            {
                Selected = Items.Where(i => i.Col == Selected.Col && i.Row < Selected.Row).OrderByDescending(i => i.Row).FirstOrDefault();
                if (Selected == null)
                {
                    Selected = Items.Where(i => i.Col == origSelection.Col - 1 && i.Row < origSelection.Row).OrderByDescending(i => i.Row).FirstOrDefault();
                }
                if (Selected == null)
                {
                    Selected = Items.Where(i => i.Col == origSelection.Col + 1 && i.Row < origSelection.Row).OrderByDescending(i => i.Row).FirstOrDefault();
                }
            }
        }