Example #1
0
 public BaseObject AddObject(ObjectType type, ColorSwaps colorSwap, Direction direction, string itemDrops, int delay)
 {
     if (type == ObjectType.PrizeBlock)
     {
         DragonTrap.PrizeBlock item = new DragonTrap.PrizeBlock(itemDrops, this.mapFilename);
         this.objects.Add(item);
         item.Location = new PointF(this.screenPos.X + (GameEngine.ScreenWidth / 2), this.screenPos.Y + (GameEngine.ScreenHeight / 2));
         item.Update(this.tileMap, this.screenPos, true);
         return item;
     }
     if (type == ObjectType.FallingBlock)
     {
         FallingBlockTrigger playerHit;
         if (colorSwap == ColorSwaps.Red)
         {
             playerHit = FallingBlockTrigger.PlayerHit;
         }
         else if (colorSwap == ColorSwaps.Green)
         {
             playerHit = FallingBlockTrigger.PlayerNear;
         }
         else
         {
             playerHit = FallingBlockTrigger.PlayerOn;
         }
         FallingBlock block2 = new FallingBlock(this.mapFilename, playerHit, delay);
         this.objects.Add(block2);
         block2.Location = new PointF(this.screenPos.X + (GameEngine.ScreenWidth / 2), this.screenPos.Y + (GameEngine.ScreenHeight / 2));
         block2.Update(this.tileMap, this.screenPos, true);
         return block2;
     }
     if (type == ObjectType.ExplosionGenerator)
     {
         ExplosionPoint point = new ExplosionPoint(100, 10);
         this.objects.Add(point);
         point.Location = new PointF(this.screenPos.X + (GameEngine.ScreenWidth / 2), this.screenPos.Y + (GameEngine.ScreenHeight / 2));
         return point;
     }
     GameObject obj2 = ObjectFactory.CreateObjectOfType(type, colorSwap, direction, itemDrops, delay);
     obj2.Location = new PointF(this.screenPos.X + (GameEngine.ScreenWidth / 2), this.screenPos.Y + (GameEngine.ScreenHeight / 2));
     this.AddObject(obj2, false);
     obj2.Update(this.tileMap, this.screenPos, true);
     return obj2;
 }
Example #2
0
        public bool LoadMap(string filename, bool loadTiles, bool loadObjects)
        {
            this.mapFilename = filename.Substring(filename.LastIndexOf('\\') + 1);
            if (GameEngine.Framework.UsingExternalMaps)
            {
                filename = GameEngine.Framework.GetMapFolder() + this.mapFilename;
            }
            else
            {
                filename = "Maps." + filename.ToLower();
            }
            string tileSet = "";
            this.yOffset = 0;
            this.alternatePalette = false;
            int fromIndex = 0;
            string[] lines = GameEngine.ReadTextFile(filename, !GameEngine.Framework.UsingExternalMaps, !GameEngine.Framework.UsingExternalMaps);
            if (lines == null)
            {
                return false;
            }
            if (loadObjects)
            {
                this.objects.Clear();
                this.gameObjects.Clear();
                this.doors.Clear();
                this.objects.Add(this.player);
                this.gameObjects.Add(this.player);
            }
            GameEngine.Game.BaseDifficulty = 1;
            string[] strArray2 = GameEngine.GetSaveFileSegment(lines, "LEVELDATA", 0);
            foreach (string str2 in strArray2)
            {
                string[] strArray3 = str2.Split(new char[] { '=' });
                switch (strArray3[0])
                {
                    case "alternatePalette":
                        this.alternatePalette = bool.Parse(strArray3[1]);
                        goto Label_0357;

                    case "tileset":
                        tileSet = strArray3[1];
                        if (!this.alternatePalette)
                        {
                            goto Label_024E;
                        }
                        if (this.mapFilename.IndexOf("SKYDUNGEON") != 0)
                        {
                            break;
                        }
                        this.tileTexture = new GameTexture(tileSet + ".bmp", TileSize, ColorSwaps.SkyNormal, ColorSwaps.SkyAlternate, TextureDisposePolicy.DisposeOnTileChange);
                        goto Label_0357;

                    case "music":
                        this.song = Utility.ParseSongString(strArray3[1]);
                        GameEngine.Framework.PlayMusic(this.song);
                        goto Label_0357;

                    case "skycolor":
                    {
                        string[] strArray4 = strArray3[1].Split(new char[] { ',' });
                        base.BackColor = Color.FromArgb(0xff, int.Parse(strArray4[0]), int.Parse(strArray4[1]), int.Parse(strArray4[2]));
                        this.skyColor = base.BackColor;
                        goto Label_0357;
                    }
                    case "liquid":
                        if (!strArray3[1].Equals(SurfaceType.LavaSurface.ToString()))
                        {
                            goto Label_0306;
                        }
                        this.liquidSurface = SurfaceType.LavaSurface;
                        goto Label_0357;

                    case "tremor":
                        this.castleTremor = bool.Parse(strArray3[1]);
                        if (this.castleTremor)
                        {
                            this.flashColor = Color.Red;
                        }
                        goto Label_0357;

                    case "mapdifficulty":
                        GameEngine.Game.BaseDifficulty = int.Parse(strArray3[1]);
                        goto Label_0357;

                    case "yoffset":
                        this.yOffset = int.Parse(strArray3[1]);
                        goto Label_0357;

                    default:
                        goto Label_0357;
                }
                this.tileTexture = new GameTexture(tileSet + ".bmp", TileSize, ColorSwaps.CaveNormal, ColorSwaps.CaveAlternate, TextureDisposePolicy.DisposeOnTileChange);
                goto Label_0357;
            Label_024E:
                this.tileTexture = new GameTexture(tileSet + ".bmp", TileSize, TextureDisposePolicy.DisposeOnTileChange);
                goto Label_0357;
            Label_0306:
                this.liquidSurface = SurfaceType.WaterSurface;
            Label_0357:;
            }
            if (loadTiles)
            {
                fromIndex += strArray2.Length;
                string[] strArray5 = GameEngine.GetSaveFileSegment(lines, "MAP", fromIndex);
                fromIndex += strArray5.Length;
                string[] strArray6 = GameEngine.GetSaveFileSegment(lines, "MAP", fromIndex);
                fromIndex += strArray6.Length;
                string[] foredata = GameEngine.GetSaveFileSegment(lines, "MAP", fromIndex);
                this.tileMap = new TileMap(this.tileTexture, strArray5, strArray6, foredata);
            }
            if (loadObjects)
            {
                string[] strArray9 = GameEngine.GetSaveFileSegment(lines, "OBJECTS", 0)[1].Split(new char[] { ';' });
                for (int i = 0; i < strArray9.Length; i++)
                {
                    string[] strArray10 = strArray9[i].Split(new char[] { ' ' });
                    if (strArray10.Length > 1)
                    {
                        if (strArray10[0].Equals("Door"))
                        {
                            Door item = new Door(int.Parse(strArray10[2]), Utility.ParseDoorTypeString(strArray10[5]), this.mapFilename);
                            Point point = Utility.ParsePointString(strArray10[1]);
                            item.Location = new PointF((float) point.X, (float) point.Y);
                            item.DestinationDoor = int.Parse(strArray10[3]);
                            item.DestinationMap = strArray10[4];
                            item.ObjClass = ObjectClass.Door;
                            if (strArray10.Length > 6)
                            {
                                item.IsWaterTransition = bool.Parse(strArray10[6]);
                            }
                            if (strArray10.Length > 7)
                            {
                                item.Flipped = bool.Parse(strArray10[7]);
                            }
                            this.objects.Insert(0, item);
                            this.doors.Add(item);
                        }
                        else if (strArray10[0].Equals("PrizeBlock"))
                        {
                            string str3 = "";
                            if (strArray10.Length > 2)
                            {
                                str3 = strArray10[2];
                            }
                            DragonTrap.PrizeBlock block = new DragonTrap.PrizeBlock(str3, this.mapFilename);
                            Point point2 = Utility.ParsePointString(strArray10[1]);
                            block.Location = new PointF((float) point2.X, (float) point2.Y);
                            this.objects.Add(block);
                        }
                        else if (strArray10[0].Equals("FallingBlock"))
                        {
                            FallingBlockTrigger playerOn = FallingBlockTrigger.PlayerOn;
                            if (strArray10[3].Equals("PlayerNear"))
                            {
                                playerOn = FallingBlockTrigger.PlayerNear;
                            }
                            if (strArray10[3].Equals("PlayerHit"))
                            {
                                playerOn = FallingBlockTrigger.PlayerHit;
                            }
                            if (strArray10[3].Equals("PlayerOn"))
                            {
                                playerOn = FallingBlockTrigger.PlayerOn;
                            }
                            FallingBlock block2 = new FallingBlock(this.mapFilename, playerOn, int.Parse(strArray10[2]));
                            Point point3 = Utility.ParsePointString(strArray10[1]);
                            block2.Location = new PointF((float) (point3.X * 0x10), (float) (point3.Y * 0x10));
                            this.objects.Add(block2);
                        }
                        else if (strArray10[0].Equals("Treasure"))
                        {
                            Point point4 = Utility.ParsePointString(strArray10[1]);
                            PointF tf = new PointF((float) point4.X, (float) point4.Y);
                            Direction left = Direction.Left;
                            if (strArray10.Length > 4)
                            {
                                left = Utility.ParseDirectionString(strArray10[4]);
                            }
                            TreasureChest chest = new TreasureChest(int.Parse(strArray10[2]), strArray10[3].Split(new char[] { ':' }), this.mapFilename, left) {
                                Location = tf
                            };
                            this.objects.Add(chest);
                        }
                        else if (strArray10[0].Equals("Generator"))
                        {
                            Point point5 = Utility.ParsePointString(strArray10[1]);
                            PointF tf2 = new PointF((float) point5.X, (float) point5.Y);
                            EnemyGenerator generator = new EnemyGenerator(Utility.ParseObjectTypeString(strArray10[2]), Utility.ParseColorSwapString(strArray10[3]), int.Parse(strArray10[4])) {
                                Location = tf2
                            };
                            this.objects.Add(generator);
                        }
                        else if (strArray10[0].Equals("ExplosionGenerator"))
                        {
                            Point point6 = Utility.ParsePointString(strArray10[1]);
                            PointF tf3 = new PointF((float) point6.X, (float) point6.Y);
                            ExplosionPoint point7 = new ExplosionPoint(100, 10) {
                                Location = tf3
                            };
                            this.objects.Add(point7);
                        }
                        else
                        {
                            ObjectType t = Utility.ParseObjectTypeString(strArray10[0]);
                            ColorSwaps normal = ColorSwaps.Normal;
                            int delay = 0;
                            if (strArray10.Length > 2)
                            {
                                normal = Utility.ParseColorSwapString(strArray10[2]);
                            }
                            if (strArray10.Length > 5)
                            {
                                delay = int.Parse(strArray10[5]);
                            }
                            GameObject obj2 = ObjectFactory.CreateObjectOfType(t, normal, Utility.ParseDirectionString(strArray10[3]), strArray10[4], delay);
                            Point point8 = Utility.ParsePointString(strArray10[1]);
                            obj2.Location = new PointF((float) point8.X, (float) point8.Y);
                            this.objects.Add(obj2);
                            this.gameObjects.Add(obj2);
                        }
                    }
                }
            }
            this.InitSpecialTiles(tileSet);
            if (!this.castleTremor)
            {
                if (this.mapFilename.ToUpper().Equals("SKYFALL.TXT"))
                {
                    this.tileMap.ScrollBackground = true;
                    this.castleTremor = true;
                    this.flashColor = Color.Black;
                    this.skyColor = Color.Black;
                }
                else
                {
                    this.castleTremor = false;
                    this.tileMap.ScrollBackground = false;
                }
            }
            return true;
        }
Example #3
0
        public override void Update(bool inFade)
        {
            this.tileMap.DetermineVisibleTiles(this.screenPos);
            if (this.flashDuration > 0)
            {
                this.flashDuration--;
                if (this.flashDelay.Update())
                {
                    this.useFlashColor = !this.useFlashColor;
                    if (this.useFlashColor)
                    {
                        base.BackColor = this.flashColor;
                    }
                    else
                    {
                        base.BackColor = this.skyColor;
                    }
                }
                if (this.flashDuration == 0)
                {
                    this.useFlashColor = false;
                    base.BackColor = this.skyColor;
                }
            }
            switch (this.state)
            {
                case SceneState.Normal:
                    foreach (BaseObject obj3 in this.objects)
                    {
                        if (!obj3.Update(this.tileMap, this.screenPos, !this.initialized))
                        {
                            if (obj3 is GameObject)
                            {
                                this.deletedObjects.Add((GameObject) obj3);
                            }
                            else if (obj3 is Door)
                            {
                                this.state = SceneState.DoorIn;
                                this.currentDoor = (Door) obj3;
                            }
                        }
                    }
                    if (!this.CheckEdgeExits())
                    {
                        if ((GameEngine.Game.GetPlayerStats().HP <= 0) && !this.player.IsBlinking)
                        {
                            PlayerStatus playerStats = GameEngine.Game.GetPlayerStats();
                            if (playerStats.MedicineContainers > 0)
                            {
                                playerStats.MedicineContainers--;
                                this.HeartRefill();
                            }
                            else if ((GameEngine.Game.GetItemByName("HADES ARMOR").State == EquipItemState.Equipped) && (Utility.RandomInt(0, 100) < 40))
                            {
                                this.HeartRefill();
                            }
                            else
                            {
                                this.state = SceneState.GameOver;
                                this.OnGameOver();
                            }
                        }
                        this.tileTexture.Animate();
                        this.SetScreenPos();
                        if (this.castleTremor)
                        {
                            this.HandleCastleTremor();
                        }
                    }
                    goto Label_0990;

                case SceneState.InTransit:
                    this.player.StopsAtBoundries = false;
                    foreach (GameObject obj2 in this.gameObjects)
                    {
                        obj2.Update(this.tileMap, this.screenPos, !this.initialized);
                    }
                    if (!inFade)
                    {
                        if (this.currentDoor != null)
                        {
                            this.state = SceneState.DoorOut;
                        }
                        else
                        {
                            this.state = SceneState.Normal;
                            this.player.StopsAtBoundries = true;
                        }
                    }
                    this.SetScreenPos();
                    this.tileMap.DetermineVisibleTiles(this.screenPos);
                    goto Label_0990;

                case SceneState.DoorIn:
                    this.SetScreenPos();
                    this.currentDoor.Update(this.tileMap, this.screenPos, false);
                    if (!this.currentDoor.Opening)
                    {
                        this.player.Visible = false;
                    }
                    if (!this.currentDoor.OpenDoor())
                    {
                        goto Label_0990;
                    }
                    if (this.currentDoor.IsWaterTransition)
                    {
                        GameEngine.Game.GetPlayerStats().IsUnderwater = !GameEngine.Game.GetPlayerStats().IsUnderwater;
                        GameEngine.Game.GetPlayer().ObjectBehavior.HandleHitSurface(SurfaceType.WaterSurface, RectangleF.Empty, Direction.Up);
                    }
                    if (this.currentDoor.TypeOfDoor == DoorType.Shop)
                    {
                        this.state = SceneState.InShop;
                        GameEngine.Game.GotoShop(this.currentDoor.DestinationMap);
                        this.currentDoor = null;
                        goto Label_0990;
                    }
                    if (this.currentDoor.TypeOfDoor == DoorType.Church)
                    {
                        this.state = SceneState.InShop;
                        GameEngine.Game.GotoSpecialScene(SpecialScenes.Church);
                        this.currentDoor = null;
                        goto Label_0990;
                    }
                    if (this.currentDoor.DestinationMap.Equals(""))
                    {
                        foreach (Door door in this.doors)
                        {
                            if (door.ID == this.currentDoor.DestinationDoor)
                            {
                                this.player.Location = new PointF(door.Location.X + 16f, door.Location.Y + 64f);
                                this.state = SceneState.DoorOut;
                                GameEngine.Framework.PlaySound(SoundEffects.OpenDoor);
                                this.currentDoor = door;
                                return;
                            }
                        }
                        goto Label_0990;
                    }
                    switch (this.currentDoor.TypeOfDoor)
                    {
                        case DoorType.Walk:
                        case DoorType.VerticalEdge:
                        case DoorType.HorizontalEdge:
                            goto Label_07B2;
                    }
                    this.player.XSpeed.SetSpeed((float) 0f);
                    if (this.player.YSpeed.CurrentSpeed < 0f)
                    {
                        this.player.YSpeed.SetSpeed((float) 0f);
                    }
                    goto Label_07B2;

                case SceneState.DoorOut:
                    this.SetScreenPos();
                    this.currentDoor.Update(this.tileMap, this.screenPos, false);
                    if (!this.currentDoor.Opening)
                    {
                        this.player.Visible = true;
                    }
                    if (this.currentDoor.OpenDoor())
                    {
                        this.state = SceneState.Normal;
                    }
                    goto Label_0990;

                case SceneState.GameOver:
                    this.singleMoveObject.Update(this.tileMap, this.screenPos, true);
                    if (this.gameOverTimer > 0)
                    {
                        this.gameOverTimer--;
                        if (this.gameOverTimer == 0)
                        {
                            GameEngine.Game.GotoSpecialScene(SpecialScenes.GameOver);
                        }
                    }
                    goto Label_0990;

                case SceneState.Frozen:
                    GameEngine.Framework.PauseCurrentSong(true);
                    if (!this.singleMoveObject.Update(this.tileMap, this.screenPos, true))
                    {
                        this.singleMoveObject = null;
                        GameEngine.Framework.PauseCurrentSong(false);
                        this.state = SceneState.Normal;
                    }
                    goto Label_0990;

                case SceneState.HeartRefill:
                    if (GameEngine.Game.GetPlayerStats().DoHeartRefill())
                    {
                        this.state = SceneState.Normal;
                    }
                    goto Label_0990;

                case SceneState.Transforming:
                    this.singleMoveObject.Update(this.tileMap, this.screenPos, false);
                    if (this.flashDuration == 0)
                    {
                        this.state = SceneState.Normal;
                        GameEngine.Game.OnSetTransform(this.singleMoveObject.Type, false);
                        this.objects.Remove(this.player);
                        this.gameObjects.Remove(this.player);
                        this.player = this.singleMoveObject;
                        this.singleMoveObject = null;
                        this.player.AttackDamage = GameEngine.Game.GetPlayerStats().AP;
                        GameEngine.Game.SetPlayer(this.player);
                        this.player.CurrentDirection = Direction.Right;
                        this.player.IgnoreBehavior = false;
                        if (!this.nextMap.StartsWith("*"))
                        {
                            GameEngine.Framework.ChangeScene(this.nextMap, 1);
                        }
                    }
                    goto Label_0990;

                case SceneState.InShop:
                    this.state = SceneState.Normal;
                    GameEngine.Framework.PlayMusic(this.song);
                    this.player.Visible = true;
                    goto Label_0990;

                case SceneState.Editor:
                    this.EditorFrameMove();
                    goto Label_0990;

                case SceneState.EndingText:
                    foreach (BaseObject obj4 in this.objects)
                    {
                        if (obj4 is EndingText)
                        {
                            obj4.Update(this.tileMap, this.screenPos, false);
                        }
                    }
                    this.tileTexture.Animate();
                    goto Label_0990;

                case SceneState.FinalBossTransform:
                    this.singleMoveObject.Update(this.tileMap, this.screenPos, false);
                    if (this.flashDuration == 0)
                    {
                        this.state = SceneState.Normal;
                        this.deletedObjects.Add(this.singleMoveObject);
                        this.singleMoveObject = null;
                    }
                    goto Label_0990;

                case SceneState.FinalBossDeath:
                {
                    GameEngine.Framework.PauseCurrentSong(true);
                    if (this.finalBossDeathTimer != 0)
                    {
                        this.finalBossDeathTimer++;
                        if (this.finalBossDeathTimer >= 240)
                        {
                            this.RevealDoor(true);
                            this.state = SceneState.Normal;
                            for (int j = 0; j < this.objects.Count; j++)
                            {
                                if (this.objects[j].Type == ObjectType.ExplosionGenerator)
                                {
                                    this.objects.RemoveAt(j);
                                    j--;
                                }
                                if (this.objects[j].Type == ObjectType.FinalDragon)
                                {
                                    this.deletedObjects.Add((GameObject) this.objects[j]);
                                }
                            }
                        }
                        break;
                    }
                    this.singleMoveObject.XSpeed.SetSpeed((float) 0f);
                    this.singleMoveObject.YSpeed.SetSpeed((float) 0f);
                    this.singleMoveObject.CurrentAnimation = AnimType.Hit;
                    for (int i = 0; i < this.objects.Count; i++)
                    {
                        if (this.objects[i].Type == ObjectType.TransformSpirit)
                        {
                            this.deletedObjects.Add((GameObject) this.objects[i]);
                        }
                    }
                    this.finalBossDeathTimer = 1;
                    ExplosionPoint item = new ExplosionPoint(40, 5);
                    this.objects.Add(item);
                    item.X = this.singleMoveObject.X;
                    item.Y = this.singleMoveObject.Y - 30f;
                    this.singleMoveObject = null;
                    break;
                }
                default:
                    goto Label_0990;
            }
            foreach (BaseObject obj5 in this.objects)
            {
                obj5.Update(this.tileMap, this.screenPos, !this.initialized);
            }
            this.SetScreenPos();
            goto Label_0990;
            Label_07B2:
            GameEngine.Framework.ChangeScene(this.currentDoor.DestinationMap, ((this.currentDoor.TypeOfDoor == DoorType.StoneLocked) || (this.currentDoor.TypeOfDoor == DoorType.LockedRed)) ? 1 : this.currentDoor.DestinationDoor);
            this.currentDoor = null;
            return;
            Label_0990:
            if (((this.state == SceneState.Normal) && this.initialized) && GameEngine.Framework.KeyPressed(GameKey.Start))
            {
                GameEngine.Game.OpenMenu();
            }
            this.DebugFrameMove();
            foreach (GameObject obj6 in this.deletedObjects)
            {
                this.objects.Remove(obj6);
                this.gameObjects.Remove(obj6);
            }
            foreach (GameObject obj7 in this.addedObjects)
            {
                this.objects.Add(obj7);
                this.gameObjects.Add(obj7);
            }
            this.deletedObjects.Clear();
            this.addedObjects.Clear();
            this.initialized = true;
        }