public static void Rules() { // TODO: Make it so the "Player" is what is being controlled new TouchRule <Player, Goal>("Goal victory", Rule.RuleType.VICTORY, (location, obj) => { if (!location.GetEntities <Banner>().Any() && Referee.IsStarted) { Referee.Stop(); Program.Engine.AddEntity(Banner.Create("you win")); if (Referee.OutofControl) { ArcadeWins++; } } }); new TouchRule <Player, Enemy>("Enemy victory", Rule.RuleType.VICTORY, (location, obj) => { if (!location.GetEntities <Banner>().Any() && Referee.IsStarted) { Referee.Stop(); Program.Engine.AddEntity(Banner.Create("you win")); if (Referee.OutofControl) { ArcadeWins++; } } }); new TouchRule <Player, Powerup>("Powerup victory", Rule.RuleType.VICTORY, (location, obj) => { if (!location.GetEntities <Banner>().Any() && Referee.IsStarted) { Referee.Stop(); Program.Engine.AddEntity(Banner.Create("you win")); if (Referee.OutofControl) { ArcadeWins++; } } }); new TouchRule <Player, Enemy>("Enemy hurty", Rule.RuleType.DEATH, (location, obj) => { if (!location.GetEntities <Banner>().Any() && Referee.IsStarted) { if (Iframe == 0 && Lives-- == 1) { Referee.Stop(); if (!Referee.OutofControl) { Program.Engine.AddEntity(Banner.Create("you lose")); } else { Program.Engine.AddEntity(Banner.Create($"you lose. Score: {ArcadeWins}")); ArcadeWins = 0; } } if (Iframe == 0) { Iframe = TPS; } } }); new TouchRule <Player, Powerup>("Powerup hurty", Rule.RuleType.DEATH, (location, obj) => { if (!location.GetEntities <Banner>().Any() && Referee.IsStarted) { if (Iframe == 0 && Lives-- == 1) { Referee.Stop(); if (!Referee.OutofControl) { Program.Engine.AddEntity(Banner.Create("you lose")); } else { Program.Engine.AddEntity(Banner.Create($"you lose. Score: {ArcadeWins}")); ArcadeWins = 0; } } if (Iframe == 0) { Iframe = TPS; } } }); new TouchRule <Player, Goal>("Goal hurty", Rule.RuleType.DEATH, (location, obj) => { if (!location.GetEntities <Banner>().Any() && Referee.IsStarted) { if (Iframe == 0 && Lives-- == 1) { Referee.Stop(); if (!Referee.OutofControl) { Program.Engine.AddEntity(Banner.Create("you lose")); } else { Program.Engine.AddEntity(Banner.Create($"you lose. Score: {ArcadeWins}")); ArcadeWins = 0; } } if (Iframe == 0) { Iframe = TPS; } } }); // TODO: Make it so the "Player" is what is being controlled new TouchRule <Player, Powerup>("Player pickup Powerup", Rule.RuleType.POWERUP, (location, obj) => { Powerup powerup = obj as Powerup; Program.Referee.AddRule(powerup.Rule); location.RemoveEntity(powerup.Id); ////Referee.AddRule(Rule.Rules["Enemy pickup Powerup"]); }); new TouchRule <Enemy, Powerup>("Enemy pickup Powerup", Rule.RuleType.POWERUP, (location, obj) => { Powerup powerup = obj as Powerup; Program.Referee.AddRule(powerup.Rule); location.RemoveEntity(powerup.Id); ////Referee.AddRule(Rule.Rules["Player pickup Powerup"]); }); new TouchRule <Description2D, Powerup>("Any pickup Powerup", Rule.RuleType.POWERUP, (location, obj) => { Powerup powerup = obj as Powerup; Program.Referee.AddRule(powerup.Rule); location.RemoveEntity(powerup.Id); ////Referee.AddRule(Rule.Rules["Player pickup Powerup"]); }); new Rule("clicky attack", Rule.RuleType.ATTACK, (location, obj) => { if (Program.Mouse[(int)Program.Actions.ACTION].IsPress()) { MouseControllerInfo mci = Program.Mouse[(int)Program.Actions.ACTION].Info as MouseControllerInfo; foreach (Enemy enemy in location.GetEntities <Enemy>()) { if (enemy.Distance(new Point(mci.X, mci.Y)) < 8) { location.RemoveEntity(enemy.Id); } } } }); new Rule("shoot Enemy", Rule.RuleType.ATTACK, (location, obj) => { if (location.GetEntities <DialogBox>().Any()) { return; } if (Program.Mouse[(int)Program.Actions.ACTION].IsPress()) { MouseControllerInfo mci = Program.Mouse[(int)Program.Actions.ACTION].Info as MouseControllerInfo; Player player = location.GetEntities <Player>().FirstOrDefault(); if (player == null) { return; } double dir = player.Direction(new Point(mci.X, mci.Y)); int spawnX = (int)(player.X + Math.Cos(dir) * 8); int spawnY = (int)(player.Y + Math.Sin(dir) * 8); location.AddEntity(Bullet <Enemy> .Create(spawnX, spawnY, dir)); } }); int shootTimer = 15; new Rule("shoot Boss", Rule.RuleType.ATTACK, (location, obj) => { if (location.GetEntities <DialogBox>().Any()) { return; } if (shootTimer-- <= 0 && Program.Mouse[(int)Program.Actions.ACTION].IsDown()) { shootTimer = 15; MouseControllerInfo mci = Program.Mouse[(int)Program.Actions.ACTION].Info as MouseControllerInfo; Player player = location.GetEntities <Player>().FirstOrDefault(); if (player == null) { return; } double dir = player.Direction(new Point(mci.X, mci.Y)); int spawnX = (int)(player.X + Math.Cos(dir) * 8); int spawnY = (int)(player.Y + Math.Sin(dir) * 8); location.AddEntity(Bullet <BulletNull> .Create(spawnX, spawnY, dir)); } }); new TouchRule <Player, Enemy>("Player kill Enemy", Rule.RuleType.ATTACK, (location, obj) => { Enemy enemy = obj as Enemy; location.RemoveEntity(enemy.Id); }); new TouchRule <Player, Goal>("Player kill Goal", Rule.RuleType.ATTACK, (location, obj) => { Goal goal = obj as Goal; location.RemoveEntity(goal.Id); }); new Rule("no attack. haha.", Rule.RuleType.ATTACK, (location, obj) => { }); new Rule("be fast", Rule.RuleType.SPEED, (location, obj) => { return(3); }); new Rule("be slow", Rule.RuleType.SPEED, (location, obj) => { return(0.8); }); new Rule("be normal", Rule.RuleType.SPEED, (location, obj) => { return(1); }); new Rule("spawn Powerup", Rule.RuleType.SPAWN, (location, obj) => { location.AddEntity(Powerup.Create(Rule.GetNameRandomRule(), Program.Random.Next(16, Program.ScreenWidth - 16), Program.Random.Next(16, Program.ScreenWidth - 16))); }); new Rule("spawn Enemy", Rule.RuleType.SPAWN, (location, obj) => { location.AddEntity(Enemy.Create(Program.Random.Next(16, Program.ScreenWidth - 16), Program.Random.Next(16, Program.ScreenWidth - 16))); }); new Rule("spawn Goal", Rule.RuleType.SPAWN, (location, obj) => { location.AddEntity(Goal.Create(Program.Random.Next(16, Program.ScreenWidth - 16), Program.Random.Next(16, Program.ScreenWidth - 16))); }); new Rule("control Player", Rule.RuleType.CONTROL, (location, obj) => { foreach (Player player in location.GetEntities <Player>()) { if (Referee.Piles[Rule.RuleType.PERSPECTIVE].Any()) { Referee.Piles[Rule.RuleType.PERSPECTIVE].Peek().Action(location, player); } } }); new Rule("control Enemy", Rule.RuleType.CONTROL, (location, obj) => { foreach (Enemy enemy in location.GetEntities <Enemy>()) { Referee.Piles[Rule.RuleType.PERSPECTIVE].Peek().Action(location, enemy); } }); new Rule("control Goal", Rule.RuleType.CONTROL, (location, obj) => { foreach (Goal goal in location.GetEntities <Goal>()) { Referee.Piles[Rule.RuleType.PERSPECTIVE].Peek().Action(location, goal); } }); new Rule("top-down", Rule.RuleType.PERSPECTIVE, ControlSchemas.TopDown); new Rule("platformer", Rule.RuleType.PERSPECTIVE, ControlSchemas.Platformer); new Rule("vvvvvv-platformer", Rule.RuleType.PERSPECTIVE, ControlSchemas.VVVVVVPlatformer); ////new Rule("colorblind", Rule.RuleType.OVERLAY, (location, obj) => ////{ ////}); ////new Rule("vertical-flip", Rule.RuleType.OVERLAY, (location, obj) => ////{ ////}); foreach (Rule.RuleType type in Enum.GetValues(typeof(Rule.RuleType))) { new Rule($"pop {type}", Rule.RuleType.POP, null); } Referee.AddRule(Rule.Rules["Goal victory"]); Referee.AddRule(Rule.Rules["Enemy hurty"]); Referee.AddRule(Rule.Rules["Player pickup Powerup"]); Referee.AddRule(Rule.Rules["clicky attack"]); Referee.AddRule(Rule.Rules["spawn Powerup"]); Referee.AddRule(Rule.Rules["control Player"]); Referee.AddRule(Rule.Rules["vvvvvv-platformer"]); for (int i = 0; i < 10; i++) { Referee.AddRule(Rule.GetNameRandomRule()); } }
public static void SetupTitleScreen() { Referee.OutofControl = false; Level = 0; Referee.Stop(); Engine.SetLocation(new Location(new Description2D(0, 0, ScreenWidth, ScreenHeight))); Description2D logoDescription = new Description2D(Sprite.Sprites["gmtklogo"], ScreenWidth / 2, ScreenHeight / 2); Entity logo = new Entity(logoDescription); int timer = TPS * 2; logo.TickAction = (loc, ent) => { bool isPress = Program.Mouse[(int)Actions.ACTION].IsPress(); if (logoDescription.ImageIndex < Sprite.Sprites["gmtklogo"].HImages - 1 && timer == TPS * 2) { if (isPress) { logoDescription.ImageIndex = Sprite.Sprites["gmtklogo"].HImages - 1; } else { logoDescription.ImageIndex++; } } else { if (timer-- == 0 || timer > 0 && isPress) { timer = -1; logoDescription.ImageIndex = 0; Engine.AddEntity(Text.Create("RuleScramble", new Font("", 24, FontStyle.Italic | FontStyle.Bold | FontStyle.Underline), ScreenWidth / 2, 16)); Engine.AddEntity(Button.Create("Story Mode", () => { Levels[StartingLevel - 1].SetupLevel(); if (Program.Diff == Difficulty.NORMAL && Level == 7) { Lives = 3; } else if (Program.Diff == Difficulty.EASY && Level == 7) { Lives = 4; } else { Lives = 1; } }, ScreenWidth / 2 - 128 / 2, ScreenHeight / 2 - 48)); Engine.AddEntity(Button.Create("Arcade Mode", SetupCrazyMode, ScreenWidth / 2 - 128 / 2, ScreenHeight / 2 + 8)); Engine.AddEntity(Button.Create("Credits", SetupCredits, ScreenWidth / 2 - 128 / 2, ScreenHeight / 2 + 64)); Engine.AddEntity(Text.Create("Story:", new Font("Arial", 10, FontStyle.Regular), ScreenWidth / 2 + 112, ScreenHeight / 2 - 40)); Button easyButton = null; Button normalButton = null; Button hardButton = null; Entity button = Button.Create("easy", () => { Program.Diff = Difficulty.EASY; easyButton.IsSelected = true; normalButton.IsSelected = false; hardButton.IsSelected = false; }, ScreenWidth / 2 + 80, ScreenHeight / 2 - 16, 64, 32); Engine.AddEntity(button); easyButton = button.Description as Button; if (Program.Diff == Difficulty.EASY) { easyButton.IsSelected = true; } button = Button.Create("normal", () => { Program.Diff = Difficulty.NORMAL; easyButton.IsSelected = false; normalButton.IsSelected = true; hardButton.IsSelected = false; }, ScreenWidth / 2 + 80, ScreenHeight / 2 + 16, 64, 32); Engine.AddEntity(button); normalButton = button.Description as Button; if (Program.Diff == Difficulty.NORMAL) { normalButton.IsSelected = true; } button = Button.Create("hard", () => { Program.Diff = Difficulty.HARD; easyButton.IsSelected = false; normalButton.IsSelected = false; hardButton.IsSelected = true; }, ScreenWidth / 2 + 80, ScreenHeight / 2 + 48, 64, 32); Engine.AddEntity(button); hardButton = button.Description as Button; if (Program.Diff == Difficulty.HARD) { hardButton.IsSelected = true; } Engine.AddEntity(Text.Create("Controls:\nWASD+Mouse\n[Radial\nmove toward\nmouse]\nR: Reset\nEsc: Title", new Font("Arial", 10, FontStyle.Regular), ScreenWidth / 8 + 8, ScreenHeight / 2 - 48)); } } }; Engine.AddEntity(logo); }