Beispiel #1
0
        public static Entity Resolve(RealmManager manager, ushort id)
        {
            var node = manager.GameData.ObjectTypeToElement[id];
            var cls  = node.Element("Class");

            if (cls == null)
            {
                throw new ArgumentException("Invalid XML Element, field class is missing");
            }
            var type = cls.Value;

            switch (type)
            {
            case "Projectile":
                throw new Exception("Projectile should not instantiated using Entity.Resolve");

            case "Sign":
                return(new Sign(manager, id));

            case "Wall":
            case "DoubleWall":
                return(new Wall(manager, id, node));

            case "ConnectedWall":
            case "CaveWall":
                return(new ConnectedObject(manager, id));

            case "GameObject":
            case "CharacterChanger":
            case "MoneyChanger":
            case "NameChanger":
                return(new StaticObject(manager, id, StaticObject.GetHP(node), StaticObject.GetStatic(node), false, true));

            case "GuildRegister":
            case "GuildChronicle":
            case "GuildBoard":
                return(new StaticObject(manager, id, null, false, false, false));

            case "Container":
                return(new Container(manager, node));

            case "Player":
                throw new Exception("Player should not instantiated using Entity.Resolve");

            case "Character":     //Other characters means enemy
                return(new Enemy(manager, id));

            case "Portal":
            case "GuildHallPortal":
                return(new Portal(manager, id, null));

            case "ClosedVaultChest":
            case "ClosedVaultChestGold":
            case "ClosedGiftChest":
            case "VaultChest":
            case "Merchant":
                return(new Merchants(manager, id));

            case "GuildMerchant":
                return(new GuildMerchant(manager, id));

            case "ArenaGuard":
            case "ArenaPortal":
            case "MysteryBoxGround":
            case "ReskinVendor":
            case "PetUpgrader":
            case "FortuneTeller":
            case "YardUpgrader":
            case "FortuneGround":
            case "QuestRewards":
                return(new StaticObject(manager, id, null, true, false, false));

            case "Pet":
                throw new Exception("Pets should not instantiated using Entity.Resolve");

            default:
                Log.Warn("Not supported type: " + type);
                return(new Entity(manager, id));
            }
        }