public ArthurDanger(EntityPreset preset, Player p) : base(preset.Position, "arthur", 16, 16, Drawing.DrawOrder.ENTITIES) { _preset = preset; AddAnimation("walk_d", CreateAnimFrameArray(0, 1), 8); AddAnimation("walk_l", CreateAnimFrameArray(4, 5), 8); AddAnimation("walk_u", CreateAnimFrameArray(2, 3), 8); AddAnimation("walk_r", CreateAnimFrameArray(4, 5), 8); AddAnimation("roll", CreateAnimFrameArray(6), 6); // For flying through the air AddAnimation("stunned", CreateAnimFrameArray(8, 9), 6); AddAnimation("wobble", CreateAnimFrameArray(16, 17), 8); AddAnimation("fall_1", CreateAnimFrameArray(10), 8); AddAnimation("fall", CreateAnimFrameArray(10, 11, 12, 13, 14, 15, 6), 2, false); // Should end on an empty frame _parabola = new Parabola_Thing(this, 32, 1); shadow = new Shadow(this, new Vector2(0, -2), ShadowType.Normal); Play("wobble"); Position.Y -= 32; offset.Y = 5 * 16; _initPos = Position; _dustPillow = new Dust(MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid) + new Vector2(46, 16), p); _stateLogic = StateLogic(); }
public void Spawn(Touching dir, Red_Boss parent) { if (dir.HasFlag(Touching.UP)) { Position = parent.Position + new Vector2(16 * t_index - 14, -13); } else if (dir.HasFlag(Touching.LEFT)) { Position = parent.Position + new Vector2(-14, 16 * t_index - 16); } else if (dir.HasFlag(Touching.RIGHT)) { Position = parent.Position + new Vector2(parent.width + 2, 16 * t_index - 16); } else if (dir.HasFlag(Touching.DOWN)) { Position = parent.Position + new Vector2(16 * t_index - 14, parent.height + 2); } else { //player isn't close in any direction, so random locations Vector2 ul = MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid); Position.X = ul.X + 16 + 12 * (1 + t_index) + GlobalState.RNG.Next(-5, 6); Position.Y = ul.Y + 16 * GlobalState.RNG.Next(1, 4) + GlobalState.RNG.Next(-5, 6) + tentacle.height - height; } tentacle.Position = Position + Vector2.UnitY * (height - 3 - tentacle.height); tentacle.y_push = tentacle.height; Flicker(0.7f + (float)GlobalState.RNG.NextDouble()); state = StateLogic(); }
public void Spawn() { Vector2 tl = MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid); Position = tl + new Vector2(GlobalState.RNG.Next(0, 160 - 24), GlobalState.RNG.Next(0, 32)); Play("explode"); }
public void DoCollision(Map map, bool ignore_player_map_collision) { foreach (Entity e in _mapColliders.Where(e => e.exists)) { Touching t = e.allowCollisions; if (ignore_player_map_collision && e is Player) { e.Solid = false; //during transition no collision with map, but do have tile effects take an effect } map.Collide(e); foreach (Entity m in _mapEntities.Where(m => m.Solid && m.exists && m.Hitbox.Intersects(e.Hitbox))) { m.Collided(e); } e.allowCollisions = t; } //map-entity collision sets per-frame state values that are checked in entity-entity collisions(player+dust->raft) foreach (Group g in _groups.Values) { foreach (Entity collider in g.colliders.Where(e => e.exists)) { foreach (Entity target in g.targets.Where(e => e.exists && !ReferenceEquals(e, collider))) { if (collider.Hitbox.Intersects(target.Hitbox)) { collider.Collided(target); } } } } Vector2 roomUpLeft = MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid); Vector2 roomBottomRight = roomUpLeft + Vector2.One * GameConstants.SCREEN_WIDTH_IN_PIXELS; foreach (Entity e in _keepOnScreen.Where(e => e.exists)) { if (e.Hitbox.Left < roomUpLeft.X) { e.Position.X = roomUpLeft.X; e.touching |= Touching.LEFT; } else if (e.Hitbox.Right > roomBottomRight.X) { e.Position.X = roomBottomRight.X - e.width; e.touching |= Touching.RIGHT; } if (e.Hitbox.Top < roomUpLeft.Y) { e.Position.Y = roomUpLeft.Y; e.touching |= Touching.UP; } else if (e.Hitbox.Bottom > roomBottomRight.Y) { e.Position.Y = roomBottomRight.Y - e.height; e.touching |= Touching.DOWN; } } }
public Laser() : base(Vector2.Zero, "wallboss_laser", 64, 10, Drawing.DrawOrder.BG_ENTITIES) { AddAnimation("charge", CreateAnimFrameArray(0)); AddAnimation("attack", CreateAnimFrameArray(1, 2), 12); exists = false; visible = false; start_loc = Position = MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid) + new Vector2(48, 32 + 11); }
public SkittishSecret(EntityPreset preset, Player p) : base(preset.Position, "forest_npcs", 16, 16, Drawing.DrawOrder.ENTITIES) { AddAnimation("walk_r", CreateAnimFrameArray(32, 33), 4, true); Play("walk_r"); Position.X = initial_pos = MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid).X; player = p; }
public SmallWave(Red_Boss parent) : base(Vector2.Zero, "red_boss_small_wave", 16, 64, Drawing.DrawOrder.BG_ENTITIES) { spawn_point = MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid) + new Vector2(96, 48); AddAnimation("move", CreateAnimFrameArray(0, 1), 8); AddAnimation("rise", CreateAnimFrameArray(2, 3), 8); AddAnimation("fall", CreateAnimFrameArray(1, 2, 3, 4), 8, false); exists = false; immovable = true; }
public DeathPlace(EntityPreset preset, Player p) : base(preset.Position, DrawOrder.ENTITIES) { exists = GlobalState.InDeathRoom; immovable = true; visible = false; gridToCheck = MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid + new Point(0, 1)); _player = p; }
public Face() : base(MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid) + Vector2.UnitX * (160 - 64) / 2, "f_wallboss_face", 64, 32, Drawing.DrawOrder.ENTITIES) { AddAnimation("normal", CreateAnimFrameArray(0, 2), 5); AddAnimation("hurt", CreateAnimFrameArray(3, 5), 14); AddAnimation("charge", CreateAnimFrameArray(1), 5); AddAnimation("shoot", CreateAnimFrameArray(4), 10); Play("normal"); state = StateLogic(); bullets = new(8, () => new(this)); }
public override void Update() { base.Update(); MathUtilities.MoveTo(ref opacity, 1, 0.3f); Rectangle screen = new(MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid).ToPoint(), new(160, 160)); if (!screen.Intersects(Hitbox)) { exists = false; preset.Alive = false; } }
private void LoadMap() { TileData.SetTileset(GlobalState.CURRENT_MAP_NAME); _map.LoadMap(MapLoader.GetMap(GlobalState.CURRENT_MAP_NAME), TileData.Tiles, DrawOrder.MAP_BG); _map_bg_2.LoadMap(MapLoader.GetMap(GlobalState.CURRENT_MAP_NAME, 2), TileData.Tiles, DrawOrder.MAP_BG2); _map_bg_2.y = HEADER_HEIGHT; _map_fg.LoadMap(MapLoader.GetMap(GlobalState.CURRENT_MAP_NAME, 3), TileData.Tiles, DrawOrder.MAP_FG); _map_fg.y = HEADER_HEIGHT; //Sets tile collission and tile events TileData.Set_tile_properties(_map, _map_bg_2); _player.Position = _map.GetFirstWalkable(_map_bg_2) * TILE_WIDTH; Vector2 gridPos = MapUtilities.GetRoomCoordinate(_player.Position); Vector2 roomPos = MapUtilities.GetRoomUpperLeftPos(gridPos); GlobalState.CURRENT_GRID_X = (int)gridPos.X; GlobalState.CURRENT_GRID_Y = (int)gridPos.Y; _player.Reset(); _camera.GoTo(roomPos); UpdateScreenBorders(); foreach (EntityPreset p in EntityManager.GetMapEntities(GlobalState.CURRENT_MAP_NAME).Where(p => p.Permanence == Permanence.MAP_LOCAL)) { p.Alive = true; } LoadGridEntities(); _keyValueLabel.SetText($"x{InventoryManager.GetCurrentMapKeys()}"); PlayMapMusic(); UpdateBroomIcon(); if (GlobalState.GameMode != GameMode.Normal) { ReloadMapTextures(); } }
public override void Update() { base.Update(); if (velocity != Vector2.Zero) { Rectangle screen = new(MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid).ToPoint(), new(160, 160)); if (!screen.Intersects(Hitbox)) { exists = false; } } else if ((_player.Position - Position).Length() < 48) { velocity = FacingDirection(facing) * 100; SoundManager.PlaySoundEffect("rat_move"); } }
public Red_Boss(EntityPreset preset, Player p) : base(preset.Position, "red_boss", 32, 32, Drawing.DrawOrder.ENTITIES) { height = 19; width = 26; offset = new Vector2(3, 13); AddAnimation("bob", CreateAnimFrameArray(0), 20); AddAnimation("close_eyes", CreateAnimFrameArray(1), 10, false); AddAnimation("warn", CreateAnimFrameArray(2), 24); AddAnimation("die", CreateAnimFrameArray(0, 1, 2, 1), 3, false); Play("close_eyes"); ripple = new(this); Vector2 tl = MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid); Point splash_start = new(2, 2); splash_bullets = new(4, () => { splash_start.Y++; return(new(tl + splash_start.ToVector2() * 16 + Vector2.One * 3)); }); int start = 0; tentacles = new(4, () => new(start++)); sensors = new ProximitySensor[] { new(Touching.LEFT, this), new(Touching.RIGHT, this), new(Touching.UP, this), new(Touching.DOWN, this), }; small_wave = new(this); big_wave = new(this); player = p; this.preset = preset; state = State(); }
public override void Update() { base.Update(); if (_player.state == PlayerState.AIR) { player_jumped = true; } Vector2 player_grid_pos = MapUtilities.GetInGridPosition(_player.Position); if (!visible && player_grid_pos.Y > 50) { Position = MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid) + new Vector2(180, 80); visible = true; GlobalState.StartCutscene = Entrance(); } else if (!exiting && visible && (player_grid_pos.X > 135 || player_grid_pos.Y < 49)) { exiting = true; GlobalState.StartCutscene = Exit(); } }
IEnumerator State() { y_push = sprite.Height; player.grid_entrance = MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid) + Vector2.One * 20; GlobalState.SpawnEntity(new VolumeEvent(0, 3)); while (MapUtilities.GetInGridPosition(player.Position).X < 48) { yield return(null); } GlobalState.Dialogue = Dialogue.DialogueManager.GetDialogue("redboss", "before_fight"); float push_timer = 0f; loopSFX = true; while (!GlobalState.LastDialogueFinished) { push_timer += GameTimes.DeltaTime; if (push_timer >= push_tick_max) { push_timer = 0f; if (y_push > 0) { GlobalState.screenShake.Shake(0.021f, 0.1f); y_push--; } } yield return(null); } loopSFX = false; SoundManager.PlaySong("redcave-boss"); Play("bob"); IState state = new StateMachineBuilder() .State <SplashState>("Splash") .Enter((s) => amp = 5) .Event("Splash", (s) => { splash_bullets.Spawn(b => b.Spawn(), 4); }) .Event("Tentacles", (s) => { SpawnTentacles(); if (proximity_hits != Touching.NONE) { s.got_too_close++; if (s.got_too_close == 2) { s.got_too_close = 0; s.Parent.ChangeState("Stun"); } } }) .End() .State <DashState>("Dash") .Enter((s) => { amp = 0; velocity = new Vector2(30, 20); Play("bob"); }) .Update((s, _) => { Drawing.Effects.ScreenShake.Directions dirs = new(); Vector2 tl = MapUtilities.GetInGridPosition(Position); Vector2 br = MapUtilities.GetInGridPosition(Position + new Vector2(width, height)); if (tl.Y < 2 * 16) { velocity.Y = 60; dirs |= Drawing.Effects.ScreenShake.Directions.Vertical; } else if (br.Y > 16 * 8) { velocity.Y = -60; dirs |= Drawing.Effects.ScreenShake.Directions.Vertical; } if (tl.X < 2 * 16) { velocity.X = 60; dirs |= Drawing.Effects.ScreenShake.Directions.Horizontal; } else if (br.X > 16 * 8) { velocity.X = -60; dirs |= Drawing.Effects.ScreenShake.Directions.Horizontal; } GlobalState.screenShake.Shake(0.05f, 0.1f, dirs); }) .Event("Tentacles", (s) => { SpawnTentacles(); if (proximity_hits != Touching.NONE) { s.got_too_close++; if (s.got_too_close == 2) { s.got_too_close = 0; s.Parent.ChangeState("Splash"); } } }) .Event("EndDash", (s) => { s.Parent.ChangeState("Stun"); }) .Exit((s) => velocity = Vector2.Zero) .End() .State <StunState>("Stun") .Enter((s) => s.stateLogic = StunStateLogic()) .Update((s, _) => { if (!s.stateLogic.MoveNext()) { s.Parent.ChangeState("Dash"); } }) .End() .Build(); state.ChangeState("Splash"); state.TriggerEvent("Splash"); //First time instantly fires splash bullets while (health > 0) { state.Update(GameTimes.DeltaTime); pushdown_timer += GameTimes.DeltaTime * 3; y_push = (int)(amp + MathF.Sin(pushdown_timer) * amp); yield return(null); } velocity = Vector2.Zero; SoundManager.StopSong(); GlobalState.Dialogue = Dialogue.DialogueManager.GetDialogue("redboss", "after_fight"); GlobalState.screenShake.Shake(0.05f, 0.1f); GlobalState.flash.Flash(1f, Color.Red); while (!GlobalState.LastDialogueFinished) { yield return(null); } Play("die"); SoundManager.PlaySoundEffect("redboss_death"); GlobalState.wave.active = true; y_push = 0; while (y_push < sprite.Height) { MathUtilities.MoveTo(ref ripple.opacity, 0, 0.3f); push_timer += GameTimes.DeltaTime; if (push_timer >= push_tick_max) { push_timer = 0f; y_push++; } yield return(null); } float final_timer = 2f; while (final_timer > 0f) { final_timer -= GameTimes.DeltaTime; yield return(null); } preset.Alive = exists = false; GlobalState.wave.active = false; SoundManager.PlaySong("redcave"); GlobalState.events.BossDefeated.Add("REDCAVE"); yield break; }
public Wall() : base(MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid), "wallboss_wall", 160, 32, Drawing.DrawOrder.VERY_BG_ENTITIES) { AddAnimation("move", CreateAnimFrameArray(0, 1), 4); Play("move"); immovable = true; }
IEnumerator <CutsceneEvent> WindmillCutscene() { VolumeEvent e = new(0f, 0.6f); Entity statue = new(Vector2.Zero, "big_statue", 32, 48, Drawing.DrawOrder.ENTITIES) { visible = false }; yield return(new EntityEvent(new List <Entity>() { e, statue })); while (!e.ReachedTarget) { yield return(null); } GlobalState.gameScreenFade.fadeColor = Color.Black; while (!MathUtilities.MoveTo(ref GlobalState.gameScreenFade.alpha, 1, 0.6f)) { yield return(null); } List <(string map, Point grid, Vector2 tile)> locs = new() { ("BEDROOM", new(4, 0), new(5, 2)), ("REDCAVE", new(6, 2), new(4, 4)), ("CROWD", new(9, 4), new(4, 2)) }; for (int i = 0; i < 3; ++i) { var(map, grid, tile) = locs[i]; statue.Position = MapUtilities.GetRoomUpperLeftPos(grid) + tile * 16; statue.SetFrame(i); statue.visible = true; yield return(new WarpEvent(map, grid)); while (!MathUtilities.MoveTo(ref GlobalState.gameScreenFade.alpha, 0.45f, 0.6f)) { yield return(null); } SoundManager.PlaySoundEffect("red_cave_rise"); while (!MathUtilities.MoveTo(ref GlobalState.gameScreenFade.alpha, 0, 0.6f)) { yield return(null); } Vector2 target = statue.Position + FacingDirection(DungeonStatue.MoveDir(i)) * 32; while (!MathUtilities.MoveTo(ref statue.Position.X, target.X, 12) | !MathUtilities.MoveTo(ref statue.Position.Y, target.Y, 12)) { yield return(null); } GlobalState.screenShake.Shake(0.05f, 0.5f); SoundManager.PlaySoundEffect("wb_hit_ground"); while (!MathUtilities.MoveTo(ref GlobalState.gameScreenFade.alpha, 1, 0.6f)) { yield return(null); } statue.visible = false; } statue.exists = false; yield return(new ReturnWarp()); e.SetTarget(1); while (!MathUtilities.MoveTo(ref GlobalState.gameScreenFade.alpha, 0, 0.6f) | !e.ReachedTarget) { yield return(null); } SoundManager.PlaySong("windmill"); GlobalState.events.IncEvent("WindmillOpened"); GlobalState.FireEvent(new OpenedWindmill()); yield break; } }
IEnumerator StunStateLogic() { Play("warn"); amp = 5; Vector2 target = MapUtilities.GetRoomUpperLeftPos(GlobalState.CurrentMapGrid) + new Vector2(6, 4) * 16; small_wave.Rise(); while (!(MathUtilities.MoveTo(ref Position.X, target.X, 30) & MathUtilities.MoveTo(ref Position.Y, target.Y, 30))) { yield return(null); } while (y_push != 0) { yield return(null); } loopSFX = true; amp = 13; while (y_push < amp) { yield return(null); } small_wave.Launch(); while (y_push != 0) { yield return(null); } amp = 20; while (y_push < 18) { yield return(null); } big_wave.Rise(); while (big_wave.velocity == Vector2.Zero) { yield return(null); } Play("close_eyes"); while (y_push > 2) { yield return(null); } amp = 5; while (small_wave.exists || big_wave.exists) { yield return(null); } target -= Vector2.UnitX * 16; while (!(MathUtilities.MoveTo(ref Position.X, target.X, 30) & MathUtilities.MoveTo(ref Position.Y, target.Y, 30))) { yield return(null); } loopSFX = false; yield break; }