Ejemplo n.º 1
0
 public Session(AreaKey area, string checkpoint = null, AreaStats oldStats = null)
     : this()
 {
     this.Area            = area;
     this.StartCheckpoint = checkpoint;
     this.ColorGrade      = this.MapData.Data.ColorGrade;
     this.Dreaming        = AreaData.Areas[area.ID].Dreaming;
     //this.Inventory = AreaData.GetCheckpointInventory(area, checkpoint);
     this.CoreMode   = AreaData.Areas[area.ID].CoreMode;
     this.FirstLevel = true;
     //this.Audio = this.MapData.ModeData.AudioState.Clone();
     if (this.StartCheckpoint == null)
     {
         this.Level = this.MapData.StartLevel().Name;
         this.StartedFromBeginning = true;
     }
     else
     {
         this.Level = this.StartCheckpoint;
         this.StartedFromBeginning = false;
         this.Dreaming             = AreaData.GetCheckpointDreaming(area, checkpoint);
         this.CoreMode             = AreaData.GetCheckpointCoreMode(area, checkpoint);
         //AudioState checkpointAudioState = AreaData.GetCheckpointAudioState(area, checkpoint);
         //if (checkpointAudioState != null)
         //{
         //    if (checkpointAudioState.Music != null)
         //        this.Audio.Music = checkpointAudioState.Music.Clone();
         //    if (checkpointAudioState.Ambience != null)
         //        this.Audio.Ambience = checkpointAudioState.Ambience.Clone();
         //}
         string checkpointColorGrading = AreaData.GetCheckpointColorGrading(area, checkpoint);
         if (checkpointColorGrading != null)
         {
             this.ColorGrade = checkpointColorGrading;
         }
         CheckpointData checkpoint1 = AreaData.GetCheckpoint(area, checkpoint);
         if (checkpoint1 != null && checkpoint1.Flags != null)
         {
             foreach (string flag in checkpoint1.Flags)
             {
                 this.SetFlag(flag, true);
             }
         }
     }
     //if (oldStats != null)
     //    this.OldStats = oldStats;
     //else
     //    this.OldStats = SaveData.Instance.Areas[this.Area.ID].Clone();
 }
Ejemplo n.º 2
0
 public void CleanCheckpoints()
 {
     foreach (AreaMode areaMode in Enum.GetValues(typeof(AreaMode)))
     {
         if ((AreaMode)AreaData.Get(this.ID).Mode.Length > areaMode)
         {
             AreaModeStats    mode           = this.Modes[(int)areaMode];
             ModeProperties   modeProperties = AreaData.Get(this.ID).Mode[(int)areaMode];
             HashSet <string> stringSet      = new HashSet <string>((IEnumerable <string>)mode.Checkpoints);
             mode.Checkpoints.Clear();
             if (modeProperties != null && modeProperties.Checkpoints != null)
             {
                 foreach (CheckpointData checkpoint in modeProperties.Checkpoints)
                 {
                     if (stringSet.Contains(checkpoint.Level))
                     {
                         mode.Checkpoints.Add(checkpoint.Level);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
        //加载关卡数据
        private void LoadingThread()
        {
            //MapData表示整个地图的数据
            MapData mapData = this.session.MapData;

            AreaData areaData = AreaData.Get(this.session.Area.ID);

            //if (this.session.Area.ID == 0)
            //    SaveData.Instance.Assists.DashMode = Assists.DashModes.Normal;
            //this.Level.Add((Monocle.Renderer)(this.Level.Background = new BackdropRenderer()));
            //this.Level.Add((Entity)new DustEdges());
            //this.Level.Add((Entity)new WaterSurface());
            //this.Level.Add((Entity)new MirrorSurfaces());
            //this.Level.Add((Entity)new GlassBlockBg());
            //this.Level.Add((Entity)new LightningRenderer());
            //this.Level.Add((Entity)new SeekerBarrierRenderer());
            this.Level.Background           = new BackdropRenderer();
            this.Level.BackgroundColor      = mapData.BackgroundColor;
            this.Level.Background.Backdrops = mapData.CreateBackdrops(mapData.Background);
            foreach (Backdrop backdrop in this.Level.Background.Backdrops)
            {
                backdrop.Renderer = this.Level.Background;
            }
            //加载前景地图
            //this.Level.Foreground.Backdrops = mapData.CreateBackdrops(mapData.Foreground);
            //foreach (Backdrop backdrop in this.Level.Foreground.Backdrops)
            //{
            //    backdrop.Renderer = this.Level.Foreground;
            //}

            Rectangle tileBounds1 = mapData.TileBounds;

            Gfx.FGAutotiler.LevelBounds.Clear();
            VirtualMap <char> data1      = new VirtualMap <char>(tileBounds1.Width, tileBounds1.Height, '0');
            VirtualMap <char> data2      = new VirtualMap <char>(tileBounds1.Width, tileBounds1.Height, '0');
            VirtualMap <bool> virtualMap = new VirtualMap <bool>(tileBounds1.Width, tileBounds1.Height, false);
            Regex             regex      = new Regex("\\r\\n|\\n\\r|\\n|\\r");

            foreach (LevelData level in mapData.Levels)
            {
                Rectangle tileBounds2 = level.TileBounds;
                int       left1       = tileBounds2.Left;
                tileBounds2 = level.TileBounds;
                int      top1      = tileBounds2.Top;
                string[] strArray1 = regex.Split(level.Bg);
                for (int index1 = top1; index1 < top1 + strArray1.Length; ++index1)
                {
                    for (int index2 = left1; index2 < left1 + strArray1[index1 - top1].Length; ++index2)
                    {
                        data1[index2 - tileBounds1.X, index1 - tileBounds1.Y] = strArray1[index1 - top1][index2 - left1];
                    }
                }

                string[] strArray2 = regex.Split(level.Solids);
                for (int index1 = top1; index1 < top1 + strArray2.Length; ++index1)
                {
                    for (int index2 = left1; index2 < left1 + strArray2[index1 - top1].Length; ++index2)
                    {
                        data2[index2 - tileBounds1.X, index1 - tileBounds1.Y] = strArray2[index1 - top1][index2 - left1];
                    }
                }
                tileBounds2 = level.TileBounds;
                int left2 = tileBounds2.Left;
                while (true)
                {
                    int num1 = left2;
                    tileBounds2 = level.TileBounds;
                    int right = tileBounds2.Right;
                    if (num1 < right)
                    {
                        tileBounds2 = level.TileBounds;
                        int top2 = tileBounds2.Top;
                        while (true)
                        {
                            int num2 = top2;
                            tileBounds2 = level.TileBounds;
                            int bottom = tileBounds2.Bottom;
                            if (num2 < bottom)
                            {
                                virtualMap[left2 - tileBounds1.Left, top2 - tileBounds1.Top] = true;
                                ++top2;
                            }
                            else
                            {
                                break;
                            }
                        }
                        ++left2;
                    }
                    else
                    {
                        break;
                    }
                }
                Gfx.FGAutotiler.LevelBounds.Add(new Rectangle(level.TileBounds.X - tileBounds1.X, level.TileBounds.Y - tileBounds1.Y, level.TileBounds.Width, level.TileBounds.Height));
            }

            foreach (Rectangle rectangle in mapData.Filler)
            {
                for (int left = rectangle.Left; left < rectangle.Right; ++left)
                {
                    for (int top = rectangle.Top; top < rectangle.Bottom; ++top)
                    {
                        char ch1 = '0';
                        if (rectangle.Top - tileBounds1.Y > 0)
                        {
                            char ch2 = data2[left - tileBounds1.X, rectangle.Top - tileBounds1.Y - 1];
                            if (ch2 != '0')
                            {
                                ch1 = ch2;
                            }
                        }
                        if (ch1 == '0' && rectangle.Left - tileBounds1.X > 0)
                        {
                            char ch2 = data2[rectangle.Left - tileBounds1.X - 1, top - tileBounds1.Y];
                            if (ch2 != '0')
                            {
                                ch1 = ch2;
                            }
                        }
                        if (ch1 == '0' && rectangle.Right - tileBounds1.X < tileBounds1.Width - 1)
                        {
                            char ch2 = data2[rectangle.Right - tileBounds1.X, top - tileBounds1.Y];
                            if (ch2 != '0')
                            {
                                ch1 = ch2;
                            }
                        }
                        if (ch1 == '0' && rectangle.Bottom - tileBounds1.Y < tileBounds1.Height - 1)
                        {
                            char ch2 = data2[left - tileBounds1.X, rectangle.Bottom - tileBounds1.Y];
                            if (ch2 != '0')
                            {
                                ch1 = ch2;
                            }
                        }
                        if (ch1 == '0')
                        {
                            ch1 = '1';
                        }
                        data2[left - tileBounds1.X, top - tileBounds1.Y]      = ch1;
                        virtualMap[left - tileBounds1.X, top - tileBounds1.Y] = true;
                    }
                }
            }
            using (List <LevelData> .Enumerator enumerator = mapData.Levels.GetEnumerator())
            {
label_85:
                while (enumerator.MoveNext())
                {
                    LevelData current     = enumerator.Current;
                    Rectangle tileBounds2 = current.TileBounds;
                    int       left1       = tileBounds2.Left;
                    while (true)
                    {
                        int num1 = left1;
                        tileBounds2 = current.TileBounds;
                        int right = tileBounds2.Right;
                        if (num1 < right)
                        {
                            tileBounds2 = current.TileBounds;
                            int  top = tileBounds2.Top;
                            char ch1 = data1[left1 - tileBounds1.X, top - tileBounds1.Y];
                            for (int index = 1; index < 4 && !virtualMap[left1 - tileBounds1.X, top - tileBounds1.Y - index]; ++index)
                            {
                                data1[left1 - tileBounds1.X, top - tileBounds1.Y - index] = ch1;
                            }
                            tileBounds2 = current.TileBounds;
                            int  num2 = tileBounds2.Bottom - 1;
                            char ch2  = data1[left1 - tileBounds1.X, num2 - tileBounds1.Y];
                            for (int index = 1; index < 4 && !virtualMap[left1 - tileBounds1.X, num2 - tileBounds1.Y + index]; ++index)
                            {
                                data1[left1 - tileBounds1.X, num2 - tileBounds1.Y + index] = ch2;
                            }
                            ++left1;
                        }
                        else
                        {
                            break;
                        }
                    }
                    tileBounds2 = current.TileBounds;
                    int num3 = tileBounds2.Top - 4;
                    while (true)
                    {
                        int num1 = num3;
                        tileBounds2 = current.TileBounds;
                        int num2 = tileBounds2.Bottom + 4;
                        if (num1 < num2)
                        {
                            tileBounds2 = current.TileBounds;
                            int  left2 = tileBounds2.Left;
                            char ch1   = data1[left2 - tileBounds1.X, num3 - tileBounds1.Y];
                            for (int index = 1; index < 4 && !virtualMap[left2 - tileBounds1.X - index, num3 - tileBounds1.Y]; ++index)
                            {
                                data1[left2 - tileBounds1.X - index, num3 - tileBounds1.Y] = ch1;
                            }
                            tileBounds2 = current.TileBounds;
                            int  num4 = tileBounds2.Right - 1;
                            char ch2  = data1[num4 - tileBounds1.X, num3 - tileBounds1.Y];
                            for (int index = 1; index < 4 && !virtualMap[num4 - tileBounds1.X + index, num3 - tileBounds1.Y]; ++index)
                            {
                                data1[num4 - tileBounds1.X + index, num3 - tileBounds1.Y] = ch2;
                            }
                            ++num3;
                        }
                        else
                        {
                            goto label_85;
                        }
                    }
                }
            }
            using (List <LevelData> .Enumerator enumerator = mapData.Levels.GetEnumerator())
            {
label_100:
                while (enumerator.MoveNext())
                {
                    LevelData current     = enumerator.Current;
                    Rectangle tileBounds2 = current.TileBounds;
                    int       left        = tileBounds2.Left;
                    while (true)
                    {
                        int num1 = left;
                        tileBounds2 = current.TileBounds;
                        int right = tileBounds2.Right;
                        if (num1 < right)
                        {
                            tileBounds2 = current.TileBounds;
                            int top = tileBounds2.Top;
                            if (data2[left - tileBounds1.X, top - tileBounds1.Y] == '0')
                            {
                                for (int index = 1; index < 8; ++index)
                                {
                                    virtualMap[left - tileBounds1.X, top - tileBounds1.Y - index] = true;
                                }
                            }
                            tileBounds2 = current.TileBounds;
                            int num2 = tileBounds2.Bottom - 1;
                            if (data2[left - tileBounds1.X, num2 - tileBounds1.Y] == '0')
                            {
                                for (int index = 1; index < 8; ++index)
                                {
                                    virtualMap[left - tileBounds1.X, num2 - tileBounds1.Y + index] = true;
                                }
                            }
                            ++left;
                        }
                        else
                        {
                            goto label_100;
                        }
                    }
                }
            }
            using (List <LevelData> .Enumerator enumerator = mapData.Levels.GetEnumerator())
            {
label_122:
                while (enumerator.MoveNext())
                {
                    LevelData current     = enumerator.Current;
                    Rectangle tileBounds2 = current.TileBounds;
                    int       left1       = tileBounds2.Left;
                    while (true)
                    {
                        int num1 = left1;
                        tileBounds2 = current.TileBounds;
                        int right = tileBounds2.Right;
                        if (num1 < right)
                        {
                            tileBounds2 = current.TileBounds;
                            int  top = tileBounds2.Top;
                            char ch1 = data2[left1 - tileBounds1.X, top - tileBounds1.Y];
                            for (int index = 1; index < 4 && !virtualMap[left1 - tileBounds1.X, top - tileBounds1.Y - index]; ++index)
                            {
                                data2[left1 - tileBounds1.X, top - tileBounds1.Y - index] = ch1;
                            }
                            tileBounds2 = current.TileBounds;
                            int  num2 = tileBounds2.Bottom - 1;
                            char ch2  = data2[left1 - tileBounds1.X, num2 - tileBounds1.Y];
                            for (int index = 1; index < 4 && !virtualMap[left1 - tileBounds1.X, num2 - tileBounds1.Y + index]; ++index)
                            {
                                data2[left1 - tileBounds1.X, num2 - tileBounds1.Y + index] = ch2;
                            }
                            ++left1;
                        }
                        else
                        {
                            break;
                        }
                    }
                    tileBounds2 = current.TileBounds;
                    int num3 = tileBounds2.Top - 4;
                    while (true)
                    {
                        int num1 = num3;
                        tileBounds2 = current.TileBounds;
                        int num2 = tileBounds2.Bottom + 4;
                        if (num1 < num2)
                        {
                            tileBounds2 = current.TileBounds;
                            int  left2 = tileBounds2.Left;
                            char ch1   = data2[left2 - tileBounds1.X, num3 - tileBounds1.Y];
                            for (int index = 1; index < 4 && !virtualMap[left2 - tileBounds1.X - index, num3 - tileBounds1.Y]; ++index)
                            {
                                data2[left2 - tileBounds1.X - index, num3 - tileBounds1.Y] = ch1;
                            }
                            tileBounds2 = current.TileBounds;
                            int  num4 = tileBounds2.Right - 1;
                            char ch2  = data2[num4 - tileBounds1.X, num3 - tileBounds1.Y];
                            for (int index = 1; index < 4 && !virtualMap[num4 - tileBounds1.X + index, num3 - tileBounds1.Y]; ++index)
                            {
                                data2[num4 - tileBounds1.X + index, num3 - tileBounds1.Y] = ch2;
                            }
                            ++num3;
                        }
                        else
                        {
                            goto label_122;
                        }
                    }
                }
            }
            Vector2 position = new Vector2((float)tileBounds1.X, (float)tileBounds1.Y) * 8f;

            RandomUtil.PushRandom(mapData.LoadSeed);
            Level           level1 = this.Level;
            Level           level2 = this.Level;
            BackgroundTiles backgroundTiles1;
            BackgroundTiles backgroundTiles2 = backgroundTiles1 = new BackgroundTiles(position, data1);

            //BackgroundTiles backgroundTiles3 = backgroundTiles1;
            level2.BgTiles = backgroundTiles1;
            //BackgroundTiles backgroundTiles4 = backgroundTiles3;
            //level2.BgTiles = backgroundTiles4;
            //level1.Add((Entity)backgroundTiles4);
            //Level level3 = this.Level;
            //Level level4 = this.Level;
            solidTiles = new SolidTiles(position, data2);
            //level3.Add((Entity)solidTiles4);
            //this.Level.BgData = data1;
            //this.Level.SolidsData = data2;
            RandomUtil.PopRandom();
            //this.Level.FgTilesLightMask = new TileGrid(8, 8, tileBounds1.Width, tileBounds1.Height);
            //this.Level.FgTilesLightMask.Color = Color.black;
            //foreach (LevelData level5 in mapData.Levels)
            //{
            //    int left = level5.TileBounds.Left;
            //    int top = level5.TileBounds.Top;
            //    int width = level5.TileBounds.Width;
            //    int height = level5.TileBounds.Height;
            //    if (!string.IsNullOrEmpty(level5.BgTiles))
            //    {
            //        int[,] tiles = Util.ReadCSVIntGrid(level5.BgTiles, width, height);
            //        backgroundTiles2.Tiles.Overlay(Gfx.SceneryTiles, tiles, left - tileBounds1.X, top - tileBounds1.Y);
            //    }
            //    if (!string.IsNullOrEmpty(level5.FgTiles))
            //    {
            //        int[,] tiles = Util.ReadCSVIntGrid(level5.FgTiles, width, height);
            //        solidTiles.Tiles.Overlay(Gfx.SceneryTiles, tiles, left - tileBounds1.X, top - tileBounds1.Y);
            //        this.Level.FgTilesLightMask.Overlay(Gfx.SceneryTiles, tiles, left - tileBounds1.X, top - tileBounds1.Y);
            //    }
            //}
            //if (areaData.OnLevelBegin != null)
            //    areaData.OnLevelBegin(this.Level);
            //this.Level.StartPosition = this.startPosition;
            //this.Level.Pathfinder = new Pathfinder(this.Level);
            //this.Loaded = true;
        }
Ejemplo n.º 4
0
 public static string GetCheckpointColorGrading(AreaKey area, string level)
 {
     return(AreaData.GetCheckpoint(area, level)?.ColorGrade);
 }
Ejemplo n.º 5
0
        public static Session.CoreModes GetCheckpointCoreMode(AreaKey area, string level)
        {
            CheckpointData checkpoint = AreaData.GetCheckpoint(area, level);

            return(checkpoint != null && checkpoint.CoreMode.HasValue ? checkpoint.CoreMode.Value : AreaData.Areas[area.ID].CoreMode);
        }
Ejemplo n.º 6
0
        public static bool GetCheckpointDreaming(AreaKey area, string level)
        {
            CheckpointData checkpoint = AreaData.GetCheckpoint(area, level);

            return(checkpoint != null ? checkpoint.Dreaming : AreaData.Areas[area.ID].Dreaming);
        }