public async Task LoadGameAsync(String path) { if (_dataAccess == null) { throw new InvalidOperationException("No data access is provided."); } _isLost = false; _table = await _dataAccess.LoadAsync(path); switch (_table.Size) { case 4: _gameSize = GameSize.Small; break; case 8: _gameSize = GameSize.Medium; break; case 12: _gameSize = GameSize.Large; break; } }
private Int32 _wallsCount; // lerakott falak száma #endregion Fields #region Constructors public RobotGameModel() { _gameSpeed = GameSpeed.Fast; _gameSize = GameSize.Small; _gameActive = false; _first = false; }
public TetrisModel(TetrisDataAccessInterface dataAccess = null) { _gameSize = GameSize.Medium; _table = new TetrisTable(); NewShapeSpawn(); _dataAccess = dataAccess; }
public string[][] CreateGame(GameSize gameSize, string[][] pexesoGrid, string nickOfCreator, string nickOfCompetitor) { try { _pexesoPlayers.TryGetValue(nickOfCompetitor, out var competitor); if (competitor == null) { return(null); } var result = competitor.GetInvitation(nickOfCreator, pexesoGrid, gameSize); if (result) { _playersInGame.Add(nickOfCreator); _playersInGame.Add(nickOfCompetitor); } else { pexesoGrid = null; } return(pexesoGrid); } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } }
/********************************************************************************/ public GameWindow(GameSize gameSize) { //Init form InitializeComponent(); //Init nums GAMESIZE = gameSize; SHEEP_TO_PLACE = ((int)GAMESIZE * (int)GAMESIZE) / 5; randomizer = new Random(); //Init Images flower = new ImageBrush(); flower.ImageSource = new BitmapImage(new Uri("Images/flower.png", UriKind.Relative)); sheep = new ImageBrush(); sheep.ImageSource = new BitmapImage(new Uri("Images/sheep.png", UriKind.Relative)); deadSheep = new ImageBrush(); deadSheep.ImageSource = new BitmapImage(new Uri("Images/red-sheep.png", UriKind.Relative)); backgroundI = new ImageBrush(); backgroundI.ImageSource = new BitmapImage(new Uri("Images/background.fw.png", UriKind.Relative)); this.Background = backgroundI; //Init Sounds sheepSound = new System.Media.SoundPlayer(@"Sounds\sheep.wav"); gunSound = new System.Media.SoundPlayer(@"Sounds\gun.wav"); //Init structs playerSquares = new Square[(int)GAMESIZE, (int)GAMESIZE]; computerSquares = new Square[(int)GAMESIZE, (int)GAMESIZE]; computerChoices = new List <Point>(); //Init func DrawSquares(); InitializeSheep(); }//end GameWindow()
public void SetDirection(Direction direction, GameSize gameSize) { if (SnakePoints.Count > 1 && !SnakePoints[1].Equals(GetNextHeadPosition(direction).CorrectPoint(gameSize))) { Direction = direction; } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here allAsteroids = new ArrayList(); allItems = new Powerup[20]; rand = new Random((int)DateTime.Now.Ticks & 0x0000FFFF); player = new Player(); currentState = GameStates.StartMenu; buttonTextures = new Texture2D[11]; asteroidModels = new Model[7]; currentDifficulty = GameDifficulties.Medium; currentSize = GameSize.Medium; allExplosions = new Explosion[15]; //should be enough for (int i = 0; i < allExplosions.Length; i++) { allExplosions[i] = new Explosion(); } lives = 3; gameTimer = 0; goodToGo = false; base.Initialize(); }
public async Task <IActionResult> Edit(int id, [Bind("GameSizeId,GameSizeName")] GameSize gameSize) { if (id != gameSize.GameSizeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(gameSize); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GameSizeExists(gameSize.GameSizeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(gameSize)); }
public TetrisGameState(GameSize gameSize) : base(gameSize) { GenerateFigure(); Walls = new List <BitArray>(gameSize.Height); for (int i = 0; i < gameSize.Height; i++) { AddWallLevel(); } }
public WindowManager(GameSize gameSize, GameObject backgroundPrefab, Color backgroundColor) { _gameSize = gameSize; backgroundPrefab.name = "Background"; background = backgroundPrefab.GetComponent <SpriteRenderer>(); background.color = backgroundColor; background.transform.localScale = new Vector3(gameSize.width, gameSize.height, 1); background.transform.position = new Vector3(gameSize.width / 2f, -1, gameSize.height / 2f); }
private GameSize GetGameSize(IReadOnlyList <int> list) { var gameSize = new GameSize { LineSizeX = list[0], LineSizeY = list[1] }; return(gameSize); }
void Start() { GameSize GameSizeObject = GameSize.gameSize; GameSizeObjectSizeX = GameSizeObject.transform.localScale.x / 2.0f; GameSizeObjectSizeY = GameSizeObject.transform.localScale.y / 2.0f; gameStartCounter = GameStartCounter.gameStartCounter; StartCoroutine(gameStartCounter.FirstStartCounting(gameStartCounter.startTime, StartLevel)); }
public GameWindow(string gameSize) { InitializeComponent(); if (!Enum.TryParse(gameSize, out GameSize size)) { throw new ArgumentException($"Invalid game size {gameSize}"); } _size = size; SetupGame(this._size); }
public async Task <IActionResult> Create([Bind("GameSizeId,GameSizeName")] GameSize gameSize) { if (ModelState.IsValid) { _context.Add(gameSize); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(gameSize)); }
public SnakeGameState(GameSize gameSize, int initialSnakeLength, bool canSnakeGrow) : base(gameSize) { SnakeState = new SnakeState(initialSnakeLength, canSnakeGrow); Walls = new List <BitArray>(gameSize.Height); for (int i = 0; i < gameSize.Height; i++) { Walls.Add(new BitArray(gameSize.Width)); } Bonus = GenerateBonus(); }
void Awake() { if (gameSize == null) { // DontDestroyOnLoad(gameObject); gameSize = this; } else if (gameSize != this) { Destroy(gameObject); } }
public void ShowPexeso(GameSize gameSize, string[][] pexesoGrid, string competitor) { ResetPexeso(); Challenger = _mainWindow._pexesoPlayer.NickName; Competitor = competitor; PexesoGrid = pexesoGrid; game = new Game { GameSize = gameSize, NickOfChallenger = Challenger, NickOfCompetitor = Competitor }; startGame = DateTime.Now; switch (gameSize) { case GameSize.size3x2: MakePexeso(); break; case GameSize.size4x3: MakePexeso(); break; case GameSize.size4x4: MakePexeso(); break; case GameSize.size5x4: MakePexeso(); break; case GameSize.size6x5: MakePexeso(); break; case GameSize.size6x6: MakePexeso(); break; case GameSize.size7x6: MakePexeso(); break; case GameSize.size8x7: MakePexeso(); break; case GameSize.size8x8: MakePexeso(); break; } }
public void Revert(GameSize gameSize) { for (int i = 0; i < SnakePoints.Count / 2; i++) { var tmp = SnakePoints[i]; SnakePoints[i] = SnakePoints[SnakePoints.Count - i - 1]; SnakePoints[SnakePoints.Count - i - 1] = tmp; } Direction = SnakePoints.Count > 1 ? SnakePoints[1].DirectionTo(SnakePoints[0], gameSize) : RevertDirection(Direction); }
public void It_should_kill_an_alone_alive_cell() { var initialState = new GameState(); initialState.PutAliveCell(new Position(0,0)); var size = new GameSize(3,3); var game = new GameOfLife(size, initialState); var currentState = game.Next(); Assert.AreEqual(0, currentState.AliveCells()); Assert.AreEqual(CellState.Dead, currentState.GetState(new Position(0,0))); }
public static Field Create(GameSize size) { switch (size) { case GameSize.small: return(new Field(8, 8, 10)); case GameSize.medium: return(new Field(16, 16, 40)); default: return(new Field(30, 16, 99)); } }
public void It_should_keeps_alive_cell_when_there_is_two_neighbors() { var initialState = new GameState(); initialState.PutAliveCell(new Position(0,0)); initialState.PutAliveCell(new Position(1,0)); initialState.PutAliveCell(new Position(0,1)); var size = new GameSize(3,3); var game = new GameOfLife(size, initialState); var currentState = game.Next(); Assert.AreEqual(CellState.Alive, currentState.GetState(new Position(0,0))); }
public Game(int id, GameSize gameSize, int countOfMovesCompetitor, int countOfUncoveredCardsCompetitor, int countOfUncoveredCardsChallenger, int countOfMovesChallenger, TimeSpan gameTime, string nickOfChallenger, string winner, string nickOfCompetitor) { Id = id; GameSize = gameSize; CountOfMovesCompetitor = countOfMovesCompetitor; CountOfUncoveredCardsCompetitor = countOfUncoveredCardsCompetitor; CountOfUncoveredCardsChallenger = countOfUncoveredCardsChallenger; CountOfMovesChallenger = countOfMovesChallenger; GameTime = gameTime; NickOfChallenger = nickOfChallenger; Winner = winner; NickOfCompetitor = nickOfCompetitor; }
public static IReadOnlyList <GamePoint> GenerateNewFigure(Random random, GameSize gameSize) { var template = BaseFigures[random.Next(BaseFigures.Count)]; var figureArea = template.GetArea(); IReadOnlyList <GamePoint> figure = template .Select(p => new GamePoint(p.X + (gameSize.Width - figureArea.Size.Width) / 2, p.Y + gameSize.Height)) .ToList(); var rotations = random.Next(MaxRotations); for (int i = 0; i < rotations; i++) { figure = figure.Rotate(); } return(figure); }
private static IGameWithMetaInfo GenerateDatabaseGame( int ID, GameSize size, GameDifficulty difficulty, int[] rowTallyData, int[] columnTallyData, int[] shipSettingsData, IEnumerable <Tuple <GridPoint, BimaruValue> > initialFieldValues ) { var metaInfo = new GameMetaInfo(ID, size, difficulty); var game = GenerateGame(rowTallyData, columnTallyData, shipSettingsData, initialFieldValues); return(new GameWithMetaInfo(metaInfo, game)); }
private void ShowNextBoard(GameSize newSize) { String newText = ""; if (String.IsNullOrEmpty(newSize.Name)) { newText = newSize.Name + " (" + newSize.X + "x" + newSize.Y + ")"; } else { newText = newSize.X + " x " + newSize.Y; } boardText.text = newText; boardImg.sprite = newSize.SourceImage; }
private void SendInvitationThread(string name, GameSize gameSize) { pickedGameSize = gameSize; var grid = _pexeso_Page.MakePexesoGrid(gameSize); var game = _pexesoServiceClient.CreateGame(gameSize, grid, Player.NickName, name); if (game == null) { OnInvitationResultCame(name, false); } else { OnInvitationResultCame(name, true); } }
public bool InvitePlayer(GameSize gameSize, string otherNick) { if (Nick == otherNick) { return(false); } var msg = new InvitationMessage() { SenderNick = Nick, ReceiverNick = otherNick, GameSize = gameSize }; _pexesoChannel.InvitePlayer(msg); return(true); }
private List <char> GenerateGameCards(GameSize gameSize) { var numberOfCards = gameSize.Height() * gameSize.Width(); var index = _gameBoardRandom.Next(_gameCardsChars.Length); var result = new List <char>(numberOfCards); for (var i = 0; i < numberOfCards / 2; i++) { var c = _gameCardsChars[(index + i) % _gameCardsChars.Length]; result.Add(c); result.Add(c); } return(new Queue <char>(result.OrderBy(i => _gameBoardRandom.Next())).ToList()); }
public int[] InitilaizeShipCount(GameSize gameSize) { int[] shipCounts = new int[5]; if (gameSize == GameSize.Small) { shipCounts = new int[] { 1, 1, 1, 1, 1 }; } else if (gameSize == GameSize.Medium) { shipCounts = new int[] { 2, 2, 2, 2, 2 }; } else//Large { shipCounts = new int[] { 3, 3, 3, 3, 3 }; } return(shipCounts); }
/// <summary> /// This increases the loss counter kept by settings based on the size of the game. /// </summary> public void IncreaseLossCounter(GameSize size) { switch (size) { case GameSize.small: Settings.Default.SmallLossData++; break; case GameSize.medium: Settings.Default.MediumLossData++; break; case GameSize.large: Settings.Default.LargeLossData++; break; } Settings.Default.Save(); }
public string[][] MakePexesoGrid(GameSize gameSize) { GameSize = gameSize; switch (gameSize) { case GameSize.size3x2: MakePexesoGrid(3, 2); break; case GameSize.size4x3: MakePexesoGrid(4, 3); break; case GameSize.size4x4: MakePexesoGrid(4, 4); break; case GameSize.size5x4: MakePexesoGrid(5, 4); break; case GameSize.size6x5: MakePexesoGrid(6, 5); break; case GameSize.size6x6: MakePexesoGrid(6, 6); break; case GameSize.size7x6: MakePexesoGrid(7, 6); break; case GameSize.size8x7: MakePexesoGrid(8, 8); break; case GameSize.size8x8: MakePexesoGrid(8, 8); break; } return(PexesoGrid); }
public bool GetInvitation(string nickName, string[][] pexesoGrid, GameSize gameSize) { MessageBoxResult result = MessageBox.Show($"You got invitation for game from {nickName}\n" + $"Game size is: {gameSize}\n" + $"Do you wanna accept it?", "Game invitation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { _pexeso_Page.ShowPexeso(gameSize, pexesoGrid, nickName); _frame_Main.Content = _pexeso_Page; return(true); } else { return(false); } }
public void SetTableSize(Int32 size) { switch (size) { case 0: _gameSize = GameSize.Small; break; case 1: _gameSize = GameSize.Medium; break; case 2: _gameSize = GameSize.Large; break; default: _gameSize = GameSize.Medium; break; } }