public void OnHit(TileMap collisionMap) { this.textureTile = collisionMap.GetTileFromPoint(TileLayer.Fore, new Point(((int) this.location.X) + 8, ((int) this.location.Y) + 8)); if ((this.state == PrizeBlockState.Hidden) && GameEngine.Game.CanSpawnBlocks()) { if (!GameEngine.Game.GetPlayer().GetCollisionRectangle().IntersectsWith(this.GetCollisionRectangle())) { collisionMap.SetTile(TileLayer.Fore, this.textureTile.X, this.textureTile.Y, GameEngine.Game.CurrentMap.PrizeBlock); this.state = PrizeBlockState.Visible; GameEngine.Framework.PlaySound(SoundEffects.OpenChest); } } else if ((this.state == PrizeBlockState.Visible) && GameEngine.Game.CanBreakBlocks()) { collisionMap.SetTile(TileLayer.Fore, this.textureTile.X, this.textureTile.Y, new Point(0, 0)); this.state = PrizeBlockState.Broken; GameEngine.Framework.PlaySound(SoundEffects.BreakBlock); ObjectFactory.CreateDebris(base.Location, ObjectType.BrokenBlock, Direction.UpLeft); ObjectFactory.CreateDebris(base.Location, ObjectType.BrokenBlock, Direction.UpRight); ObjectFactory.CreateDebris(base.Location, ObjectType.BrokenBlock, Direction.DownLeft); ObjectFactory.CreateDebris(base.Location, ObjectType.BrokenBlock, Direction.DownRight); if (GameEngine.Game.CheckGlobal(this)) { this.empty = true; } if (!this.empty) { this.prize.CreateObject((PointF) new Point(((int) this.location.X) + 8, ((int) this.location.Y) + 8)); if (this.prize.Item != ObjectType.MysteryBlock) { GameEngine.Game.SetGlobal(this, true); } } } }
public override bool Update(TileMap collisionMap, PointF screenPos, bool force) { if (this.IsInScreenBounds(screenPos) && this.explosionTimer.Update()) { GameEngine.Framework.PlaySound(SoundEffects.BreakBlock); GameObject obj2 = ObjectFactory.CreateObjectOfType(ObjectType.Explosion); int num = Utility.RandomInt(-this.range, this.range); int num2 = Utility.RandomInt(-this.range, this.range); obj2.Location = new PointF(this.location.X + num, this.location.Y + num2); GameEngine.Game.CurrentMap.AddObject(obj2); } return true; }
public override bool Update(TileMap collisionMap, PointF screenPos, bool force) { ObjectType watersplash = ObjectType.Watersplash; SurfaceType waterSurface = SurfaceType.WaterSurface; GameObject player = GameEngine.Game.GetPlayer(); RectangleF collisionRectangle = this.GetCollisionRectangle(); float num = player.Y - this.location.Y; player.MakeAirBubbles = !this.lava && (num > 50f); if (player.GetCollisionRectangle().IntersectsWith(collisionRectangle)) { if ((!GameEngine.Game.GetPlayerStats().IsUnderwater && (num > 0f)) && (num < 100f)) { if (this.lava) { waterSurface = SurfaceType.LavaSurface; } GameEngine.Game.GetPlayerStats().IsUnderwater = true; player.ObjectBehavior.HandleHitSurface(waterSurface, collisionRectangle, Direction.Up); GameEngine.Framework.PlaySound(SoundEffects.WaterSplash); if (this.lava) { watersplash = ObjectType.LavaSplash; } ObjectFactory.CreateDebris(player.Location, watersplash, Direction.UpLeft); ObjectFactory.CreateDebris(player.Location, watersplash, Direction.UpRight); } } else if (((GameEngine.Game.GetPlayerStats().IsUnderwater && (player.Location.X >= this.location.X)) && ((((int) player.X) <= (this.location.X + collisionRectangle.Width)) && (num < 0f))) && (num > -30f)) { if (this.lava) { waterSurface = SurfaceType.LavaSurface; } GameEngine.Game.GetPlayerStats().IsUnderwater = false; player.ObjectBehavior.HandleHitSurface(waterSurface, collisionRectangle, Direction.Up); if (player.YSpeed.CurrentSpeed > -3f) { player.YSpeed.CurrentSpeed = -3f; } GameEngine.Framework.PlaySound(SoundEffects.WaterSplash); if (this.lava) { watersplash = ObjectType.LavaSplash; } ObjectFactory.CreateDebris(player.Location, watersplash, Direction.UpLeft); ObjectFactory.CreateDebris(player.Location, watersplash, Direction.UpRight); } return true; }
public override bool Update(TileMap collisionMap, PointF screenPos, bool force) { switch (this.state) { case 0: this.pars[this.curPar].TextColor = Utility.FadeColor(Color.Black, this.textColor, this.fadePercent); this.pars[this.curPar].CenterText(new Rectangle(0, 0x20, 320, 0x40)); this.fadePercent += 0.1f; if (this.fadePercent >= 1f) { this.fadePercent = 1f; this.state = 1; } break; case 1: if (GameEngine.Framework.GetFirstPressedKey() > 0) { this.state = 2; } break; case 2: this.fadePercent -= 0.1f; this.pars[this.curPar].TextColor = Utility.FadeColor(Color.Black, this.textColor, this.fadePercent); this.pars[this.curPar].CenterText(new Rectangle(0, 0x20, 320, 0x40)); if (this.fadePercent > 0f) { break; } this.fadePercent = 0f; this.curPar++; if (this.curPar < this.pars.Count) { this.state = 0; break; } GameEngine.Game.GotoSpecialScene(SpecialScenes.Ending); return false; } return true; }
public override bool Update(TileMap collisionMap, PointF screenPos, bool force) { this.springSpeed.UpdateSpeed(); this.springHeight += (int) this.springSpeed.CurrentSpeed; if (this.springHeight < 0) { this.springHeight = 0; if (this.springStrength > 0) { this.springSpeed.CurrentSpeed = this.springStrength; this.springSpeed.TargetSpeed = -1 * this.springStrength; this.springStrength--; } } if (this.springHeight > 0x10) { this.springHeight = 0x10; } return true; }
public override bool Update(TileMap collisionMap, PointF screenPos, bool force) { float x = GameEngine.Game.GetPlayer().X; if (Math.Abs((float) (x - this.location.X)) < this.range) { if (x < this.location.X) { this.generator.X = (screenPos.X + GameEngine.ScreenWidth) + 32f; } else { this.generator.X = screenPos.X - 32f; } this.generator.SetActivated(true); } else { this.generator.SetActivated(false); } this.generator.FrameMove(); this.generator.Location = base.location; return true; }
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; }
public override bool Update(TileMap collisionMap, PointF screenPos, bool force) { if (this.state != PrizeBlockState.Broken) { if (this.state == PrizeBlockState.None) { this.textureTile = collisionMap.GetTileFromPoint(TileLayer.Fore, new Point(((int) this.location.X) + 8, ((int) this.location.Y) + 8)); if (collisionMap.GetTile(TileLayer.Fore, this.textureTile.X, this.textureTile.Y).Equals(GameEngine.Game.CurrentMap.MagicBlock)) { this.state = PrizeBlockState.Hidden; } else { this.state = PrizeBlockState.Visible; } } GameObject player = GameEngine.Game.GetPlayer(); if (player.CurAnimHitType == AnimHitType.Sword) { if (this.GetCollisionRectangle().IntersectsWith(player.GetShieldSwordRectangle())) { this.OnHit(collisionMap); } } else if ((player.Type == ObjectType.Lizard) && (player.YSpeed.CurrentSpeed < 0f)) { float num = player.Y - player.GetCollisionRectangle().Height; if (((player.X >= this.location.X) && (player.X <= (this.location.X + 16f))) && ((num < (this.location.Y + 20f)) && (num > (this.location.Y + 8f)))) { this.OnHit(collisionMap); } } } return true; }
public override bool Update(TileMap collisionMap, PointF screenPos, bool force) { this.tilePoint = collisionMap.GetTileFromPointUnchecked(TileLayer.Fore, new Point((int) base.X, (int) base.Y)); if (this.startingTilePoint.X < 0) { this.startingTilePoint.X = this.tilePoint.X; this.startingTilePoint.Y = this.tilePoint.Y; } switch (this.state) { case FallingBlockState.Resting: { GameObject player = GameEngine.Game.GetPlayer(); if ((this.trigger == FallingBlockTrigger.PlayerNear) || collisionMap.GetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y + 1).Equals(new Point(0, 0))) { switch (this.trigger) { case FallingBlockTrigger.PlayerNear: if (Math.Abs((float) (player.X - base.X)) < 100f) { this.state = FallingBlockState.Triggered; } break; case FallingBlockTrigger.PlayerOn: if (((player.X >= base.X) && (player.X <= (base.X + 16f))) && (player.GetCollisionRectangle().Bottom == this.GetCollisionRectangle().Top)) { this.state = FallingBlockState.Triggered; } if (player.GetCollisionRectangle().IntersectsWith(this.GetCollisionRectangle())) { this.state = FallingBlockState.Triggered; } break; case FallingBlockTrigger.PlayerHit: if ((player.CurAnimHitType == AnimHitType.Sword) && this.GetCollisionRectangle().IntersectsWith(player.GetShieldSwordRectangle())) { this.state = FallingBlockState.Triggered; } break; } break; } return true; } case FallingBlockState.Triggered: if (this.delay.Update()) { if (this.trigger != FallingBlockTrigger.PlayerNear) { collisionMap.SetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y, new Point(0, 0)); } this.state = FallingBlockState.Falling; this.fallBegin = base.Y; } break; case FallingBlockState.Falling: base.Y += 4f; if (GameEngine.Game.GetPlayer().GetCollisionRectangle().IntersectsWith(this.GetCollisionRectangle())) { GameObject colObject = new GameObject(null, ObjectType.FallingBlock) { AttackDamage = 8 }; GameEngine.Game.GetPlayer().ObjectBehavior.HandleHit(colObject); } if (((base.Y - this.fallBegin) >= 64f) && !collisionMap.GetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y).Equals(new Point(0, 0))) { collisionMap.SetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y - 1, new Point(3, 0)); this.state = FallingBlockState.Fallen; return true; } break; } return true; }
private void DropBlock(TileMap collisionMap) { for (Point point = collisionMap.GetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y); point.Equals(new Point(0, 0)); point = collisionMap.GetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y)) { this.tilePoint.Y++; } collisionMap.SetTile(TileLayer.Fore, this.tilePoint.X, this.tilePoint.Y - 1, new Point(3, 0)); }
public override bool Update(TileMap collisionMap, PointF screenPos, bool force) { this.updateLocation = true; this.initialized = true; bool solid = this.solid; if (!force && !this.IsInScreenBounds(screenPos)) { solid = false; if (this.deactivateIfFar) { return !this.destroyIfFar; } } bool flag2 = false; if (this.blinkStatus > 0) { this.blinkDuration--; if (this.blinkTime <= 0) { this.blinkTime = 2; if (this.blinkStatus == 1) { this.blinkStatus = 2; } else { this.blinkStatus = 1; } } else { this.blinkTime--; } if (this.blinkDuration <= 0) { this.blinkStatus = 0; } } this.newLocation.X = this.location.X; this.newLocation.Y = this.location.Y; if (this.ignoreBehavior) { flag2 = true; } else { flag2 = this.behavior.Update(screenPos); this.xSpeed.UpdateSpeed(); this.ySpeed.UpdateSpeed(); this.newLocation.X += this.xSpeed.CurrentSpeed; this.newLocation.Y += this.ySpeed.CurrentSpeed; } if (this.solidFallStart > 0) { if ((this.ySpeed.CurrentSpeed > 0f) && (this.location.Y > this.solidFallStart)) { this.solidFallStart = 0; } } else if (solid) { this.CheckCollisions(collisionMap); } if (this.updateLocation) { this.location.X = this.newLocation.X; this.location.Y = this.newLocation.Y; } if (this.stopsAtBoundries || this.stopsAtSides) { if (this.location.X < 0f) { this.location.X = 0f; this.behavior.HandleHitSurface(SurfaceType.Solid, RectangleF.Empty, Direction.Right); } if (this.stopsAtBoundries && (this.location.Y < 16f)) { this.location.Y = 16f; } float num = collisionMap.MapSize.Width * GameMap.TileSize.Width; float num2 = collisionMap.MapSize.Height * GameMap.TileSize.Height; if (this.location.X > num) { this.location.X = num; this.behavior.HandleHitSurface(SurfaceType.Solid, RectangleF.Empty, Direction.Left); } if (this.stopsAtBoundries && (this.location.Y > num2)) { this.location.Y = num2; } } this.UpdateFrame(screenPos); return flag2; }
public void CheckCollisions(TileMap tileMap) { bool flag = base.type == ObjectType.Mouse; bool flag2 = false; bool flag3 = true; bool flag4 = true; PointF tf = new PointF(); PointF tf2 = new PointF(); PointF tf3 = new PointF(); RectangleF collisionRectangle = this.GetCollisionRectangle(true); RectangleF ef2 = this.GetCollisionRectangle(false); RectangleF block = new RectangleF((PointF) new Point(0, 0), (SizeF) GameMap.TileSize); RectangleF ef4 = new RectangleF((PointF) new Point(0, 0), (SizeF) GameMap.TileSize); bool flag5 = false; bool flag6 = false; float num = 0f; float num2 = 0f; float num3 = 0f; float num4 = 0f; Rectangle tilesAroundObject = tileMap.GetTilesAroundObject(collisionRectangle); for (int i = tilesAroundObject.X; i < (tilesAroundObject.X + tilesAroundObject.Width); i++) { for (int j = tilesAroundObject.Y; j < (tilesAroundObject.Y + tilesAroundObject.Height); j++) { flag3 = true; flag4 = true; tf.X = collisionRectangle.X + (collisionRectangle.Width / 2f); tf.Y = collisionRectangle.Y + (collisionRectangle.Height / 2f); tf2.X = ef2.X + (ef2.Width / 2f); tf2.Y = ef2.Y + (ef2.Height / 2f); num = collisionRectangle.X - ef2.X; num2 = collisionRectangle.Y - ef2.Y; SurfaceType surfaceType = GameEngine.Game.CurrentMap.GetSurfaceType(i, j, this.aquatic); SurfaceType type4 = GameEngine.Game.CurrentMap.GetSurfaceType(i, j - 1, this.aquatic); SurfaceType type5 = GameEngine.Game.CurrentMap.GetSurfaceType(i, j + 1, this.aquatic); SurfaceType type2 = GameEngine.Game.CurrentMap.GetSurfaceType(i - 1, j, this.aquatic); SurfaceType type3 = GameEngine.Game.CurrentMap.GetSurfaceType(i + 1, j, this.aquatic); if (surfaceType != SurfaceType.None) { flag6 = false; num3 = 0f; num4 = 0f; block.X = i * block.Width; block.Y = j * block.Height; tf3.X = block.X + (block.Width / 2f); tf3.Y = block.Y + (block.Height / 2f); ef4.X = block.X; ef4.Y = block.Y; ef4.Width = block.Width; ef4.Height = block.Height; ef4.Intersect(collisionRectangle); if ((ef4.Width > 0f) || (ef4.Height > 0f)) { num3 = 0f; num4 = 0f; if (ef4.Height <= ef4.Width) { if ((num2 >= 0f) && (tf.Y < tf3.Y)) { if (type4 == SurfaceType.None) { flag2 = true; flag6 = this.ySpeed.CurrentSpeed >= 0f; if (this.CurrentAnimation == AnimType.Jump) { this.CurrentAnimation = AnimType.Stopped; } if ((surfaceType == SurfaceType.Spring) || ((tf.X > block.Left) && (tf.X <= block.Right))) { if ((surfaceType != SurfaceType.MouseBlock) || (base.objectClass == ObjectClass.Item)) { flag6 = false; } this.behavior.HandleHitSurface(surfaceType, block, Direction.Up); } num4 = block.Top - collisionRectangle.Bottom; } } else if (((num2 <= 0f) && (tf.Y > tf3.Y)) && (type5 == SurfaceType.None)) { num4 = block.Bottom - collisionRectangle.Top; flag6 = this.ySpeed.CurrentSpeed <= 0f; if ((tf.X > block.Left) && (tf.X < block.Right)) { this.behavior.HandleHitSurface(surfaceType, block, Direction.Down); } } } if (ef4.Height >= ef4.Width) { if ((num >= 0f) && (tf.X < tf3.X)) { if (type2 == SurfaceType.None) { num3 = block.Left - collisionRectangle.Right; if ((tf.Y >= block.Top) && (tf.Y <= block.Bottom)) { this.behavior.HandleHitSurface(surfaceType, block, Direction.Left); } flag5 = this.xSpeed.CurrentSpeed >= 0f; } } else if (((num <= 0f) && (tf.X > tf3.X)) && (type3 == SurfaceType.None)) { num3 = block.Right - collisionRectangle.Left; if ((tf.Y >= block.Top) && (tf.Y <= block.Bottom)) { this.behavior.HandleHitSurface(surfaceType, block, Direction.Right); } flag5 = this.xSpeed.CurrentSpeed <= 0f; } } if (this.stopsAtLedges && ((base.objectClass == ObjectClass.Enemy) || (surfaceType == SurfaceType.MouseBlock))) { if (flag6) { if (tf.X > tf3.X) { if (((flag && (type3 != SurfaceType.MouseBlock)) || (!flag && (type3 == SurfaceType.None))) && (((this.xSpeed.CurrentSpeed >= 0f) && (tf.X >= block.Right)) && (tf2.X <= block.Right))) { if (type3 == SurfaceType.None) { if ((tf.Y < tf3.Y) && (this.currentRotation == Direction.Up)) { this.behavior.HandleOnLedge(surfaceType, block, Corner.TopRight); } else if ((tf.Y >= tf3.Y) && (this.currentRotation == Direction.Down)) { this.behavior.HandleOnLedge(surfaceType, block, Corner.BottomRight); } else { flag6 = false; } } if (flag6) { this.xSpeed.CurrentSpeed = 0f; this.newLocation.X = block.Right; collisionRectangle.X = block.Right; flag3 = false; } } } else if (((flag && (type2 != SurfaceType.MouseBlock)) || (!flag && (type2 == SurfaceType.None))) && (((this.xSpeed.CurrentSpeed <= 0f) && (tf.X <= block.Left)) && (tf2.X >= block.Left))) { if (type2 == SurfaceType.None) { if ((tf.Y < tf3.Y) && (this.currentRotation == Direction.Up)) { this.behavior.HandleOnLedge(surfaceType, block, Corner.TopLeft); } else if ((tf.Y >= tf3.Y) && (this.currentRotation == Direction.Down)) { this.behavior.HandleOnLedge(surfaceType, block, Corner.BottomLeft); } else { flag6 = false; } } if (flag6) { this.xSpeed.CurrentSpeed = 0f; this.newLocation.X = block.Left; collisionRectangle.X = block.Left; flag3 = false; } } } else if (flag5) { if (tf.Y > tf3.Y) { if (((flag && (type5 != SurfaceType.MouseBlock)) || (!flag && (type5 == SurfaceType.None))) && (((this.ySpeed.CurrentSpeed >= 0f) && (tf.Y >= block.Bottom)) && (tf2.Y <= block.Bottom))) { if (type5 == SurfaceType.None) { if ((tf.X < tf3.X) && (this.currentRotation == Direction.Left)) { this.behavior.HandleOnLedge(surfaceType, block, Corner.LeftBottom); } else if ((tf.X >= tf3.X) && (this.currentRotation == Direction.Right)) { this.behavior.HandleOnLedge(surfaceType, block, Corner.RightBottom); } else { flag5 = false; } } if (flag5) { this.ySpeed.CurrentSpeed = 0f; this.newLocation.Y = block.Bottom; collisionRectangle.Y = block.Bottom; flag4 = false; } } } else if (((flag && (type4 != SurfaceType.MouseBlock)) || (!flag && (type4 == SurfaceType.None))) && (((this.ySpeed.CurrentSpeed <= 0f) && (tf.Y <= block.Top)) && (tf2.Y >= block.Top))) { if (type4 == SurfaceType.None) { if ((tf.X < tf3.X) && (this.currentRotation == Direction.Left)) { this.behavior.HandleOnLedge(surfaceType, block, Corner.LeftTop); } else if ((tf.X >= tf3.X) && (this.currentRotation == Direction.Right)) { this.behavior.HandleOnLedge(surfaceType, block, Corner.RightTop); } else { flag5 = false; } } if (flag5) { this.ySpeed.CurrentSpeed = 0f; this.newLocation.Y = block.Top; collisionRectangle.Y = block.Top; flag4 = false; } } } } if (flag5) { this.xSpeed.CurrentSpeed = 0f; } if (flag6) { this.ySpeed.CurrentSpeed = 0f; } if (flag3) { this.newLocation.X += num3; } if (flag4) { this.newLocation.Y += num4; } if (flag3) { collisionRectangle.X += num3; } if (flag4) { collisionRectangle.Y += num4; } } } } } this.onGround = flag2; }
public override bool Update(TileMap collisionMap, PointF screenPos, bool force) { this.itemGenerator.Location = base.location; if (!this.opened && this.GetCollisionRectangle().IntersectsWith(GameEngine.Game.GetPlayer().GetCollisionRectangle())) { this.opened = true; GameEngine.Framework.PlaySound(SoundEffects.OpenChest); if (!GameEngine.Game.CheckGlobal(this)) { GameEngine.Game.SetGlobal(this, true); this.itemGenerator.SetActivated(true); } } this.itemGenerator.FrameMove(); return true; }
public override bool Update(TileMap collisionMap, PointF screenPos, bool force) { this.rec[0].X += this.scrollSpeed; if (this.repeating) { if (this.rec[0].X < -this.rec[0].Width) { this.rec[0].X += this.rec[0].Width; } if (this.rec[0].X > 0f) { this.rec[0].X -= this.rec[0].Width; } } return true; }
public virtual bool Update(TileMap collisionMap, PointF screenPos, bool force) { return true; }
public override bool Update(TileMap collisionMap, PointF screenPos, bool force) { if (this.active) { if (this.doorFrame != this.closedFrame) { return true; } if (this.IsOverlapping(GameEngine.Game.GetPlayer())) { if (this.IsWalkDoor()) { if (this.doorType == DoorType.Walk) { return false; } return true; } if (GameEngine.Framework.KeyPressed(GameKey.Up) && this.IsOpenable()) { if (this.wasLocked) { PlayerStatus playerStats = GameEngine.Game.GetPlayerStats(); playerStats.Keys--; GameEngine.Framework.PlaySoundAndLock(SoundEffects.UseKey); } else if (this.doorType != DoorType.Silent) { GameEngine.Framework.PlaySound(SoundEffects.OpenDoor); } return false; } } } return true; }