Ejemplo n.º 1
0
    private static void ReadObjects(DS1 ds1, BinaryReader reader, int act)
    {
        if (ds1.version < 2)
        {
            return;
        }
        int objectCount = reader.ReadInt32();

        //Debug.Log("Objects " + objectCount);
        ds1.objects = new ObjectSpawnInfo[objectCount];

        for (int i = 0; i < objectCount; i++)
        {
            var info = new ObjectSpawnInfo();
            int type = reader.ReadInt32();
            int id   = reader.ReadInt32();
            info.x = reader.ReadInt32();
            info.y = reader.ReadInt32();

            if (ds1.version > 5)
            {
                reader.ReadInt32(); // flags
            }

            info.preset    = SpawnPreset.Find(act, type, id);
            ds1.objects[i] = info;
        }
    }
Ejemplo n.º 2
0
        private void InstantiateShadows(DS1 ds1, int offsetX, int offsetY, Transform root)
        {
            var layerObject    = new GameObject("shadows");
            var layerTransform = layerObject.transform;

            layerTransform.SetParent(root);

            int i = 0;

            for (int y = 0; y < ds1.height - 1; ++y)
            {
                for (int x = 0; x < ds1.width - 1; ++x)
                {
                    var cell = ds1.shadows[i + x];
                    if (cell.prop1 == 0) // no tile here
                    {
                        continue;
                    }

                    if ((cell.prop4 & 0x80) != 0)
                    {
                        continue;
                    }

                    DT1.Tile tile;
                    if (ds1.tileSampler.Sample(cell.tileIndex, out tile))
                    {
                        CreateTile(tile, offsetX + x, offsetY + y, parent: layerTransform);
                    }
                }
                i += ds1.width;
            }
        }
Ejemplo n.º 3
0
        private void InstantiateSpecialTiles(DS1 ds1, int offsetX, int offsetY, Transform root)
        {
            for (int w = 0; w < ds1.walls.Length; ++w)
            {
                var layerObject    = new GameObject("special_tiles " + (w + 1));
                var layerTransform = layerObject.transform;
                layerTransform.SetParent(root);

                var cells = ds1.walls[w];
                int i     = 0;
                for (int y = 0; y < ds1.height - 1; ++y)
                {
                    for (int x = 0; x < ds1.width - 1; ++x)
                    {
                        var cell = cells[i + x];
                        if (cell.prop1 == 0) // no tile here
                        {
                            continue;
                        }

                        if (cell.orientation == 10 || cell.orientation == 11)
                        {
                            CreateSpecialTile(cell, offsetX + x, offsetY + y, parent: root);
                        }
                    }
                    i += ds1.width;
                }
            }
        }
Ejemplo n.º 4
0
    private static void ReadGroups(DS1 ds1, BinaryReader reader, int tagType)
    {
        bool hasGroups = ds1.version >= 12 && (tagType == 1 || tagType == 2);

        if (!hasGroups)
        {
            return;
        }

        if (ds1.version >= 18)
        {
            reader.ReadInt32();
        }
        int groupCount = reader.ReadInt32();

        ds1.groups = new List <Group>();

        for (int i = 0; i < groupCount; i++)
        {
            var group = new Group();
            group.x      = reader.ReadInt32();
            group.y      = reader.ReadInt32();
            group.width  = reader.ReadInt32();
            group.height = reader.ReadInt32();
            if (ds1.version >= 13)
            {
                reader.ReadInt32(); // unknown
            }
            ds1.groups.Add(group);
        }
    }
Ejemplo n.º 5
0
    void InstantiatePopups(DS1 ds1, int offsetX, int offsetY, Transform parent = null)
    {
        bool firstFound = false;
        int  x1         = 0;
        int  y1         = 0;

        for (int layerIndex = 0; layerIndex < ds1.walls.Length; ++layerIndex)
        {
            var walls = ds1.walls[layerIndex];
            int i     = 0;
            for (int y = 0; y < ds1.height; ++y)
            {
                for (int x = 0; x < ds1.width; ++x, ++i)
                {
                    if (walls[i].mainIndex == 8 && walls[i].orientation == 10)
                    {
                        if (firstFound)
                        {
                            var scanArea    = new IntRect(offsetX, offsetY, ds1.width, ds1.height);
                            var triggerArea = new IntRect(x1 + offsetX, y1 + offsetY, x - x1, y - y1);
                            var popup       = Popup.Create(triggerArea, scanArea, walls[i].subIndex);
                            popup.transform.SetParent(parent);
                            popups.Add(popup);
                            return;
                        }

                        x1         = x;
                        y1         = y;
                        firstFound = true;
                    }
                }
            }
        }
    }
Ejemplo n.º 6
0
    public LevelBuilder(string name, int gridX = -1, int gridY = -1)
    {
        info      = LevelInfo.Find(name);
        this.name = info.levelName;

        if (info.preset != null)
        {
            var ds1 = DS1.Load(info.preset.ds1Files[0]);
            this.gridX = ds1.width - 1;
            this.gridY = ds1.height - 1;
            gridWidth  = 1;
            gridHeight = 1;
            grid       = new DS1[1] {
                ds1
            };
        }
        else
        {
            if (info.maze != null)
            {
                this.gridX = info.maze.sizeX;
                this.gridY = info.maze.sizeY;
            }
            else
            {
                this.gridX = gridX;
                this.gridY = gridY;
            }
            gridWidth  = info.sizeX / this.gridX;
            gridHeight = info.sizeY / this.gridY;
            grid       = new DS1[gridWidth * gridHeight];
        }

        InitTileSampler();
    }
Ejemplo n.º 7
0
 private void Instantiate(DS1 ds1, int x, int y, Transform root)
 {
     InstantiatePopups(ds1, x, y, root);
     InstantiateFloors(ds1, x, y, root);
     InstantiateWalls(ds1, x, y, root);
     InstantiateObjects(ds1, x, y, root);
 }
Ejemplo n.º 8
0
        private void InstantiateFloors(DS1 ds1, int offsetX, int offsetY, Transform root)
        {
            var layerObject    = new GameObject("floors");
            var layerTransform = layerObject.transform;

            layerTransform.SetParent(root);

            for (int f = 0; f < ds1.floors.Length; ++f)
            {
                var floors = ds1.floors[f];
                int i      = 0;
                for (int y = 0; y < ds1.height - 1; ++y)
                {
                    for (int x = 0; x < ds1.width - 1; ++x)
                    {
                        var cell = floors[i + x];
                        if (cell.prop1 == 0) // no tile here
                        {
                            continue;
                        }

                        if ((cell.prop4 & 0x80) != 0)
                        {
                            continue;
                        }

                        if (ds1.tileSampler.Sample(cell.tileIndex, out var tile))
                        {
                            WorldState.instance.Grid.PutFloor(tile, offsetX + x, offsetY + y, f);
                        }
                    }
                    i += ds1.width;
                }
            }
        }
Ejemplo n.º 9
0
        public void Actualiser()
        {
            DS1 ds = new DS1();

            new JoueurTableAdapter().Fill(ds.Joueur);
            new EquipeTableAdapter().Fill(ds.Equipe);
            bindingSource1.DataSource = ds.Joueur.ToList <DS1.JoueurRow>();
        }
Ejemplo n.º 10
0
        public override global::System.Data.DataSet Clone()
        {
            DS1 cln = ((DS1)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Ejemplo n.º 11
0
 private void Instantiate(DS1 ds1, int x, int y, Transform root)
 {
     UnityEngine.Profiling.Profiler.BeginSample("LevelBuilder.InstantiateDS1");
     InstantiatePopups(ds1, x, y, root);
     InstantiateFloors(ds1, x, y, root);
     InstantiateWalls(ds1, x, y, root);
     InstantiateObjects(ds1, x, y, root);
     UnityEngine.Profiling.Profiler.EndSample();
 }
Ejemplo n.º 12
0
    private void InstantiateWalls(DS1 ds1, int offsetX, int offsetY, Transform root)
    {
        for (int w = 0; w < ds1.walls.Length; ++w)
        {
            var layerObject    = new GameObject("walls " + (w + 1));
            var layerTransform = layerObject.transform;
            layerTransform.SetParent(root);
            var sampler = ds1.tileSampler;

            var cells = ds1.walls[w];
            int i     = 0;
            for (int y = 0; y < ds1.height - 1; ++y)
            {
                for (int x = 0; x < ds1.width - 1; ++x)
                {
                    var cell = cells[i + x];
                    if (cell.prop1 == 0) // no tile here
                    {
                        continue;
                    }

                    DT1.Tile tile;

                    if (cell.orientation == 10 || cell.orientation == 11)
                    {
                        CreateSpecialTile(cell, offsetX + x, offsetY + y, parent: root);
                        continue;
                    }

                    if (sampler.Sample(cell.tileIndex, out tile))
                    {
                        var renderer = CreateTile(tile, offsetX + x, offsetY + y, parent: layerTransform);
                        PutToPopup(cell, renderer, offsetX + x, offsetY + y);
                    }
                    else
                    {
                        Debug.LogWarning("wall tile not found (index " + cell.mainIndex + " " + cell.subIndex + " " + cell.orientation + ") at " + x + ", " + y);
                    }

                    if (cell.orientation == 3)
                    {
                        int orientation = 4;
                        int index       = DT1.Tile.Index(cell.mainIndex, cell.subIndex, orientation);
                        if (sampler.Sample(index, out tile))
                        {
                            CreateTile(tile, offsetX + x, offsetY + y, parent: layerTransform);
                        }
                        else
                        {
                            Debug.LogWarning("wall tile not found (index " + cell.mainIndex + " " + cell.subIndex + " " + orientation + ") at " + x + ", " + y);
                        }
                    }
                }
                i += ds1.width;
            }
        }
    }
Ejemplo n.º 13
0
 private void Instantiate(DS1 ds1, int x, int y, Transform root)
 {
     Profiler.BeginSample("LevelBuilder.InstantiateDS1");
     InstantiatePopups(ds1, x, y, root);
     InstantiateFloors(ds1, x, y, root);
     InstantiateShadows(ds1, x, y, root);
     InstantiateSpecialTiles(ds1, x, y, root);
     InstantiateWalls(ds1, x, y, root);
     InstantiateObjects(ds1, x, y, root);
     Profiler.EndSample();
 }
Ejemplo n.º 14
0
    static DS1 Load(byte[] bytes)
    {
        using (var stream = new MemoryStream(bytes))
            using (var reader = new BinaryReader(stream))
            {
                DS1 ds1 = new DS1();
                ds1.version = reader.ReadInt32();
                ds1.width   = reader.ReadInt32() + 1;
                ds1.height  = reader.ReadInt32() + 1;

                int act = 0;
                if (ds1.version >= 8)
                {
                    act = reader.ReadInt32();
                    act = Mathf.Min(act, 4);
                }

                int tagType = 0;
                if (ds1.version >= 10)
                {
                    tagType = reader.ReadInt32();
                }

                if (ds1.version >= 3)
                {
                    Palette.LoadPalette(act);
                    ds1.dt1Files    = ReadDependencies(reader);
                    ds1.tileSampler = new DT1.Sampler();
                    foreach (var dt1Filename in ds1.dt1Files)
                    {
                        var dt1 = DT1.Load(dt1Filename);
                        ds1.tileSampler.Add(dt1.tiles);
                    }
                }

                if ((ds1.version >= 9) && (ds1.version <= 13))
                {
                    stream.Seek(8, SeekOrigin.Current);
                }

                ReadLayers(ds1, bytes, reader, stream, tagType);
                ReadObjects(ds1, reader, act);
                try
                {
                    ReadGroups(ds1, reader, tagType);
                }
                catch (EndOfStreamException)
                {
                    // in fact there can be less groups than expected
                }

                return(ds1);
            }
    }
Ejemplo n.º 15
0
    public void Place(LevelPreset preset, Vector2i pos, int minIndex = 0, int maxIndex = -1)
    {
        if (maxIndex == -1)
        {
            maxIndex = preset.ds1Files.Count;
        }
        var ds1Filename = preset.ds1Files[Random.Range(minIndex, maxIndex)];
        var ds1         = DS1.Load(ds1Filename);

        Place(ds1, pos);
    }
Ejemplo n.º 16
0
 public LevelBuilder(DS1 ds1)
 {
     name = System.IO.Path.GetFileName(ds1.filename);
     grid = new DS1[1] {
         ds1
     };
     gridWidth  = 1;
     gridHeight = 1;
     gridX      = ds1.width - 1;
     gridY      = ds1.height - 1;
 }
Ejemplo n.º 17
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            DS1 ds = new DS1();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
Ejemplo n.º 18
0
 protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
 {
     DS1.SelectCommand = "SELECT * FROM REGISTER WHERE Username = '******' AND Password = '******'";
     //DS1.Select(DataSourceSelectArguments.Empty);
     if (DS1.Select(DataSourceSelectArguments.Empty).GetEnumerator().MoveNext())
     {
         System.Web.Security.FormsAuthentication.RedirectFromLoginPage(login_1.UserName, false);
     }
     else
     {
         login_1.FailureText = "Invalid Login";
     }
 }
Ejemplo n.º 19
0
 protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
 {
     DS1.SelectCommand = "SELECT * FROM [User] WHERE username = '******' AND password = '******'";
     if (DS1.Select(DataSourceSelectArguments.Empty).GetEnumerator().MoveNext())
     {
         System.Web.Security.FormsAuthentication.RedirectFromLoginPage(Login.UserName, false);
     }
     else
     {
         Login.FailureText = "Invalid Login,check your input!";
     }
 }
Ejemplo n.º 20
0
        static LevelBuilder CreateBloodMoor()
        {
            var bloodMoor   = new LevelBuilder("Act 1 - Wilderness 1", 8, 8);
            var riverN      = DS1.Load(@"data\global\tiles\act1\outdoors\UriverN.ds1");
            var uRiver      = DS1.Load(@"data\global\tiles\act1\outdoors\Uriver.ds1");
            var lRiver      = DS1.Load(@"data\global\tiles\act1\outdoors\Lriver.ds1");
            var bord1       = LevelPreset.Find("Act 1 - Wild Border 1");
            var bord2       = LevelPreset.Find("Act 1 - Wild Border 2");
            var bord3       = LevelPreset.Find("Act 1 - Wild Border 3");
            var bord5       = LevelPreset.Find("Act 1 - Wild Border 5");
            var bord6       = LevelPreset.Find("Act 1 - Wild Border 6");
            var bord9       = LevelPreset.Find("Act 1 - Wild Border 9");
            var cottage     = LevelPreset.Find("Act 1 - Cottages 1");
            var denEntrance = LevelPreset.Find("Act 1 - DOE Entrance");

            for (int i = 0; i < bloodMoor.gridHeight; ++i)
            {
                bloodMoor.Place(lRiver, new Vector2i(bloodMoor.gridWidth - 1, i));
            }
            for (int i = 1; i < bloodMoor.gridHeight; ++i)
            {
                bloodMoor.Place(uRiver, new Vector2i(bloodMoor.gridWidth - 2, i));
            }
            bloodMoor.Place(riverN, new Vector2i(bloodMoor.gridWidth - 2, 0));

            for (int i = 1; i < bloodMoor.gridHeight - 1; ++i)
            {
                bloodMoor.Place(bord2, new Vector2i(0, i), 0, 3);
            }
            bloodMoor.Place(bord5, new Vector2i(0, bloodMoor.gridHeight - 1));

            for (int i = 1; i < 3; ++i)
            {
                bloodMoor.Place(bord1, new Vector2i(i, bloodMoor.gridHeight - 1), 0, 3);
            }
            bloodMoor.Place(bord9, new Vector2i(3, bloodMoor.gridHeight - 1));

            for (int i = 1; i < bloodMoor.gridWidth - 2; ++i)
            {
                bloodMoor.Place(bord3, new Vector2i(i, 0), 0, 3);
            }

            bloodMoor.Place(bord6, new Vector2i(0, 0));
            for (int i = 1; i < 5; ++i)
            {
                bloodMoor.Place(cottage, new Vector2i(i, 4 + Random.Range(-1, 1)));
            }
            bloodMoor.Place(denEntrance, new Vector2i(5, 7));

            return(bloodMoor);
        }
Ejemplo n.º 21
0
        static public void LoadDS1()
        {
            var assetPath = AssetDatabase.GetAssetPath(Selection.activeObject);

            if (!Application.isPlaying)
            {
                DT1.ResetCache();
                DS1.ResetCache();
            }
            var ds1   = DS1.Load(assetPath, mpq: false);
            var level = new LevelBuilder(ds1);

            level.Instantiate(new Vector2i(0, 0));
        }
Ejemplo n.º 22
0
    private void InstantiateObjects(DS1 ds1, int offsetX, int offsetY, Transform root)
    {
        offsetX *= Iso.SubTileCount;
        offsetY *= Iso.SubTileCount;
        int monsterLevel = info != null ? info.id : 1;

        foreach (var spawnInfo in ds1.objects)
        {
            bool created = CreateObject(spawnInfo.preset, offsetX + spawnInfo.x, offsetY + spawnInfo.y, monsterLevel, root);
            if (!created)
            {
                Debug.LogWarning("Object not instantiated " + spawnInfo.preset.description);
            }
        }
    }
Ejemplo n.º 23
0
        private void InstantiateObjects(DS1 ds1, int offsetX, int offsetY, Transform root)
        {
            offsetX *= Iso.SubTileCount;
            offsetY *= Iso.SubTileCount;
            int monsterLevel = info != null ? info.id : 1;

            foreach (var spawnInfo in ds1.objects)
            {
                var  preset  = spawnInfo.preset;
                bool created = CreateObject(preset, offsetX + spawnInfo.x, offsetY + spawnInfo.y, monsterLevel, root);
                if (!created)
                {
                    Debug.LogWarning("Failed to instantiate objects from \"" + ds1.filename + "\" act " + preset.act + ", type " + preset.type + ", id " + preset.id);
                }
            }
        }
Ejemplo n.º 24
0
        private void InstantiateWalls(DS1 ds1, int offsetX, int offsetY, Transform root)
        {
            for (int w = 0; w < ds1.walls.Length; ++w)
            {
                var layerObject    = new GameObject("walls " + (w + 1));
                var layerTransform = layerObject.transform;
                layerTransform.SetParent(root);
                var sampler = ds1.tileSampler;

                var cells = ds1.walls[w];
                int i     = 0;
                for (int y = 0; y < ds1.height - 1; ++y)
                {
                    for (int x = 0; x < ds1.width - 1; ++x)
                    {
                        var cell = cells[i + x];
                        if (cell.prop1 == 0) // no tile here
                        {
                            continue;
                        }

                        if (cell.orientation == 10 || cell.orientation == 11)  // special tiles
                        {
                            continue;
                        }

                        if (sampler.Sample(cell.tileIndex, out var tile))
                        {
                            WorldState.instance.Grid.PutWall(tile, offsetX + x, offsetY + y, w);
                        }

                        if (cell.orientation == 3)
                        {
                            int orientation = 4;
                            int index       = DT1.Tile.Index(cell.mainIndex, cell.subIndex, orientation);
                            if (sampler.Sample(index, out tile))
                            {
                                WorldState.instance.Grid.PutWall(tile, offsetX + x, offsetY + y, w + 1);
                            }
                        }
                    }
                    i += ds1.width;
                }
            }
        }
Ejemplo n.º 25
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     DS1 ds = new DS1();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
Ejemplo n.º 26
0
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                DS1 ds = new DS1();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "BillsDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }
Ejemplo n.º 27
0
 protected void LoginX_Authenticate(object sender, AuthenticateEventArgs e)
 {
     DS1.SelectCommand = "SELECT * FROM [user] WHERE [user_name] = '" + LoginX.UserName +
                         "' AND [password] = '" + LoginX.Password + "'";
     DS1.Select(DataSourceSelectArguments.Empty);
 }
Ejemplo n.º 28
0
    static void ReadLayers(DS1 ds1, byte[] bytes, BinaryReader reader, Stream stream, int tagType)
    {
        int wallLayerCount   = 1;
        int floorLayerCount  = 1;
        int shadowLayerCount = 1;
        int tagLayerCount    = 0;

        if (ds1.version >= 4)
        {
            wallLayerCount = reader.ReadInt32();

            if (ds1.version >= 16)
            {
                floorLayerCount = reader.ReadInt32();
            }
        }
        else
        {
            tagLayerCount = 1;
        }

        if ((tagType == 1) || (tagType == 2))
        {
            tagLayerCount = 1;
        }

        //Debug.Log("layers : (2 * " + wallLayerCount + " walls) + " + floorLayerCount + " floors + " + shadowLayerCount + " shadow + " + tagLayerCount + " tag");

        ds1.floors = new Cell[floorLayerCount][];
        for (int i = 0; i < floorLayerCount; ++i)
        {
            ds1.floors[i] = new Cell[ds1.width * ds1.height];
        }

        ds1.walls = new Cell[wallLayerCount][];
        for (int i = 0; i < wallLayerCount; ++i)
        {
            ds1.walls[i] = new Cell[ds1.width * ds1.height];
        }

        if (ds1.version < 4)
        {
            ReadCells(ds1.walls[0], bytes, stream);
            ReadCells(ds1.floors[0], bytes, stream);
            ReadOrientations(ds1.walls[0], bytes, stream);
            stream.Seek(4 * ds1.width * ds1.height, SeekOrigin.Current); // tag
            stream.Seek(4 * ds1.width * ds1.height, SeekOrigin.Current); // shadow
        }
        else
        {
            for (int i = 0; i < wallLayerCount; i++)
            {
                ReadCells(ds1.walls[i], bytes, stream);
                ReadOrientations(ds1.walls[i], bytes, stream);
            }
            for (int i = 0; i < floorLayerCount; i++)
            {
                ReadCells(ds1.floors[i], bytes, stream);
            }
            if (shadowLayerCount != 0)
            {
                stream.Seek(4 * ds1.width * ds1.height, SeekOrigin.Current); // shadow
            }
            if (tagLayerCount != 0)
            {
                stream.Seek(4 * ds1.width * ds1.height, SeekOrigin.Current); // tag
            }
        }

        for (int w = 0; w < wallLayerCount; w++)
        {
            var cells = ds1.walls[w];
            int i     = 0;
            for (int y = 0; y < ds1.height; y++)
            {
                for (int x = 0; x < ds1.width; x++, i++)
                {
                    var cell = cells[i];
                    if (cell.prop1 == 0)
                    {
                        continue;
                    }

                    if (ds1.version < 7)
                    {
                        cell.orientation = dirLookup[cell.orientation];
                    }

                    cell.mainIndex = (cell.prop3 >> 4) + ((cell.prop4 & 0x03) << 4);
                    cell.subIndex  = cell.prop2;
                    cell.tileIndex = DT1.Tile.Index(cell.mainIndex, cell.subIndex, cell.orientation);

                    cells[i] = cell;
                }
            }
        }

        for (int f = 0; f < floorLayerCount; f++)
        {
            var cells = ds1.floors[f];
            for (int i = 0; i < cells.Length; i++)
            {
                var cell = cells[i];

                if (cell.prop1 == 0)
                {
                    continue;
                }

                cell.mainIndex   = (cell.prop3 >> 4) + ((cell.prop4 & 0x03) << 4);
                cell.subIndex    = cell.prop2;
                cell.orientation = 0;
                cell.tileIndex   = DT1.Tile.Index(cell.mainIndex, cell.subIndex, cell.orientation);

                cells[i] = cell;
            }
        }
    }
Ejemplo n.º 29
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     DS1 ds = new DS1();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "TFolderKaitaiDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
Ejemplo n.º 30
0
        void InstantiatePopups(DS1 ds1, int offsetX, int offsetY, Transform parent = null)
        {
            var startPos   = new Vector2i[7];
            var firstFound = new bool[7];

            for (int layerIndex = 0; layerIndex < ds1.walls.Length; ++layerIndex)
            {
                var walls = ds1.walls[layerIndex];
                int i     = 0;
                for (int y = 0; y < ds1.height; ++y)
                {
                    for (int x = 0; x < ds1.width; ++x, ++i)
                    {
                        if (walls[i].orientation != 10)
                        {
                            continue;
                        }
                        int mainIndex = walls[i].mainIndex;
                        int group;
                        // TODO merge 8, 9, 10
                        // TODO merge 12, 13
                        if (mainIndex == 8)
                        {
                            group = 0;
                        }
                        else if (mainIndex == 9)
                        {
                            group = 1;
                        }
                        else if (mainIndex == 10)
                        {
                            group = 2;
                        }
                        else if (mainIndex == 12)
                        {
                            group = 3;
                        }
                        else if (mainIndex == 13)
                        {
                            group = 4;
                        }
                        else if (mainIndex == 16)
                        {
                            group = 5;
                        }
                        else if (mainIndex == 20)
                        {
                            group = 6;
                        }
                        else
                        {
                            continue;
                        }

                        if (firstFound[group])
                        {
                            int x1          = startPos[group].x;
                            int y1          = startPos[group].y;
                            int width       = x - x1;
                            int height      = y - y1;
                            var triggerArea = new IntRect(x1 + offsetX, y1 + offsetY, width, height);
                            var revealArea  = new IntRect(
                                x1 + offsetX - 1,
                                y1 + offsetY - 1,
                                width + 3,
                                height + 3
                                );
                            var popup = Popup.Create(triggerArea, revealArea, walls[i].subIndex);
                            popup.gameObject.name += "_pad" + popPad;  // TODO use popPad to adjust triggerArea
                            popup.transform.SetParent(parent);
                            popups.Add(popup);
                        }
                        else
                        {
                            startPos[group]   = new Vector2i(x, y);
                            firstFound[group] = true;
                        }
                    }
                }
            }
        }
Ejemplo n.º 31
0
 public void Place(DS1 ds1, Vector2i pos)
 {
     Debug.Assert(ds1.width - 1 == gridX);
     Debug.Assert(ds1.height - 1 == gridY);
     grid[pos.y * gridWidth + pos.x] = ds1;
 }