Пример #1
0
        public static Scene GetScene(string name)
        {
            var filename = Path.Combine(SCENE_FOLDER, $"{name}.xml");

            var root       = new XmlRootAttribute("Scene");
            var serializer = new XmlSerializer(typeof(Scene), root);

            using (var stream = File.OpenRead(filename))
            {
                Scene scene = (Scene)serializer.Deserialize(stream);
                scene.Name = name;

                scene.Text = scene.Text.Replace("\n", Environment.NewLine); //TODO: Remove me please

                foreach (var pickup in scene.Pickups)
                {
                    if (!string.IsNullOrEmpty(pickup.ItemId))
                    {
                        pickup.Item = ItemParser.ParseItem(pickup.ItemId);
                    }
                }

                return(scene);
            }
        }
        public bool Add(string itemId)
        {
            var item = ItemParser.ParseItem(itemId);

            GameManager.Instance.State.Inventory.Add(item);

            return(true);
        }