private List<string> BonusListMaker(Brute brute, String name)
 {
     List<string> tmp = new List<string>();
     for (int i = 0; i < brute.BonusList.Count; i++)
     {
         tmp.Add(name + i + ".png");
     }
     return tmp;
 }
 public bool GetBonus(int nbBonus, Brute brute)
 {
     if (this.GetReader().ReadDiscriminant() == ProtocoleImplementation.ANSWER_KO)
         return false;
     else
     {
         String[] tmp = this.GetReader().ReadStringParam();
         brute.BonusList.Add(new Bonus(tmp));
         if(MyBrute.Name.Equals(brute.Name))
             this.GetReader().ReadImage("BruteBonus" + nbBonus +".png");
         else
             this.GetReader().ReadImage("OtherBruteBonus" + nbBonus + ".png");
         return true;
     }
 }
        public static Dictionary<String, Brute> Read()
        {
            Dictionary<String, Brute> brutes = new Dictionary<String, Brute>();
            Console.WriteLine(File.Exists("Users.xml"));
            if(File.Exists("Users.xml"))
            {
                XmlTextReader xml = new XmlTextReader("Users.xml");
                while (xml.Read())
                {
                    if (xml.Name.Equals("Brute") && (xml.NodeType == XmlNodeType.Element))
                    {
                        xml.Read();
                        String name = xml.ReadElementString("Name");
                        short level = Convert.ToInt16(xml.ReadElementString("Level"));
                        short life = Convert.ToInt16(xml.ReadElementString("Life"));
                        short strength = Convert.ToInt16(xml.ReadElementString("Strength"));
                        short agility = Convert.ToInt16(xml.ReadElementString("Agility"));
                        short speed = Convert.ToInt16(xml.ReadElementString("Speed"));
                        int image = Convert.ToInt32(xml.ReadElementString("Image"));
                        Brute brute = new Brute(name, level, life, strength, agility, speed, image);
                        if(xml.Name.Equals("BonusList") && (xml.NodeType == XmlNodeType.Element))
                        {
                            XmlReader inner = xml.ReadSubtree();
                            while (inner.Read())
                            {
                                if (inner.Name.Equals("Bonus") && (xml.NodeType == XmlNodeType.Element))
                                {
                                    xml.Read();
                                    name = xml.ReadElementString("Name");
                                    life = Convert.ToInt16(xml.ReadElementString("Life"));
                                    strength = Convert.ToInt16(xml.ReadElementString("Strength"));
                                    agility = Convert.ToInt16(xml.ReadElementString("Agility"));
                                    speed = Convert.ToInt16(xml.ReadElementString("Speed"));
                                    image = Convert.ToInt32(xml.ReadElementString("Image"));
                                    brute.BonusList.Add(new Bonus(name, life, strength, agility, speed, image));
                                }
                            }
                            inner.Close();
                            Console.WriteLine(brute.ToString());
                        }
                        brutes.Add(brute.Name, brute);
                    }

                }
                xml.Close();
            }
            return brutes;
        }
Exemple #4
0
 public void GetOpponent(String name)
 {
     Console.WriteLine("GetOpponent");
      Brute tmp = new Brute(); bool OtherBrute = true;
      while (OtherBrute)
      {
         tmp = SocketServer.listBrute.ElementAt(new Random().Next(0,SocketServer.listBrute.Count)).Value;
         OtherBrute = tmp.Name.Equals(name);
      }
      this.GetWriter.CreateDiscriminant(ProtocoleImplementation.ANSWER_DOWNLOAD_BRUTE);
      this.GetWriter.CreateString(tmp.getParam());
      this.GetWriter.CreateDiscriminant(ProtocoleImplementation.ANSWER_DOWNLOAD_BRUTE_IMG);
      this.GetWriter.CreateImage("../../res/perso/Perso-" + tmp.Image + ".jpg");
      this.GetWriter.CreateLongInt(tmp.BonusList.Count);
      foreach (Bonus bonus in tmp.BonusList) { this.GetBonus(bonus.Name); }
      this.GetWriter.Send();
      Console.WriteLine("FinGetOpponent");
 }
Exemple #5
0
 public void NewBrute(String name)
 {
     Console.WriteLine("NewBrute");
      if(!SocketServer.listBrute.ContainsKey(name))
      {
          Brute brute = new Brute(name);
          brute.randomValue();
          SocketServer.listBrute.Add(name,brute);
          this.GetWriter.CreateDiscriminant(ProtocoleImplementation.ANSWER_OK);
     }
      else
          this.GetWriter.CreateDiscriminant(ProtocoleImplementation.ANSWER_KO);
      this.GetWriter.Send();
      Console.WriteLine("NewBrute");
 }
 private List<string> StatBruteMaker(Brute brute)
 {
     List<String> tmp = new List<String>();
     tmp.Add(Convert.ToString(brute.Level));
     tmp.Add(Convert.ToString(brute.Life));
     tmp.Add(Convert.ToString(brute.Strength));
     tmp.Add(Convert.ToString(brute.Agility));
     tmp.Add(Convert.ToString(brute.Speed));
     return tmp;
 }