예제 #1
0
        private void LevelHandler(BasePlayer player, Item item, Skill skill)
        {
            if (player == null || !skills.ContainsKey(player.userID))
            {
                return;
            }

            PlayerSkill pskill = skills[player.userID];

            int  xpProc = GetExperiencePercent(player, skill);
            long level  = pskill.GetLevel(skill.code);
            long xp     = pskill.GetXp(skill.code);

            item.amount = Mathf.CeilToInt((float)(item.amount * (1 + 1 * 0.1 * (level - 1))));

            xp += 5;

            if (xp > GetLevelXp(level + 1))
            {
                level = GetXpLevel(xp);

                player.ChatMessage($"<color=\"#DD32AA\">{skill.name}</color> level up! { ((((1 + 1 * 0.1 * (level - 1)) * 100) - 100).ToString("0.##"))}% bonus");
            }

            pskill.SetLevel(skill.code, level);
            pskill.SetXp(skill.code, xp);

            var newXp = GetExperiencePercent(player, skill);

            if (newXp != xpProc)
            {
                UpdateUI(player, skill);
            }
        }
예제 #2
0
        private void LoadPlayer(BasePlayer player)
        {
            if (player == null || playerSkills.ContainsKey(player.userID))
            {
                return;
            }

            if (!playerInfo.ContainsKey(player.userID))
            {
                timer.Once(0.5f, () => LoadPlayer(player));
                return;
            }

            PlayerInfo info = playerInfo[player.userID];

            MQuery(MBuild("SELECT * FROM skills WHERE user_id=@0", info.id), records =>
            {
                PlayerSkill pskill = new PlayerSkill();

                foreach (var record in records)
                {
                    string skill = Convert.ToString(record["skill"]);
                    int xp       = Convert.ToInt32(record["xp"]);
                    int level    = Convert.ToInt32(record["level"]);

                    pskill.SetXp(skill, xp);
                    pskill.SetLevel(skill, level);
                }

                playerSkills.Add(player.userID, pskill);
                CreateGUI(player);
            });
        }
예제 #3
0
    void Awake()
    {
        PlayerSkills = new List <PlayerSkill>();

        GameDatabase db     = GameObject.FindGameObjectWithTag("Database").GetComponent <GameDatabase>();
        List <Skill> skills = db.skilldb.Skills;

        for (int i = 0; i < skills.Count; i++)
        {
            PlayerSkill newSkill = new PlayerSkill(skills[i]);
            newSkill.SetLevel(1);
            PlayerSkills.Add(newSkill);

            //Debug.LogWarning(newSkill.GetSkill().SkillName + " added to skillset.");
        }
    }
예제 #4
0
        private void LoadPlayer(BasePlayer player)
        {
            if (player == null)
            {
                return;
            }

            PlayerData.PData pdata = PlayerData.Get(player);

            if (pdata == null)
            {
                Puts($"Loading for [{player.UserIDString}] has been delayed, waiting for the PlayerData plugin");
                timer.Once(1f, () => LoadPlayer(player));
                return;
            }

            // Remove the old homes first
            UnloadPlayer(player);

            Database.Query(Database.Build("SELECT * FROM skills WHERE user_id = @0;", pdata.id), records =>
            {
                PlayerSkill pskill = new PlayerSkill();

                string info = $"Player skills for [{pdata.id}:{player.UserIDString}]:\n";

                foreach (var record in records)
                {
                    string skill = Convert.ToString(record["skill"]);
                    int xp       = Convert.ToInt32(record["xp"]);
                    int level    = Convert.ToInt32(record["level"]);

                    pskill.SetLevel(skill, level);
                    pskill.SetXp(skill, xp);

                    info += $"{skill}: Lv. {level} / Xp. {xp}\n";
                }

                skills.Add(player.userID, pskill);

                // Puts(info.TrimEnd('\n'));

                CreateUI(player);
            });
        }