Beispiel #1
0
        public Sage(EntityPreset preset, Player p, int initDistance, int stopDistance, string scene) : base(preset.Position, "sage", 16, 16, DrawOrder.ENTITIES)
        {
            _player       = p;
            _preset       = preset;
            _initDistance = initDistance;
            _stopDistance = stopDistance;
            _scene        = scene;

            width     = height = 10;
            offset    = Vector2.One * 3;
            Position += offset;
            immovable = true;

            AddAnimation("walk_d", CreateAnimFrameArray(0, 1), 6, true);
            AddAnimation("walk_r", CreateAnimFrameArray(2, 3), 6, true);
            AddAnimation("walk_l", CreateAnimFrameArray(2, 3), 6, true);
            AddAnimation("walk_u", CreateAnimFrameArray(4, 5), 6, true);
            AddAnimation("idle_d", CreateAnimFrameArray(6));
            AddAnimation("idle_r", CreateAnimFrameArray(7));
            AddAnimation("idle_l", CreateAnimFrameArray(7));
            AddAnimation("idle_u", CreateAnimFrameArray(8));

            Play("idle_d");
        }
Beispiel #2
0
 public DoorMapPair(EntityPreset door, string map)
 {
     Door = door;
     Map  = map;
 }
Beispiel #3
0
        public DungeonEntranceRef(EntityPreset preset, Player p) : base(preset.Position, DrawOrder.ENTITIES)
        {
            exists = false;

            _ = new DungeonEntrance(EntityManager.GetLinkGroup(preset.LinkID).Where(s => s.TypeValue == "entrance").First(), p);
        }
Beispiel #4
0
        private static void ReadEntities(string xml)
        {
            var type_lookup = (from t in Assembly.GetExecutingAssembly().GetTypes()
                               where t.IsDefined(typeof(NamedEntity), false)
                               group new { type = t, check = t.GetCustomAttribute <NamedEntity>() } by t.GetCustomAttribute <NamedEntity>().GetName(t)
                               ).ToDictionary(t => t.Key, t => t.ToList());

            HashSet <string> missing = new HashSet <string>();

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            XmlNode root = doc.FirstChild;

            List <DoorMapPair> doors = new List <DoorMapPair>();

            if (root.HasChildNodes)
            {
                for (int i = 0; i < root.ChildNodes.Count; i++)
                {
                    var map = root.ChildNodes[i];

                    string mapName = map.Attributes.GetNamedItem("name").Value;

                    if (!_entities.ContainsKey(mapName))
                    {
                        _entities.Add(mapName, new List <EntityPreset>());
                    }
                    List <EntityPreset> presets = _entities[mapName];

                    foreach (XmlNode child in map.ChildNodes)
                    {
                        if (!type_lookup.ContainsKey(child.Name))
                        {
                            if (!missing.Contains(child.Name))
                            {
                                DebugLogger.AddWarning($"Missing Entity {child.Name}!");
                                missing.Add(child.Name);
                            }
                            continue;
                        }
                        if (int.TryParse(child.Attributes.GetNamedItem("x").Value, out int x) &&
                            int.TryParse(child.Attributes.GetNamedItem("y").Value, out int y) &&
                            Guid.TryParse(child.Attributes.GetNamedItem("guid").Value, out Guid id) &&
                            int.TryParse(child.Attributes.GetNamedItem("frame").Value, out int frame))
                        {
                            Permanence p = Permanence.GRID_LOCAL;

                            if (child.Attributes.GetNamedItem("p") != null)
                            {
                                p = (Permanence)int.Parse(child.Attributes.GetNamedItem("p").Value);
                            }

                            string type = "";

                            if (child.Attributes.GetNamedItem("type") != null)
                            {
                                type = child.Attributes.GetNamedItem("type").Value;
                            }

                            bool alive = true;

                            if (child.Attributes.GetNamedItem("alive") != null)
                            {
                                alive = bool.Parse(child.Attributes.GetNamedItem("alive").Value);
                            }

                            var matching = type_lookup[child.Name].FindAll(t => t.check.Matches(frame, type)).ToList();
                            if (matching.Count == 0)
                            {
                                string missing_entity = $"{child.Name}-{frame}-'{type}'";
                                if (!missing.Contains(missing_entity))
                                {
                                    missing.Add(missing_entity);
                                    DebugLogger.AddWarning($"Missing Entity {missing_entity}!");
                                }
                            }
                            else if (matching.Count > 1)
                            {
                                DebugLogger.AddWarning($"Conflict at {child.Name}-{frame}-'{type}': " + String.Join(", ", matching.Select(t => t.type.Name)));
                            }
                            else
                            {
                                EntityPreset preset = new EntityPreset(matching[0].type, new Vector2(x, y), id, frame, p, type, alive);

                                presets.Add(preset);

                                if (child.Name == "Door")
                                {
                                    DoorMapPair newDoor = new DoorMapPair(preset, mapName);

                                    if (doors.Any(d => d.Door.Frame == preset.Frame))
                                    {
                                        DoorMapPair doorOne = doors.First(d => d.Door.Frame == preset.Frame);
                                        _doorPairs.Add(preset.Frame, new DoorPair(doorOne, newDoor));

                                        doors.Remove(doorOne);

                                        DebugLogger.AddInfo($"DOOR PAIR {preset.Frame}\n{doorOne.Door.Position.X} {doorOne.Door.Position.Y} {doorOne.Map}\n{newDoor.Door.Position.X} {newDoor.Door.Position.Y} {newDoor.Map}");
                                    }
                                    else
                                    {
                                        doors.Add(newDoor);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #5
0
 public SageBlank(EntityPreset preset, Player p) : base(preset.Position, DrawOrder.ENTITIES)
 {
     visible = false;
     _preset = preset;
 }
Beispiel #6
0
 public SageCrowd(EntityPreset preset, Player p)
     : base(preset, p, 46, 24, "one")
 {
 }
Beispiel #7
0
 public SageRedCave(EntityPreset preset, Player p)
     : base(preset, p, 28, 16, "one")
 {
 }
Beispiel #8
0
 public SageBedroom(EntityPreset preset, Player p)
     : base(preset, p, 48, 24, "after_boss")
 {
 }
Beispiel #9
0
 public Dust(EntityPreset preset, Player p) : this(preset.Position, p)
 {
 }