/// <summary> /// So the idea here is that we can't move to our desired spot, because it's not valid. /// To try to find where the player wanted to go, we lineraly search SelectionSearchLength /// points in a direction looking for a good position. If nothing is found, MoveSelectionToNewPoint /// calls this again with an offset that has us look one tile in the perpendicular direction /// for a matching tile. This is so something like this /// . /// . @ . /// . /// can allow one from moving from the south to the east point. /// </summary> /// <param name="engine">Game Engine</param> /// <param name="pointWantToGoTo">Where was the original ideal point</param> /// <param name="directionFromCenter">What direction was this from the center</param> /// <param name="offsets">Which ways to shift if we're trying for nearby matches</param> /// <returns></returns> private static Point MoveSelectionToNewPointSearchDirection(IGameEngine engine, Point pointWantToGoTo, Direction directionFromCenter, List<Point> offsets, List<EffectivePoint> targetablePoints) { Point nextSelectionAttempt = pointWantToGoTo; const int SelectionSearchLength = 20; for (int i = 0; i < SelectionSearchLength; ++i) { if (i != 0) nextSelectionAttempt = PointDirectionUtils.ConvertDirectionToDestinationPoint(nextSelectionAttempt, directionFromCenter); if (EffectivePoint.PositionInTargetablePoints(nextSelectionAttempt, targetablePoints)) { return nextSelectionAttempt; } if (offsets != null) { foreach (Point o in offsets) { if (EffectivePoint.PositionInTargetablePoints(nextSelectionAttempt + o, targetablePoints)) { return nextSelectionAttempt + o; } } } } return Point.Invalid; }
public override void UpdateFromNewData(IGameEngine engine, Point mapUpCorner, Point cursorPosition) { if (m_isSelectionCursor) { m_currentToolTips = engine.GameState.GetDescriptionForTile(cursorPosition); } }
public GameForm() { this.InitializeComponent(); this.timer.Interval = 1000; this.timer.Tick += this.TimerTick; this.updates.Interval = 100; this.updates.Tick += this.UpdateTick; this.textboxBigBlind.Visible = false; this.textboxSmallBlind.Visible = false; this.buttonBigBlind.Visible = false; this.buttonSmallBlind.Visible = false; this.textboxRaise.Text = (AppSettigns.DefaultMinBigBlind * 2).ToString(); IPlayer human = this.GetHumanPlayer(); IAILogicProvider logicProvider = new AILogicProvider(); ICollection<IAIPlayer> enemies = this.GetEnemies(logicProvider); IPot pot = new Pot(this.textboxPot); IDealer dealer = this.GetDealer(); IDeck deck = Deck.Instance; this.messageWriter = new MessageBoxWriter(); IHandTypeHandler handTypeHandler = new HandTypeHandler(); this.engine = new GameEngine(human, enemies, pot, dealer, deck, this.messageWriter, handTypeHandler); this.engine.GameEngineStateEvent += this.ChangeGameEngineStateHandler; this.updates.Start(); this.engine.Run(); }
public RunningKeyboardHandler(GameWindow window, IGameEngine engine) { m_window = window; m_engine = engine; m_lock = new object(); m_dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); }
public void UpdateFromNewData(IGameEngine engine) { foreach (PainterBase p in m_painters) { p.UpdateFromNewData(engine, CalculateMapCorner(engine)); } }
private EngineFacade() { this.highscore = new Highscore(); this.renderer = new ConsoleUIRenderer(); this.provider = new BasicIOProvider<ConsoleUIRenderer>(this.renderer, this.highscore); this.gameEngine = new GameEngine(this.provider); }
public GameController(IGameEngine gameEngine, IInputHandler inputReader, IRenderer renderer) { this.gameEngine = gameEngine; this.inputReader = inputReader; this.renderer = renderer; this.currentCmd = null; }
public void OnKeyboardDown(MagecrawlKey key, Map map, GameWindow window, IGameEngine engine) { switch (key) { case MagecrawlKey.Enter: { ICharacter possiblyTargettedMonster = engine.Map.Monsters.Where(x => x.Position == map.TargetPoint).FirstOrDefault(); // Rememeber last targetted monster so we can target them again by default next turn. if (m_targettingType == TargettingType.Monster && possiblyTargettedMonster != null) m_lastTargetted = possiblyTargettedMonster; if (m_action != null) { m_action(window, engine, map.TargetPoint); m_action = null; } Escape(map, window); break; } case MagecrawlKey.Escape: { Escape(map, window); break; } case MagecrawlKey.v: { Escape(map, window); break; } case MagecrawlKey.Left: HandleDirection(Direction.West, map, window, engine); break; case MagecrawlKey.Right: HandleDirection(Direction.East, map, window, engine); break; case MagecrawlKey.Down: HandleDirection(Direction.South, map, window, engine); break; case MagecrawlKey.Up: HandleDirection(Direction.North, map, window, engine); break; case MagecrawlKey.Insert: HandleDirection(Direction.Northwest, map, window, engine); break; case MagecrawlKey.Delete: HandleDirection(Direction.Southwest, map, window, engine); break; case MagecrawlKey.PageUp: HandleDirection(Direction.Northeast, map, window, engine); break; case MagecrawlKey.PageDown: HandleDirection(Direction.Southeast, map, window, engine); break; default: break; } }
public MainWindowViewModel(IGameEngine gameEngine, IObservable<IGameEvent> events, IViewController viewController) { _events = events; _viewController = viewController; GameEngine = gameEngine; Hit = new ActionCommand(OnPlayerHit2); }
public override void UpdateFromNewData(IGameEngine engine, Point mapUpCorner, Point cursorPosition) { CalculateMovability(engine); m_width = engine.Map.Width; m_height = engine.Map.Height; m_mapUpCorner = mapUpCorner; }
public Game(IOutputAdapter outputAdapter, IGameEngine gameEngine, IPlayer firstPlayer, IPlayer secondPlayer, int waitBetweenMoves = 0) { _outputAdapter = outputAdapter; _gameEngine = gameEngine; _players[0] = firstPlayer; _players[1] = secondPlayer; _waitBetweenMoves = waitBetweenMoves; }
public GameManager(IGameRepository gameRepository, IGameValidator gameValidator, IGameCriteria gameCriteria, IGameEngine gameEngine, IRatingRepository ratingRepository) { _GameRepository = gameRepository;// Ioc.Container.Get<IGameRepository>(); _GameValidator = gameValidator; _GameCriteria = gameCriteria; _GameEngine = gameEngine; _RatingRepository = ratingRepository; }
public void Dispose() { m_container.Dispose(); m_engine = null; if (m_painters != null) m_painters.Dispose(); m_painters = null; }
public override void UpdateFromNewData(IGameEngine engine, Point mapUpCorner, Point cursorPosition) { if (m_enabled) { m_map = engine.Map; m_mapCorner = mapUpCorner; m_cursorPosition = cursorPosition; } }
protected GameEngineEventsListnerBase(IGameEngine gameEngine) { gameEngine.PlayerLoggedIn += OnPlayerLoggedIn; gameEngine.PlayerLoggedOut += OnPlayerLoggedOut; gameEngine.GameCreated += OnGameCreated; gameEngine.GameJoined += OnGameJoined; gameEngine.GameEnded += OnGameEnded; gameEngine.TurnMade += OnTurnMade; }
private void CalculateFOV(IGameEngine engine) { // This is expensive, so only do if we've going to use it if (m_enabled) { m_playerFOV = engine.Debugger.CellsInPlayersFOV(); m_monsterFOV = engine.Debugger.CellsInAllMonstersFOV(); } }
public MainWindow(IGameEngine gameEngine) { GameEngine = gameEngine; var rand = new Random(); GameEngine.Events.OfType<GameObjectCreated>().Subscribe( e => Canvas.Children.Add(new GolfBall {X = rand.NextDouble()*600, Y = rand.NextDouble()*400})); InitializeComponent(); }
public IGameCommand CreateCommand(string[] commandArguments, IGameEngine engine) { string replacedString = commandArguments[0].Replace("-", string.Empty); string commandName = replacedString + ValidationControl.CommandStringPostFix; Type currentType = assemblyCommandTypes.FirstOrDefault(x => x.Name.ToLower() == commandName); IGameCommand currentCommand = Activator.CreateInstance(currentType, engine) as IGameCommand; return currentCommand; }
public void UpdateFromNewData(IGameEngine engine) { TileVisibility[,] tileVisibility = engine.GameState.CalculateTileVisibility(); Point mapCorner = CalculateMapCorner(engine); foreach (PainterBase p in m_painters) { p.UpdateFromVisibilityData(tileVisibility); // Needs to be called before FromNewData. p.UpdateFromNewData(engine, mapCorner, MapCursorEnabled ? CursorSpot : engine.Player.Position); } }
private void RestartGame(IGameEngine engine) { engine.Dispose(); engine.Logger.LogMessageAndGoNextLine(Resources.GameMessagesResources.StartingNewGame); engine.StartGame(); ////pri restart trqbva da se napravi prototypePattern i s observer da se zakachim //// i da trigger- nem eventa koito shte vzeme predishniq state /v nachaloto na igrata na obektite //// i shte zapochne s tqh }
private void PauseGame(IGameEngine engine) { engine.Logger.LogMessageAndGoNextLine(Resources.GameMessagesResources.UnpauseMessage); var keyPressed = engine.Logger.ReadKey(true); while (keyPressed.Key != ConsoleKey.Escape) { engine.Logger.LogMessageAndGoNextLine(Resources.GameMessagesResources.UnpauseMessage); keyPressed = engine.Logger.ReadKey(true); } }
public GameEngineManager(string snapshotJson, string templateJson, int targetUpdatesPerSecond) { // allocate the engine // TODO: examine the maybe, make sure the game actually loaded _gameEngine = GameEngineFactory.CreateEngine(snapshotJson, templateJson).Value; // create the event monitors CreateEventMonitors(_gameEngine.EventNotifier); _networkContext = NetworkContext.CreateServer(new Player("test-player"), ""); _turnGame = new AutomaticTurnGame(_networkContext, targetUpdatesPerSecond); }
/// <summary> /// Starts a new console game. /// </summary> internal void Start() { this.balloonsGame = new Game(this.field); this.gameLogic = new GameLogicProvider(this.balloonsGame); this.data = new BalloonsData(this.players, this.games); this.topScoreController = new TopScoreController(this.data.Players); this.gamesController = new GamesController(this.data.Games); this.engine = new GameEngine(this.gameLogic, this.printer, this.reader, this.data, this.topScoreController, this.gamesController); this.engine.StartGame(); }
private void Application_Startup(object sender, StartupEventArgs e) { m_engine = new PublicGameEngineInterface(); m_engine.PlayerDiedEvent += new PlayerDied(PlayerDiedEvent); m_engine.RangedAttackEvent += new RangedAttack(RangedAttackEvent); m_engine.TextOutputEvent += new TextOutputFromGame(TextOutputEvent); m_engine.CreateNewWorld("Donblas", "Scholar"); m_window.Setup(m_engine); m_window.Focus(); }
public static IStyles GetStyles(IGameEngine game) { if (game is Threes) return new ThreesStyles(game.GetMaxNumber()); else if (game is Fives) return new FivesStyles(); else if (game is Eights) return new EightsStyles(); else if (game is TwentyFortyEight) return new TwentyFortyEightStyles(); throw new NotSupportedException(String.Format("Styles not implemented for {0}", game.GetType().Name)); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); _dm = new DependencyManager(); _dm.InitDIContainer(); _gi = _dm.CreateGame(); ServerEndPoint = _gi.Start(); }
public TargettingModeKeyboardHandler(TargettingType targettingType, IGameEngine engine, Map map, List<EffectivePoint> targetablePoints) { m_targetablePoints = targetablePoints; m_targettingType = targettingType; map.InTargettingMode = true; map.TargetPoint = SetTargettingInitialSpot(engine); if (m_targetablePoints != null) map.TargetablePoints = m_targetablePoints; m_lastTargetted = null; }
public void DrawBoard(IGameEngine game) { var styles = StylesFactory.GetStyles(game).GetStylesCollection(); game.Board.ForEachCell((i, j) => { if (game.Board[i, j] != 0) { var tile = (ContentControl)this.FindName(String.Format("tile{0}{1}", i, j)); DisplayTile(tile, styles, game.Board[i, j].ToString()); } }); DisplayTile(NextTile, styles, game.NextNumber.ToString()); }
public Form1() { InitializeComponent(); IoC.IoC.Initialize(new DependencyResolver()); InitializeBoard(); _gameEngine = IoC.IoC.Resolve<IGameEngine>(); _gameEngine.Output.OnBoardChange += Output_OnBoardChange; _gameEngine.NewGame(); //Initializing some tiles //_gameEngine.SetTile(0, 0, 2); _gameEngine.SetTile(0, 1, 2); _gameEngine.SetTile(0, 2, 0); _gameEngine.SetTile(0, 3, 4); //_gameEngine.SetTile(1, 0, 4); _gameEngine.SetTile(1, 1, 2); _gameEngine.SetTile(1, 2, 4); _gameEngine.SetTile(1, 3, 4); //_gameEngine.SetTile(2, 0, 2); _gameEngine.SetTile(2, 1, 2); _gameEngine.SetTile(2, 2, 0); _gameEngine.SetTile(2, 3, 2); }
public ICommand CreateCommand(string commandName, IGameEngine engine) { var commandType = Assembly.GetExecutingAssembly() .GetTypes() .FirstOrDefault(c => c.CustomAttributes.Any(a => a.AttributeType == typeof(CommandAttribute)) && c.Name == commandName); if (commandType == null) { throw new ArgumentNullException("commandType", "Unknown command"); } var command = Activator.CreateInstance(commandType, engine) as ICommand; return command; }
protected Command(IGameEngine engine) { this.Engine = engine; }
public BuildStructureCommand(IGameEngine engine) : base(engine) { }
public void Effect(Item item, Player player, IGameEngine gameEngine, Action <Item, Player> inventoryCallback) { inventoryCallback(item, player); }
public GameOfLifeMvcEngine(IGameEngine gameEngine) { _gameEngine = gameEngine; }
public WarCardsPuzzle(IGameEngine gameEngine) : base(gameEngine) { }
public PlotJumpCommand(IGameEngine gameEngine) : base(gameEngine) { }
public Player(IGameEngine engine, long id, ClassTemplate myClass) { Initialize(engine, id, myClass); }
public ConsoleGui(IGameEngine game) { this.game = game; }
public UserInterface(IGameEngine gameEngine) { _engine = gameEngine; }
public CreateUnitCommand(IGameEngine engine) : base(engine) { }
public SystemReportCommand(IGameEngine gameEngine) : base(gameEngine) { }
public void DrawBoard(IGameEngine game) { Console.Clear(); ShowBoard(game); }
public GameHub(IGameEngine gameEngine, IConfig config, IMapState mapState) { _gameEngine = gameEngine; _config = config; _mapState = mapState; }
public DefibrillatorsSolution(IGameEngine gameEngine) : base(gameEngine) { }
public DinoHub(IGameEngine engine, ILogger <DinoHub> logger) { _engine = engine; _logger = logger; }
public Game(IGameEngine gameEngine, IGameUi gameUi) { _gameEngine = gameEngine; _gameUi = gameUi; }
public UpgradeCityCommand(IGameEngine engine) : base(engine) { }
public StatusReportCommand(IGameEngine gameEngine) : base(gameEngine) { }
public RpgPlayer(IGameEngine gameEngine) { _gameEngine = gameEngine; }
public JoinGameCommand(IGameEngine gameEngine) : base(gameEngine) { }
protected AbstractCommand(IGameEngine engine) { this.Engine = engine; }
public SkillReader(IGameEngine engine) { Engine = engine; }
protected Game(IGameEngine gameEngine) : base(gameEngine) { _gameReader = new GameReader(gameEngine); _gameEngine = gameEngine; }
/// <summary> /// Initializes a new instance of the <see cref="CreateCommand"/> class. /// </summary> /// <param name="gameEngine"> /// The game engine. /// </param> public CreateCommand(IGameEngine gameEngine) : base(gameEngine) { }
public CityStatusCommand(IGameEngine engine) : base(engine) { }
internal static ProcessingResult?GameSetup(ReceivedMessage message) { ProcessingResult?result = null; var activeGame = GameManager.GetActiveGameByChatId(message.ChatId); if (activeGame == null) { if (ConversationManager.WaitingList.Any(x => x.chatId == message.ChatId && x.sender == message.SenderId)) { ConversationManager.WaitingList.RemoveAll(x => x.chatId == message.ChatId && x.sender == message.SenderId); } ConversationManager.WaitingList.Add((message.ChatId, message.SenderId, ConversationManager.WaitingReason.GameUrl)); result = new ProcessingResult() { ChatId = message.ChatId, Text = Constants.Replies.NO_ACTIVE_GAME_CREATE, Markup = Constants.Keyboards.CreateNewGame, }; } else if (activeGame.Type == GameType.CustomEnCx && String.IsNullOrEmpty(activeGame.CustomEnCxDomain)) { if (message.Parameter == null) { return(ProcessingResult.CreateText(message, String.Format(Constants.Replies.EN_CX_NO_DOMAIN, activeGame.Guid))); } else { var parts = message.Parameter.Replace("/", "\\").Split("\\").ToList(); if (parts.Count() > 1) { parts = parts.Where(x => x.Contains("en.cx")).Take(1).ToList(); } if (parts.Count() == 1) { var domain = parts.First(); if (!domain.Contains("en.cx")) { domain += ".en.cx"; } activeGame.CustomEnCxDomain = $"http://{domain}"; GameManager.Update(activeGame); return(GameSetup(message)); } } } else if (activeGame.Login == null || activeGame.Password == null) { if (IGameEngine.Get(activeGame) is IEnCxGameEngine && activeGame.EnCxId == null) { result = FindEnCxGame(message); } else { var _markup = Constants.Keyboards.GameWithoutAuth(activeGame); var loginsConf = Config.GetSection("LOGINS") ?.GetSection(message.ChatId.ToString()) ?.GetSection(activeGame.Type.ToString()); if (loginsConf != null) { var logins = loginsConf.GetChildren(); if (logins != null && logins.ToList().Any()) { var buttons = _markup.InlineKeyboard.ToList(); buttons.AddRange( logins.Select(x => new List <InlineKeyboardButton> { new InlineKeyboardButton { Text = $"Login as: {x.Key}", CallbackData = $"/{Constants.Commands.SetAuth} {x.Key}" } }).ToList() ); _markup = new InlineKeyboardMarkup(buttons); } } result = new ProcessingResult() { ChatId = message.ChatId, Text = String.Format(Constants.Replies.GAME_NO_AUTH, activeGame.Guid, activeGame.Type.ToString()), Markup = _markup }; } } else { result = new ProcessingResult() { ChatId = message.ChatId, Text = Constants.Replies.GAME_FULL, Markup = Constants.Keyboards.GameCommands(activeGame) }; } if (result != null && message.IsCallback) { result.MessageId = message.Id; result = new ProcessingResult() { EditMessages = new List <ProcessingResult> { result } }; } if (result != null && message.Command == Constants.Commands.GameSetup) { result.Delete = true; result.MessageId = message.Id; } return(result); }
protected DispatchPlayer(IGameEngine gameEngine) : base(gameEngine) { }
internal static ProcessingResult?StartSetingAuth(ReceivedMessage message) { var activeGame = GameManager.GetActiveGameByChatId(message.ChatId); if (activeGame == null) { return(null);//todo:ex } if (String.IsNullOrEmpty(message.Parameter)) { //has nothing if (!message.PrivateChat) { //send to private GameManager.JoinGame(activeGame.Id, activeGame.Guid, message.ChatId, true); return(new ProcessingResult() { ChatId = message.SenderId, Text = String.Format(Constants.Replies.AUTH_GET_LOGIN_FROM_PUBLIC, activeGame.Guid), }); } else { return(new ProcessingResult() { ChatId = message.ChatId, Text = String.Format(Constants.Replies.AUTH_GET_LOGIN, activeGame.Guid), Markup = new ForceReplyMarkup() }); } } else if (message.Parameters != null && message.Parameters.Count == 1) { var loginsConf = Config.GetSection("LOGINS") ?.GetSection(message.ChatId.ToString()) ?.GetSection(activeGame.Type.ToString()); var logins = loginsConf?.GetChildren(); if (logins != null && logins.ToList().Any(x => x.Key == message.Parameter)) { message.Parameters.Add(logins.Where(x => x.Key == message.Parameter).First().Value); } //has login else { return new ProcessingResult() { ChatId = message.ChatId, Text = String.Format(Constants.Replies.AUTH_GET_PASSWORD, activeGame.Guid, message.Parameter), Markup = new ForceReplyMarkup(), Delete = true, MessageId = message.Id } }; } if (message.Parameters != null && message.Parameters.Count == 2) { //has login and pass activeGame.Login = message.Parameters[0]; activeGame.Password = message.Parameters[1]; var engine = IGameEngine.Get(activeGame); try { if (engine.Login(activeGame)) { //activeGame.Update(); GameManager.Update(activeGame); } } catch (Exception ex) { Log.New(ex); } var result = GameSetup(message); result.Delete = true; result.MessageId = message.Id; return(result); } return(null); }
public Sanitizer(IGameEngine engine) { _engine = engine; }
public void Execute(Command command, IGameEngine engine) { if (command.Args.Length < 1) { engine.Log().Log("Usage of cast command: duel challenge <target>\nduel accept \nduel reject \nduel exit"); return; } if (!CommandManager.Instance.CheckCurrentPlayer(command)) { return; } Player currentPlayer = engine.GetPlayerManager().FindPlayerById(command.UserId); string option = command.Args[0]; switch (option) { case "challenge": { if (command.Args.Length < 2) { engine.Log().Log("Please chose a target to challenge (duel challenge <target>)"); return; } string targetName = command.Args[1]; Player target = engine.GetPlayerManager().FindPlayerByName(targetName); if (target == null) { engine.Log().Log($"A player with name {targetName} does not exist."); return; } if (target.Entity.IsDead) { engine.Log().Log($"{targetName} is dead. You can't challenge a dead player."); return; } if (currentPlayer.Id == target.Id) { engine.Log().Log($"{targetName} you can't challenge yourself, you idiot."); return; } target.AddChallenge(currentPlayer); } break; case "accept": { if (currentPlayer.Dueling) { engine.Log().Log($"[{currentPlayer.Entity.Name}] Currently dueling."); return; } if (currentPlayer.DuelRequests.Count != 0) { currentPlayer.AcceptDuel(); } else { engine.Log().Log($"[{currentPlayer.Entity.Name}] No duel requests."); } } break; case "reject": { if (currentPlayer.Dueling) { engine.Log().Log($"[{currentPlayer.Entity.Name}] Currently dueling."); return; } if (currentPlayer.DuelRequests.Count != 0) { currentPlayer.AcceptDuel(); } else { engine.Log().Log($"[{currentPlayer.Entity.Name}] No duel requests."); } } break; case "exit": { if (currentPlayer.Dueling) { currentPlayer.EndDuel(); } else { engine.Log().Log($"[{currentPlayer.Entity.Name}] Not currently dueling."); } } break; } }