public object GetStat(BasePlayer player, string Stat) { if (players.Find(player) == null) { OnPlayerInit(player); } players playerData = players.Find(player); if (Stat == "Kills") { return(playerData.Kills); } if (Stat == "Deaths") { return(playerData.Deaths); } if (Stat == "Rank") { return(playerData.Rank); } if (Stat == "Humanity") { return(playerData.Humanity); } return(null); }
public ActionResult Create(players player) { if (player.name != null && player.score != 0) { //var fg = db.players.ToList(); //db.players.RemoveRange(fg); //db.SaveChanges(); string n = player.name; int ss = player.score; players oo = new players { name = n, score = ss }; db.players.Add(oo); db.SaveChanges(); } var p = db.players.ToList(); p.Sort(); Session["uu"] = p; return(View("Create", p)); }
private void runTicker_Tick(object sender, EventArgs e) { if (rightDown == true) { position++; rotate(defaultalienPicture, Properties.Resources.space_invader, position); } if (leftDown == true) { position--; rotate(defaultalienPicture, Properties.Resources.space_invader, position); } if (gamephase == 1) { for (int x = 0; x < playersList.Count; x++) { players player = playersList[x]; player.position = PointControlTowardsCursor(spaceship, Properties.Resources.spaceship); playersList[x] = player; if (waitingToMove < 1) { MoveTowardsCursor(spaceship, player.position); waitingToMove = 3; } } waitingToMove--; for (int x = 0; x < laserList.Count; x++) { MoveTowardsPosition(laserList[x].position, 5, laserPictureList[x]); if (laserPictureList[x].Location.Y > this.Height || laserPictureList[x].Location.Y <-40 || laserPictureList[x].Location.X> this.Width || laserPictureList[x].Location.X < -40) { laserList.RemoveAt(x); Controls.Remove(laserPictureList[x]); laserPictureList[x].Dispose(); laserPictureList.RemoveAt(x); } } for (int x = 0; x < alienList.Count; x++) { for (int y = 0; x < laserList.Count; x++) { if ((laserPictureList[y].Location.X > (alienPictureList[x].Location.X + alienPictureList[x].Width - 5) && laserPictureList[y].Location.X < (alienPictureList[x].Location.X + 5)) && (laserPictureList[y].Location.Y > (alienPictureList[x].Location.Y + alienPictureList[x].Height - 5) && laserPictureList[y].Location.Y < (alienPictureList[x].Location.Y + 5))) { MessageBox.Show("Gottem"); } } } for (int x = createAlienWaitTimers.Count - 1; x >= 0; x--) { createAlienWaitTimers[x] = createAlienWaitTimers[x] - 1; if (createAlienWaitTimers[x] < 1) { createAlien(); createAlienWaitTimers.RemoveAt(x); } } } }
public async void Refresh() { inProgress.Visibility = Visibility.Visible; errorDetails.Visibility = Visibility.Collapsed; playerDetails.Visibility = Visibility.Collapsed; if (!string.IsNullOrEmpty(ScoreoidManager.username)) { try { if (ScoreoidManager.CachedPlayer == null) { players _players = await ScoreoidManager.ScoreoidClient.GetPlayerAsync(ScoreoidManager.username, ScoreoidManager.password); ScoreoidManager.CachedPlayer = _players.items.First(); } inProgress.Visibility = Visibility.Collapsed; errorDetails.Visibility = Visibility.Collapsed; playerDetails.Visibility = Visibility.Visible; username.Text = ScoreoidManager.CachedPlayer.username; best_score.Text = ScoreoidManager.CachedPlayer.best_score; if (!string.IsNullOrEmpty(ScoreoidManager.CachedPlayer.email)) { var gravatarImage = new BitmapImage(CreateGravatarUri(ScoreoidManager.CachedPlayer.email, 50)); gravatar.Source = gravatarImage; } } catch (ScoreoidException ex) { inProgress.Visibility = Visibility.Collapsed; errorDetails.Visibility = Visibility.Visible; playerDetails.Visibility = Visibility.Collapsed; errorMessage.Text = ex.Message; } catch (HttpRequestException ex) { inProgress.Visibility = Visibility.Collapsed; errorDetails.Visibility = Visibility.Visible; playerDetails.Visibility = Visibility.Collapsed; errorMessage.Text = ex.Message; } } else { inProgress.Visibility = Visibility.Collapsed; errorDetails.Visibility = Visibility.Visible; playerDetails.Visibility = Visibility.Collapsed; errorMessage.Text = "No username/password"; } }
private void button1_Click(object sender, EventArgs e) { gamephase = 1; button1.Visible = false; this.Focus(); this.Cursor = Cursors.Cross; players player = new players(); playersList.Add(player); }
public void scoreBoard() { score = GameObject.Find("GameEndOBJ"); /*for (int k = 0; k < 8; k++) * { * for (int i = 1; i < playerlist.Count; i++) * { * if (playerlist[i--].playerScore < playerlist[i].playerScore) * { * players p = playerlist[i--]; * playerlist[i--] = playerlist[i]; * playerlist[i] = p; * } * } * }*/ int[] array1 = new int[3]; array1[0] = -1; array1[1] = -1; array1[2] = -1; players[] array2 = new players[3]; array2[0] = playerlist[0]; array1[0] = playerlist[0].playerScore; for (int i = 1; i < playerlist.Count; i++) { if (playerlist[i].playerScore > array1[0]) { array2[0] = playerlist[i]; array1[0] = playerlist[i].playerScore; } } for (int i = 1; i < playerlist.Count; i++) { if (playerlist[i].playerScore > array1[1] && playerlist[i].user != array2[0].user) { array2[1] = playerlist[i]; array1[1] = playerlist[i].playerScore; } } for (int i = 1; i < playerlist.Count; i++) { if (playerlist[i].playerScore > array1[2] && playerlist[i].user != array2[0].user && playerlist[i].user != array2[1].user) { array2[2] = playerlist[i]; array1[2] = playerlist[i].playerScore; } } for (int i = 0; i < 3; i++) { score.GetComponent <Score>().scoreUI((i + 1) + ". " + array2[i].user + " - " + array2[i].playerScore); } }
public PartialViewResult GetPartial() { List <users> d = (List <users>)Session["Data"]; int uid = d[0].userid; if (d[0].usertype == "Player") { using (var ctx = new Entities()) { List <players> p = (from _p in ctx.players where _p.userid == uid select _p).ToList(); players pp = p[0]; int pid = pp.roleid; List <games_positions> gp = (from g in ctx.games_positions where g.positionid == pid select g).ToList(); int gid = gp[0].gameid; string pname = gp[0].position; string gname = (from g in ctx.games where g.gameid == gid select g.gamename).SingleOrDefault(); ViewBag.GameName = gid + " | " + pid + " | " + gname + " | " + pname; return(PartialView("~/Views/Shared/Partial/playerdetail.cshtml", pp)); } } else if (d[0].usertype == "Coach") { using (var ctx = new Entities()) { List <coachs> p = (from _p in ctx.coachs where _p.userid == uid select _p).ToList(); coachs pp = p[0]; int? pid = pp.positionid; List <games_positions> gp = (from g in ctx.games_positions where g.positionid == pid select g).ToList(); int gid = gp[0].gameid; string pname = gp[0].position; string gname = (from g in ctx.games where g.gameid == gid select g.gamename).SingleOrDefault(); ViewBag.GameName = gid + " | " + pid + " | " + gname + " | " + pname; return(PartialView("~/Views/Shared/Partial/coachdetail.cshtml", pp)); } } else if (d[0].usertype == "Club") { using (var ctx = new Entities()) { List <clubs> p = (from _p in ctx.clubs where _p.userid == uid select _p).ToList(); clubs pp = p[0]; return(PartialView("~/Views/Shared/Partial/clubdetail.cshtml", pp)); } } else { return(PartialView("~/Views/Shared/Partial/admin.cshtml")); } }
// / // / // / // //OnPlayerInit // // / // / // / // void OnPlayerInit(BasePlayer player) { if (!humanityData.playerH.ContainsKey(player.userID)) { var info = new players() { playerID = player.userID, Humanity = 0, Rank = 0 }; humanityData.playerH.Add(player.userID, info); SaveData(); } RankAlgorithm(player); }
private static void AnnounceWinner(players currentPlayer) { if(currentPlayer == players.User) { Console.ForegroundColor = SYSTEM_MESSAGE_COLOR; Console.WriteLine("Congratulations, player, you have won the game of Nim!"); } else { Console.ForegroundColor = ERROR_MESSAGE_COLOR; Console.WriteLine("Sorry, the computer has beaten you. Better luck next time!"); } Console.ResetColor(); }
private static void AnnounceWinner(players currentPlayer) { if (currentPlayer == players.User) { Console.ForegroundColor = SYSTEM_MESSAGE_COLOR; Console.WriteLine("Congratulations, player, you have won the game of Nim!"); } else { Console.ForegroundColor = ERROR_MESSAGE_COLOR; Console.WriteLine("Sorry, the computer has beaten you. Better luck next time!"); } Console.ResetColor(); }
private static void AnnounceMove(players currentPlayer, int pileNumber, int sticksToRemove) { string playerDescription = ""; if (currentPlayer == players.User) { playerDescription = "You have"; } else { playerDescription = "The Computer has"; } Console.ForegroundColor = SYSTEM_MESSAGE_COLOR; Console.WriteLine(playerDescription + " removed {0} sticks from pile {1}.", sticksToRemove, pileNumber + 1); Console.ResetColor(); }
private static void AnnounceMove(players currentPlayer, int pileNumber, int sticksToRemove) { string playerDescription = ""; if(currentPlayer == players.User) { playerDescription = "You have"; } else { playerDescription = "The Computer has"; } Console.ForegroundColor = SYSTEM_MESSAGE_COLOR; Console.WriteLine(playerDescription + " removed {0} sticks from pile {1}.", sticksToRemove, pileNumber + 1); Console.ResetColor(); }
private static void PlayGame() { players currentPlayer = players.User; NimAi computer = new NimAi(); int pileNumber = 0, sticksToRemove = 0; bool winner = false; Pile[] piles = new Pile[GetIntInRange(0, 10, "How many piles do you wish to have?")]; InitializePileSizes(piles); currentPlayer = GetFirstPlayer(); while (!winner) { PrintPiles(piles); Console.WriteLine(); if (currentPlayer == players.User) { GetUserMove(piles, out pileNumber, out sticksToRemove); piles[pileNumber].Count -= sticksToRemove; AnnounceMove(currentPlayer, pileNumber, sticksToRemove); } else //player is computer { computer.GetMove(piles, out pileNumber, out sticksToRemove); piles[pileNumber].Count -= sticksToRemove; AnnounceMove(currentPlayer, pileNumber, sticksToRemove); } winner = CheckForWinner(piles); if (winner) { AnnounceWinner(currentPlayer); } else if (currentPlayer == players.User) { currentPlayer = players.Computer; } else { currentPlayer = players.User; } } }
static void Main(string[] args) { int[,] Playground = new int [3, 3] { // spelplanen { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; bool Gameactive = true; players activeplayer = players.P1; while (Gameactive) { } }
// / // / // / // //Death Handler// // / // / // / // void OnEntityDeath(BaseCombatEntity victimEntity, HitInfo info) { if (info?.Initiator?.ToPlayer() != null && victimEntity?.ToPlayer() != null) { BasePlayer victim = victimEntity.ToPlayer(); BasePlayer attacker = info.Initiator.ToPlayer(); CuiHelper.DestroyUi(victim, "HumanUI"); if (victim.userID == attacker.userID) { return; } if (players.Find(victim) == null) { OnPlayerInit(victim); } if (players.Find(attacker) == null) { OnPlayerInit(attacker); } players victimData = players.Find(victim); players attackerData = players.Find(attacker); victimData.Deaths++; attackerData.Kills++; if (victimData.Rank == 0 || victimData.Rank == 1) { attackerData.Humanity -= Convert.ToInt32(Config["HumanityLossGainOnKill"]); RankAlgorithm(attacker); } else if (victimData.Rank == 2) { attackerData.Humanity += Convert.ToInt32(Config["HumanityLossGainOnKill"]); RankAlgorithm(attacker); } SaveData(); } }
private void laserShoot() { lasers laser = new lasers(); PictureBox laserPicture = new PictureBox(); players player = playersList[0]; laser.position = player.position; laserPicture.Size = laserDefaultPicture.Size; laserPicture.Image = laserDefaultPicture.Image; laserPicture.MouseDown += mouseDown; laserPicture.MouseUp += mouseUp; rotate(laserPicture, Properties.Resources.Laser2, laser.position + 90); laserPicture.SizeMode = laserDefaultPicture.SizeMode; laserPicture.Location = spaceship.Location; laser.damage = 1; laserList.Add(laser); laserPictureList.Add(laserPicture); Controls.Add(laserPictureList[laserPictureList.Count - 1]); MoveTowardsPosition(laser.position, 40, laserPictureList[laserPictureList.Count - 1]); laserPictureList[laserPictureList.Count - 1].BringToFront(); }
private void Button_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; if (button.Content == "") { if (player == players.X) { button.Content = "X"; player = players.O; } else if (player == players.O) { button.Content = "O"; player = players.X; } turn++; if (CheckWins()) { if (button.Content == "X") { MessageBox.Show("Player X won!"); winX++; } else { MessageBox.Show("Player O won!"); winO++; } NewGame(); } if (CheckDraw()) { MessageBox.Show("Draw!"); draw++; NewGame(); } UploadScore(); } }
public object GetRank(BasePlayer player) { if (players.Find(player) == null) { OnPlayerInit(player); } players playerData = players.Find(player); if (playerData.Rank == 0) { return("Neutral"); } else if (playerData.Rank == 1) { return("Hero"); } else if (playerData.Rank == 2) { return("Bandit"); } return(null); }
private List <players> LoadXml() { string path = Application.persistentDataPath + ConstString.FILE_XML_PLAYER_INFO_PATH; XmlDocument xml = new XmlDocument(); xml.Load(path); List <players> playerList = new List <players>(); //get the note in xml file XmlNodeList playersList = xml.SelectSingleNode("players").ChildNodes; foreach (XmlElement playerNode in playersList) { players playerModel = new players(); foreach (XmlElement player in playerNode) { switch (player.Name) { case "name": playerModel.playerName = player.InnerText; break; case "score": playerModel.bestScore = player.InnerText; break; case "date": playerModel.recordDate = player.InnerText; break; } } playerList.Add(playerModel); } return(playerList); }
var(players, lastMarbleWorth) = game;
public bool AddPlayer(players player) { var Player = PlayersService.AddEntity(player); return(Player != null && Player.ID != 0 ? true : false); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // applause[0] = Content.Load<SoundEffect>("applause-2"); // Loads the sound effect applause[0] = Content.Load<SoundEffect>("woof"); // Loads the sound effect applause[1] = Content.Load<SoundEffect>("yipee"); // Loads the sound effect applause[5] = Content.Load<SoundEffect>("fandab"); // Loads the sound effect applause[2] = Content.Load<SoundEffect>("woop"); // Loads the sound effect applause[3] = Content.Load<SoundEffect>("yeah"); // Loads the sound effect applause[4] = Content.Load<SoundEffect>("yeah2"); // Loads the sound effect // TODO: use this.Content to load your game content here mainfont = Content.Load<SpriteFont>("andynew"); // Load font digfont = Content.Load<SpriteFont>("quartz4"); // Load font fontwhite = Content.Load<SpriteFont>("miramonte9"); // Load font background = new graphic2d(Content, "kinectbackground", displaywidth, displayheight); gamebackground1 = new graphic2d(Content, "game screen 3", displaywidth, displayheight); gamebackground1.stretch2fit(displaywidth, displayheight); gamebackground2 = new graphic2d(Content, "game screen 4", displaywidth, displayheight); gamebackground2.stretch2fit(displaywidth, displayheight); gamebackground3 = new graphic2d(Content, "game screen 5", displaywidth, displayheight); gamebackground3.stretch2fit(displaywidth, displayheight); gamelogo = new sprite2d(Content, "kinect angles", displaywidth / 2, displayheight - 100, 0.4f, Color.White, true); gamelogo.rect.Y = displayheight-gamelogo.rect.Height/2; mousepointer1 = new sprite2d(Content, "X-Games-Cursor", 0, 0, 0.15f, Color.White, true); mousepointer2 = new sprite2d(Content, "X-Games-Cursor-Highlight", 0, 0, 0.15f, Color.White, true); hand[0] = new sprite2d(Content, "conniehand", displaywidth/4, 84, 0.5f, Color.White, true); hand[1] = new sprite2d(Content, "conniehand", (displaywidth / 4)*3, 84, 0.5f, Color.White, true); menuoptions[0, 0] = new sprite2d(Content, "player1", displaywidth / 2, 180, 1, Color.White, true); menuoptions[0, 1] = new sprite2d(Content, "player1over", displaywidth / 2, 180, 1, Color.White, true); menuoptions[1, 0] = new sprite2d(Content, "player2", displaywidth / 2, 260, 1, Color.White, true); menuoptions[1, 1] = new sprite2d(Content, "player2over", displaywidth / 2, 260, 1, Color.White, true); menuoptions[2, 0] = new sprite2d(Content, "options", displaywidth / 2, 340, 1, Color.White, true); menuoptions[2, 1] = new sprite2d(Content, "optionsover", displaywidth / 2, 340, 1, Color.White, true); menuoptions[3, 0] = new sprite2d(Content, "highscores", displaywidth / 2, 420, 1, Color.White, true); menuoptions[3, 1] = new sprite2d(Content, "highscoreover", displaywidth / 2, 420, 1, Color.White, true); menuoptions[4, 0] = new sprite2d(Content, "exit", displaywidth / 2, 500, 1, Color.White, true); menuoptions[4, 1] = new sprite2d(Content, "exitover", displaywidth / 2, 500, 1, Color.White, true); for (int i = 0; i < numberofoptions; i++) menuoptions[i, 0].updateobject(); backbutton[0] = new sprite2d(Content, "xboxControllerBack", 60, 60, 1, Color.White, true); backbutton[1] = new sprite2d(Content, "backglow", 60, 60, 1, Color.White, true); typeoptions[0, 0] = new sprite2d(Content, "angles1", 100, 140, 1, Color.White, true); typeoptions[0, 1] = new sprite2d(Content, "angles2", 100, 140, 1, Color.White, true); typeoptions[1, 0] = new sprite2d(Content, "percentages1", 250, 140, 1, Color.White, true); typeoptions[1, 1] = new sprite2d(Content, "percentages2", 250, 140, 1, Color.Yellow, true); typeoptions[2, 0] = new sprite2d(Content, "decimal1", 400, 140, 1, Color.White, true); typeoptions[2, 1] = new sprite2d(Content, "decimal2", 400, 140, 1, Color.White, true); typeoptions[3, 0] = new sprite2d(Content, "fractions1", 550, 140, 1, Color.White, true); typeoptions[3, 1] = new sprite2d(Content, "fractions2", 550, 140, 1, Color.Yellow, true); typeoptions[4, 0] = new sprite2d(Content, "all1", 700, 140, 1, Color.White, true); typeoptions[4, 1] = new sprite2d(Content, "all2", 700, 140, 1, Color.Yellow, true); for (int i = 0; i < numberoftypes; i++) typeoptions[i, 0].updateobject(); leveloptions[0, 0] = new sprite2d(Content, "easy", 200, 220, 1, Color.White, true); leveloptions[0, 1] = new sprite2d(Content, "easy2", 200, 220, 1, Color.White, true); leveloptions[1, 0] = new sprite2d(Content, "medium", 400, 220, 1, Color.White, true); leveloptions[1, 1] = new sprite2d(Content, "medium2", 400, 220, 1, Color.Yellow, true); leveloptions[2, 0] = new sprite2d(Content, "hard", 600, 220, 1, Color.White, true); leveloptions[2, 1] = new sprite2d(Content, "hard2", 600, 220, 1, Color.White, true); for (int i = 0; i < numberoflevels; i++) leveloptions[i, 0].updateobject(); lefthanded[0, 0] = new sprite2d(Content, "p1left", 300, 300, 1, Color.White, true); lefthanded[0, 1] = new sprite2d(Content, "p1lefthigh", 300, 300, 1, Color.White, true); lefthanded[0, 2] = new sprite2d(Content, "p1right", 300, 300, 1, Color.White, true); lefthanded[0, 3] = new sprite2d(Content, "p1rightglow", 300, 300, 1, Color.White, true); lefthanded[0, 0].updateobject(); lefthanded[1, 0] = new sprite2d(Content, "p2left", 500, 300, 1, Color.White, true); lefthanded[1, 1] = new sprite2d(Content, "p2lefthigh", 500, 300, 1, Color.White, true); lefthanded[1, 2] = new sprite2d(Content, "p2right", 500, 300, 1, Color.White, true); lefthanded[1, 3] = new sprite2d(Content, "p2rightglow", 500, 300, 1, Color.White, true); lefthanded[1, 0].updateobject(); questionsto = new sprite2d(Content, "questions2ask", 340, 400, 1, Color.White, true); questionspinner[0] = new sprite2d(Content, "spinner", 500, 400, 1, Color.White, true); questionspinner[1] = new sprite2d(Content, "spinnerup", 500, 400, 1, Color.White, true); questionspinner[2] = new sprite2d(Content, "spinnerdown", 500, 400, 1, Color.White, true); questionspinner[1].updateobject(); questionspinner[2].updateobject(); questionspinner[1].bbox.Max.Y -= questionspinner[1].rect.Height / 2; questionspinner[2].bbox.Min.Y += questionspinner[2].rect.Height / 2; savepicbutton[0, 0] = new sprite2d(Content, "savepicson", 400, 500, 1, Color.White, true); savepicbutton[0, 1] = new sprite2d(Content, "savepicsonglow", 400, 500, 1, Color.White, true); savepicbutton[1, 0] = new sprite2d(Content, "savepicturesoff", 400, 500, 1, Color.White, true); savepicbutton[1, 1] = new sprite2d(Content, "savepicturesoffglow", 400, 500, 1, Color.White, true); savepicbutton[0, 0].updateobject(); fullscreenbutton[0, 0] = new sprite2d(Content, "full screen off", 700, 60, 1, Color.White, true); fullscreenbutton[0, 1] = new sprite2d(Content, "fullscreenoffglow", displaywidth - (fullscreenbutton[0, 0].rect.Width / 2), fullscreenbutton[0, 0].rect.Height / 2, 1, Color.White, true); fullscreenbutton[1, 0] = new sprite2d(Content, "full screen on", fullscreenbutton[0, 1].rect.X, fullscreenbutton[0, 1].rect.Y, 1, Color.White, true); fullscreenbutton[1, 1] = new sprite2d(Content, "fullscreenonglow", fullscreenbutton[0, 1].rect.X, fullscreenbutton[0, 1].rect.Y, 1, Color.White, true); fullscreenbutton[0, 0].position = fullscreenbutton[0, 1].position; fullscreenbutton[0, 0].updateobject(); funnypics = new Texture2D[questions2ask]; aline1 = new angleart(Content, "line3", displaywidth / 4, displayheight / 2, 1f, Color.White, true); aline2 = new angleart(Content, "line4", (displaywidth / 4) * 3, displayheight / 2, 1f, Color.White, true); gamer[0] = new players(); gamer[1] = new players(); if (File.Exists(@"options.txt")) { StreamReader sr = new StreamReader(@"options.txt"); // Open the file String line; // Create a string variable to read each line into if (!sr.EndOfStream) { line = sr.ReadLine(); // Read the first line in the text file questions2ask = (int)Convert.ToDecimal(line); // This converts line to numeric } if (!sr.EndOfStream) { line = sr.ReadLine(); // Read the first line in the text file delaybetween = (int)Convert.ToDecimal(line); // This converts line to numeric } if (!sr.EndOfStream) { line = sr.ReadLine(); // Read the first line in the text file roundlength = (int)Convert.ToDecimal(line); // This converts line to numeric } if (!sr.EndOfStream) { line = sr.ReadLine(); // Read the first line in the text file bonuspoints = (int)Convert.ToDecimal(line); // This converts line to numeric } if (!sr.EndOfStream) { line = sr.ReadLine(); // Read the first line in the text file gamemode = (int)Convert.ToDecimal(line); // This converts line to numeric } if (!sr.EndOfStream) { line = sr.ReadLine(); // Read the first line in the text file skilllevel = (int)Convert.ToDecimal(line); // This converts line to numeric } if (!sr.EndOfStream) { line = sr.ReadLine(); // Read the first line in the text file saveallpics = (Convert.ToDecimal(line)==1); // This converts line to numeric then boolean } if (!sr.EndOfStream) { line = sr.ReadLine(); // Read the first line in the text file cameraangle = (int)Convert.ToDecimal(line); // This converts line to numeric } sr.Close(); // Close the file } loadhighscores("highscore" + gamemode.ToString("0") + skilllevel.ToString("0") + questions2ask.ToString("00") + ".txt"); if (!Directory.Exists(Content.RootDirectory + "\\..\\pictures")) Directory.CreateDirectory(Content.RootDirectory + "\\..\\pictures"); // Set up Kinect to stream video kinectSensor.ElevationAngle = cameraangle; kinectRGBVideo = new Texture2D(GraphicsDevice, 640, 480); //vframe = new Texture2D(GraphicsDevice, kinectRGBVideo.Width, kinectRGBVideo.Height); //vcolour = new Color[kinectRGBVideo.Height * kinectRGBVideo.Width]; }
void Update() { if (!TilemapHandler.hasTurnEnded()) { return; } if (turn == players.player) { Vector3 tile = tmh.roundToTilePosition(Camera.main.ScreenToWorldPoint(Input.mousePosition)); if (selectedTile == null) { cursor.transform.position = tile + new Vector3(0.5f, 0.5f); } else { if (Input.GetButton("Kick")) { cursor.transform.position = tile + new Vector3(0.5f, 0.5f); br.SetActive(true); ma.SetActive(false); isKicking = true; } else { br.SetActive(false); ma.SetActive(true); isKicking = false; generateArrow(tile - GameObject.Find("Playing Area").GetComponent <Tilemap>().origin); } } if (Input.GetButtonDown("Next Round")) { TilemapHandler.endTurn(); selectedTile = null; ma.SetActive(false); selected.SetActive(false); br.GetComponent <Tilemap>().ClearAllTiles(); turn = players.enemy; } if (Input.GetMouseButtonDown(0)) { Vector2Int highlightedTile = TilemapHandler.getTileAtPosition(Camera.main.ScreenToWorldPoint(Input.mousePosition)); if (selectedTile == null) { if (TilemapHandler.getTile(highlightedTile.x, highlightedTile.y).containsPlayer()) { selectedTile = TilemapHandler.getTile(highlightedTile.x, highlightedTile.y); selected.transform.position = selectedTile.transform.position + new Vector3(0.5f, 0.5f); selected.SetActive(true); br.SetActive(true); selectedTile.getCharacter().GetComponent <PlayerHandler>().generateField(); br.transform.position += br.GetComponent <Tilemap>().WorldToCell(selectedTile.getCharacter().transform.position) * new Vector3Int(1, 1, 0) - new Vector3Int(0, 1, 0); br.SetActive(false); } } else if (!isKicking) { if (selectedTile.tilemapPosition != highlightedTile) { selectedTile.getCharacter().GetComponent <PlayerHandler>().move(tmh, highlightedTile); } selectedTile = null; ma.SetActive(false); selected.SetActive(false); br.GetComponent <Tilemap>().ClearAllTiles(); } else { selectedTile.getCharacter().GetComponent <PlayerHandler>().kick(tmh, highlightedTile); selectedTile = null; ma.SetActive(false); selected.SetActive(false); br.GetComponent <Tilemap>().ClearAllTiles(); } } if (Input.GetMouseButtonDown(1)) { selectedTile = null; ma.SetActive(false); selected.SetActive(false); br.GetComponent <Tilemap>().ClearAllTiles(); } } else { List <Transform> enemies = new List <Transform>(); enemies.AddRange(TilemapHandler.enemies); Transform hasBall = null; foreach (Transform enemy in enemies) { PlayerHandler ph = enemy.GetComponent <PlayerHandler>(); if (TilemapHandler.getTile(ph.tilePosition).getHasBall()) { hasBall = enemy; enemies.Remove(enemy); break; } if (!ph.tooFarAway(GameObject.Find("Ball").GetComponent <BallController>().tilePosition)) { ph.move(tmh, GameObject.Find("Ball").GetComponent <BallController>().tilePosition); enemies.Remove(enemy); break; } } //Goal enemies.Sort((p1, p2) => p2.GetComponent <PlayerHandler>().moveDistanceTo(new Vector2Int(7, 20)).CompareTo(p1.GetComponent <PlayerHandler>().moveDistanceTo(new Vector2Int(7, 20)))); enemies[enemies.Count - 1].GetComponent <PlayerHandler>().tryMove(tmh, new Vector2Int(7, 20)); enemies.Remove(enemies[enemies.Count - 1]); //Right enemies.Sort((p1, p2) => p2.GetComponent <PlayerHandler>().moveDistanceTo(new Vector2Int(12, 3)).CompareTo(p1.GetComponent <PlayerHandler>().moveDistanceTo(new Vector2Int(12, 3)))); enemies[enemies.Count - 1].GetComponent <PlayerHandler>().tryMove(tmh, new Vector2Int(12, 3)); enemies.Remove(enemies[enemies.Count - 1]); //Left enemies.Sort((p1, p2) => p2.GetComponent <PlayerHandler>().moveDistanceTo(new Vector2Int(2, 3)).CompareTo(p1.GetComponent <PlayerHandler>().moveDistanceTo(new Vector2Int(2, 3)))); enemies[enemies.Count - 1].GetComponent <PlayerHandler>().tryMove(tmh, new Vector2Int(2, 3)); enemies.Remove(enemies[enemies.Count - 1]); //Middle enemies.Sort((p1, p2) => p2.GetComponent <PlayerHandler>().moveDistanceTo(new Vector2Int(7, 3)).CompareTo(p1.GetComponent <PlayerHandler>().moveDistanceTo(new Vector2Int(7, 3)))); enemies[enemies.Count - 1].GetComponent <PlayerHandler>().tryMove(tmh, new Vector2Int(7, 3)); enemies.Remove(enemies[enemies.Count - 1]); if (hasBall != null) { enemies.Clear(); enemies.AddRange(TilemapHandler.enemies); enemies.Remove(hasBall); enemies.Sort((p1, p2) => p2.GetComponent <PlayerHandler>().moveDistanceTo(hasBall.GetComponent <PlayerHandler>().tilePosition).CompareTo(p1.GetComponent <PlayerHandler>().moveDistanceTo(hasBall.GetComponent <PlayerHandler>().tilePosition))); foreach (Transform player in TilemapHandler.players) { if ((player.GetComponent <PlayerHandler>().tilePosition - hasBall.GetComponent <PlayerHandler>().tilePosition).sqrMagnitude < 4) { hasBall.GetComponent <PlayerHandler>().kick(tmh, enemies[enemies.Count - 1].GetComponent <PlayerHandler>().tilePosition); } } if (!hasBall.GetComponent <PlayerHandler>().outOfKickingRange(new Vector2Int(7, 0))) { hasBall.GetComponent <PlayerHandler>().kick(tmh, new Vector2Int(7, 0)); } } TilemapHandler.endEnemyTurn(); turn = players.player; } }
public ActionResult Register(RegisterModel rm) { if (ModelState.IsValid) { try { using (var context = new Entities()) { users _u = new users { usertype = rm.Type, username = rm.Username, passwd = _auth.GenPassword(rm.Password), email = rm.Email, phone = rm.Username, C_date = DateTime.Now, ispayment = false, isemail = false, isphone = false, C_status = true }; context.users.Add(_u); context.SaveChanges(); if (rm.Type == "Player") { players _p = new players { userid = (from u in context.users where u.email == rm.Email select u.userid).SingleOrDefault(), roleid = rm.RoleId, photo = "no-image.jpg", cover = "no-cover.jpg", playername = "", age = 0, bio = "" }; context.players.Add(_p); context.SaveChanges(); } else if (rm.Type == "Coach") { coachs _c = new coachs { userid = (from u in context.users where u.email == rm.Email select u.userid).SingleOrDefault(), name = rm.Username, age = 40, picture = "no-image.jpg", cover = "no-cover.jpg", positionid = rm.RoleId, bio = "Hey, I am coach!" }; context.coachs.Add(_c); context.SaveChanges(); } else { int __userid = (from u in context.users where u.email == rm.Email select u.userid).SingleOrDefault(); clubs _c = new clubs { clubid = (context.clubs.Max(c => c.clubid) + 1), userid = __userid, logo = "no-image.jpg", cover = "no-cover.jpg", cg = "" }; context.clubs.Add(_c); context.SaveChanges(); } ViewBag.Message = "Your account has been created, please login to continue!"; return(RedirectToAction("login")); } } catch (Exception ex) { ViewBag.Message = ex.Message; Console.WriteLine(ex); return(View("register", GamesPositions())); } } else { ViewBag.Message = "Input valid data!"; return(View("register", GamesPositions())); } }
private void button4_Click(object sender, EventArgs e) { if (label2.Text == string.Empty) { MessageBox.Show("Select The valid player,amount and betting Car"); return; } else if (label3.Text == string.Empty) { MessageBox.Show("Select The valid player,amount and betting Car"); return; } else if (label4.Text == string.Empty) { MessageBox.Show("Select The valid player,amount and betting Car"); return; } players objector = new players(); int x = objector.RandomGenerator(); MessageBox.Show("Congratulations ! \n Car " + x + " Wins The Race"); // code to get the amount betted by the bob string text = label2.Text; string[] bobarr = new string[9]; bobarr = text.Split(' '); //code to get the amount betted by the jack string text1 = label3.Text; string[] jackarr = new string[9]; jackarr = text1.Split(' '); //code to get the amount betted by the jim string text2 = label4.Text; string[] jimarr = new string[9]; jimarr = text2.Split(' '); if (x == Convert.ToInt32(bobarr[8])) { MessageBox.Show("Congratulations bob wins the race"); int result = Convert.ToInt32(jackarr[5]) + Convert.ToInt32(jimarr[5]); if (boblist.Count > 0) { int bobamount = Convert.ToInt32(boblist[boblist.Count - 1]); int result1 = bobamount + result; MessageBox.Show("Amount credited to bobs side " + result); MessageBox.Show("Total Amount " + result1); boblist.Add(result1); } int jackreduction = Convert.ToInt32(jacklist.Last()) - Convert.ToInt32(jackarr[5]); MessageBox.Show("Amount deducted from Jack account " + Convert.ToInt32(jackarr[5])); MessageBox.Show("Amount remains in Jack account " + jackreduction); jacklist.Add(jackreduction); int jimreduction = Convert.ToInt32(jimlist.Last()) - Convert.ToInt32(jimarr[5]); MessageBox.Show("Amount deducted from jim account " + Convert.ToInt32(jimarr[5])); MessageBox.Show("Amount remains in Jack account " + jimreduction); jimlist.Add(jimreduction); if (Convert.ToInt32(jacklist.Last()) <= 0) { radioButton2.Enabled = false; label3.Text = "you are busted"; } if (Convert.ToInt32(jimlist.Last()) <= 0) { radioButton1.Enabled = false; label2.Text = "You are busted"; } } // jim function if (x == Convert.ToInt32(jimarr[8])) { MessageBox.Show("Congratulations Jim wins the race"); int result = Convert.ToInt32(jackarr[5]) + Convert.ToInt32(bobarr[5]); if (jimlist.Count > 0) { int jimamount = Convert.ToInt32(jimlist[jimlist.Count - 1]); int result1 = jimamount + result; MessageBox.Show("Amount credited to jim side " + result); MessageBox.Show("Total Amount " + result1); jimlist.Add(result1); } int jackreduction = Convert.ToInt32(jacklist.Last()) - Convert.ToInt32(jackarr[5]); MessageBox.Show("Amount deducted from Jack account " + Convert.ToInt32(jackarr[5])); MessageBox.Show("Amound remains in Jack account " + jackreduction); jacklist.Add(jackreduction); int bobreduction = Convert.ToInt32(boblist.Last()) - Convert.ToInt32(bobarr[5]); MessageBox.Show("Amount deducted from bob account " + Convert.ToInt32(bobarr[5])); MessageBox.Show("Amound remains in Bob account " + bobreduction); boblist.Add(bobreduction); if (Convert.ToInt32(jacklist.Last()) <= 0) { radioButton3.Enabled = false; label4.Text = "you are busted"; } if (Convert.ToInt32(boblist.Last()) <= 0) { radioButton1.Enabled = false; label2.Text = "you are busted"; } /*objector.bobupdateData(result1); * int mscore = Convert.ToInt32(objector.Selectdata(2)); * int mscore1 = mscore - Convert.ToInt32(jackarr[5]); * objector.jackupdateData(mscore1); * int jascore = Convert.ToInt32(objector.Selectdata(3)); * int jascore1 = jascore - Convert.ToInt32(jimarr[5]); * objector.jimupdateData(jascore1);*/ } /* else * { * radioButton1.Enabled = false; * label2.Text = "You are busted"; * }*/ if (x == Convert.ToInt32(jackarr[8])) { MessageBox.Show("Congratulations jack wins the race"); int jackresult = Convert.ToInt32(bobarr[5]) + Convert.ToInt32(jimarr[5]); if (jacklist.Count > 0) { int jackamount = Convert.ToInt32(jacklist[jacklist.Count - 1]); int result1 = jackamount + jackresult; MessageBox.Show("Amount credited to Jack side " + jackresult); MessageBox.Show("Total Amount " + result1); jacklist.Add(result1); } int jimreduction = Convert.ToInt32(jimlist.Last()) - Convert.ToInt32(jimarr[5]); MessageBox.Show("Amount deducted from Jim account " + Convert.ToInt32(jimarr[5])); MessageBox.Show("Amound remains in Jim account " + jimreduction); jimlist.Add(jimreduction); int bobreduction = Convert.ToInt32(boblist.Last()) - Convert.ToInt32(bobarr[5]); MessageBox.Show("Amount deducted from bob account " + Convert.ToInt32(bobarr[5])); MessageBox.Show("Amound remains in Bob account " + bobreduction); boblist.Add(bobreduction); if (Convert.ToInt32(jimlist.Last()) <= 0) { radioButton2.Enabled = false; label3.Text = "you are busted"; } if (Convert.ToInt32(boblist.Last()) <= 0) { radioButton1.Enabled = false; label2.Text = "you are busted"; } /*objector.jackupdateData(jackresult1); * int mscore = Convert.ToInt32(objector.Selectdata(1)); * int mscore1 = mscore - Convert.ToInt32(bobarr[5]); * objector.bobupdateData(mscore1); * int jascore = Convert.ToInt32(objector.Selectdata(3)); * int jascore1 = jascore - Convert.ToInt32(jimarr[5]); * objector.jimupdateData(jascore1);*/ } /*else * { * radioButton2.Enabled = false; * label3.Text = "you are busted"; * }/* * if (x == Convert.ToInt32(jimarr[8])) * { * MessageBox.Show("Congratulations jim wins the race"); * int jimresult = Convert.ToInt32(jackarr[5]) + Convert.ToInt32(bobarr[5]); * int jimresult1 = Convert.ToInt32(jimarr[5]) + jimresult; * MessageBox.Show("Amount credited to Jim side" + jimresult); * MessageBox.Show("Total Amount" + jimresult1); * objector.jimupdateData(jimresult1); * int mscore = Convert.ToInt32(objector.Selectdata(1)); * int mscore1 = mscore - Convert.ToInt32(bobarr[5]); * objector.bobupdateData(mscore1); * int jascore = Convert.ToInt32(objector.Selectdata(2)); * int jascore1 = jascore - Convert.ToInt32(jackarr[5]); * objector.jackupdateData(jascore1); * } * else * { * radioButton3.Enabled = false; * label4.Text = "You are Busted"; * }*/ }
public ActionResult Clubs(string id, string city, int?game) { try { if (city == "all") { city = null; } if (game == 0) { game = null; } if (id == null) { using (var context = new Entities()) { // if (city == null) city = ""; // if (name == null) name = ""; List <games> gms = (from gm in context.games select gm).ToList(); List <clubs> clubd = new List <clubs>(); List <clubs> cls = (from c in context.clubs where (c.city == null || DbFunctions.Like(c.city, "%" + city + "%")) && (c.cg == null || DbFunctions.Like(c.cg, "%" + game + "," + "%")) select c).ToList(); for (int i = 0; i < cls.Count; i++) { { int uid = cls[i].userid; int cid = cls[i].clubid; string username = (from u in context.users where u.userid == uid select u.username).SingleOrDefault(); int tcount = (from c in context.teams where c.clubid == cid select c).Count(); int ccount = (from cc in context.coach_associations where cc.coachid == cid select cc).Count(); clubs clbd = new clubs { clubid = cls[i].clubid, userid = cls[i].userid, clubname = cls[i].clubname + "♦" + username + "♦" + tcount + "♦" + ccount, city = cls[i].city, C_address = cls[i].C_address, C_state = cls[i].C_state, lat = cls[i].lat, @long = cls[i].@long, logo = cls[i].logo, cover = cls[i].cover }; clubd.Add(clbd); } } ViewBag.Games = gms; return(View(clubd)); } } else { using (var context = new Entities()) { int?uid = (from u in context.users where u.username == id select u.userid).SingleOrDefault(); if (uid != null) { List <clubs> clb = (from c in context.clubs where c.userid == uid select c).ToList(); int cid = clb[0].clubid; //club id // Get Teams Data List <teams> tms = (from t in context.teams where t.clubid == cid select t).ToList(); List <teams> teams = new List <teams>(); for (int i = 0; i < tms.Count; i++) { int teamid = tms[i].teamid; int gameid = tms[i].gameid; int totalplayerinteam = (from tpt in context.player_associations where tpt.teamid == teamid select tpt).Count(); int totalcoachsinteam = (from tct in context.coach_associations where tct.teamid == teamid select tct).Count(); string gamename = (from gn in context.games where gn.gameid == gameid select gn.gamename).SingleOrDefault(); teams tm = new teams() { teamid = teamid, name = tms[i].name + "♦" + gamename + "♦" + totalplayerinteam + "♦" + totalcoachsinteam, logo = tms[i].logo }; teams.Add(tm); } //Get Coachs Data List <int> chs = (from ch in context.coach_associations where ch.clubid == cid select ch.coachid).ToList(); //Get Coachs - Complete data ------------------ List <coachs> ourcoachs = new List <coachs>(); for (int i = 0; i < chs.Count; i++) { int chid = chs[i]; List <coachs> coachs = (from c_c in context.coachs where c_c.coachid == chid select c_c).ToList(); int? positionid = coachs[0].positionid; string position = (from pos in context.games_positions where pos.positionid == positionid select pos.position).SingleOrDefault(); //get user data int userid = coachs[0].userid; List <users> users = (from usr in context.users where usr.userid == userid select usr).ToList(); coachs _coach = new coachs { coachid = coachs[0].coachid, userid = coachs[0].userid, name = coachs[0].name + "♦" + users[0].username + "♦" + position, age = coachs[0].age, picture = coachs[0].picture, }; ourcoachs.Add(_coach); } // get top 3 players List <player_associations> pa = (from plas in context.player_associations where plas.clubid == cid select plas).ToList(); List <players> asplayers = new List <players>(); int j = 0; if (pa.Count >= 3) { j = 3; } else { j = pa.Count; } for (int i = 0; i < j; i++) { int roleid = pa[i].roleid; int playerid = pa[i].playerid; string position = (from rnam in context.games_positions where rnam.positionid == roleid select rnam.position).SingleOrDefault(); List <players> player = (from ply in context.players where ply.playerid == playerid select ply).ToList(); players plyr = new players { playerid = playerid, playername = player[0].playername + "♦" + position, age = player[0].age, photo = player[0].photo, height = player[0].height, }; asplayers.Add(plyr); } ViewBag.Players = asplayers; ViewBag.Teams = teams; ViewBag.Coachs = ourcoachs; return(View("clubdetail", clb)); } else { ViewBag.Message = "Club not found!"; return(View("error404")); } } } } catch (Exception ex) { ViewBag.Message = ex.Message; return(View("error404")); } }
public object RankAlgorithm(BasePlayer player) { if (players.Find(player) == null) { OnPlayerInit(player); } players playerData = players.Find(player); if (playerData.Humanity <= -2500) { if (Convert.ToBoolean(BetterChat?.Call("API_IsUserInGroup", player.UserIDString, "Hero")) == true) { BetterChat?.Call("API_RemoveUserFromGroup", player.UserIDString, "Hero"); } if (Convert.ToBoolean(BetterChat?.Call("API_IsUserInGroup", player.UserIDString, "Neutral")) == true) { BetterChat?.Call("API_RemoveUserFromGroup", player.UserIDString, "Neutral"); } if (Convert.ToBoolean(BetterChat?.Call("API_IsUserInGroup", player.UserIDString, "Bandit")) == true || playerData.Rank == 2) { return("Bandit"); } BetterChat?.Call("API_AddUserToGroup", player.UserIDString, "Bandit"); humanityData.playerH[player.userID].Rank = 2; SendReply(player, lang.GetMessage("NowA", this), "Bandit"); } else if (playerData.Humanity >= 2500) { if (Convert.ToBoolean(BetterChat?.Call("API_IsUserInGroup", player.UserIDString, "Bandit"))) { BetterChat?.Call("API_RemoveUserFromGroup", player.UserIDString, "Bandit"); } if (Convert.ToBoolean(BetterChat?.Call("API_IsUserInGroup", player.UserIDString, "Neutral"))) { BetterChat?.Call("API_RemoveUserFromGroup", player.UserIDString, "Neutral"); } if (Convert.ToBoolean(BetterChat?.Call("API_IsUserInGroup", player.UserIDString, "Hero")) || playerData.Rank == 1) { return("Hero"); } BetterChat?.Call("API_AddUserToGroup", player.UserIDString, "Hero"); humanityData.playerH[player.userID].Rank = 1; SendReply(player, lang.GetMessage("NowA", this), "Hero"); } else { if (Convert.ToBoolean(BetterChat?.Call("API_IsUserInGroup", player.UserIDString, "Bandit"))) { BetterChat?.Call("API_RemoveUserFromGroup", player.UserIDString, "Bandit"); } if (Convert.ToBoolean(BetterChat?.Call("API_IsUserInGroup", player.UserIDString, "Hero"))) { BetterChat?.Call("API_RemoveUserFromGroup", player.UserIDString, "Hero"); } if (Convert.ToBoolean(BetterChat?.Call("API_IsUserInGroup", player.UserIDString, "Neutral")) || playerData.Rank == 0) { return("Neutral"); } BetterChat?.Call("API_AddUserToGroup", player.UserIDString, "Neutral"); humanityData.playerH[player.userID].Rank = 0; SendReply(player, lang.GetMessage("NowA", this), "Neutral"); } SaveData(); return(true); }