public void RemoveApplication(string applicantId) { ApplicationModels applicant = context.Applicaitons.Where(x => x.AspNetUsersId == applicantId).First(); context.Applicaitons.Remove(applicant); context.SaveChanges(); }
// PUT /api/applications/5 public HttpResponseMessage Put(String id, ApplicationModels.UpdateApplicationRequest request) { var application = GetApplication(id); if (application == null) { var response = new HttpResponseMessage<ApplicationModels.ApplicationResponse>(HttpStatusCode.BadRequest); response.ReasonPhrase = "Invalid Application"; return response; } //TODO: check to make sure passed in id is the calling application try { application.Url = request.url; } catch (Exception ex) { //TODO: log exception var message = new HttpResponseMessage(HttpStatusCode.InternalServerError); message.ReasonPhrase = ex.Message; return message; } return new HttpResponseMessage(HttpStatusCode.OK); }
public void AddNewApplication(string fileName) { if (!ExistsApplication(fileName)) { ApplicationModels.Add(new ApplicationModel(fileName)); } }
public void addNewApplicationModel(ApplicationModels am) { if (am != null) { applications.Add(am); } }
private void SpawnPlayer(PlayerController controller, int spawnIndex) { var battleModels = ApplicationModels.GetModel <BattleModel>().Players; var model = battleModels.Find(p => p.PlayerModel == controller.Owner); SpawnPlayer(controller, model, spawnIndex); }
private void ResetBoard() { _spawnPoints.Shuffle(); for (int i = 0, count = _players.Count; i < count; ++i) { var controller = _players[i]; SpawnPlayer(controller, i); } if (ApplicationModels.GetModel <GameModel>().SpawnBlocks) { for (int i = 0; i < NB_COLUMNS; ++i) { for (int j = 0; j < NB_ROWS; ++j) { var tile = _tiles[i, j]; if (tile.IsEmpty()) // No ignore flags => tile must be completely empty to receive a block (spawn areas stay empty) { var block = Instantiate(_destructibleBlockPrefab, _groundMesh.transform); var position = GetTileCenter(tile); position.y += 0.5f * block.BoxCollider.size.y * block.transform.localScale.y; block.transform.position = position; tile.Content.Add(block); } } } } GameFacade.RoundStart.Invoke(); }
public ActionResult Index(PlayerRegistration subscriber) { var applicants = context.Applicaitons.Select(x => x.AspNetUsersId).ToList(); var userName = User.Identity.GetUserName(); var user = context.Users.Where(x => x.UserName == userName).First(); if (applicants.Contains(user.Id)) { return(RedirectToAction("AlreadyApplied", "PlayerApplication")); } else { ApplicationModels applicant = new ApplicationModels(); user.FirstName = subscriber.FirstName; user.LastName = subscriber.LastName; user.Address = subscriber.Address; user.City = subscriber.City; user.State = subscriber.State; user.Phone = subscriber.PhoneNumber; user.Zip = subscriber.Zip; user.Position = subscriber.SelectedPosition; applicant.AspNetUsersId = user.Id; applicant.ApplicationDate = DateTime.Today; context.Applicaitons.Add(applicant); context.SaveChanges(); return(RedirectToAction("AwaitConfirmation", "PlayerApplication")); } }
private bool OnExplosionOnTile(Bomb bomb, Vector2Int coords, int contentIgnoreFlags) { var canPropagate = true; var tile = _tiles[coords.x, coords.y]; Vector3 position = GetTileCenter(tile); var explosion = Instantiate(ScriptableObjectsDatabase.PlayerSettings.ExplosionPrefab, position, Quaternion.identity, _groundMesh.transform); Destroy(explosion, 1); //Debug.Log("spawning explosion at : " + position); if (!tile.IsEmpty(contentIgnoreFlags)) { if (tile.IsWall) { canPropagate = false; } else if (tile.IsDestructibleBlock) { var block = tile.DestructibleBlock; tile.Content.Remove(block); Destroy(block.gameObject); // TODO: Spawn bonus canPropagate = false; // TODO: Depends on the player's bonus (spiked bomb?) } else { // TODO: determine if the explosion propagates when it hits a player or a bomb. // For the moment, let's say yes var tileBomb = tile.Bomb; if (tileBomb) { tileBomb.Explode(); } // Handle players hit by the bomb var players = tile.Players; if (players != null) { var battleModels = ApplicationModels.GetModel <BattleModel>().Players; for (int i = 0, count = players.Count; i < count; ++i) { var player = players[i]; player.transform.position = OFF_SCREEN_POSITION; player.Status = PlayerController.InputStatus.Blocked; tile.Content.Remove(player); var victim = battleModels.Find(p => p.PlayerModel == player.Owner); victim.IsSpawned = false; var attacker = battleModels.Find(p => p.PlayerModel == bomb.Owner); _gameMode.OnPlayerHit(victim, attacker); } } } } return(canPropagate); }
public void ShowRankings() { var players = new List <PlayerBattleModel>(ApplicationModels.GetModel <BattleModel>().Players); players.Sort(PlayerBattleModel.CompareScores); players.ForEach(AddRankingItem); GameFacade.ReadyInputPressed.Connect(OnReadyInputPressed); }
public BattleModel() { Players = new List <PlayerBattleModel>(); var models = ApplicationModels.GetModel <GameModel>().Players; for (int i = 0, count = models.Count; i < count; ++i) { Players.Add(new PlayerBattleModel(models[i])); } }
public void Setup(PlayerBattleModel player) { _playerColor.color = player.PlayerModel.Color; _playerScore.text = player.Score.ToString(); var playerIndex = ApplicationModels.GetModel <BattleModel>().Players.FindIndex(player); _playerName.text = string.Format(PlayerNameFormat, playerIndex + 1); SetPlayerReady(false); }
private void OnPlayerStarted(int joystickNumber) { var gameModel = ApplicationModels.GetModel <GameModel>(); var startPlayer = gameModel.Players.FindIndex(player => player.JoystickNumber == joystickNumber); if (startPlayer >= 0) { Debug.Log(string.Format("Game started by player {0} (joystick {1})", startPlayer + 1, joystickNumber)); } SceneManager.LoadScene("Scenes/TestLevel", LoadSceneMode.Single); }
public void OnDestroy() { _view.Deinitialize(); GameFacade.SpawnPlayer.Disconnect(SpawnPlayer); GameFacade.PlayerMoved.Disconnect(OnPlayerMoved); GameFacade.BombExploded.Disconnect(OnBombExploded); GameFacade.BombInputPressed.Disconnect(OnBombInputPressed); GameFacade.BattleEnd.Disconnect(OnBattleEnd); ApplicationModels.UnregisterModel <BattleModel>(); }
public void Initialize() { _scoreItems = new List <PlayerScoreUI>(); var players = ApplicationModels.GetModel <BattleModel>().Players; for (int i = 0, count = players.Count; i < count; ++i) { var parent = i % 2 == 0 ? _leftColumn : _rightColumn; var item = Instantiate(_scoreUiPrefab, parent.transform); item.Initialize(players[i]); _scoreItems.Add(item); } }
public void Show(int winnerIndex) { bool hasWinner = winnerIndex >= 0; _winRoot.SetActive(hasWinner); _drawRoot.SetActive(!hasWinner); if (hasWinner) { var playerModel = ApplicationModels.GetModel <GameModel>().Players[winnerIndex]; _winnerColor.color = playerModel.Color; _winText.text = string.Format(WinTextFormat, winnerIndex + 1); } }
private void Awake() { var model = ApplicationModels.GetModel <GameModel>(); var joystickOffset = TestData.UseKeyboard ? 0 : 1; for (int i = 0; i < TestData.NbPlayers; ++i) { model.AddPlayer(i + joystickOffset, ScriptableObjectsDatabase.PlayerSettings.Colors[i]); } model.SelectedMode = _testData.GameMode; model.SpawnBlocks = _testData.SpawnBlocks; SceneManager.LoadScene(TestData.ScenePath, LoadSceneMode.Single); }
private void OnPlayerJoined(int joystickNumber) { var gameModel = ApplicationModels.GetModel <GameModel>(); if (gameModel.Players.Find(player => player.JoystickNumber == joystickNumber) == null) { int playerOrder = gameModel.Players.Count; var color = ScriptableObjectsDatabase.PlayerSettings.Colors[playerOrder]; _playersItem[playerOrder].Open(playerOrder, color); gameModel.AddPlayer(joystickNumber, color); _startMessage.gameObject.SetActive(true); _joinMessage.gameObject.SetActive(playerOrder != BlikeGame.MAX_PLAYERS - 1); } }
public void OnUpdate() { if (!IsOver) { ElapsedTime += Time.deltaTime; var secondsRemaining = Mathf.CeilToInt(_timeLimit - ElapsedTime); GameFacade.TimeRemainingChanged.Invoke(secondsRemaining); if (IsOver) { var players = ApplicationModels.GetModel <BattleModel>().Players; var winners = new List <int>(); var bestScore = int.MinValue; for (int i = 0, count = players.Count; i < count; ++i) { var playerScore = players[i].Score; if (playerScore >= bestScore) { if (playerScore > bestScore) { winners.Clear(); } winners.Add(i); bestScore = playerScore; } } var winnerIndex = winners.Count > 1 ? -1 : winners[0]; GameFacade.BattleEnd.Invoke(winnerIndex, true); } else { // TODO: wait for a few seconds before respawn for (int i = 0, count = _playersToRespawn.Count; i < count; ++i) { GameFacade.SpawnPlayer.Invoke(_playersToRespawn[i]); } _playersToRespawn.Clear(); } } }
public void OnBombExploded() { var players = ApplicationModels.GetModel <BattleModel>().Players; var activePlayers = players.FindAll(player => player.IsSpawned); var nbActivePlayers = activePlayers.Count; bool isRoundOver = nbActivePlayers <= 1; if (isRoundOver) { int winnerIndex = -1; bool isGameOver = false; if (nbActivePlayers > 0) { var winner = activePlayers[0]; winnerIndex = players.FindIndex(winner); isGameOver = ++winner.Score == NbRoundsToWin; } GameFacade.BattleEnd.Invoke(winnerIndex, isGameOver); } }
public List <ApplicationModels> GetApplicationsForUserID(IConnectToDB _Connect, CoreModels CoreModel, List <ApplicationModels> Applications, int identity_id) { AppHelper applicationhelper = new AppHelper(); DataTable CoreApplications = applicationhelper.FindbyColumnID(_Connect, "Cores_ID", CoreModel.Core.Core.cores_id.ToString()); ApplicationModels applicationModel = new ApplicationModels(); foreach (DataRow AppRows in CoreApplications.Rows) { applicationModel = new ApplicationModels(); applicationModel.AppView = new ViewApplicationModel(); applicationModel.AppView.application_name = AppRows.Field <string>("application_name"); applicationModel.AppView.applications_id = AppRows.Field <long?>("applications_id"); applicationModel.AppView.cores_id = AppRows.Field <long?>("cores_id"); applicationModel.stages = GetStagesForAppandUserID(_Connect, new List <StageModels>(), applicationModel, identity_id); Applications.Add(applicationModel); } return(Applications); }
public void Awake() { ApplicationModels.RegisterModel <BattleModel>(new BattleModel()); var gameModel = ApplicationModels.GetModel <GameModel>(); var mode = gameModel.SelectedMode; _gameMode = GameModeFactory.Create(mode); _view = Instantiate(ScriptableObjectsDatabase.GameViews[mode]); _view.Initialize(); for (int i = 0; i < NB_COLUMNS; ++i) { for (int j = 0; j < NB_ROWS; ++j) { _tiles[i, j] = new Tile(i, j); } } var playerModels = gameModel.Players; int playersCount = playerModels.Count; UpdateTilesWithContent <Wall>(_terrain, null); var nbSpawns = Math.Min(_spawnPointPositions.Length, playersCount); _spawnPoints = new SpawnPoint[nbSpawns]; for (int i = 0; i < nbSpawns; ++i) { var tile = GetTile(_spawnPointPositions[i].position); _spawnPoints[i].Tile = tile; _spawnPoints[i].Position = GetTileCenter(tile); // Flag all nearby tiles as SpawnArea to avoid spawning blocks on them var coords = tile.Coords; for (int offsetX = -1; offsetX <= 1; ++offsetX) { for (int offsetY = -1; offsetY <= 1; ++offsetY) { var x = coords.x + offsetX; var y = coords.y + offsetY; if (x >= 0 && x < NB_COLUMNS && y >= 0 && y < NB_ROWS) { var areaTile = _tiles[x, y]; if (!areaTile.IsWall) { areaTile.Content.Add(SpawnArea.Instance); } } } } } _players = new List <PlayerController>(playerModels.Count); for (int i = 0; i < playersCount; ++i) { var model = playerModels[i]; var controller = Instantiate(ScriptableObjectsDatabase.PlayerSettings.PlayerPrefab, _groundMesh.transform); controller.Initialize(model); var playerView = controller.GetComponent <PlayerView>(); playerView.Initialize(model.Color); _players.Add(controller); } ResetBoard(); GameFacade.SpawnPlayer.Connect(SpawnPlayer); GameFacade.PlayerMoved.Connect(OnPlayerMoved); GameFacade.BombExploded.Connect(OnBombExploded); GameFacade.BombInputPressed.Connect(OnBombInputPressed); GameFacade.BattleEnd.Connect(OnBattleEnd); GameFacade.AllPlayersReadyForNextGame.Connect(OnLeave); }
private static void Initialize() { ApplicationModels.Initialize(); ScriptableObjectsDatabase.Initialize(); }
public void RemoveApplication(Guid id) { var remove = ApplicationModels.FirstOrDefault(model => model.Id == id); ApplicationModels.Remove(remove); }
public List <StageModels> GetStagesForAppandUserID(IConnectToDB _Connect, List <StageModels> Stages, ApplicationModels application, int identity_id) { StagesHelper stageshelper = new StagesHelper(); DataTable ApplicationStages = stageshelper.FindbyColumnID(_Connect, "Applications_ID", application.AppView.applications_id.ToString()); foreach (DataRow StageRows in ApplicationStages.Rows) { StageModels tempStageModel = new StageModels(); tempStageModel.Stage = new StageModel(); tempStageModel.Grips = new List <GripModels>(); tempStageModel.Stage.stages_id = StageRows.Field <long?>("stages_id"); tempStageModel.Stage.stage_name = StageRows.Field <string>("stage_name"); tempStageModel.Stage.stage_type = StageRows.Field <string>("stage_type"); tempStageModel.Stage.dt_created = StageRows.Field <DateTime>("dt_created"); tempStageModel.Stage.dt_available = StageRows.Field <DateTime?>("dt_available"); tempStageModel.Stage.dt_end = StageRows.Field <DateTime?>("dt_end"); tempStageModel.Stage.enabled = StageRows.Field <string>("enabled"); tempStageModel.Grips = GetgripsforStage(_Connect, new List <GripModels>(), tempStageModel, identity_id); Stages.Add(tempStageModel); } return(Stages); }
public bool ExistsApplication(string fileName) { return(ApplicationModels.Any(x => x.FileName == fileName)); }
// POST /api/applications public HttpResponseMessage Post(ApplicationModels.SubmitApplicationRequest request) { DomainServices.ApplicationService applicationService = new DomainServices.ApplicationService(_ctx); Domain.Application application; try { application = applicationService.AddApplication(request.name, request.url, request.isActive); } catch (Exception ex) { _logger.Log(LogLevel.Error, String.Format("Unhandled exception adding application. {0}", ex.Message)); return new HttpResponseMessage(HttpStatusCode.InternalServerError); } return new HttpResponseMessage(HttpStatusCode.Created); }
// PUT /api/applications/5 public HttpResponseMessage Put(String id, ApplicationModels.UpdateApplicationRequest request) { DomainServices.ApplicationService applicationService = new DomainServices.ApplicationService(_ctx); Guid apiKey; Guid.TryParse(id, out apiKey); if(apiKey == null) { _logger.Log(LogLevel.Error, String.Format("Exception Updating Application. ApiKey {0} could not be parsed as a GUID.", id)); var message = new HttpResponseMessage(HttpStatusCode.BadRequest); message.ReasonPhrase = "Invalid ApiKey. Cannot be parsed to GUID."; return message; } Application application = null; try { application = applicationService.GetApplication(id); } catch(Exception ex) { _logger.Log(LogLevel.Error, String.Format("Unhandled Exception Deleting Application. Application with the API Key {0} not found. {0}", id, ex.Message)); var message = new HttpResponseMessage(HttpStatusCode.NotFound); message.ReasonPhrase = "Application Resource Not Found."; return message; } try { application.IsActive = request.isActive; application.ApplicationName = request.name; application.Url = request.url; applicationService.UpdateApplication(application); } catch (Exception ex) { _logger.Log(LogLevel.Error, String.Format("Unhandled Exception updating application {0}. {1}", id, ex.Message)); var message = new HttpResponseMessage(HttpStatusCode.InternalServerError); message.ReasonPhrase = ex.Message; return message; } return new HttpResponseMessage(HttpStatusCode.OK); }
public bool removeApplication(ApplicationModels am) { return(applications.Remove(am)); }
public void read() { try { file = File.Open(fileName, FileMode.Open); } catch (FileNotFoundException ex) { Console.WriteLine("ERROR! " + fileName + " could not open the dataFile!"); Console.WriteLine(ex.Message); return; } file.Close(); IEnumerable <string> lines = File.ReadLines(fileName); JobModels curJob = null; ApplicationModels curApp = null; string[] splitter = null; foreach (string line in lines) { // Test for new objects if (line.Contains("->Job")) { if (curApp != null) { applications.Add(curApp); } curApp = null; if (curJob != null) { jobs.Add(curJob); } curJob = new JobModels(); continue; } if (line.Contains("->Application")) { if (curApp != null) { applications.Add(curApp); } curApp = new ApplicationModels(); if (curJob != null) { jobs.Add(curJob); } curJob = null; continue; } splitter = line.Split(new char[] { ':' }); if (splitter.Count() < 2) { continue; } switch (splitter[0]) { case "-|ID": if (curJob != null) { curJob.id = getIntFromString(splitter[1]); } else if (curApp != null) { curApp.id = getIntFromString(splitter[1]); } break; case "-|Title": if (curJob != null) { curJob.Title = splitter[1]; } break; case "-|Description": if (curJob != null) { curJob.description = splitter[1]; } break; case "-|Skills": if (curApp != null) { curApp.skills = splitter[1]; } else if (curJob != null) { curJob.skills = splitter[1]; } break; case "-|Location": if (curJob != null) { curJob.Location = splitter[1]; } break; case "-|Salary": if (curJob != null) { curJob.salary = splitter[1]; } break; case "-|Name": if (curApp != null) { curApp.Name = splitter[1]; } break; case "-|City": if (curApp != null) { curApp.City = splitter[1]; } break; case "-|State": if (curApp != null) { curApp.State = splitter[1]; } break; case "-|Education": if (curApp != null) { curApp.education = splitter[1]; } break; case "-|Reason": if (curApp != null) { curApp.reason = splitter[1]; } break; case "-|JobID": if (curApp != null) { curApp.jobID = getIntFromString(splitter[1]); } break; } } // End of foreach foreach (JobModels jm in jobs) { foreach (ApplicationModels am in applications) { if (jm.id == am.jobID) { jm.applications.Add(am); } } } }