Advertisement
InanZen

AutoBossSpawner-Config.cs

Feb 13th, 2012
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.79 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using Newtonsoft.Json;
  5.  
  6. namespace AutoBossSpawner
  7. {
  8.     public class BossObj
  9.     {
  10.         public int id;
  11.         public int amt;
  12.         public BossObj(int i, int a)
  13.         {
  14.             id = i;
  15.             amt = a;
  16.         }
  17.     }
  18.     public class BossSet
  19.     {
  20.         public int setID = -1;
  21.         public List<BossObj> bosses;
  22.         public BossSet(int id, List<BossObj> bosses)
  23.         {
  24.             setID = id;
  25.             this.bosses = bosses;
  26.         }
  27.     }
  28.     public class ABSconfig
  29.     {
  30.         public bool BossStartEnabled = false;
  31.         public int BossTimer = 30;
  32.         public string BossText = "Nightly Boss battle in Arena starting in 30 seconds";
  33.         public string BossText10s = "Nightly Boss battle in Arena starting in 10 seconds";
  34.         public string BossText0s = "Boss battle in Arena has begun!";
  35.         public string BossDefeat = "All Bosses have been defeated. That's it for tonight.";
  36.         public bool BossContinuous = false;
  37.         public bool MinionsAnnounce = true;
  38.         public int MinionsTimer = 20;
  39.         public int[] MinionsMinMax = { 10, 30 };        
  40.         public int[] MinionsList = { 2, 6, 16, 23, 24, 28, 29, 31, 32, 34, 42, 44, 45, 48, 59, 60, 62, 71, 75, 77, 78, 81, 82, 83, 84, 85, 86, 93, 104, 110, 111, 120, 121, 122, 133, 137, 138, 140, 141, 143, 144 };
  41.         public List<BossSet> BossList;
  42.  
  43.         public static ABSconfig Read(string path)
  44.         {
  45.             if (!File.Exists(path))
  46.                 return new ABSconfig();
  47.             using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
  48.             {
  49.                 return Read(fs);
  50.             }
  51.         }
  52.  
  53.         public static ABSconfig Read(Stream stream)
  54.         {
  55.             using (var sr = new StreamReader(stream))
  56.             {
  57.                 var cf = JsonConvert.DeserializeObject<ABSconfig>(sr.ReadToEnd());
  58.                 if (ConfigRead != null)
  59.                     ConfigRead(cf);
  60.                 return cf;
  61.             }
  62.         }
  63.  
  64.         public void Write(string path)
  65.         {
  66.             using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write))
  67.             {
  68.                 Write(fs);
  69.             }
  70.         }
  71.  
  72.         public void Write(Stream stream)
  73.         {
  74.             BossList = new List<BossSet>();
  75.             List<BossObj> bossSet = new List<BossObj>();
  76.             bossSet.Add(new BossObj(4, 5));
  77.             bossSet.Add(new BossObj(70, 5));
  78.             BossList.Add(new BossSet(1, bossSet));
  79.  
  80.             bossSet = new List<BossObj>();
  81.             bossSet.Add(new BossObj(134, 1));
  82.             bossSet.Add(new BossObj(70, 5));
  83.             BossList.Add(new BossSet(2, bossSet));
  84.  
  85.             bossSet = new List<BossObj>();
  86.             bossSet.Add(new BossObj(125, 1));
  87.             bossSet.Add(new BossObj(126, 1));
  88.             bossSet.Add(new BossObj(70, 5));
  89.             BossList.Add(new BossSet(3, bossSet));
  90.  
  91.             bossSet = new List<BossObj>();
  92.             bossSet.Add(new BossObj(127, 1));
  93.             bossSet.Add(new BossObj(70, 5));
  94.             BossList.Add(new BossSet(4, bossSet));
  95.  
  96.             bossSet = new List<BossObj>();
  97.             bossSet.Add(new BossObj(134, 2));
  98.             BossList.Add(new BossSet(5, bossSet));
  99.  
  100.             bossSet = new List<BossObj>();
  101.             bossSet.Add(new BossObj(50, 5));
  102.             bossSet.Add(new BossObj(70, 5));
  103.             BossList.Add(new BossSet(6, bossSet));
  104.  
  105.             var str = JsonConvert.SerializeObject(this, Formatting.Indented);
  106.             using (var sw = new StreamWriter(stream))
  107.             {
  108.                 sw.Write(str);
  109.             }
  110.         }
  111.         public static Action<ABSconfig> ConfigRead;
  112.     }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement