Example #1
0
 private void loadPerk(Perk perk)
 {
     txtName.Text          = perk.Name;
     richtextDesc.Text     = perk.Desc;
     numLevel.Value        = perk.MaxLevel;
     cmbType.SelectedIndex = (int)perk.Type;
     trackBar1.Maximum     = perk.MaxLevel;
     trackBar1.Minimum     = 1;
     trackBar1.Value       = 1;
     currentPerk           = perk;
     unlockControls();
     setPerkLevelData();
 }
Example #2
0
 private static void writeWikiPerk(StreamWriter writer, Perk p)
 {
     writer.WriteLine("**" + p.Name + " (" + p.Id + ")**");
     writer.WriteLine("  * Ranks: " + p.MaxLevel);
     writer.Write("  * Generic requirements: ");
     for (int i = 0; i < p.MaxLevel; i++)
     {
         bool first = true;
         foreach (Requirement req in p.Levels[i].Requirements)
         {
             if (first)
             {
                 first = false;
             }
             else
             {
                 writer.Write(", ");
             }
             writer.Write(req.ToString());
         }
         writer.Write(" (rank " + (i + 1) + "); ");
     }
     writer.WriteLine();
     writer.Write("  * Generic effects: ");
     for (int i = 0; i < p.MaxLevel; i++)
     {
         bool first = true;
         foreach (Effect eff in p.Levels[i].UpEffects)
         {
             if (first)
             {
                 first = false;
             }
             else
             {
                 writer.Write(", ");
             }
             writer.Write(eff.ToString());
         }
         writer.Write(" (rank " + (i + 1) + "); ");
     }
     writer.WriteLine();
     writer.WriteLine("  * //" + p.Desc + "//");
 }
Example #3
0
 public static bool LoadPerks(String filename)
 {
     Perks = new List<Perk>();
     Perk cur = null;
     XmlTextReader reader = new XmlTextReader(filename);
     LevelData level = null;
     int levelid = -1;
     int state = -1;
     while(reader.Read())
     {
         switch(reader.NodeType)
         {
             case XmlNodeType.Element:
                 if(reader.Name.Equals("perks") && state == -1)
                 {
                     state = 0;
                     continue;
                 }
                 if(reader.Name.Equals("level") && state == 1)
                 {
                     level = new LevelData();
                     levelid = Int32.Parse(reader.GetAttribute(0));
                     level.JustRevert = reader.GetAttribute(1).Equals("1");
                     state = 2;
                     continue;
                 }
                 if(reader.Name.Equals("perk") && state == 0)
                 {
                     state = 1;
                     int id = Int32.Parse(reader.GetAttribute(0));
                     cur = new Perk(id, Config.MsgParser.GetMSGValue(id * 10 + 100001), Config.MsgParser.GetMSGValue(id * 10 + 100002));
                     cur.MaxLevel = Int32.Parse(reader.GetAttribute(1));
                     cur.Type = (Perk.PerkType)Int32.Parse(reader.GetAttribute(2));
                     Perks.Add(cur);
                     continue;
                 }
                 if(reader.Name.Equals("up") && state == 2)
                 {
                     int param = Int32.Parse(reader.GetAttribute(0));
                     bool increase = reader.GetAttribute(1).Equals("1");
                     int value = Int32.Parse(reader.GetAttribute(2));
                     Effect eff = new Effect(param, increase, value);
                     level.UpEffects.Add(eff);
                     continue;
                 }
                 if(reader.Name.Equals("down") && state == 2)
                 {
                     int param = Int32.Parse(reader.GetAttribute(0));
                     bool increase = reader.GetAttribute(1).Equals("1");
                     int value = Int32.Parse(reader.GetAttribute(2));
                     Effect eff = new Effect(param, increase, value);
                     level.DownEffects.Add(eff);
                     continue;
                 }
                 if(reader.Name.Equals("req") && state == 2)
                 {
                     int param = Int32.Parse(reader.GetAttribute(0));
                     bool atleast = reader.GetAttribute(1).Equals("1");
                     int value = Int32.Parse(reader.GetAttribute(2));
                     Requirement eff = new Requirement(param, atleast, value);
                     level.Requirements.Add(eff);
                     continue;
                 }
                 break;
             case XmlNodeType.Text:
                 break;
             case XmlNodeType.EndElement:
                 if(reader.Name.Equals("perks") && state == 0)
                 {
                     state = -1;
                     continue;
                 }
                 if(reader.Name.Equals("perk") && state == 1)
                 {
                     state = 0;
                     continue;
                 }
                 if(reader.Name.Equals("level") && state == 2)
                 {
                     cur.EnsureLevel(levelid - 1);
                     cur.Levels[levelid - 1] = level;
                     state = 1;
                     continue;
                 }
                 break;
         }
     }
     reader.Close();
     return true;
 }
Example #4
0
 public static void NewPerks()
 {
     if(Data.Perks == null) return;
     int idx = -1;
     for(int i = Config.PerkBegin; i <= Config.PerkEnd; i++)
     {
         idx = i;
         foreach(Perk p in Perks)
             if(p.Id == idx)
             {
                 idx = -1;
                 break;
             }
         if(idx >= 0) break;
     }
     if(idx < 0)
     {
         MessageBox.Show("No more room for new perks. Remove the existing ones or increase crdata perk space.");
         return;
     }
     Perk perk = new Perk(idx, "", "");
     Perks.Add(perk);
 }
Example #5
0
        public static bool LoadPerks(String filename)
        {
            Perks = new List <Perk>();
            Perk          cur     = null;
            XmlTextReader reader  = new XmlTextReader(filename);
            LevelData     level   = null;
            int           levelid = -1;
            int           state   = -1;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if (reader.Name.Equals("perks") && state == -1)
                    {
                        state = 0;
                        continue;
                    }
                    if (reader.Name.Equals("level") && state == 1)
                    {
                        level            = new LevelData();
                        levelid          = Int32.Parse(reader.GetAttribute(0));
                        level.JustRevert = reader.GetAttribute(1).Equals("1");
                        state            = 2;
                        continue;
                    }
                    if (reader.Name.Equals("perk") && state == 0)
                    {
                        state = 1;
                        int id = Int32.Parse(reader.GetAttribute(0));
                        cur          = new Perk(id, Config.MsgParser.GetMSGValue(id * 10 + 100001), Config.MsgParser.GetMSGValue(id * 10 + 100002));
                        cur.MaxLevel = Int32.Parse(reader.GetAttribute(1));
                        cur.Type     = (Perk.PerkType)Int32.Parse(reader.GetAttribute(2));
                        Perks.Add(cur);
                        continue;
                    }
                    if (reader.Name.Equals("up") && state == 2)
                    {
                        int    param    = Int32.Parse(reader.GetAttribute(0));
                        bool   increase = reader.GetAttribute(1).Equals("1");
                        int    value    = Int32.Parse(reader.GetAttribute(2));
                        Effect eff      = new Effect(param, increase, value);
                        level.UpEffects.Add(eff);
                        continue;
                    }
                    if (reader.Name.Equals("down") && state == 2)
                    {
                        int    param    = Int32.Parse(reader.GetAttribute(0));
                        bool   increase = reader.GetAttribute(1).Equals("1");
                        int    value    = Int32.Parse(reader.GetAttribute(2));
                        Effect eff      = new Effect(param, increase, value);
                        level.DownEffects.Add(eff);
                        continue;
                    }
                    if (reader.Name.Equals("req") && state == 2)
                    {
                        int         param   = Int32.Parse(reader.GetAttribute(0));
                        bool        atleast = reader.GetAttribute(1).Equals("1");
                        int         value   = Int32.Parse(reader.GetAttribute(2));
                        Requirement eff     = new Requirement(param, atleast, value);
                        level.Requirements.Add(eff);
                        continue;
                    }
                    break;

                case XmlNodeType.Text:
                    break;

                case XmlNodeType.EndElement:
                    if (reader.Name.Equals("perks") && state == 0)
                    {
                        state = -1;
                        continue;
                    }
                    if (reader.Name.Equals("perk") && state == 1)
                    {
                        state = 0;
                        continue;
                    }
                    if (reader.Name.Equals("level") && state == 2)
                    {
                        cur.EnsureLevel(levelid - 1);
                        cur.Levels[levelid - 1] = level;
                        state = 1;
                        continue;
                    }
                    break;
                }
            }
            reader.Close();
            return(true);
        }
Example #6
0
 private void loadPerk(Perk perk)
 {
     txtName.Text = perk.Name;
     richtextDesc.Text = perk.Desc;
     numLevel.Value = perk.MaxLevel;
     cmbType.SelectedIndex = (int)perk.Type;
     trackBar1.Maximum = perk.MaxLevel;
     trackBar1.Minimum = 1;
     trackBar1.Value = 1;
     currentPerk = perk;
     unlockControls();
     setPerkLevelData();
 }
Example #7
0
 private static void writeWikiPerk(StreamWriter writer, Perk p)
 {
     writer.WriteLine("**" + p.Name + " (" + p.Id + ")**");
     writer.WriteLine("  * Ranks: " + p.MaxLevel);
     writer.Write("  * Generic requirements: ");
     for(int i = 0; i < p.MaxLevel; i++)
     {
         bool first = true;
         foreach(Requirement req in p.Levels[i].Requirements)
         {
             if(first) first = false;
             else writer.Write(", ");
             writer.Write(req.ToString());
         }
         writer.Write(" (rank " + (i + 1) + "); ");
     }
     writer.WriteLine();
     writer.Write("  * Generic effects: ");
     for(int i = 0; i < p.MaxLevel; i++)
     {
         bool first = true;
         foreach(Effect eff in p.Levels[i].UpEffects)
         {
             if(first) first = false;
             else writer.Write(", ");
             writer.Write(eff.ToString());
         }
         writer.Write(" (rank " + (i + 1) + "); ");
     }
     writer.WriteLine();
     writer.WriteLine("  * //" + p.Desc + "//");
 }