public HttpResponse AddToCollection(int playerId) { var player = this.data.Players.FirstOrDefault(p => p.Id == playerId); var user = this.data.Users.FirstOrDefault(u => u.Id == this.User.Id); var up = this .data .UserPlayers .FirstOrDefault(up => up.UserId == user.Id && up.PlayerId == player.Id); if (up != null) { return(Redirect("/Players/All")); } var userPlayer = new UserPlayer { UserId = user.Id, PlayerId = player.Id }; this.data.UserPlayers.Add(userPlayer); this.data.SaveChanges(); return(Redirect("/Players/All")); }
public UserPlayer GetUserDB(int id) { UserPlayer user; string sqlExpression = String.Format("SELECT * FROM Users Where ID = {0};", id); SqlConnection connection = new SqlConnection(conectionString); connection.Open(); SqlCommand command = new SqlCommand(sqlExpression, connection); SqlDataReader read = command.ExecuteReader(); if (read.Read()) { user = new UserPlayer(read.GetString(1), read.GetString(1), read.GetDecimal(4), read.GetString(3)); connection.Close(); return(user); } return(null); }
public void RegisterPlayerToDatabase(UserPlayer player, System.Action OnComplete = null, System.Action <System.Exception> OnFalure = null) { DatabaseReference _ref = FirebaseDatabase.DefaultInstance.GetReference(UsersNodePath).Child(player.userid); _ref.SetRawJsonValueAsync(JsonUtility.ToJson(player)).ContinueWith(task => { if (task.IsCanceled || task.IsFaulted) { QEventExecutor.ExecuteInUpdate(() => { Debug.LogError("[QDataManager] Error at register user to database " + task.Exception); OnFalure?.Invoke(task.Exception); }); return; } QEventExecutor.ExecuteInUpdate(() => { Debug.Log("[QDataManager] Register to database Completed"); OnComplete?.Invoke(); }); }); }
protected void btnAcceptQuinielaCalcularConfirm_Click(object sender, EventArgs e) { string QuinielaNo = ""; UserPlayer Usuario = Utils.Generico.usuarioRegistrado(Session); QuinielaNo = DB_Quiniela.CalcularQuiniela(idQuinielaHidden.Value); if (QuinielaNo == "Error") { pnlTitles.Visible = true; pnlValuesCalculate.Visible = false; lblMsgCalcular.Text = "Error al Calcular Quiniela. Intente de Nuevo"; lblMsgCalcular.ForeColor = System.Drawing.Color.Red; } else { pnlTitles.Visible = false; pnlValuesCalculate.Visible = true; btnAcceptQuinielaCalcularConfirm.Visible = false; txtQuinielaCalcular.Text = QuinielaNo; lblMsgCalcular.Text = "Quiniela Calculada Correctamente"; lblMsgCalcular.ForeColor = System.Drawing.Color.Green; actualizarGrid(); } }
public (bool created, string errors) AddPlayerToCollection(int playerId, string userId) { string errors = null; bool created = false; var user = repo.All <User>().FirstOrDefault(u => u.Id == userId); var player = user.UserPlayers.FirstOrDefault(up => up.PlayerId == playerId); if (player != null) { return(created, errors); } try { var userPlayer = new UserPlayer { UserId = userId, PlayerId = playerId }; repo.Add(userPlayer); repo.SaveChanges(); created = true; } catch (Exception) { errors = "Could not save user players"; } return(created, errors); }
public void GenPlayer(int x, int z) { UserPlayer player = ((GameObject)Instantiate(GO_tree)).GetComponent <UserPlayer>(); Hex hex = MapManager.GetInst().GetPlayerHex(x, 0, z); player.CurHex = hex; player.CurHex.Passable = false; Vector3 v = player.CurHex.transform.position; v.y = 1.5f; player.transform.position = v; player.m_type = Type.USER; int find = 0; for (int i = 0; i < Players.Count; ++i) { if (player.m_type == Type.MAINCHARACTER) { find = i; } } Players.Insert(1, player); MapManager.GetInst().ResetMapColor(); }
public bool AddPlayerToMyCollection(int playerId, string userId) { var user = repo.All <User>().FirstOrDefault(u => u.Id == userId); var player = repo.All <Player>().FirstOrDefault(p => p.Id == playerId); bool isCreated = false; var userPlayer = new UserPlayer { User = user, UserId = userId, PlayerId = playerId, Player = player }; bool contains = repo.All <UserPlayer>().Contains(userPlayer); if (!contains) { repo.Add(userPlayer); user.UserPlayers.Add(userPlayer); repo.SaveChanges(); isCreated = true; } return(isCreated); }
void Awake() { // Creating Game Board this.gameBoard = new GameBoardController(this.boardView, new GameBoardModel(ROWS, COLS)); // Creating Players var userPlayer = new UserPlayer(gameBoard, TileMark.Cross); // Use different AI player settings based on selected difficulty AbstractPlayer aiPlayer; if (PlayerProfile.PreferredDifficulty == 0) { aiPlayer = new RandomAIPlayer(gameBoard, TileMark.Circle); } else { aiPlayer = new MinMaxAIPlayer(gameBoard, TileMark.Circle, PlayerProfile.PreferredDifficulty == 1 ? 0.3f : 0.0f); } this.turnManager = new TurnManager(gameBoard, userPlayer, aiPlayer); this.hudManager.Init(); // Initializing State Machine this.fsm = new SKStateMachine <GameManager>(this, new GameplayState()); this.fsm.addState(new GameoverState()); this.fsm.addState(new GameLoadingState()); #if DEBUG this.fsm.onStateChanged += () => { Debug.LogFormat("<color=green>GameManager FSM state changed to {0}</color>", this.fsm.currentState); }; #endif }
public void EditPlayer(UserPlayer player) { var oldPlayer = this.ctx.UserPlayers.SingleOrDefault(x => x.user_id == player.user_id); oldPlayer.player_id = player.player_id; oldPlayer.modified_on = DateTime.Now; }
private void GeneratePlayers() { var userObject = Object.Instantiate(Resources.Load <GameObject>("Prefabs/Player")); var userPlayer = new UserPlayer(userObject, Player.Team.Blue, 1.5f); userPlayer.SetPosition(); userPlayer.AssignKeys(KeyCode.W, KeyCode.A, KeyCode.S, KeyCode.D); _players.Add(userPlayer); for (var i = 0; i < _numberOfPlayers - 1; i++) { var aiObject = Object.Instantiate(Resources.Load <GameObject>("Prefabs/NPC")); var aiPlayer = new AIPlayer(aiObject, Player.Team.Blue, 0.8f); aiPlayer.SetPosition(); _players.Add(aiPlayer); } for (var i = 0; i < _numberOfPlayers; i++) { var aiObject = Object.Instantiate(Resources.Load <GameObject>("Prefabs/NPC")); var aiPlayer = new AIPlayer(aiObject, Player.Team.Orange, 0.8f); aiPlayer.SetPosition(); _players.Add(aiPlayer); } var refereeObject = Object.Instantiate(Resources.Load <GameObject>("Prefabs/NPC")); _referee = new Referee(refereeObject, Player.Team.Referee, 1.5f); }
public EwnController() { turn = Turn.PLAYER2; moveChessNum = DiceUtil.GetChessNum(); player1 = new AiPlayer(); player2 = new UserPlayer(); chessButtonHandler = new System.EventHandler(OnButtonClick); }
private void Timer_Tick(object sender, EventArgs e) { if (!UserPlayer.IsLevelSolved(UserPlayer.MyGame.LevelGroup, UserPlayer.MyGame.LevelNumber)) { UserPlayer.MyGame.Grid.TimeElapsed += UserPlayer.MyGame.Grid.DefaultTick; } elapsedTimeLabel.Text = $"Time: {UserPlayer.MyGame.Grid.TimeElapsed:mm\\:ss}"; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { UserPlayer Usuario = Utils.Generico.usuarioRegistrado(Session); getSportFilter(); } }
public void UpdateUserPlayer(UserPlayer userPlayer) { _userPlayer = userPlayer; if (_userPlayer != null) { _userPlayer.SetLocalTimes(); _userPlayer.Print(); } }
internal void SaveUserPlayer(UserPlayer userPlayer) { string path = Path.Combine(Application.streamingAssetsPath, "UserPlayer.xml"); XmlSerializer serializer = new XmlSerializer(typeof(UserPlayer)); FileStream fs = new FileStream(path, FileMode.Create); serializer.Serialize(fs, userPlayer); fs.Close(); }
protected void btnAccept_Click(object sender, EventArgs e) { int TotalChecks = 0; string Opciones = ""; TotalChecks = gridQuiniela.Rows.Count; for (int x = 0; x < TotalChecks; x++) { RadioButtonList rdbOpcion = gridQuiniela.Rows[x].FindControl("rdbOpcion") as RadioButtonList; if (x == 0) { Opciones = rdbOpcion.SelectedValue + ", "; } else if (x == (TotalChecks - 1)) { Opciones = Opciones + rdbOpcion.SelectedValue; } else { Opciones = Opciones + rdbOpcion.SelectedValue + ", "; } } string boleto = ""; UserPlayer Usuario = Utils.Generico.usuarioRegistrado(Session); boleto = DB_Quiniela.InsertQuinielaGetBoletoNo(idQuinielaHidden.Value, Usuario.idUser.ToString(), Opciones); if (boleto == "Error") { pnlBoleto.Visible = false; btnBoletos.Visible = false; lblModalMsg.Text = "Error al agregar la Quiniela. Intente de Nuevo"; lblModalMsg.ForeColor = System.Drawing.Color.Red; updateGridPrincipal.Update(); updateModalNewQuiniela.Update(); } else { lblTittleModal.Visible = false; pnlBoleto.Visible = true; btnBoletos.Visible = true; txtBoleto.Text = boleto; lblModalMsg.Text = "Quiniela agregada Correctamente"; lblModalMsg.ForeColor = System.Drawing.Color.Green; gridQuinielaModal.Visible = false; btnAccept.Visible = false; actualizarGrid(); updateGridPrincipal.Update(); updateModalNewQuiniela.Update(); updateGridPrincipal.Update(); } }
public void FieldCreation() { IPlayer player1 = new UserPlayer("player1", null, Guid.Empty), player2 = new AIPlayer("player2", Guid.Empty); GameLogic logic = new GameLogic(10, player1, player2, player1); PrivateObject prLogic = new PrivateObject(logic); List <Cell> resultField = prLogic.GetField("field") as List <Cell>; List <Cell> expectedField = GenerateField(6, player1, player2, new int[] { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }, 0, 0); CollectionAssert.AreEqual(expectedField, resultField, cellComparer.Value); }
public void WeakHpPlayerDamage() { UserPlayer userPlayer = PlayerFactory.GetPlayer(PlayerType.Weak); double actual = userPlayer.Attack(userPlayer); double expected = 20; Assert.Equal(expected, actual); }
public void StrongPlayerHpDamage() { UserPlayer userPlayer = PlayerFactory.GetPlayer(PlayerType.Strong); double actual = userPlayer.Attack(userPlayer); double expected = 20; Assert.Equal(expected, actual); }
//Player gets injured if health falls below 50, next damage is greater than 8 //and random agility is divisible by 3 private bool MarkAsInjured(UserPlayer player, int damage) { if (player.Health < 50 && damage > 8 && new Random(DateTime.Now.Millisecond).Next(0, Convert.ToInt32(player.Agility)) % 3 == 0) { return(true); } return(false); }
public HttpResponse Add(CreatePlayerFormModel model) { var modelErrors = this.validator.ValidatePlayer(model); if (modelErrors.Any()) { return(Error(modelErrors)); } if (!this.User.IsAuthenticated) { var errors = new List <string>() { "Users must login to add a player." }; return(Error(modelErrors)); } var user = this.data .Users .Where(u => u.Id == this.User.Id) .FirstOrDefault(); var player = new Player { FullName = model.FullName, ImageUrl = model.ImageURL, Position = model.Position, Speed = model.Speed, Endurance = model.Endurance, Description = model.Description }; this.data.Players.Add(player); this.data.SaveChanges(); var addedPlayer = this.data .Players .Where(p => p.FullName == player.FullName && p.ImageUrl == player.ImageUrl) .FirstOrDefault(); var userPlayer = new UserPlayer { UserId = user.Id, PlayerId = addedPlayer.Id, }; this.data.UserPlayers.Add(userPlayer); this.data.SaveChanges(); return(Redirect("/Players/All")); }
public void SaveMyPlayList(UserPlayer user, string nameAlbum, List <Song> listSong) { try { service.SaveUserSelectedAlbum(user, nameAlbum, listSong); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void UpdateCountListen(UserPlayer user, Song song) { try { service.UpdateCountListen(user, song); } catch (Exception) { throw; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { UserPlayer Usuario = Utils.Generico.usuarioRegistrado(Session); GetDataQuiniela("1", "1", "1"); actualizarGrid(); actualizarGridTablaGeneral(); } }
private void actualizarGrid() { UserPlayer Usuario = Utils.Generico.usuarioRegistrado(Session); DataQuinielaList = DB_Quiniela.getApuestaQuinielaByIdUser(ddlSport.SelectedValue, ddlLiga.SelectedValue, ddlTorneo.SelectedValue, ddlJornada.SelectedValue, Usuario.idUser.ToString()); gridQuinielas.DataSource = DataQuinielaList; gridQuinielas.DataBind(); updateGridPrincipal.Update(); }
private void GeneratePlayers() { listPlayers.Clear(); UserPlayer player = ((GameObject)(Instantiate(userPlayerPrefab, new Vector3(-Mathf.Floor(MapSizeX / 2), 1.5f, Mathf.Floor(MapSizeY / 2)), Quaternion.Euler(new Vector3())))).GetComponent <UserPlayer>(); listPlayers.Add(player); player = ((GameObject)(Instantiate(userPlayerPrefab, new Vector3(MapSizeX - 1 - Mathf.Floor(MapSizeX / 2), 1.5f, -MapSizeY + 1 + Mathf.Floor(MapSizeY / 2)), Quaternion.Euler(new Vector3())))).GetComponent <UserPlayer>(); listPlayers.Add(player); }
public void DeleteUserAlbum(UserPlayer user, string nameAlbum) { try { service.DeleteUserAlbum(user, nameAlbum); } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
public List <Song> GetSelectedAlbum(UserPlayer user, string nameAlbum) { try { return(service.GetSelectedAlbum(user, nameAlbum)); } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
public void ContinuousMove1() { IPlayer player1 = new UserPlayer("player1", null, Guid.Empty), player2 = new UserPlayer("player2", null, Guid.Empty); GameLogic logic = new GameLogic(player1, player2, player1, new int[] { 3, 4, 6, 2, 4, 11, 4, 7, 10, 2, 0, 1 }, 0, 0); MoveResult move = logic.MakeMove(player1, 5); PrivateObject prLogic = new PrivateObject(logic); List <Cell> resultField = prLogic.GetField("field") as List <Cell>; List <Cell> expectedField = GenerateField(6, player1, player2, new int[] { 4, 5, 7, 0, 5, 1, 5, 8, 11, 3, 1, 2 }, 2, 0); Assert.AreEqual(move, MoveResult.EndedMove); CollectionAssert.AreEqual(expectedField, resultField, cellComparer.Value); }
/* *Checks if target is within attacking range of player */ public bool isTargetInRange(UserPlayer playerTemp, AiPlayer target) { int playerX, playerY, targetX, targetY; playerX = (int)playerTemp.gridPosition.x; playerY = (int)playerTemp.gridPosition.y; targetX = (int)target.gridPosition.x; targetY = (int)target.gridPosition.y; print (playerX+ " " + playerY); print (targetX+ " " + targetY); return(playerX >= targetX - attackRange && playerX <= targetX + attackRange && playerY >= targetY - attackRange && playerY <= targetY + attackRange); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { UserPlayer Usuario = Utils.Generico.usuarioRegistrado(Session); idSportHidden.Value = StringCipher.Decrypt(Request["idSport"]); idLigaHidden.Value = StringCipher.Decrypt(Request["idLiga"]); GetDataQuiniela(idSportHidden.Value, idLigaHidden.Value); actualizarGrid(); } }
// Use this for initialization void Start() { UserPl = transform.parent.GetComponent<UserPlayer>(); playerInv = GetComponent<InventoryV2>(); escScript = GetComponent<GameMenu>(); sx = Screen.width; sy = Screen.height; cwLocX = mainX + 2; cwLocY = mainY + 40; cwWidth = 200; cwHeight = mainH - 40 - 50; picX = mainX + cwWidth + 10; picY = cwLocY; btnW = cwWidth - 16; recX = picX + picW + 5; recY = picY; recW = mainX + mainW - recX - 2; recH = cwHeight; rbtnW = recW - 16; crBtnX = mainX + 10; crBtnY = cwLocY + cwHeight + 10; crBtnW = mainW - 20; crBtnH = mainH - cwHeight - 40 - 20; canCraft = new bool[craftList.Length]; }
// Use this for initialization void Awake() { UserP = this.GetComponent<UserPlayer>(); }
void Start() { UserPl = transform.parent.GetComponent<UserPlayer>(); }
void Start() { TerraMgr = GameObject.Find(" TerrainMgr"); sx = Screen.width; sy = Screen.height; posx = (sx/2) - (xhairDim/2); posy = (sy/2) - (xhairDim/2); UserPl = transform.root.GetComponent<UserPlayer>(); }
void Start() { sx = Screen.width; sy = Screen.height; showGUI = false; UserPl = transform.parent.GetComponent<UserPlayer>(); devArray = transform.parent.GetComponent<GameInv>(); detScript = GetComponent<Detector>(); escScript = GetComponent<GameMenu>(); CheckKnife(); }
void Awake() { instance = this; //initilizing the gamemanager instance on line 7 }
// Use this for initialization void Awake() { UserP = transform.parent.GetComponent<UserPlayer>(); }
void Start() { sx = Screen.width; sy = Screen.height; UserP = transform.root.GetComponent<UserPlayer>(); helpText = "QUICK TIPS:\n" + "\nI - Inventory.\n" + "\nQ - Gather / Pick up\n"+ "\nK - Crafting window\n"+ "\nKeys 1,2,3...0 will select the corresponding Toolbar slot.\n" + "\nWhen holding a tool, it's crosshair will change and turn green to show possible interaction.\n"; for (int i = 0; i < showArr.Length; i++) { showArr[i] = false; Debug.Log("Set to false"); } }
void Start() { speed = walkSpeed; UserPl = Root.GetComponent<UserPlayer>(); rootCol = Root.GetComponent<ColDetect>(); }