Esempio n. 1
0
        public void ResetSkillsProgress()
        {
            int TotalLevel = 0;
            List <GuardianSkills> SkillList = GetSkillList;

            for (int s = 0; s < SkillList.Count; s++)
            {
                TotalLevel              += SkillList[s].Level;
                SkillList[s].Level       = 0;
                SkillList[s].Progress    = 0;
                SkillList[s].MaxProgress = GuardianSkills.ReturnSkillMaxProgress(0, true);
            }
            int ExtraLevel = LastTotalSkillLevel - TotalLevel;

            if (ExtraLevel < 0)
            {
                ExtraLevel = 0;
            }
            int TotalSkillLevel = TotalLevel + ExtraLevel;

            if (GuardianCommonStatus.UseSkillProgressShare)
            {
                GetCommonStatus.LastTotalSkillLevel = TotalSkillLevel;
            }
            else
            {
                LastTotalSkillLevel = TotalSkillLevel;
            }
            Main.NewText(Name + "'s skill levels were resetted.");
        }
        public static void SaveStatus(int CompanionID, string CompanionModID = "")
        {
            if (CompanionModID == "")
            {
                CompanionModID = MainMod.mod.Name;
            }
            GuardianBase Base          = GuardianBase.GetGuardianBase(CompanionID, CompanionModID);
            string       SaveDirectory = GetSaveFolder + "/" + CompanionModID;

            if (!Directory.Exists(SaveDirectory))
            {
                Directory.CreateDirectory(SaveDirectory);
            }
            string SaveFile = SaveDirectory + "/" + Base.Name + ".tgf";

            if (File.Exists(SaveFile))
            {
                File.Delete(SaveFile);
            }
            GuardianCommonStatus status = GetCommonStatus(CompanionID, CompanionModID);

            using (FileStream stream = new FileStream(SaveFile, FileMode.CreateNew))
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write(MainMod.ModVersion);
                    writer.Write(status.LifeCrystalsUsed);
                    writer.Write(status.LifeFruitsUsed);
                    writer.Write(status.ManaCrystalsUsed);
                    if (status.LifeTime.HasValue)
                    {
                        writer.Write(true);
                        writer.Write(status.LifeTime.Value.TotalSeconds);
                    }
                    else
                    {
                        writer.Write(false);
                    }
                    int Skills = status.SkillList.Count;
                    writer.Write(Skills);
                    for (int s = 0; s < Skills; s++)
                    {
                        GuardianSkills skill = status.SkillList[s];
                        writer.Write(skill.skillType.ToString());
                        writer.Write(skill.Level);
                        writer.Write(skill.Progress);
                    }
                    writer.Write(status.LastTotalSkillLevel);
                }
            }
        }
Esempio n. 3
0
        public void UpdateData(Player player)
        {
            if (Base.InvalidGuardian)
            {
                return;
            }
            AddSecond();
            if (player.whoAmI != Main.myPlayer)
            {
                return;
            }
            int LevelSum = 0;
            List <GuardianSkills> SkillList = GetSkillList;

            for (int s = 0; s < SkillList.Count; s++)
            {
                if (SkillList[s].MaxProgress == 0)
                {
                    SkillList[s].MaxProgress = GuardianSkills.ReturnSkillMaxProgress(SkillList[s].Level, true);
                }
                int LastSkillIncreaseLevel = -1;
                while (SkillLevelSum > -1 && SkillList[s].Level < GuardianSkills.MaxLevel && ((!MainMod.IndividualSkillLeveling && SkillList[s].Progress >= LastSkillRateMaxValue) || (MainMod.IndividualSkillLeveling && SkillList[s].Progress >= SkillList[s].MaxProgress)))
                {
                    SkillList[s].Level++;
                    SkillList[s].Progress   -= (MainMod.IndividualSkillLeveling ? SkillList[s].MaxProgress : LastSkillRateMaxValue);
                    SkillList[s].MaxProgress = GuardianSkills.ReturnSkillMaxProgress(SkillList[s].Level, true);
                    if (SkillList[s].Level % 100 == 0)
                    {
                        LastSkillIncreaseLevel = SkillList[s].Level;
                    }
                }
                if (LastSkillIncreaseLevel > -1)
                {
                    Main.NewText(Name + " has reached " + SkillList[s].skillType.ToString() + " level " + LastSkillIncreaseLevel + ".", MainMod.SkillUpColor);
                }
                LevelSum += SkillList[s].Level;
            }
            if (LevelSum != SkillLevelSum)
            {
                SkillLevelSum         = LevelSum;
                LastSkillRateMaxValue = GuardianSkills.ReturnSkillMaxProgress(LevelSum, true);
                if (PlayerMod.HasGuardianSummoned(player, ID, ModID))
                {
                    PlayerMod.GetPlayerSummonedGuardian(player, ID, ModID).UpdateStatus = true;
                }
            }
            bool StatusUpdate = false;

            if (MainMod.UsingGuardianNecessitiesSystem)
            {
                if (WorldMod.HourChange)
                {
                    StatusUpdate = true;
                    if (Injury > 0)
                    {
                        Injury--;
                        if (PlayerMod.HasGuardianSummoned(player, ID, ModID))
                        {
                            PlayerMod.GetPlayerSummonedGuardian(player, ID, ModID).UpdateStatus = true;
                        }
                    }
                }
                if (WorldMod.DayChange)
                {
                    if (PlayerMod.HasGuardianSummoned(player, ID, ModID))
                    {
                        Injury -= 2;
                        if (PlayerMod.HasGuardianSummoned(player, ID, ModID))
                        {
                            PlayerMod.GetPlayerSummonedGuardian(player, ID, ModID).UpdateStatus = true;
                        }
                    }
                    else
                    {
                        Injury  -= 8;
                        Fatigue -= 36;
                    }
                    StatusUpdate = true;
                }
            }
            if (StatusUpdate)
            {
                if (Injury < 0)
                {
                    Injury = 0;
                }
                if (Fatigue < -32)
                {
                    Fatigue = -32;
                }
            }
            UpdateMood();
            if (ShouldScheduleVisit())
            {
                WorldMod.ScheduledVisits.Add(MyID);
            }
        }