private void ChangeTotalLabel(int num, PLAYERS player) { if (num < 0) { throw new ArgumentOutOfRangeException("The number to write to the label cannot be negative.", nameof(num)); } switch (player) { case PLAYERS.Dealer: if (num == 0) { this.DealerBoxHeader = DEALER_HIDDEN_HEADER_TEXT; } else { this.DealerBoxHeader = String.Format(DEALER_HEADER_TEXT, num); } RaisePropertyChanged(nameof(DealerBoxHeader)); break; case PLAYERS.Human: if (num == 0) { this.PlayerBoxHeader = PLAYER_HIDDEN_HEADER_TEXT; } else { this.PlayerBoxHeader = String.Format(PLAYER_HEADER_TEXT, num); } RaisePropertyChanged(nameof(PlayerBoxHeader)); break; } }
private void PlayerConfirm(int id, String token, String nickname, String age, String sex, String description) { TOKENS t = (from data in c.TOKENS where data.VALUE_TOKEN.Contains(token) select data).FirstOrDefault(); c.TOKENS.Remove(t); c.SaveChanges(); USERS u = (from data in c.USERS where data.ID_USER == id select data).FirstOrDefault(); u.STATUS_USER = 2; c.SaveChanges(); PLAYERS p = new PLAYERS() { ID_USER = id, NICK_PLAYER = nickname, AGE_PLAYER = int.Parse(age), SEX_PLAYER = sex, DESCRIPTION_PLAYER = description, PP_PLAYER = 0, NP_PLAYER = 0, SEALS_PLAYER = 0, LEVEL_PLAYER = 1 }; c.PLAYERS.Add(p); c.SaveChanges(); }
public double GetArmy(int team) { double army = 0; foreach (dsplayer pl in PLAYERS.Where(x => x.TEAM == team)) { army += pl.ARMY; } return(army / 1000); }
public double GetIncome(int team) { double income = 0; foreach (dsplayer pl in PLAYERS.Where(x => x.TEAM == team)) { income += pl.INCOME; } return(income / 1000); }
public double GetKilled(int team) { double kills = 0; foreach (dsplayer pl in PLAYERS.Where(x => x.TEAM == team)) { kills += pl.KILLSUM; } return(kills / 1000); }
public List <string> _RACES() { List <string> races = new List <string>(); foreach (dsplayer pl in PLAYERS.OrderBy(o => o.REALPOS)) { races.Add(pl.RACE); } return(races); }
public void CreatePlayer(string nick, string pass) { PLAYERS pl = new PLAYERS(); pl.NickName = nick; pl.Password = pass; pl.Coins = 1000; bJContext.PLAYERS.Add(pl); bJContext.SaveChanges(); }
public Game() { gameInProgress = false; winner = PLAYERS.NEITHER; computer = PLAYERS.P1; human = PLAYERS.P2; computerColor = ConsoleColor.DarkGreen; humanColor = ConsoleColor.White; board = new PIECES[8, 6]; zBoard = new long[48, 10]; currentHash = 0; removals = new Stack<Removal>(); }//end of constructor
public void Init() { MINKILLSUM = _MINKILLSUM(); MAXKILLSUM = _MAXKILLSUM(); MINARMY = _MINARMY(); MININCOME = _MININCOME(); MAXLEAVER = _MAXLEAVER(); PLAYERCOUNT = PLAYERS.Count; FixPos(); PLAYERS = PLAYERS.OrderBy(x => x.REALPOS).ToList(); RACES = _RACES(); }
private void RememberJustPlayed(PLAYERS played) { if (played == PLAYERS.PLAYER_X) { m_justPlayed = PLAYERS.PLAYER_X; m_justNotPlayed = PLAYERS.PLAYER_O; } else { m_justPlayed = PLAYERS.PLAYER_O; m_justNotPlayed = PLAYERS.PLAYER_X; } }
}//end of IsGameOver method public List<Move> MoveGenerator(PLAYERS player) { List<Move> returnValue; if(player == PLAYERS.P1) { returnValue = MoveGenP1(); } else if(player == PLAYERS.P2) { returnValue = MoveGenP2(); } else { returnValue = new List<Move>(); } return returnValue; }//end of MoveGenerator method
}//end of StartGame method public bool IsMoveLegal(int[] move, PLAYERS player) { bool returnValue = false; Move checkMove = new Move(move); List<Move> legalMoves = MoveGenerator(player); // Console.WriteLine("Moves Generated:"); foreach(Move m in legalMoves) { //DEBUG // Console.WriteLine($"\t{m.ToString()}"); //END DEBUG if(checkMove == m) { returnValue = true; } } return returnValue; }//end of IsMoveLegal method
public void UpdatePlayer(int playerID, int WinnerID) { PLAYERS pl = GetPLAYERS(playerID); pl.GamesCount++; if (playerID == WinnerID) { pl.WinCount++; } bJContext.PLAYERS.Attach(pl); bJContext.Entry(pl).State = System.Data.Entity.EntityState.Modified; bJContext.SaveChanges(); }
public string GenHash() { string md5 = ""; string hashstring = ""; foreach (dsplayer pl in PLAYERS.OrderBy(o => o.POS)) { hashstring += pl.POS + pl.RACE; } hashstring += MINARMY + MINKILLSUM + MININCOME + MAXKILLSUM; using (MD5 md5Hash = MD5.Create()) { md5 = GetMd5Hash(md5Hash, hashstring); } HASH = md5; return(md5); }
private PLAYERS GetPLAYERS(int playerID) { PLAYERS pl = new PLAYERS(); using (var db = new BJContext()) { var query = from s in db.PLAYERS where s.PlayerID == playerID select s; foreach (var student in query) { if (student.PlayerID != 0) { pl = student; } } } return(pl); }
}//end of UndoMove method public bool IsGameOver() { bool returnValue = false; bool p1KingFound = false; for(int i = 0; i < 8; i++) { for(int j = 0; j < 6; j++) { if(board[i, j] == PIECES.P1_KING) { p1KingFound = true; break; } } if(p1KingFound) { break; } } if(!p1KingFound || MoveGenerator(PLAYERS.P1).Count == 0) { winner = PLAYERS.P2; returnValue = true; } bool p2KingFound = false; for(int i = 0; i < 8; i++) { for(int j = 0; j < 6; j++) { if(board[i, j] == PIECES.P2_KING) { p2KingFound = true; break; } } if(p2KingFound) { break; } } if(!p1KingFound || MoveGenerator(PLAYERS.P1).Count == 0) { winner = PLAYERS.P2; returnValue = true; } if(!p2KingFound || MoveGenerator(PLAYERS.P2).Count == 0) { winner = PLAYERS.P1; returnValue = true; } return returnValue; }//end of IsGameOver method
public bool tryMove(PLAYERS player, int gridX, int gridY, int previousGridX, int previousGridY) { Player movingPlayer = player == PLAYERS.player1 ? player1 : player2; Player otherPlayer = player == PLAYERS.player1 ? player2 : player1; bool checkLimits = gridX < 0 || gridX >= gridWidth || gridY >= gridHeight || gridY < 0; bool checkOtherPlayer = otherPlayer.gridX == gridX && otherPlayer.gridY == gridY; if (!checkLimits && !checkOtherPlayer && tiles[gridX, gridY].checkIfCanMove(movingPlayer)) { if (tileContent[gridX, gridY] != null) { if (tileContent[gridX, gridY].contentType == TILE_CONTENTS.obstacle) { return(false); } if (tileContent[gridX, gridY].contentType == TILE_CONTENTS.powerUp) { Destroy(tileContent[gridX, gridY].gameObject); movingPlayer.getPowerup(); tileContent[gridX, gridY] = null; } } tiles[previousGridX, previousGridY].setOwner(movingPlayer); //empty the current tile //tiles[gridX, gridY].setOwner(null); if (Random.Range(0f, 1f) < gameSettings.powerUpsSpawnRate) { spawnPowerUp(); } return(true); } return(false); }
public void OnTriggerStay(Collider co) { // if (c < 0.1f) return; //GunBehavior gb = co.transform.root.GetComponent<GunBehavior>(); //if (gb == null) gb = co.transform.GetComponent<GunBehavior>(); PLAYERS pl = co.transform.root.GetComponent <PLAYERS>(); if (pl == null) { pl = co.transform.GetComponent <PLAYERS>(); } BulletBehaviour bb = co.transform.root.GetComponent <BulletBehaviour>(); if (bb == null) { bb = co.transform.GetComponent <BulletBehaviour>(); } if (bb != null) { Debug.Log("弾丸同士の接触"); Destroy(gameObject); return; } if (pl == null /* && gb == null*/) { HittingObject(co, false); } else if (pl != null /*&& gb != null*/ && pl.userID != n /*&& gb.userID != n*/) { HittingObject(co, true); } }
}//end of SetComputerPlayer method public void SetHumanPlayer(PLAYERS player) { human = player; }//end of SetHumanPlayer method
}//end of GetWinner method public void SetComputerPlayer(PLAYERS player) { computer = player; }//end of SetComputerPlayer method
public void setCurrentPlayer(int p) { currentPlayer = (PLAYERS)p; playerNumber = p; }
//勝者を設定 public void SetWinner(PLAYERS winner) { DataManager.Instance.SetWinPlayer(winner); }
// Start is called before the first frame update void Start() { players = GetComponent <PLAYERS>(); wSel = GetComponent <WeaponSelector>(); }
//勝者を設定 public void SetWinPlayer(PLAYERS winner) { _Winner = winner; }