Ejemplo n.º 1
0
 private void btnAddReq_Click(object sender, EventArgs e)
 {
     Requirement req = new Requirement(0, true, 0);
     AddForm window = new AddForm(true, req, null);
     window.ShowDialog();
     if (window.Ok)
     {
         LevelData level = getCurrentLevel();
         level.Requirements.Add(req);
         refreshReq();
     }
 }
Ejemplo n.º 2
0
 public AddForm(bool isreq, Requirement req, Effect eff)
 {
     this.isreq = isreq;
     Req = req;
     Eff = eff;
     InitializeComponent();
     if (!isreq)
     {
         rbAtleast.Text = "Increase by";
         rbAtmost.Text = "Decrease by";
         groupBox2.Text = "Operation";
     }
     ShowInTaskbar = false;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
 public object Clone()
 {
     Requirement r = new Requirement(Param, AtLeast, Value);
     return r;
 }
Ejemplo n.º 6
0
        public object Clone()
        {
            Requirement r = new Requirement(Param, AtLeast, Value);

            return(r);
        }