public void Run() { Random random = new Random(); var world = Target.GetWorld(); var lastSeen = Target.GetBehavior <BehaviorLastSeen>(); var canBeSeen = lastSeen.CanSee(Origin); SkillUtil.CreateBloodCircle(world, Target.GetVisualTarget(), 60, 64, Random); if (canBeSeen) { SoundRat.Play(1, Random.NextFloat(-0.5f, +0.5f), 0); SkillUtil.CreateSpatter(world, Target.GetVisualTarget(), 5, Vector2.Zero, 1, Random); if (Score > 0) { world.AddWorldScore(Score, Target.GetVisualTarget(), ScoreType.Small); } if (Origin == world.PlayerCurio) { world.RunStats.Gibs += 1; world.RunStats.RatsHunted += 1; } } Splat.Play(1.0f, Random.NextFloat(-0.5f, +0.5f), 0); Behavior.Apply(new BehaviorGib(Target)); }
public void Run() { Random random = new Random(); var world = Origin.GetWorld(); var alive = Target.GetBehavior <BehaviorAlive>(); var grapple = Origin.GetBehavior <BehaviorGrapplingHook>(); Target.GetFlashHelper()?.AddFlash(ColorMatrix.Flat(Color.White), 20); Target.GetShakeHelper()?.AddShakeRandom(3, LerpHelper.QuadraticOut, 30); if (!Target.IsHeartless()) { var delta = Vector2.Normalize(Origin.GetVisualTarget() - Target.GetVisualTarget()); alive.SetDamage(alive.HP); SkillUtil.CreateSpatter(world, Target.GetVisualTarget(), 5, delta * 24, 2, Random); if (grapple != null) { grapple.HasHeart = true; } if (Origin == world.PlayerCurio) { world.RunStats.HeartsRipped += 1; } Blood.Play(1, 0, 0); new TimeFade(world, 0.01f, LerpHelper.ExponentialIn, 60); Behavior.Apply(new BehaviorHeartless(Target)); } }
public void Run() { Random random = new Random(); var world = Origin.GetWorld(); var alive = Target.GetBehavior <BehaviorAlive>(); var sword = Origin.GetBehavior <BehaviorSword>(); Target.GetFlashHelper()?.AddFlash(ColorMatrix.Flat(Color.White), 20); Target.GetShakeHelper()?.AddShakeRandom(3, LerpHelper.QuadraticOut, 30); if (!Target.IsHeartless()) { alive.SetDamage(alive.HP); SkillUtil.CreateSpatter(world, Target.GetVisualTarget(), 5, Util.AngleToVector(sword.Angle) * 24, 2, Random); if (sword != null) { sword.HasBlood = true; sword.HasHeart = true; } if (Origin == world.PlayerCurio) { world.RunStats.HeartsRipped += 1; } Blood.Play(1, 0.5f, 0); Behavior.Apply(new BehaviorHeartless(Target)); } }
private void EmitWraith() { var targetTile = Target.GetMainTile().GetNearby(5).ToList().Pick(Random); var wraith = new Curio(Template.Wraith); wraith.MoveTo(targetTile); Behavior.Apply(new BehaviorWraith(wraith, Origin.GetVisualTarget(), Random.NextFloat(10, 30))); }
public void TestApply() { var bf = new BehaviorSink <Func <long, String> >(b => "1 " + b); var ba = new BehaviorSink <long>(5L); var @out = new List <String>(); Listener l = Behavior <long> .Apply(bf, ba).Value().Listen(x => { @out.Add(x); }); bf.Send(b => "12 " + b); ba.Send(6L); l.Unlisten(); CollectionAssert.AreEqual(new[] { "1 5", "12 5", "12 6" }, @out); }
public void Run() { Random random = new Random(); var world = Target.GetWorld(); SkillUtil.CreateBloodCircle(world, Target.GetVisualTarget(), Particles, Radius, Random); if (Score > 0) { world.AddWorldScore(Score, Target.GetVisualTarget(), ScoreType.Small); } Splat.Play(1.0f, Random.NextFloat(-0.5f, +0.5f), 0); Behavior.Apply(new BehaviorGib(Target)); }
private void SummonWraiths(SceneGame world, BehaviorLich lich) { var target = world.PlayerCurio; for (int i = 0; i < 4; i++) { var targetTile = target.GetMainTile().GetNearby(5).ToList().Pick(Random); var wraith = new Curio(Template.Wraith); wraith.MoveTo(targetTile); Behavior.Apply(new BehaviorWraith(wraith, Origin.GetVisualTarget() + Util.AngleToVector(lich.SwordAngle) * 8 * i, Random.NextFloat(30, 60))); } }
public void Run() { var world = Origin.GetWorld(); var sword = new BehaviorSword(Origin, 3); Behavior.Apply(sword); sword.SetScale(1, LerpHelper.QuadraticOut, this); var star = new BigStar(world, SpriteLoader.Instance.AddSprite("content/effect_star_big")); star.Angle.Set(0, MathHelper.TwoPi, LerpHelper.QuadraticOut, 30); star.Scale.Set(0, 0.1f, LerpHelper.QuadraticOut, 30); star.ShouldDestroy.Set(true, LerpHelper.Linear, 30); var swordEffect = new SwordEffect(world, star, sword, 16) { DrawPass = DrawPass.EffectAdditive, }; }
public SceneGame(Game game) : base(game) { PlayerCurio = new Curio(Template.Player); CameraCurio = new Curio(Template.Camera); Behavior.Apply(new BehaviorFollowCamera(PlayerCurio, CameraCurio)); Map = new Map(this, 100, 100); GenerateMap(); Menu = new PlayerUI(this); Cutscene = Scheduler.Instance.RunAndWait(RoutineStartLevel()); string runName = $"run{DateTime.Now.ToString("ddMMyyyyHHmm")}"; HighscoreRunFile = new HighscoreRunFile($"stats/runs/{runName}.json", RunStats); }
public override void Apply(SceneGame world, Vector2 cardPos) { Behavior.Apply(new BehaviorDoom(world.PlayerCurio, 5)); }
public void Add(Curio curio) { Behavior.Apply(new BehaviorOnTile(this, curio)); }
public override void Apply(SceneGame world, Vector2 cardPos) { Behavior.Apply(new BehaviorSkillButterflyKnives(world.PlayerCurio)); }
public override void Apply(SceneGame world, Vector2 cardPos) { Behavior.Apply(new BehaviorSkillDestructionWave(world.PlayerCurio)); }
private void GenerateMap() { var generator = new MapGenerator(); generator.Generate(); generator.Print(Map); RunStats.Level += 1; new Curio(Template.BellTower).MoveTo(Map.GetTile(0, 0)); var positions = Map.EnumerateTiles().Shuffle(Random); Point?start = null; var weak = new List <Template>(); var strong = new List <Template>(); bool hasOmicron = PlayerCurio.HasBehaviors <BehaviorOmicron>(); //TODO: There was gonna be a tutorial with blood urns for smashing if (RunStats.Level >= 1) { weak.Add(Template.Grunt); } if (RunStats.Level >= 2) { weak.Add(Template.Twitch); } if (RunStats.Level >= 3) { weak.Add(Template.Bulwark); } if (RunStats.Level >= 4) { strong.Add(Template.Lich); } if (RunStats.Level >= 5) { weak.Remove(Template.Grunt); } if (RunStats.Level % 2 == 0) { weak.Add(Template.Rat); } weak.Add(Template.Executioner); weak.Add(Template.Lich); var toSpawn = new List <Template>(); if (weak.Any()) { for (int i = 0; i < 30; i++) { toSpawn.Add(weak.Pick(Random)); } } if (strong.Any()) { for (int i = 0; i < 5; i++) { toSpawn.Add(strong.Pick(Random)); } } if (hasOmicron || (RunStats.Level >= 6 && RunStats.Level % 3 == 0)) { toSpawn.Add(Template.Nemesis); } var spawned = new List <ICurio>(); foreach (var tile in positions) { if (toSpawn.Any() && !tile.IsSolid() && !tile.IsChasm()) { var template = toSpawn[0]; toSpawn.RemoveAt(0); var enemy = new Curio(template); enemy.MoveTo(tile); if (template != Template.Nemesis && template != Template.Rat) { spawned.Add(enemy); } if (template == Template.Nemesis && hasOmicron) { Behavior.Apply(new BehaviorKillTarget(enemy)); } } else if (tile.HasBehaviors <BehaviorLevelStart>()) { start = new Point(tile.X, tile.Y); } if (toSpawn.Empty() && start.HasValue) { break; } } if (RunStats.Level % 3 == 0) { foreach (var enemy in spawned.Shuffle(Random).Take(3)) { Behavior.Apply(new BehaviorKillTarget(enemy)); } } PlayerCurio.MoveTo(Map.GetTile(start.Value.X, start.Value.Y)); CameraCurio.MoveTo(Map.GetTile(start.Value.X, start.Value.Y)); }
public override void Apply(SceneGame world, Vector2 cardPos) { Behavior.Apply(new BehaviorSkillBloodThorn(world.PlayerCurio)); }
public void Print(Map map) { SimpleNoise spikeNoise = new SimpleNoise(Random.Next()); if (map.Width != Width || map.Height != Height) { throw new Exception(); } var tiles = Rooms.SelectMany(x => x.GetCoveredTiles().Select(y => new Tuple <Room, Point>(x, y))).GroupBy(pair => pair.Item2, pair => pair.Item1); foreach (var rooms in tiles) { var pos = rooms.Key; var tile = map.GetTile(pos.X, pos.Y); var count = rooms.Count(); var singleRoom = count == 1 ? rooms.Single() : null; RoomType[] normalRooms = new[] { RoomType.None, RoomType.Start, RoomType.End, RoomType.Corridor }; RoomType[] startEnd = new[] { RoomType.Start, RoomType.End }; Template[] floors = new[] { null, Template.Corridor }; Template template = null; if (singleRoom != null && singleRoom.Type == RoomType.Filled) { template = Template.Wall; } if (singleRoom != null && singleRoom.Type == RoomType.Chasm) { template = Template.Chasm; } if (count > 1) { template = Template.Wall; } if (rooms.Any(x => x.Type == RoomType.Chasm)) { template = Template.Corridor; } if (rooms.All(x => x.Type == RoomType.Chasm)) { template = Template.Chasm; } if (rooms.All(x => x.Type == RoomType.Corridor)) { template = Template.Corridor; } if (singleRoom?.Type == RoomType.Start || singleRoom?.Type == RoomType.End) { template = Template.Floor; } if (count == 2 && IsConnected(rooms.First(), rooms.Last()) && !floors.Contains(template)) { template = null; } if (IsEdgeTile(pos) && floors.Contains(template) && !rooms.All(x => startEnd.Contains(x.Type))) { template = Template.Wall; } int spikeValue = spikeNoise.GetValue(pos.X / 3, pos.Y / 3); if (template == Template.Wall && (spikeValue % 10 == 0 || spikeNoise.GetValue(pos.X, pos.Y) % 30 == 0)) { template = Template.SpikeWall; } if (template == Template.Wall && Random.NextDouble() < 0.1) { template = Template.WraithWall; } if (template == null) { template = Template.Floor; } if (template != null) { tile.ApplyTemplate(template); } if (rooms.Any(x => x.Type == RoomType.Chasm) && template != Template.Chasm) { Behavior.Apply(new BehaviorChasmSeam(tile, template == Template.Corridor ? new Color(155, 99, 74) : new Color(124, 88, 114))); } if (singleRoom?.Type == RoomType.Start) { Behavior.Apply(new BehaviorLevelStart(tile, singleRoom.GetEdgeDirection())); } if (singleRoom?.Type == RoomType.End) { Behavior.Apply(new BehaviorLevelEnd(tile, singleRoom.GetEdgeDirection())); if (singleRoom.Interior.Center == pos) { var pointer = new Curio(Template.Pointer); pointer.MoveTo(tile); Behavior.Apply(new BehaviorEscapeTarget(pointer, singleRoom.Interior)); } } } }
public void LazyInit() { Curio = LazyInitFunc(); Behavior.Apply(new BehaviorTemplate(Curio, this)); }