/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { List <Player> tempPlayers = new List <Player>(); tempPlayers.Add(new Player { Index = 0, IsDead = false, IsHuman = true, Name = "player1", Points = 0 }); tempPlayers.Add(new Player { Index = 1, IsDead = true, IsHuman = true, Name = "player2", Points = 0 }); tempPlayers.Add(new Player { Index = 2, IsDead = false, IsHuman = true, Name = "player3", Points = 0 }); StateGlobals.Players = tempPlayers; PhaseHandler.CurrentPlayer = StateGlobals.Players[0]; // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); gameboard = ServiceContainer.Container.Resolve <IGameboard>(); spellboard = ServiceContainer.Container.Resolve <ISpellboard>(); gameboard.GenerateEmptyGameboard(); spellboard.GenerateEmptySpellboard(); gameEventHandler = ServiceContainer.Container.Resolve <IGameEventHandler>(); infoStringHandler = ServiceContainer.Container.Resolve <IInfoStringHandler>(); SpellsGenerator sg = new SpellsGenerator(); sg.GenerateSpells(); }
public static int CombatWithElevatedElfPower(IList <string> input, IGameEventHandler gameEventHandler = null) { var ui = gameEventHandler ?? new NoUi(); int survivingElves; int elvesAtStart; int outcome; var elvesAttackingPower = 3; do { elvesAttackingPower++; var game = Game.Create(input, ui); elvesAtStart = game.AliveElves.Count; foreach (var elf in game.AliveElves) { elf.PowerUp(elvesAttackingPower); } outcome = game.Run(stopOnDeadElf: true); survivingElves = game.AliveElves.Count; } while (survivingElves < elvesAtStart); return(outcome); }
public static Game Create(IList <string> input, IGameEventHandler gameHandler) { var allPositions = new HashSet <Point>(); var walls = new HashSet <Point>(); var elves = new List <Unit>(); var goblins = new List <Unit>(); for (var y = 0; y < input.Count; y++) { var line = input[y]; for (int x = 0; x < line.Length; x++) { var point = new Point(x, y); allPositions.Add(point); var c = line[x]; switch (c) { case '#': walls.Add(point); break; case 'E': elves.Add(new Unit(point, c, goblins, 200, 3)); break; case 'G': goblins.Add(new Unit(point, c, elves, 200, 3)); break; } } } return(new Game(allPositions, walls, elves, goblins, gameHandler)); }
public Game(HashSet <Point> allPositions, HashSet <Point> walls, List <Unit> elves, List <Unit> goblins, IGameEventHandler gameHandler) { this.allPositions = allPositions; this.gameHandler = gameHandler; this.walls = walls; this.elves = elves; this.goblins = goblins; gameHandler.SetGame(this); }
public static void RegisterHandler(GameEvent evt, IGameEventHandler handler) { List <IGameEventHandler> handlerList = _eventHandlers[(int)evt]; if (handlerList == null) { handlerList = new List <IGameEventHandler>(); _eventHandlers[(int)evt] = handlerList; } handlerList.Add(handler); }
public GameEvent(string name, string desc, DateTime start, DateTime finish, double timerInterval, IGameEventHandler handler) { Name = name; Description = desc; EventStart = start; EventFinish = finish; Handler = handler; Handler.ReferenceGameEvent = this; EventTimer = new System.Timers.Timer(); EventTimer.Interval = timerInterval; this.EventTimer.Elapsed += new System.Timers.ElapsedEventHandler(Handler.OnTick); }
public void Plugin(IGameEventHandler handler) { GameHandlers.Add(handler); }
/// <summary> /// Initializes a new instance of the <see cref="MultiModel"/> class. /// </summary> /// <param name="handler">The handler.</param> public MultiModel(IGameEventHandler handler) { mazeGen = new DFSMazeGenerator(); gameManager = new GameManager.GameManager(new ListGameContainer(), handler); }
protected void RegisterEventHandler(GameEvent evt, IGameEventHandler handler) { GameEventComponent.RegisterHandler(evt, handler); }
public static int Combat(IList <string> input, IGameEventHandler gameEventHandler = null) { var game = Game.Create(input, gameEventHandler ?? new NoUi()); return(game.Run()); }
public static void RegisterHandler <TEvent>(IGameEventHandler <TEvent> handler) where TEvent : IGameEvent { SystemMessageBroker.AddListener(handler); }
public void AddHandler(IGameEventHandler handler) { Handlers.Add(handler); }
public void SubscribeEventHandler(IGameEventHandler handler) { MoveFinished += handler.OnMoveFinished; }
/// <summary> /// GameManager Ctor /// </summary> /// <param name="container"></param> /// <param name="handler"></param> public GameManager(IGameContainer container, IGameEventHandler handler) { this.container = container; this.handler = handler; }