Exemplo n.º 1
0
        public override void OnActivate()
        {
            if (SelectedObj.NotUsable)
            {
                return;
            }

            if (DataTree.Type == TreeType.Skill && (SelectedObj.Parent == null || SelectedObj.Parent.Node.Unlocked(DataTree)))
            {
                var skill = RPG.PlayerData.GetSkill(SelectedObj.Ref);
                if (skill.Unlocked && skill.Mods.Count > 0)
                {
                    RPG.UIHandler.View.RemoveMenu(this);
                    RPG.UIHandler.View.AddMenu(new TreeMenu(SkillRepository.GetModTree(SelectedObj.Ref)));
                }
                else if (!skill.Unlocked)
                {
                    if (!RPG.PlayerData.Tutorial.UnlockSkillWithSp && RPG.PlayerData.Tutorial.PressJToOpenMenu && RPG.PlayerData.Tutorial.BoughtAmmoFromShop && RPG.PlayerData.Tutorial.GetAKill)
                    {
                        var tut = RPG.GetPopup <TutorialBox>();
                        RPG.PlayerData.Tutorial.UnlockSkillWithSp = true;
                        EventHandler.Do(o =>
                        {
                            tut.Hide();
                            EventHandler.Wait(300);
                            if (!RPG.PlayerData.Tutorial.UsingSkills)
                            {
                                tut.Pop("Skills can get you the edge in your conflicts. You can further increase skills by 'activating' them in the menu once unlocked.", "Press [Caps-Lock] to use your unlocked skill.");
                            }
                        });
                    }

                    skill.Unlock();
                }
            }
            else if (DataTree.Type == TreeType.Weapon && (SelectedObj.Parent == null || SelectedObj.Parent.Node.Unlocked(DataTree)))
            {
                var wep = RPG.PlayerData.GetWeapon(SelectedObj.WepHash);
                if (wep.Unlocked)//&& skill.Mods.Count > 0
                {
                    //RPG.UIHandler.View.RemoveMenu(this);
                    //RPG.UIHandler.View.AddMenu(new TreeMenu(SkillRepository.GetModTree(SelectedObj.Ref)));
                }
                else if (!wep.Unlocked)
                {
                    wep.Unlock();
                }
            }
            else if (DataTree.Type == TreeType.SkillMod && SelectedObj.Parent.Node.Unlocked(DataTree))
            {
                var skill       = RPG.PlayerData.GetSkill(DataTree.TreeRef);
                var modUnlocked = skill.UsedMods.FirstOrDefault(m => m == SelectedObj.Ref) != null;
                if (!modUnlocked)
                {
                    if (skill.UnlockMod(SelectedObj.Ref))
                    {
                        SelectedObj.UnlockAction.Invoke(skill);
                    }
                }
            }
        }