Beispiel #1
0
 public LANLobby(WindowManager windowManager, GameCollection gameCollection,
                 List <GameMode> gameModes)
     : base(windowManager)
 {
     this.gameCollection = gameCollection;
     this.gameModes      = gameModes;
 }
Beispiel #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);
        }
Beispiel #3
0
 public PrivateMessagingWindow(WindowManager windowManager,
                               CnCNetManager connectionManager, GameCollection gameCollection, CnCNetUserData cncnetUserData) : base(windowManager)
 {
     this.gameCollection    = gameCollection;
     this.connectionManager = connectionManager;
     this.cncnetUserData    = cncnetUserData;
 }
        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);
        }
Beispiel #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)
            };
        }
Beispiel #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);
                 }
             }
         }
     }
 }
        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);
        }
Beispiel #8
0
        public static object LoadFile(string filepath)
        {
            var    scheme = GameCollection.LoadScheme(filepath, Path.GetFileName(filepath));
            object file   = LoadScheme(scheme);

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

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

            gameList = GameDAL.GetCollection();

            rptGameList.DataSource = gameList;
            rptGameList.DataBind();
        }
Beispiel #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]));
        }
    }
Beispiel #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);
 }
Beispiel #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;
 }
Beispiel #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);
            }
        }
Beispiel #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;
			}
Beispiel #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());
        }
Beispiel #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());
        }
Beispiel #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);
            }
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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);
            }
        }
Beispiel #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;
        }
Beispiel #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();
    }
        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");
        }
Beispiel #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();
        }
Beispiel #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();
        }
Beispiel #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);
			}
Beispiel #34
0
 public void DeleteCollection(GameCollection col)
 {
     db.Delete (col);
     db.Commit ();
 }
Beispiel #35
0
 public void AddCollection(GameCollection col)
 {
     db.Set (col);
     db.Commit ();
 }
            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;
            }