Exemplo n.º 1
0
        private static void WriteBuildingReport(BuildingType bt)
        {
            string s = bt.ToString(lng) + ":";

            if (lng == Lang.En)
            {
                if (bt.DriveSkill != null)
                {
                    s += String.Format(" This is a vehicle with capacity {0} kg. It can" +
                                       " move for {1} region{2} per turn", bt.Capacity, bt.Speed,
                                       bt.Speed == 1 ? "" : "s");
                    if (bt.Fuel != null)
                    {
                        s += ", spending 1 " + bt.Fuel.ToString(1, Lang.En) + " per region";
                    }
                    s += ".";
                    if (bt.DriveSkill != null)
                    {
                        s += String.Format(" A person must know {0} to DRIVE this vehicle.",
                                           bt.DriveSkill.ToString(Lang.En));
                    }
                    if (bt.DriveTerrain != null)
                    {
                        s += " This vehicle can move in " + bt.DriveTerrain.FullNameEn + ".";
                    }
                }
                else
                {
                    s += " This is a building.";
                }

                if (bt.Defence > 0)
                {
                    s += String.Format(" This structure provides protection to first {0} persons inside.",
                                       bt.Defence);
                }

                if (bt.Radiation != 0)
                {
                    s += String.Format(" Radiation inside this structure is {0} by {1}.",
                                       bt.Radiation < 0 ? "lowered" : "raised", Math.Abs(bt.Radiation));
                }

                if (bt.Temperature != 0)
                {
                    s += String.Format(" This structure protects persons inside from {0}° cold.",
                                       bt.Temperature);
                }

                if (bt.Resource != null)
                {
                    s += String.Format(" Structure adds {0} to region resources.", bt.Resource.ToString(lng));
                }

                if (bt.HP > 0)
                {
                    s += String.Format(" It provides defence in battle and has {0} hit points.", bt.HP);
                }

                string materials = bt.Materials.ToString(lng);
                materials = materials.Substring(0, materials.Length - 1);
                s        += String.Format(" This structure requires " +
                                          materials + " to complete.");
                if (bt.OptionalMaterials.Count > 0)
                {
                    s += " Optional components are: " + bt.OptionalMaterials.ToString(lng);
                }

                if (bt.NoBuild)
                {
                    s += String.Format(" A person can't BUILD new objects of this type.");
                }
            }
            else
            {
                if (bt.DriveSkill != null)
                {
                    s += String.Format(" Это транспорт. Его грузоподъёмность {0} кг, скорость - {1} регионов за ход.",
                                       bt.Capacity, bt.Speed);
                    if (bt.Fuel != null)
                    {
                        s += " Для передвижения на 1 регион требуется 1 " + bt.Fuel.ToString(1, Lang.Ru);
                    }
                    s += ".";
                    if (bt.DriveSkill != null)
                    {
                        s += String.Format(" Для управления требуется навык {0}.",
                                           bt.DriveSkill.ToString(Lang.Ru));
                    }
                    if (bt.DriveTerrain != null)
                    {
                        s += " Машина может въезжать в " + bt.DriveTerrain.FullNameRu + ".";
                    }
                }
                else
                {
                    s += " Это здание.";
                }

                if (bt.Defence > 0)
                {
                    s += String.Format(" Находящимися внутри считаются первые {0} персонажей.",
                                       bt.Defence);
                }

                if (bt.Radiation != 0)
                {
                    s += String.Format(" Радиация внутри {0} на {1}.",
                                       bt.Radiation < 0 ? "понижена" : "повышена", Math.Abs(bt.Radiation));
                }

                if (bt.Temperature != 0)
                {
                    s += String.Format(" Объект защищает от {0}° холода.",
                                       bt.Temperature);
                }

                if (bt.HP > 0)
                {
                    s += String.Format(" Объект предоставляет защиту в бою и имеет {0} хитов.",
                                       bt.HP);
                }

                if (bt.Resource != null)
                {
                    s += String.Format(" Объект добавляет в ресурсы региона {0}.", bt.Resource.ToString(lng));
                }

                string materials = bt.Materials.ToString(lng);
                s += String.Format(" Для завершения требуется: " +
                                   materials);
                if (bt.OptionalMaterials.Count > 0)
                {
                    s += " Дополнительно можно установить: " + bt.OptionalMaterials.ToString(lng);
                }

                if (bt.NoBuild)
                {
                    s += String.Format(" Новый объект этого типа построить невозможно.");
                }
            }

            Write(s);
            Write("");
        }
Exemplo n.º 2
0
 public int Add(BuildingType item)
 {
     return(base.Add(item));
 }
Exemplo n.º 3
0
        private static void ShowBuildingType(BuildingType bt)
        {
            if (faction.ShownBuildings.Contains(bt) && !faction.BuildingsToShow.Contains(bt))
            {
                return;
            }

            XmlElement elBuildings = (XmlElement)doc.DocumentElement.SelectSingleNode("objects");
            XmlElement el          = (XmlElement)elBuildings.SelectSingleNode(
                String.Format("obj[@id='{0}']", bt.Name));

            if (el != null)
            {
                return;
            }
            el = doc.CreateElement("obj");
            elBuildings.AppendChild(el);
            el.SetAttribute("id", bt.Name);

            if (faction.Options.Lang == Lang.En)
            {
                el.SetAttribute("name", bt.FullNameEn);
            }
            else
            {
                el.SetAttribute("name", bt.FullNameRu);
            }

            if (!faction.BuildingsToShow.Contains(bt))
            {
                return;
            }

            el.SetAttribute("full", "True");

            if (bt.DriveSkill != null)
            {
                el.SetAttribute("is-vehicle", "True");
                el.SetAttribute("speed", bt.Speed.ToString());
                el.SetAttribute("capacity", bt.Capacity.ToString());
                if (bt.Fuel != null)
                {
                    AddItemAttribute(el, bt.Fuel, "fuel");
                }
                if (bt.DriveSkill != null)
                {
                    AddSkill(el, bt.DriveSkill, "drive-skill");
                }
                if (bt.DriveTerrain != null)
                {
                    AddTerrainAttribute(el, bt.DriveTerrain, "drive-terrain");
                }
            }

            if (bt.Defence > 0)
            {
                el.SetAttribute("defence", bt.Defence.ToString());
            }

            if (bt.Radiation != 0)
            {
                el.SetAttribute("radiation-inside", bt.Radiation.ToString());
            }

            if (bt.Temperature != 0)
            {
                el.SetAttribute("temperature-inside", bt.Temperature.ToString());
            }

            if (bt.Resource != null)
            {
                AddItem(el, bt.Resource, "resource");
            }

            if (bt.HP > 0)
            {
                el.SetAttribute("hp", bt.HP.ToString());
            }

            foreach (Item itm in bt.Materials)
            {
                AddItem(el, itm, "material");
            }
            foreach (Item itm in bt.OptionalMaterials)
            {
                AddItem(el, itm, "optional");
            }

            if (bt.NoBuild)
            {
                el.SetAttribute("no-build", "True");
            }
        }
Exemplo n.º 4
0
 public void ShowBuilding(BuildingType bt)
 {
     ShowBuilding(bt, false);
 }
Exemplo n.º 5
0
 private static void AddBuildingAttribute(XmlElement el, BuildingType bt, string nodeName)
 {
     el.SetAttribute(nodeName, bt.Name);
     ShowBuildingType(bt);
 }