public GameCommunication(WebSocketConnectionManager webSocketConnectionManager) : base(webSocketConnectionManager, new ControllerMethodInvocationStrategy()) { ValidatePlayersNumber(); ((ControllerMethodInvocationStrategy)MethodInvocationStrategy).Controller = this; GameEngine = new GameEngine.GameEngine(PlayersNumber); }
public override void OnCreateGame(ICreateGameCallInfo info) { base.OnCreateGame(info); AccountId = info.Request.GameProperties["accountId"] as string; _isEndGame = false; GameEngine = new GameEngine.GameEngine(OnGameEngineMessage, new PhotonPluginLogger(base.PluginHost, OnGameEngineMessage)); }
public Form1() { InitializeComponent(); this.gameEngine = new GameEngine.GameEngine(); this.NewGame(); }
public static void SetupCrazyMode() { Level = -1; Program.Referee.ClearRules(); Program.Referee.OutofControl = true; for (int i = 0; i < 50; i++) { string rule = Rule.GetNameRandomRule(); while (Rule.Rules[rule].Type == Rule.RuleType.POP) { rule = Rule.GetNameRandomRule(); } Referee.AddRule(rule); } Program.Referee.AddRule(Rule.Rules["top-down"]); Program.Referee.AddRule(Rule.Rules["Enemy hurty"]); Program.Referee.AddRule(Rule.Rules["control Player"]); Program.Referee.AddRule(Rule.Rules["Goal victory"]); Engine.SetLocation(new Location(new Description2D(0, 0, ScreenWidth, ScreenHeight))); Engine.AddEntity(Player.Create(Program.ScreenWidth / 4, Program.ScreenHeight / 2)); Point center = new Point(Program.ScreenWidth * 3 / 4, Program.ScreenHeight / 2); Engine.AddEntity(Goal.Create(center.X + Program.Random.Next(-32, 48), center.Y + Program.Random.Next(-48, 48))); Action <Location, Entity> moving = (location, entity) => { Enemy d2d = entity.Description as Enemy; d2d.ChangeCoordsDelta(d2d.VelX, Math.Sin(d2d.VelY)); Description2D locd2d = location.Description as Description2D; if (d2d.X < 0 || d2d.X > locd2d.Width) { d2d.VelX = -d2d.VelX; } if (d2d.Y < 0 || d2d.Y > locd2d.Height) { d2d.VelY = -d2d.VelY; } }; for (int i = 0; i < 20; i++) { Entity enemy = Enemy.Create(center.X + (int)(48 * Math.Cos(i / 20.0 * Math.PI * 2)), center.Y + (int)(48 * Math.Sin(i / 20.0 * Math.PI * 2))); enemy.TickAction = moving; //Engine.AddEntity(Enemy.Create(Program.Random.Next(16, Program.ScreenWidth - 16), Program.Random.Next(16, Program.ScreenHeight - 16))); Engine.AddEntity(enemy); } Engine.AddEntity(HeadsUpDisplay.Create()); Referee.Start(); }
public override void Update(GameTime gameTime, GameEngine.TeeEngine engine) { if (CurrentDrawableState.Contains("Spin") && Drawables.IsStateFinished(CurrentDrawableState, gameTime)) { Direction = (Direction)((int)(Direction + 1) % 4); CurrentDrawableState = "Idle_" + Direction; } }
public static void SetupCredits() { Engine.SetLocation(new Location(new Description2D(0, 0, ScreenWidth, ScreenHeight))); int time = Program.ScreenHeight / 2 + 8; TickHandler t = null; CreditsFinished = false; t = (s, o) => { if (time-- <= 0) { Engine.TickEnd -= t; CreditsFinished = true; } }; Engine.TickEnd += t; Action <Location, Entity> scroll = (loc, ent) => { Description2D entd = ent.Description as Description2D; if (time > 0) { entd.ChangeCoordsDelta(0, -1); } }; int y = Program.ScreenHeight / 2; Engine.AddEntity(Text.Create("Credits", new Font("Arial", 32, FontStyle.Underline), ScreenWidth / 2, y + 16).AddTickAction(scroll)); Engine.AddEntity(Text.Create("Developed by", new Font("Arial", 16, FontStyle.Underline), ScreenWidth / 2, y + 64).AddTickAction(scroll)); Engine.AddEntity(Text.Create("Nicholas Denaro", new Font("Arial", 12), ScreenWidth / 2, y + 96).AddTickAction(scroll)); Engine.AddEntity(Text.Create("Art by", new Font("Arial", 16, FontStyle.Underline), ScreenWidth / 2, y + 128).AddTickAction(scroll)); Engine.AddEntity(Text.Create("System.Drawing.Common", new Font("Arial", 12), ScreenWidth / 2, y + 160).AddTickAction(scroll)); Engine.AddEntity(Text.Create("Special thanks to", new Font("Arial", 16, FontStyle.Underline), ScreenWidth / 2, y + 192).AddTickAction(scroll)); Engine.AddEntity(Text.Create("My faithful Twitch chat <3", new Font("Arial", 10), ScreenWidth / 2, y + 224).AddTickAction(scroll)); }
protected void AddMenuItem(string str, GameEngine.Helpers.Input.Action action) { menuItems.Add(new StringToDraw(game, str, new Vector2(), font)); if (menuItems.Count == 1) UpdateSelected(); AddAction(menuItems.Count - 1, action); height = 0; maxLength = 0; foreach (StringToDraw s in menuItems) { Vector2 v = s.StringSize(); height += v.Y; maxLength = MathHelper.Max(maxLength, v.X); } float startY = (game.Height() - height) / 2 + ((StringToDraw)menuItems[0]).StringSize().Y / 2; float rowHeight=height/menuItems.Count; for (int ii = 0; ii < menuItems.Count; ii++) ((StringToDraw)menuItems[ii]).Position = new Vector2(0.5f, (startY + ii * rowHeight)/game.Height()); }
public void ShouldCompleteGame() { var engine = new GameEngine.GameEngine(); engine.RunGame(); }
public Main_Level() { engine = GameEngine.GetInstance(); }
public static void SetupThanksForPlaying() { Engine.SetLocation(new Location(new Description2D(0, 0, ScreenWidth, ScreenHeight))); Engine.AddEntity(Text.Create("Thanks for playing!", new Font("Arial", 24), ScreenWidth / 2, ScreenHeight / 2 - 24)); }
public Circle(Vector2f position, float radius) { engine = GameEngine.GetInstance(); straal = radius; pos = position; }
static void Main(string[] args) { GameEngine gameEngine = new GameEngine(); gameEngine.init(); }
public GameBuilder GameEngine(GameEngine engine) { Engine = engine; return(this); }
private void AddAction(int menuItem, GameEngine.Helpers.Input.Action action) { menuActions.Add(menuItem, action); }
public Draw(Collision m_goal) { engine = GameEngine.GetInstance(); goal = m_goal; }
public static void Main(string[] args) { WavPlayer.Init(WavProvider); WavPlayer.Play(); Keyboard = new WindowsKeyController(keyMap.ToDictionary(kvp => (int)kvp.Key, kvp => (int)kvp.Value)); Mouse = new WindowsMouseController(mouseMap.ToDictionary(kvp => (int)kvp.Key, kvp => (int)kvp.Value)); Builder = new GameBuilder(); Builder.GameEngine(new FixedTickEngine(TPS)) .GameView(new GameView2D(ScreenWidth, ScreenHeight, Scale, Scale, Color.DarkSlateGray)) .GameFrame(new GameFrame(new AvaloniaWindowBuilder(), 0, 0, ScreenWidth, ScreenHeight, Scale, Scale)) .Controller(Keyboard) .Controller(Mouse) .Build(); Engine = Builder.Engine; GameFrame frame = Builder.Frame; AvaloniaWindow window = frame.Window as AvaloniaWindow; Referee = new Referee(); Engine.TickEnd += Referee.Tick; Sprites(); Rules(); SetupLevels(); SetupTitleScreen(); Engine.TickEnd += (s, gs) => { if (Iframe > 0) { Iframe--; } if (Program.Keyboard[(int)Actions.ESCAPE].IsPress()) { Program.WavPlayer.Stop(); Program.WavProvider.RemoveAllMixerInputs(); StopMovingWindow(); SetupTitleScreen(); } if (Program.Keyboard[(int)Actions.DIAGS].IsPress()) { ShowDiags = !ShowDiags; } if (Program.Keyboard[(int)Actions.RESTART].IsPress()) { if ((Program.Referee.OutofControl || Program.Level == 7) && !Engine.Location.GetEntities <Banner>().Any()) { return; } if (Engine.Location.GetEntities <Banner>().FirstOrDefault()?.Text == "you win") { if (Level == -1) { for (int i = 0; i < 10; i++) { Referee.AddRule(Rule.GetNameRandomRule()); } } else { Level++; } } StopMovingWindow(); Program.WavPlayer.Stop(); Program.WavProvider.RemoveAllMixerInputs(); // Levels can call the reset with something different Referee.ResetTimer(); switch (Level) { case -1: SetupCrazyMode(); break; case 0: break; case 8: SetupCredits(); Level = 9; break; case 9: if (CreditsFinished) { SetupThanksForPlaying(); Level = 10; } break; case 10: SetupTitleScreen(); break; default: if (CreditsFinished) { StartingLevel = Level; Levels[Level - 1].SetupLevel(); } break; } if (Program.Diff == Difficulty.NORMAL && Level == 7) { Lives = 3; } else if (Program.Diff == Difficulty.EASY && Level == 7) { Lives = 4; } else { Lives = 1; } } }; Engine.Start(); while (true) { } }
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); }