示例#1
0
文件: TilesMap.cs 项目: nadar71/Krea
        public string createJSONConfigFile(Scene sceneParent, string folderDest, float xRatio, float yRatio)
        {
            string fileNameDest = folderDest +"\\"+this.TilesMapName+"jsonconfig.json";

            JSONTileMap jsonMap = new JSONTileMap(this,sceneParent,xRatio,yRatio);
            jsonMap.serialize(folderDest,this);

            //Create the last modified file time for this tilesmap
            int year = DateTime.Now.Year;
            int month = DateTime.Now.Month;
            int day = DateTime.Now.Day;
            int hour = DateTime.Now.Hour;
            int minute = DateTime.Now.Minute;
            int second = DateTime.Now.Second;

            int result = getSecondsFromDateSince2000(year, month, day, hour, minute, second);

            File.WriteAllText(folderDest + "\\" + this.TilesMapName.ToLower() + "lastmodifiedtime.txt", result.ToString());

            return fileNameDest;
        }
示例#2
0
文件: TilesMap.cs 项目: nadar71/Krea
        public bool reloadMapContent(string folder)
        {
            try
            {
                if (this.TextureSequences == null)
                    this.TextureSequences = new List<TileSequence>();

                if (this.ObjectSequences == null)
                    this.ObjectSequences = new List<TileSequence>();

                if (this.TileEvents == null)
                    this.TileEvents = new List<TileEvent>();

                this.UpdateTileMapGraphicsContent();

                //Creer le tableau a 2D des tiles
                this.TabTiles = new Tile[this.NbLines, this.NbColumns];

                JSONTileMap jsonMap = new JSONTileMap();
                jsonMap.deserialize(folder, this);
                jsonMap = null;

                for (int i = 0; i < this.NbLines; i++)
                {
                    for (int j = 0; j < this.NbColumns; j++)
                    {
                        Tile tile = new Tile(i, j, this.TilesWidth, this.TilesHeight, true, this) ;
                        int indexTileInTab = i * this.NbColumns + j;

                        if (this.textureContent != null)
                        {
                            int indexTexture = this.textureContent[indexTileInTab];
                            if (indexTexture > -1 && this.TileModelsTextureUsed.Count > indexTexture)
                            {

                                tile.setTexture(this.TileModelsTextureUsed[indexTexture]);
                            }

                        }

                        if (this.objectContent != null)
                        {
                            int indexObject = this.objectContent[indexTileInTab];
                            if (indexObject > -1 && this.TileModelsObjectsUsed.Count > indexObject)
                                tile.setObjectImage(this.TileModelsObjectsUsed[indexObject]);

                        }

                        if (this.textureSequenceContent != null)
                        {
                            int indexSequenceTexture = this.textureSequenceContent[indexTileInTab];
                            if (indexSequenceTexture > -1 && this.TextureSequences.Count > indexSequenceTexture)
                                tile.setTextureSequence(this.TextureSequences[indexSequenceTexture]);
                        }

                        if (this.objectSequenceContent != null)
                        {
                            int indexSequenceObject = this.objectSequenceContent[indexTileInTab];
                            if (indexSequenceObject > -1 && this.ObjectSequences.Count > indexSequenceObject)
                                tile.setObjectSequence(this.ObjectSequences[indexSequenceObject]);

                        }

                        if (this.collisionContent != null)
                        {
                            int collide = this.collisionContent[indexTileInTab];
                            if (collide == 0)
                                tile.IsCrossable = true;
                            else
                                tile.IsCrossable = false;

                        }

                        if (this.eventContent != null)
                        {
                            int indexEvent = this.eventContent[indexTileInTab];
                            if (indexEvent > -1 && this.TileEvents.Count > indexEvent)
                                tile.setEvent(this.TileEvents[indexEvent]);

                        }
                        this.TabTiles[i, j] = tile;

                    }
                }

                return true;
            }
            catch(Exception ex)
            {
                return false;
            }
        }