public Game.Session JoinGameSession(Game.Player joiner, Game.Type gameType, int target) { var gamesOfType = m_matchingSessions.Where((gs) => { return(gs.m_gameType == gameType); }); int bestTarget = int.MaxValue; Game.Session fallbackSession = null; var matched = gamesOfType.Where((gs) => { int score = gs.MatchScore(joiner); if (score <= target) { return(true); } else if (score < bestTarget) { bestTarget = score; fallbackSession = gs; } return(false); }); if (matched.Count() >= 0) { return(matched.ElementAt(0)); } return(fallbackSession); }
public Scene(Game.Session session) { FieldWidth = session.CurrentState.Field.Width; FieldHeight = session.CurrentState.Field.Height; Layers = new ObservableCollection <ObservableCollection <SceneObject> >(); var tileLayer = new ObservableCollection <SceneObject>(); for (int row = 0; row < session.CurrentState.Field.Height; row++) { for (int col = 0; col < session.CurrentState.Field.Width; col++) { tileLayer.Add(new TileObject(session, row, col)); } } Layers.Add(tileLayer); var mainLayer = new ObservableCollection <SceneObject>(); mainLayer.Add(new PlayerObject(session)); for (int i = 0; i < session.CurrentState.BoxesCoords.Length; i++) { mainLayer.Add(new BoxObject(session, i)); } Layers.Add(mainLayer); }
public GameSessionWindow(Game.Session session) { Session = session; Scene = new SceneTree.Scene(Session); InitializeComponent(); DataContext = this; }
public PuzzleSolvedPopUpWindow(Game.Session session) { InitializeComponent(); Session = session; Action = null; DataContext = this; }
public Game.Session HostGameSession(Game.Player host) { // TODO: make sure host is not already in another game session var gs = new Game.Session(); gs.m_host = host; gs.m_players.Add(host); m_activeSessions.Add(gs); return(gs); }
public TileObject(Game.Session session, int row, int column) : base(session) { this.Row = row; this.Column = column; switch (session.CurrentState.Field.GetCellAt(Row, Column)) { case Core.Field.Cell.Empty: TileType = TileType.EmptyTile; break; case Core.Field.Cell.Target: TileType = TileType.TargetTile; break; case Core.Field.Cell.Wall: TileType = TileType.WallTile; break; } }
public PlayerObject(Game.Session session) : base(session) { Row = session.CurrentState.PlayerCoords.Row; Column = session.CurrentState.PlayerCoords.Col; }
public BoxObject(Game.Session session, int index) : base(session) { this.index = index; Row = session.CurrentState.BoxesCoords[index].Row; Column = session.CurrentState.BoxesCoords[index].Col; }
protected SceneObject(Game.Session session) { this.session = session; session.StateChanged += session_StateChanged; }