Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
 public GameSessionWindow(Game.Session session)
 {
     Session = session;
     Scene   = new SceneTree.Scene(Session);
     InitializeComponent();
     DataContext = this;
 }
Example #4
0
 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);
        }
Example #6
0
        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;
            }
        }
Example #7
0
 public PlayerObject(Game.Session session) : base(session)
 {
     Row    = session.CurrentState.PlayerCoords.Row;
     Column = session.CurrentState.PlayerCoords.Col;
 }
Example #8
0
 public BoxObject(Game.Session session, int index) : base(session)
 {
     this.index = index;
     Row        = session.CurrentState.BoxesCoords[index].Row;
     Column     = session.CurrentState.BoxesCoords[index].Col;
 }
Example #9
0
 protected SceneObject(Game.Session session)
 {
     this.session          = session;
     session.StateChanged += session_StateChanged;
 }