Exemplo n.º 1
0
 public LANLobby(WindowManager windowManager, GameCollection gameCollection,
                 List <GameMode> gameModes)
     : base(windowManager)
 {
     this.gameCollection = gameCollection;
     this.gameModes      = gameModes;
 }
Exemplo n.º 2
0
        public static GameCollection GetCollection()
        {
            GameCollection tempList = null;

            using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("usp_GetGame", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollection);

                    myConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.HasRows)
                        {
                            tempList = new GameCollection();
                            while (myReader.Read())
                            {
                                tempList.Add(FillDataRecord(myReader));
                            }
                        }
                        myReader.Close();
                    }
                }
            }
            return(tempList);
        }
Exemplo n.º 3
0
 public PrivateMessagingWindow(WindowManager windowManager,
                               CnCNetManager connectionManager, GameCollection gameCollection, CnCNetUserData cncnetUserData) : base(windowManager)
 {
     this.gameCollection    = gameCollection;
     this.connectionManager = connectionManager;
     this.cncnetUserData    = cncnetUserData;
 }
Exemplo n.º 4
0
        public bool SetDataFromStringArray(GameCollection gc, string[] parameters)
        {
            if (parameters.Length != 9)
            {
                Logger.Log("Ignoring LAN GAME message because of an incorrect number of parameters.");
                return(false);
            }

            if (parameters[0] != ProgramConstants.LAN_PROTOCOL_REVISION)
            {
                return(false);
            }

            GameVersion  = parameters[1];
            Incompatible = GameVersion != ProgramConstants.GAME_VERSION;
            Game         = gc.GameList.Find(g => g.InternalName.ToUpper() == parameters[2]);
            Map          = parameters[3];
            GameMode     = parameters[4];
            LoadedGameID = parameters[5];
            string[] players = parameters[6].Split(',');
            Players = players;
            if (players.Length == 0)
            {
                return(false);
            }
            HostName           = players[0];
            Locked             = Conversions.IntFromString(parameters[7], 1) > 0;
            IsLoadedGame       = Conversions.IntFromString(parameters[8], 0) > 0;
            LastRefreshTime    = DateTime.Now;
            TimeWithoutRefresh = TimeSpan.Zero;
            RoomName           = HostName + "'s Game";

            return(true);
        }
Exemplo n.º 5
0
        public CnCNetManager(WindowManager wm, GameCollection gc)
        {
            gameCollection = gc;
            connection     = new Connection(this);

            this.wm = wm;

            cDefaultChatColor = AssetLoader.GetColorFromString(ClientConfiguration.Instance.DefaultChatColor);

            ircChatColors = new IRCColor[]
            {
                new IRCColor("Default color", false, cDefaultChatColor, 0),
                new IRCColor("Default color #2", false, cDefaultChatColor, 1),
                new IRCColor("Light Blue", true, Color.LightBlue, 2),
                new IRCColor("Green", true, Color.ForestGreen, 3),
                new IRCColor("Dark Red", true, new Color(180, 0, 0, 255), 4),
                new IRCColor("Red", true, Color.Red, 5),
                new IRCColor("Purple", true, Color.MediumOrchid, 6),
                new IRCColor("Orange", true, Color.Orange, 7),
                new IRCColor("Yellow", true, Color.Yellow, 8),
                new IRCColor("Lime Green", true, Color.Lime, 9),
                new IRCColor("Turquoise", true, Color.Turquoise, 10),
                new IRCColor("Sky Blue", true, Color.LightSkyBlue, 11),
                new IRCColor("Blue", true, Color.RoyalBlue, 12),
                new IRCColor("Pink", true, Color.Fuchsia, 13),
                new IRCColor("Gray", true, Color.LightGray, 14),
                new IRCColor("Gray #2", false, Color.Gray, 15)
            };
        }
Exemplo n.º 6
0
 public void BroadcastShape(object state)
 {
     foreach (Game game in GameCollection.All())
     {
         if (game.NextStage())
         {
             string player = game.GetPlayerForMove();
             if (player != null)
             {
                 _hubContext.Clients.Group(game.Id).playerFire(player);
                 continue;
             }
         }
         else
         {
             if (game.GetPlayerForMove() != null)
             {
                 var move = game.GetPlayerMove();
                 if (move != null)
                 {
                     _hubContext.Clients.Group(game.Id).playerMove(move.Item1, move.Item2, move.Item3);
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
        void DoExportAll()
        {
            Util.PrepareExportDirectory(ExportPath);
            var managedPath   = Path.Combine(GameDir, "Managed");
            var mainAssetPath = GetMainAssetPath();
            var gameStructure = GameStructure.Load(new string[]
            {
                mainAssetPath,
                managedPath
            });

            fileCollection = gameStructure.FileCollection;
            var scripts = fileCollection.FetchAssets().Where(o => o is MonoScript ms).ToArray();

            foreach (Object asset in scripts)
            {
                MonoScript script = (MonoScript)asset;
                if (ScriptByName)
                {
                    using (MD5 md5 = MD5.Create())
                    {
                        var data = md5.ComputeHash(Encoding.UTF8.GetBytes($"{script.AssemblyName}.{script.Namespace}.{script.ClassName}"));
                        Util.SetGUID(script, data);
                    }
                }
            }
            gameStructure.Export(ExportPath, asset => asset is MonoScript);
        }
Exemplo n.º 8
0
        public static object LoadFile(string filepath)
        {
            var    scheme = GameCollection.LoadScheme(filepath, Path.GetFileName(filepath));
            object file   = LoadScheme(scheme);

            scheme.Dispose();
            return(file);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Tworzy nowy obiekt PokerService
        /// </summary>
        private PokerService()
        {
            //Inicjalizacja zmiennych
            Console.WriteLine("PokerService()");

            Clients  = new List <ClientModel>();
            GameList = new GameCollection();
        }
Exemplo n.º 10
0
 public LANLobby(WindowManager windowManager, GameCollection gameCollection,
                 List <GameMode> gameModes, MapLoader mapLoader)
     : base(windowManager)
 {
     this.gameCollection = gameCollection;
     this.gameModes      = gameModes;
     this.mapLoader      = mapLoader;
 }
Exemplo n.º 11
0
        private void BindGameList()
        {
            GameCollection gameList = new GameCollection();

            gameList = GameDAL.GetCollection();

            rptGameList.DataSource = gameList;
            rptGameList.DataBind();
        }
Exemplo n.º 12
0
    public void combinations(int[] n, GameCollection x)
    {
        int k = 3;

        foreach (IEnumerable <int> i in Combinations(n, k))
        {
            x.addGame(new Game(i.ToArray()[0], i.ToArray()[1], i.ToArray()[2]));
        }
    }
Exemplo n.º 13
0
 /// <summary>
 /// Create Channel/Lobby
 /// </summary>
 /// <param name="name">lobby name</param>
 /// <param name="maxPlayers">lobby max players</param>
 /// <param name="id">lobby id</param>
 /// <param name="flag">Lobby Type/Flag</param>
 public Lobby(string name, ushort maxPlayers, byte id, uint flag)
 {
     Name       = name;
     MaxPlayers = maxPlayers;
     Id         = id;
     Flag       = flag;
     Games      = new GameCollection(this);
     Players    = new DisposableCollection <Session>(10);
 }
Exemplo n.º 14
0
 public GameController(GameCollection gameCollection, IConfiguration configuration,
                       ApplicationDbContext context, IHubContext <PacmanHub> hubContext, IHostingEnvironment hostingEnvironment)
 {
     Configuration      = configuration;
     GameCollection     = gameCollection;
     Context            = context;
     HubContext         = hubContext;
     HostingEnvironment = hostingEnvironment;
 }
Exemplo n.º 15
0
        public void playerMoved(string gameId, string player, int power, int angle)
        {
            Game game = GameCollection.Get(gameId);

            if (game != null)
            {
                game.PlayerMove(player, power, angle);
            }
        }
Exemplo n.º 16
0
        public void bulletLanded(string gameId, string playerName)
        {
            Game game = GameCollection.Get(gameId);

            if (game != null)
            {
                game.BulletLanded(playerName);
            }
        }
				FromGameCollection (GameCollection collection)
			{
				GamesCollectionDialog dlg =
					new GamesCollectionDialog ();
				dlg.titleEntry.Text = collection.Title;
				dlg.descriptionTextView.Buffer.Text =
					collection.Description;

				return dlg;
			}
Exemplo n.º 18
0
        /// <summary>
        /// Searches for a game asynchronously
        /// </summary>
        /// <param name="name">The games name or abbreviation to search for</param>
        /// <returns>Returns a list of games matching the search query</returns>
        public async Task <ReadOnlyCollection <Game> > SearchAsync(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException(nameof(name), "Parameter can't be empty");
            }
            GameCollection gs = await SrlClient.GetAsync <GameCollection>($"{BasePath}?search={name.ToLower()}").ConfigureAwait(false);

            return(gs?.Games?.AsReadOnly());
        }
Exemplo n.º 19
0
        /// <summary>
        /// Searches for a game synchronously
        /// </summary>
        /// <param name="name">The games name or abbreviation to search for</param>
        /// <returns>Returns a list of games matching the search query</returns>
        public ReadOnlyCollection <Game> Search(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException(nameof(name), "Parameter can't be empty");
            }
            GameCollection gs = SrlClient.Get <GameCollection>($"{BasePath}?search={name.ToLower()}");

            return(gs?.Games?.AsReadOnly());
        }
Exemplo n.º 20
0
        public void playerFired(string gameId, int power, int angle)
        {
            Game game = GameCollection.Get(gameId);

            if (game != null)
            {
                var player = game.GetPlayerForMove();
                game.PlayerFired(power);
                Clients.Group(gameId).playerFired(player, power, angle);
            }
        }
Exemplo n.º 21
0
        private void UpdateAlsoPlayingGames(dynamic newArenaElement, GameCollection alsoPlayingGames)
        {
            var alsoPlayingGamesArray = new JArray();

            foreach (var game in alsoPlayingGames)
            {
                alsoPlayingGamesArray.Add(new JValue(game.Id));
            }

            newArenaElement.alsoPlayingGames = alsoPlayingGamesArray;
        }
Exemplo n.º 22
0
        public static GameCollection CreateGameCollection()
        {
            var layoutInfo = new LayoutInfo(new Version(), Platform.StandaloneWin64Player, TransferInstructionFlags.NoTransferInstructionFlags);
            var layout     = new AssetLayout(layoutInfo);
            var parameters = new GameCollection.Parameters(layout);

            parameters.ScriptBackend = ScriptingBackend.Mono;
            var gameCollection = new GameCollection(parameters);

            return(gameCollection);
        }
Exemplo n.º 23
0
        public void join(string gameId, string playerId)
        {
            Game game = GameCollection.Get(gameId);

            Groups.Add(Context.ConnectionId, gameId);
            if (!game.HasPlayerJoined(playerId))
            {
                playerId = game.Join(playerId);
                Clients.Group(gameId).playerJoined(playerId);
            }
        }
Exemplo n.º 24
0
        public PrivateMessagingWindow(WindowManager windowManager,
                                      CnCNetManager connectionManager, GameCollection gameCollection, CnCNetUserData cncnetUserData) : base(windowManager)
        {
            this.gameCollection    = gameCollection;
            this.connectionManager = connectionManager;
            this.cncnetUserData    = cncnetUserData;

            connectionManager.UserAdded            += ConnectionManager_UserAdded;
            connectionManager.UserRemoved          += ConnectionManager_UserRemoved;
            connectionManager.UserGameIndexUpdated += ConnectionManager_UserGameIndexUpdated;
        }
    private void AddCollection(GameCollection collection)
    {
        grid.transform.AddChild(gameCollectionPrefab);

        var data = grid.transform.GetChild(grid.transform.childCount - 1).GetComponent <CollectionController>();

        data.copy = collection;
        data.SetParams();

        myCollection.Add(data);
    }
        public PrivateMessagingWindow(WindowManager windowManager,
                                      CnCNetManager connectionManager, GameCollection gameCollection) : base(windowManager)
        {
            this.gameCollection    = gameCollection;
            this.connectionManager = connectionManager;

            connectionManager.UserAdded            += ConnectionManager_UserAdded;
            connectionManager.UserRemoved          += ConnectionManager_UserRemoved;
            connectionManager.UserGameIndexUpdated += ConnectionManager_UserGameIndexUpdated;

            WindowManager.GameClosing += WindowManager_GameClosing;
        }
Exemplo n.º 27
0
    public void setUpComputer()
    {
        pMoves         = new Moves();
        cMoves         = new Moves();
        availableMoves = new Moves();
        mg             = new MoveGenerator();

        games = new GameCollection(new Game(0, 1, 2), new Game(3, 4, 5), new Game(0, 3, 6), new Game(2, 4, 6),
                                   new Game(1, 4, 7), new Game(2, 5, 8), new Game(0, 4, 8), new Game(6, 7, 8));

        availableMoves = games.toMoveArray();
    }
Exemplo n.º 28
0
        public PlayerListBox(WindowManager windowManager, GameCollection gameCollection) : base(windowManager)
        {
            this.gameCollection = gameCollection;

            Users = new List <ChannelUser>();

            adminGameIcon   = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.cncneticon);
            unknownGameIcon = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.unknownicon);
            friendIcon      = AssetLoader.LoadTexture("friendicon.png");
            ignoreIcon      = AssetLoader.LoadTexture("ignoreicon.png");
            badgeGameIcon   = AssetLoader.LoadTexture("Badges\\badge.png");
        }
Exemplo n.º 29
0
        public static void GetAllGames(HttpClient client)
        {
            var            allGameResp = client.GetAsync("generation").Result;
            GameCollection games       = allGameResp.Content.ReadAsAsync <GameCollection>().Result;

            foreach (var game in games.Results)
            {
                Console.WriteLine($"->> {game.name}");
            }

            Console.ReadLine();
        }
Exemplo n.º 30
0
        /***********************************
        * GetGamesList()
        *  Prints list of games
        ***********************************/
        public static void GetGamesList(HttpClient client)
        {
            var            allGames = client.GetAsync("generation").Result;
            GameCollection gameList = allGames.Content.ReadAsAsync <GameCollection>().Result;

            Console.WriteLine("\nGAMES/GENERATIONS: \n");
            foreach (var game in gameList.results)
            {
                Console.WriteLine(game.name);
            }

            Console.ReadLine();
        }
Exemplo n.º 31
0
        private InformationModel CreateGame(string map)
        {
            var id       = Guid.NewGuid().ToString();
            var basePath = HostingEnvironment.WebRootPath;
            var mapPath  = Configuration.GetSection("AppConfig:Map" + map + "Path").Value;
            var fullPath = Path.Combine(basePath, mapPath);
            var game     = new Game(fullPath, map + "Map");

            GameCollection.AddGame(id, new GameConnection(game, HubContext, id));
            return(new InformationModel {
                Widht = game.Map.Widht, Height = game.Map.Height, Id = id
            });
        }
			public EditGamesCollectionDialog (GameCollection col)
			{
				Glade.XML xml =
					Glade.XML.
					FromAssembly ("gamedb.glade",
						      "gamesCollectionDialog",
						      null);
				xml.Autoconnect (this);

				removeSelectedGamesButton.Clicked +=
					OnRemoveSelectedGamesButtonClicked;

				collectionGamesListWidget =
					new GamesListWidget ();
				gamesListBox.Add (collectionGamesListWidget);

				collectionGamesListWidget.View.SelectionMode =
					SelectionMode.Multiple;

				this.col = col;
				SetGamesCollection (col);
			}
			private void SetGamesCollection (GameCollection col)
			{
				titleEntry.Text = col.Title;
				descriptionView.Buffer.Text = col.Description;

				ArrayList games = new ArrayList ();
				col.LoadGames (games);
				collectionGamesListWidget.SetGames (games);
			}
Exemplo n.º 34
0
 public void DeleteCollection(GameCollection col)
 {
     db.Delete (col);
     db.Commit ();
 }
Exemplo n.º 35
0
 public void AddCollection(GameCollection col)
 {
     db.Set (col);
     db.Commit ();
 }
Exemplo n.º 36
0
            private bool AddGamesIdleHandler()
            {
                IList games = viewer.ChessGameWidget.Games;
                if (games == null)
                  {
                      dbDlg.Dispose ();
                      dbDlg = null;
                      return false;
                  }
                viewer.StartProgress ();
                double totalgames = games.Count;
                int ngames = 0;
                GameCollection collection = null;
                string[]tags = dbDlg.Tags;
                if (dbDlg.AddCollection
                    && dbDlg.CollectionTitle != null)
                  {
                      collection =
                          new GameCollection (dbDlg.
                                      CollectionTitle,
                                      dbDlg.
                                      Description,
                                      new
                                      ArrayList
                                      ());
                  }
                // Dont use 'foreach' since the list is going to change
                for (int i = 0; i < games.Count; i++)
                  {
                      ChessGame game =
                          (ChessGame) games[i];
                      PGNGameDetails updated;
                      if (!(game is PGNGameDetails))
                        {
                            GameDb.Instance.
                                FindOrCreateGame
                                (game,
                                 out updated);
                        }
                      else
                          updated =
                              game as
                              PGNGameDetails;

                      foreach (string tag in tags)
                      {
                          updated.AddTag (tag);
                      }
                      if (collection != null)
                          collection.
                              AddGame (updated);
                      GameDb.Instance.DB.Set (updated);
                      viewer.ChessGameWidget.
                          UpdateGame (game, updated);

                      ngames++;
                      viewer.UpdateProgress (ngames /
                                 totalgames);
                  }
                if (collection != null)
                    GameDb.Instance.DB.Set (collection);

                if (ngames > 0)
                    GameDb.Instance.Commit ();

                viewer.StopProgress ();
                dbDlg.Dispose ();
                dbDlg = null;
                return false;
            }