예제 #1
0
        public JSONTileMap(TilesMap map, Scene sceneParent, float xRatio, float yRatio)
        {
            this.NbColumns            = map.NbColumns;
            this.NbLines              = map.NbLines;
            this.TilesHeight          = Convert.ToInt32(map.TilesHeight * yRatio);
            this.TilesWidth           = Convert.ToInt32(map.TilesWidth * xRatio);
            this.TilesMapName         = map.TilesMapName;
            this.Bounce               = map.Bounce;
            this.IsInfinite           = map.isInfinite;
            this.Friction             = map.Friction;
            this.Radius               = Convert.ToInt32(map.Radius * ((xRatio + yRatio) / 2));
            this.Density              = map.Density;
            this.IsPathFindingEnabled = map.IsPathFindingEnabled;
            this.isPhysicsEnabled     = map.isPhysicsEnabled;


            this.TextureCount = map.TileModelsTextureUsed.Count;
            this.ObjectCount  = map.TileModelsObjectsUsed.Count;

            if (map.TextureCountBySheet != null)
            {
                this.TextureCountBySheet = map.TextureCountBySheet.ToArray();
            }

            if (map.ObjectCountBySheet != null)
            {
                this.ObjectCountBySheet = map.ObjectCountBySheet.ToArray();
            }


            this.TextureSheetCount = map.NbTextureSheets;
            this.ObjectSheetCount  = map.NbObjectSheets;

            this.TextureSequenceCount = map.TextureSequences.Count;
            this.ObjectSequenceCount  = map.ObjectSequences.Count;

            if (map.TextureSequenceCountBySheet != null)
            {
                this.TextureSequenceCountBySheet = map.TextureSequenceCountBySheet.ToArray();
            }

            if (map.ObjectSequenceCountBySheet != null)
            {
                this.ObjectSequenceCountBySheet = map.ObjectSequenceCountBySheet.ToArray();
            }

            this.TextureSequenceSheetCount = map.NbTextureSequenceSheets;
            this.ObjectSequenceSheetCount  = map.NbObjectSequenceSheets;

            this.TextureSequences = new JSONTileSequence[map.TextureSequences.Count];
            int textureFrameCount = TextureCount;

            for (int i = 0; i < map.TextureSequences.Count; i++)
            {
                TileSequence     seq     = map.TextureSequences[i];
                JSONTileSequence seqJson = new JSONTileSequence(seq.Name.Replace(" ", ""), textureFrameCount + 1, seq.Frames.Count, seq.Lenght, seq.Iteration);
                this.TextureSequences[i] = seqJson;

                textureFrameCount = textureFrameCount + seq.Frames.Count;
            }

            this.ObjectSequences = new JSONTileSequence[map.ObjectSequences.Count];
            int objectFrameCount = this.ObjectCount;

            for (int i = 0; i < map.ObjectSequences.Count; i++)
            {
                TileSequence     seq     = map.ObjectSequences[i];
                JSONTileSequence seqJson = new JSONTileSequence(seq.Name.Replace(" ", ""), objectFrameCount + 1, seq.Frames.Count, seq.Lenght, seq.Iteration);
                this.ObjectSequences[i] = seqJson;

                objectFrameCount = objectFrameCount + seq.Frames.Count;
            }

            if (map.CollisionFilterGroupIndex + 1 <= sceneParent.CollisionFilterGroups.Count)
            {
                CollisionFilterGroup group = sceneParent.CollisionFilterGroups[map.CollisionFilterGroupIndex];
                this.CollisionCategoryBits = group.CategorieBit;
                this.CollisionMaskBits     = group.getMaskBits();
            }
            else
            {
                this.CollisionCategoryBits = 0;
                this.CollisionMaskBits     = 0;
            }
        }
예제 #2
0
        public String getCollisionFilter(int groupIndex)
        {
            if (groupIndex + 1 <= this.objectParent.LayerParent.SceneParent.CollisionFilterGroups.Count)
            {
                CollisionFilterGroup groupFilter = this.objectParent.LayerParent.SceneParent.CollisionFilterGroups[groupIndex];
                string collisionFilter           = "{ ";
                collisionFilter += "categoryBits = " + groupFilter.CategorieBit + ", maskBits = " + groupFilter.getMaskBits();
                collisionFilter += "}";
                return(collisionFilter);
            }
            else
            {
                //string collisionFilter = "{ ";
                //collisionFilter += "categoryBits = 0, maskBits = 0" ;
                //collisionFilter += "}";
                //return collisionFilter;

                return("nil");
            }
        }