Ejemplo n.º 1
0
 public Organ(Organ o, float thickness, float hit_prob, string alias=null)
 {
     this.name = o.name;
     this.exclusive = o.exclusive;
     this.parts = new List<OrganPart>(o.parts);
     this.thickness = thickness;
     this.hit_prob = hit_prob;
     this.alias = alias;
 }
Ejemplo n.º 2
0
 public void AddOrgan(Organ organ)
 {
     if (!IsSymetrical)
         organs.Add(organ);
     else
     {
         organs.Insert(organs.Count / 2, organ);
         organs.Insert(organs.Count / 2, organ);
     }
 }
Ejemplo n.º 3
0
Archivo: Body.cs Proyecto: bilwis/SH2RL
        private Organ parseOrganDefinition(XmlTextReader reader)
        {
            string name = "ERROR";
            bool exclusive = false;

            List<OrganPart> parts = new List<OrganPart>();
            OrganPart temp = new OrganPart();
            bool readingPart=false;

            temp.critical = false;  //default

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        switch (reader.Name)
                        {
                            case "part":
                                if (readingPart)
                                    throw new Exception("Error while parsing body definition XML: New part element before end part element");
                                readingPart = true;
                                break;
                            case "name":
                                if (!readingPart)
                                    name = reader.ReadElementContentAsString();
                                else
                                    temp.name = reader.ReadElementContentAsString();
                                break;
                            case "exclusive":
                                exclusive = reader.ReadElementContentAsBoolean();
                                break;
                            case "hit_prob":
                                temp.hit_prob = reader.ReadElementContentAsFloat();
                                break;
                            case "pain":
                                temp.pain = reader.ReadElementContentAsFloat();
                                break;
                            case "blood_loss":
                                temp.blood_loss = reader.ReadElementContentAsFloat();
                                break;
                            case "resistance":
                                temp.resistance = reader.ReadElementContentAsFloat();
                                break;
                            case "on_hit_kill":
                                temp.critical = reader.ReadElementContentAsBoolean();
                                break;
                        }
                        break;
                    case XmlNodeType.EndElement:
                        switch (reader.Name)
                        {
                            case "part":
                                readingPart = false;
                                parts.Add(temp);
                                temp = new OrganPart();
                                break;
                            case "organ_def":
                                Organ self = new Organ(name, exclusive);
                                foreach (OrganPart op in parts)
                                {
                                    self.AddPart(op);
                                }
                                return self;
                        }
                        break;
                }
            }

            return null;
        }