/// <summary> /// Zaktualizuj rozmieszczenie przeciwników. /// </summary> /// <param name="gameId">id aktalnie zapisywanej gry</param> /// <param name="opponents">przeciwnicy</param> /// <param name="message">wiadomość przesyłana w razie niepowodzenia</param> /// <returns></returns> public static bool UpdateOpponentLocations(int gameId, List <OpponentLocationDao> opponents, out String message) { try { message = null; var query = from element in DataManager.DataBaseContext.OponentLocations where element.Game.Id == gameId select element; DataManager.DataBaseContext.OponentLocations.RemoveRange(query); DataManager.DataBaseContext.SaveChanges(); var gameQuery = from element in DataManager.DataBaseContext.Games where element.Id == gameId select element; if (!gameQuery.Any()) { message = "Nie istnieje taka gra"; return(false); } Game game = gameQuery.First(); for (int i = 0; i < opponents.Count; i++) { OpponentLocation opponentLocation = Mapper.Map <OpponentLocation>(opponents[i]); opponentLocation.Game = game; DataManager.DataBaseContext.OponentLocations.Add(opponentLocation); } DataManager.DataBaseContext.SaveChanges(); return(true); } catch (Exception e) { var declaringType = MethodBase.GetCurrentMethod().DeclaringType; if (declaringType != null) { Logger.LogMessage(declaringType.Name, MethodBase.GetCurrentMethod().Name, e.StackTrace); } message = e.Message; } return(false); }
private void OnCollisionEnter2D(Collision2D collision) { switch (collision.gameObject.name) { case "Platform0": opponentLocation = OpponentLocation.Platform0; jumpFlag = true; break; case "Platform1": opponentLocation = OpponentLocation.Platform1; jumpFlag = true; break; case "Platform2": opponentLocation = OpponentLocation.Platform2; jumpFlag = true; break; case "Platform3": opponentLocation = OpponentLocation.Platform3; jumpFlag = true; break; case "Platform4": opponentLocation = OpponentLocation.Platform4; jumpFlag = true; break; case "Ground": opponentLocation = OpponentLocation.Ground; jumpFlag = true; break; default: break; } }