static void Main(string[] args) { string console = ""; string input; //Read from console while ((input = Console.ReadLine()) != null) { console += input; } //Parse console input List <JToken> jTokenList = ParsingHelper.ParseJson(console); List <JToken> finalList = new List <JToken>(); PlayerAdapter aiPlayer = new PlayerAdapter(); JToken toAdd; foreach (JToken jtoken in jTokenList) { toAdd = aiPlayer.JsonCommand(jtoken); if (toAdd.Type != JTokenType.Null) { finalList.Add(toAdd); } } Console.WriteLine(JsonConvert.SerializeObject(finalList)); Console.ReadLine(); }
/// <summary> /// Any view setup should occur here. /// </summary> /// <param name="view"></param> /// <param name="savedInstanceState"></param> public override void OnViewCreated(View view, Bundle savedInstanceState) { //https://github.com/fabionuno/FloatingActionButton-Xamarin.Android var fabButton = view.FindViewById <Clans.Fab.FloatingActionButton>(Resource.Id.fab); fabButton.Click += (sender, args) => { Toast.MakeText(Activity, "FAB clicked", ToastLength.Short).Show(); }; var playerAdapter = new PlayerAdapter(Activity, Players.ToArray()); playerAdapter.PlayerClicked += (sender, player) => { Snackbar .Make(view, "Message sent", Snackbar.LengthShort) //.SetAction("Undo", (view) => { /*Undo message sending here.*/ }) .Show(); // Don’t forget to show! }; playerAdapter.DetailClicked += (sender, player) => { Toast.MakeText(Activity, $"Detail clicked: {player.Name}", ToastLength.Short).Show(); }; playerAdapter.SelectionClicked += (sender, player) => { Toast.MakeText(Activity, $"Selection clicked: {player.Name}", ToastLength.Short).Show(); }; var recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView); recyclerView.SetLayoutManager(GetLayoutManager()); recyclerView.SetAdapter(playerAdapter); }
//A method which calls the DropOff method and puts in the player's inventory //Called by the Deposit button on the UI object public void GetPlayerDeposit() { if (player == null) { player = FindObjectOfType<PlayerAdapter>(); } DropOff(player.DepositEntireInventory()); }
private static void setupDTOs(PlayerDTO playerDTO, IList <PlayerDTO> opponentDTOs, IList <ResourceDTO> resourceDTOs) { // create the player IMoveable playerShip = PlayerAdapter.playerDTOToMoveable(playerDTO, Colors.Black); playerShip.Mover = new MoveStrategy(); UIDispatcher.Invoke(() => { Player = new Player(Username, UserID, playerDTO.Wallet, playerDTO.Health, playerShip); }); // convert data transfer objects to their respective types and add them to list foreach (PlayerDTO opponent in opponentDTOs) { IMoveable moveable = PlayerAdapter.playerDTOToMoveable(opponent, Colors.Red); while (!Opponents.TryAdd(opponent.Name, moveable)) { Task.Delay(1); } } foreach (ResourceDTO resource in resourceDTOs) { IResource r = ResourceAdapter.DTOToResource(resource); while (!Resources.TryAdd(resource.ID, r)) { Task.Delay(1); } } }
private bool CheckForDeleteCheaterCommand(PlayerChatEventArgs args) { if (args.IsServerMessage || args.Text.IsNullOrTimmedEmpty()) { return(false); } ServerCommand command = ServerCommand.Parse(args.Text); if (!command.Is(Command.DeleteCheater) || command.PartsWithoutMainCommand.Count == 0) { return(false); } string login = command.PartsWithoutMainCommand[0]; if (!LoginHasRight(args.Login, true, Command.DeleteCheater)) { return(true); } if (PlayerAdapter.RemoveAllStatsForLogin(login)) { SendFormattedMessageToLogin(args.Login, Settings.CheaterDeletedMessage, "Login", login); DetermineLocalRecords(); OnLocalRecordsDetermined(new List <RankEntry>(LocalRecords)); } else { SendFormattedMessageToLogin(args.Login, Settings.CheaterDeletionFailedMessage, "Login", login); } return(true); }
/// <exception cref="ConfigurationErrorsException">Could not find connectionString Attribute for SqlNicknameResolver in NicknameResolver-Config Xml-Node.</exception> /// <exception cref="ConfigurationErrorsException">connectionString Attribute for SqlNicknameResolver in NicknameResolver-Config Xml-Node is empty.</exception> public override void ReadConfigSettings(XElement configElement) { XAttribute connectionStringAttribute = configElement.Attribute("connectionString"); if (connectionStringAttribute == null) { throw new ConfigurationErrorsException("Could not find connectionString Attribute for SqlNicknameResolver in NicknameResolver-Config Xml-Node.", (Exception)null); } if (connectionStringAttribute.Value.IsNullOrTimmedEmpty()) { throw new ConfigurationErrorsException("connectionString Attribute for SqlNicknameResolver in NicknameResolver-Config Xml-Node is empty.", (Exception)null); } try { new SqlConnectionStringBuilder(connectionStringAttribute.Value.Trim()); } catch (Exception ex) { throw new ConfigurationErrorsException("connectionString Attribute for SqlNicknameResolver in NicknameResolver-Config Xml-Node has a wrong format.", ex); } ConnectionManager = new ConnectionManager(connectionStringAttribute.Value.Trim(), false); PlayerAdapter = new PlayerAdapter(ConnectionManager); }
private Grid GeneratePlayerTitleBlock(Player p) { PlayerAdapter pa = new PlayerAdapter(); Maths u = new Maths(); Grid g; g = GenerateBlankBlockGrid(3, p.DisplayName(PersonNameReturnType.FirstnameLastname) + (Debugger.IsAttached ? string.Format(", ID: {0}", p.UniqueID.ToString()) : ""), 2); Grid.SetColumnSpan(g, 2); TextBlock t = new TextBlock(); t.Text = pa.PositionAndSideText(p, false); t.Style = Application.Current.FindResource("ListHeader") as Style; t.Margin = new Thickness(8, 0, 0, 0); Grid.SetColumn(t, 0); Grid.SetColumnSpan(t, 2); Grid.SetRow(t, 1); g.Children.Add(t); UiUtils.AddGridData(g, 0, 2, LangResources.CurLang.DateOfBirth, p.DateOfBirth.ToString(LangResources.CurLang.DateFormat) + string.Format(" (Age: {0})", u.CalculateAgeInGame(p.DateOfBirth))); StackPanel stars = GraphicUtils.StarRating(p.Stars); stars.HorizontalAlignment = HorizontalAlignment.Right; Grid.SetColumn(stars, 3); Grid.SetColumnSpan(stars, 3); Grid.SetRow(stars, 0); g.Children.Add(stars); return(g); }
private void UpdatePlayers() { PlayerAdapter pa = new PlayerAdapter(); lstPlayers.Title = LangResources.CurLang.Players; lstPlayers.Columns = new List <ListColumn>() { new ListColumn(LangResources.CurLang.Name, 200), new ListColumn(LangResources.CurLang.Position_Short, 50), new ListColumn(LangResources.CurLang.Rating, 120) }; List <ListRow> rows = new List <ListRow>(); List <Player> players = (from p in pa.GetPlayers(SetupData.TeamData.UniqueID) orderby p.Position, p.PreferredSide select p).ToList(); foreach (Player p in players) { rows.Add(new ListRow(p.UniqueID, new List <object>() { p.DisplayName(PersonNameReturnType.LastnameInitial), pa.PositionAndSideText(p, true), GraphicUtils.StarRating(p.Stars) })); } lstPlayers.Rows = rows; lstPlayers.SelectionMode = SelectMode.HighlightAndCallback; lstPlayers.Callback_ItemClick = ShowPlayer; }
public void showTable() { PlayerStr [] players = new PlayerStr[Prototype.NetworkLobby.LobbyPlayerList._instance.Players.Count]; for (int i = 0; i < players.Length; i++) { players[i].name = Prototype.NetworkLobby.LobbyPlayerList._instance.Players[i].playerName; players[i].color = Prototype.NetworkLobby.LobbyPlayerList._instance.Players[i].playerColor; players[i].score = MyNetManager.instance.playersOnServer [i].score.Score; } lastPlayerText.text = lastPlayer; players = sort(players); int lastDepth = PlayerPrefs.GetInt("depth"); int depth = 0; int.TryParse(UIController.instance.depthText.text.Substring(7), out depth); Debug.Log(UIController.instance.depthText.text.Substring(7) + ";" + depth); if (depth < lastDepth) { recordText.text = "НОВЫЙ РЕКОРД!\nМакс. глубина:"; PlayerPrefs.SetInt("depth", depth); } depthText.text = depth.ToString(); foreach (var player in players) { PlayerAdapter adap = Instantiate(adapter.Prefab, container.transform).GetComponent <PlayerAdapter> (); adap.apply(player.name, player.score.ToString(), player.color); } }
public void SetupTeam(bool WithLabels) { int FormationID = (MyTeam ? team.CurrentFormation : team.LastKnownFormation); Dictionary <int, TeamPlayer> picks = (MyTeam ? team.Players : team.LastKnownPick); FormationPaging.DisplayItem(FormationID); SetupFormationTemplate(FormationID); PlayerAdapter pa = new PlayerAdapter(); foreach (KeyValuePair <int, TeamPlayer> p in picks) { TeamPlayer tp = p.Value; Player player = pa.GetPlayer(tp.PlayerID); if (WithLabels) { StackPanel s = new StackPanel(); s.Orientation = Orientation.Horizontal; TextBlock playerLabel = new TextBlock(); playerLabel.Width = 150; playerLabel.Height = 30; playerLabel.Text = player.DisplayName(PersonNameReturnType.LastnameInitial); playerLabel.MouseMove += new MouseEventHandler(PlayerName_MouseMove); playerLabel.Tag = tp.PlayerID; playerLabel.VerticalAlignment = VerticalAlignment.Center; playerLabel.Cursor = Cursors.Hand; PlayerLabels.Add(playerLabel); s.Children.Add(PlayerLabels[PlayerLabels.Count - 1]); TextBlock playerPos = new TextBlock(); playerPos.Width = 60; playerPos.Height = 30; playerPos.Text = pa.PositionAndSideText(player, true); playerPos.VerticalAlignment = VerticalAlignment.Center; s.Children.Add(playerPos); s.Children.Add(GraphicUtils.StarRatingWithNumber(player.Stars)); //stkNames.Children.Add(PlayerLabels[PlayerLabels.Count - 1]); stkNames.Children.Add(s); playerLabel = null; } if (tp.Selected == PlayerSelectionStatus.Starting && tp.PlayerGridX > -1 && tp.PlayerGridY > -1) { MarkerText[tp.PlayerGridX, tp.PlayerGridY].Text = player.DisplayName(PersonNameReturnType.InitialOptionalLastname); MarkerText[tp.PlayerGridX, tp.PlayerGridY].Visibility = Visibility.Visible; PlayerGridPositions[tp.PlayerGridX, tp.PlayerGridY] = tp.PlayerID; } } ChangesNotSaved = false; }
// Use this for initialization void Start() { player = GetComponentInParent<PlayerAdapter>(); spriteRenderer = GetComponent<SpriteRenderer>(); spriteRenderer.sortingOrder = player.gameObject.GetComponent<SpriteRenderer> ().sortingOrder + 1; equipAnim = GetComponent<Animator>(); playerAnim = player.gameObject.GetComponent<Animator>(); }
/// <summary> /// Loop round all AI teams, and select a team appropriate to play the fixture. /// </summary> public void SelectTeamIfPlaying() { FixtureAdapter fa = new FixtureAdapter(); WorldAdapter wa = new WorldAdapter(); TeamAdapter ta = new TeamAdapter(); ManagerAdapter ma = new ManagerAdapter(); List <Fixture> AllFixtures = fa.GetFixtures(wa.CurrentDate); int TESTf = 0; foreach (Fixture f in AllFixtures) { TESTf++; Debug.Print("Fixture " + f.ToString()); for (int t = 0; t <= 1; t++) { Team ThisTeam = ta.GetTeam(f.TeamIDs[t]); Manager M = ma.GetManager(ThisTeam.ManagerID); if (!M.Human) { Team Opposition = ta.GetTeam(f.TeamIDs[1 - t]); PlayerAdapter pa = new PlayerAdapter(); int[,] PlayerGridPositions = new int[5, 8]; // TODO: Maybe not hard code these... for (int x = 0; x <= PlayerGridPositions.GetUpperBound(0); x++) { for (int y = 0; y <= PlayerGridPositions.GetUpperBound(1); y++) { PlayerGridPositions[x, y] = -1; } } Formation TeamFormation = new FormationAdapter().GetFormation(ThisTeam.CurrentFormation); List <AvailablePlayer> avail = GetEligiblePlayers(ThisTeam, f); foreach (Point2 point in TeamFormation.Points) { AvailablePlayer SelPlayer = FindBestPlayerForPosition(point, avail); if (SelPlayer == null) { throw new Exception("Unable to find a player for this position"); } PlayerGridPositions[point.X, point.Y] = SelPlayer.PlayerID; avail.Remove(SelPlayer); } ta.SavePlayerFormation(ThisTeam.UniqueID, TeamFormation.UniqueID, PlayerGridPositions); } } } }
void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.name == "Player") { if (!iManager.IsActive ()) { iManager.ShowInstruction (instruction1, instructionKey, instruction2); } playerInZone = true; player = col.gameObject.GetComponent<PlayerAdapter> (); } }
//Parse json from a file and run it through Player //Returns output of Player.JsonCommand private string TestJson(string filePath) { string json = ExtractJson(filePath); List <JToken> finalList = new List <JToken>(); //Network setup IPAddress ipAddr = IPAddress.Parse("127.0.0.1"); IPEndPoint localEndPoint = new IPEndPoint(ipAddr, _port); // Creation TCP/IP Socket using Socket Class Costructor _socket = new Socket(ipAddr.AddressFamily, SocketType.Stream, ProtocolType.Tcp); _socket.Bind(localEndPoint); PlayerClient client = new PlayerClient("localhost", _port, "less dumb", 1, "no name"); PlayerAdapter aiPlayer = new PlayerAdapter(_socket); _port++; //Parse console input while testing JsonTextReader reader = new JsonTextReader(new StringReader(json)); reader.SupportMultipleContent = true; JsonSerializer serializer = new JsonSerializer(); JToken toAdd; while (true) { //Parse console input while testing if (!reader.Read()) { break; } JToken jtoken = serializer.Deserialize <JToken>(reader); try { toAdd = aiPlayer.JsonCommand(jtoken, "no name"); if (toAdd.Type != JTokenType.Null) { finalList.Add(toAdd); } } catch (InvalidJsonInputException) { finalList.Add("GO has gone crazy!"); break; } } return(JsonConvert.SerializeObject(finalList)); }
void Update() { if (trigger && Input.GetKeyDown(KeyCode.R)) { PlayerAdapter.SetVelocity(Vector2.zero); player.SetActive(false); gateParticleSystem.SetActive(true); gateParticleSystem.transform.position = player.transform.position; Invoke("DeactivateGemGameObject", gateParticleSystem.GetComponent <ParticleSystem>().main.duration); } }
private static void opponentJoined(PlayerDTO dto) { if (!GameController.Opponents.ContainsKey(dto.Name)) { IMoveable opponent = PlayerAdapter.playerDTOToMoveable(dto, Colors.Red); if (GameController.Opponents.TryAdd(dto.Name, opponent)) { UIDispatcher.Invoke(() => ArenaController.ArenaCanvas.Children.Add(opponent.Shape.Polygon)); } } }
public async Task <IActionResult> GetByIdAsync(Guid id) { var player = await _playerService.GetByIdAsync(id); if (player != null) { return(Ok(PlayerAdapter.ToPlayerDTO(player))); } return(NoContent()); }
public async Task <IActionResult> GetAsync() { var players = await _playerService.GetAllAsync(); if (players.Any()) { return(Ok(players.Select(x => PlayerAdapter.ToPlayerDTO(x)))); } return(NoContent()); }
private void HandleCheater(string login, bool updateUI) { Context.RPCClient.Methods.BanAndBlackList(login, "Banned and blacklisted for cheating!", true); SendFormattedMessage(Settings.CheaterBannedMessage, "Login", login); PlayerAdapter.RemoveAllStatsForLogin(login); if (updateUI) { DetermineLocalRecords(); OnLocalRecordsDetermined(new List <RankEntry>(LocalRecords)); } }
//Parse json from a file and run it through Player //Returns output of Player.JsonCommand private string TestJson(string filePath) { string json = ExtractJson(filePath); List <JToken> finalList = new List <JToken>(); //string go = File.ReadAllText("go.config"); //JObject ipPort = JsonConvert.DeserializeObject<JObject>(go); //string path = ipPort["default-player"].ToObject<string>(); //Create local player //Process.Start(Path.Combine(Environment.CurrentDirectory, path)); PlayerClient client = new PlayerClient("localhost", _port, "less dumb", 1, "no name"); PlayerAdapter aiPlayer = new PlayerAdapter(_port); _port++; //Parse console input while testing JsonTextReader reader = new JsonTextReader(new StringReader(json)); reader.SupportMultipleContent = true; JsonSerializer serializer = new JsonSerializer(); JToken toAdd; while (true) { //Parse console input while testing if (!reader.Read()) { break; } JToken jtoken = serializer.Deserialize <JToken>(reader); try { toAdd = aiPlayer.JsonCommand(jtoken, "no name"); if (toAdd.Type != JTokenType.Null) { finalList.Add(toAdd); } } catch (InvalidJsonInputException) { finalList.Add("GO has gone crazy!"); break; } } return(JsonConvert.SerializeObject(finalList)); }
private void notifyPlayerTurn() { String playerTurn = model.getPlayerTurnName(); if (playerTurn != null) { playerDispatcher[playerTurn].dispatch( new GameEvent(GameController.GET_COMMAND_PLAYER_EVENT_TYPE, GameController.SYSTEM_CONTROLLER, PlayerAdapter.toTableState(model, playerTurn))); } }
public void PopulatePlayerStatuses(MatchStatus ms, Fixture f) { List <PlayerStatus> StatusList; for (int t = 0; t <= 1; t++) { ms.OverallPlayerEffectiveRating[t] = 0; TeamAdapter ta = new TeamAdapter(); Team Team = ta.GetTeam(f.TeamIDs[t]); PlayerAdapter pa = new PlayerAdapter(); StatusList = new List <PlayerStatus>(); TacticEvaluation Eval = new TacticEvaluation(); int selected = 0; int totalEffectiveRating = 0; const double HealthDeteriorationPower = 4; foreach (KeyValuePair <int, TeamPlayer> kvp in Team.Players) { Player p = pa.GetPlayer(kvp.Value.PlayerID); PlayerStatus ps = new PlayerStatus(); ps.PlayerID = kvp.Value.PlayerID; ps.Playing = kvp.Value.Selected; ps.CurrentHealth = p.Health; ps.CurrentHealthDeterioration = Math.Pow(1 - (Convert.ToDouble(p.Fitness) / 100), HealthDeteriorationPower); if (ps.Playing == PlayerSelectionStatus.Starting) { selected++; PlayerPosition pos = GridLengthToPosition(kvp.Value); ps.EffectiveRating = CalculatePlayerEffectivenessInPosition(kvp.Value); totalEffectiveRating += ps.EffectiveRating; Eval.AddRatingForPosition(pos, ps.EffectiveRating); StatusList.Add(ps); } ps = null; } ms.OverallPlayerEffectiveRating[t] = (selected > 0 ? totalEffectiveRating / selected : 0); ms.PlayerStatuses[t] = StatusList; ms.Evaluation[t] = Eval; StatusList = null; } }
/// <summary> /// Any view setup should occur here. /// </summary> /// <param name="view"></param> /// <param name="savedInstanceState"></param> public override void OnViewCreated(View view, Bundle savedInstanceState) { var adapter = new PlayerAdapter(Activity, Resource.Layout.PlayerListViewRow, Players.ToArray()); var listView = view.FindViewById <ListView>(Resource.Id.listView); listView.Adapter = adapter; listView.ItemClick += (sender, args) => { var itemAtPosition = listView.GetItemAtPosition(args.Position); OnPlayerClicked(itemAtPosition.Cast <Player>()); }; }
public void AllPlayersDailyUpdate() { const double standardDailyIncrement = 7; PlayerAdapter pa = new PlayerAdapter(); TeamAdapter ta = new TeamAdapter(); FixtureAdapter fa = new FixtureAdapter(); List <Player> players = pa.GetPlayers(); for (int i = 0; i < players.Count; i++) { Player p = players[i]; if (p.Health < 100) { // If player was not in a game today, then we increase their health bool doUpdate = true; if (p.CurrentTeam != -1) { if (ta.GetPlayerSelectionStatus(p.UniqueID, p.CurrentTeam, false) != PlayerSelectionStatus.None) { if (fa.IsTodayAMatchDay(p.CurrentTeam)) { doUpdate = false; } } } if (doUpdate) { double increment = standardDailyIncrement * ((double)p.Fitness / 100); if (increment < 1) { increment = 1; } p.Health += increment; if (p.Health > 100) { p.Health = 100; } pa.UpdatePlayer(p); } } } }
protected override void Dispose(bool connectionLost) { RunCatchLog(() => Context.PlayerSettings.GetAllAsList().ForEach(p => PlayerAdapter.UpdateTimePlayed(p.Login)), "Error updatimg TimePlayed for all players while disposing the plugin."); DisposePlugins(connectionLost); // enforce connection close here later Context.RPCClient.Callbacks.BeginRace -= Callbacks_BeginRace; Context.RPCClient.Callbacks.EndRace -= Callbacks_EndRace; Context.RPCClient.Callbacks.PlayerConnect -= Callbacks_PlayerConnect; Context.RPCClient.Callbacks.PlayerDisconnect -= Callbacks_PlayerDisconnect; Context.RPCClient.Callbacks.PlayerFinish -= Callbacks_PlayerFinish; Context.RPCClient.Callbacks.PlayerChat -= Callbacks_PlayerChat; }
private void ShowPlayer() { int id = lstPlayers.SelectedID; if (id == -1) { throw new Exception("No player selected"); } PlayerAdapter pa = new PlayerAdapter(); Player p = pa.GetPlayer(lstPlayers.SelectedID); GeneratePlayerBlocks(p); }
public void UpdatePlayerHealthForWorld(MatchStatus ms) { PlayerAdapter pa = new PlayerAdapter(); for (int t = 0; t <= 1; t++) { for (int s = 0; s < ms.PlayerStatuses[t].Count; s++) { PlayerStatus stat = ms.PlayerStatuses[t][s]; Player p = pa.GetPlayer(stat.PlayerID); p.Health = stat.CurrentHealth; pa.UpdatePlayer(p); } } }
//Parse json from a file and run it through Player //Returns output of Player.JsonCommand private string TestJson(string filePath) { string json = ExtractJson(filePath); List <JToken> finalList = new List <JToken>(); PlayerAdapter aiPlayer = new PlayerAdapter(true, _port); PlayerClient client = new PlayerClient("localhost", _port); _port++; //Parse console input while testing JsonTextReader reader = new JsonTextReader(new StringReader(json)); reader.SupportMultipleContent = true; JsonSerializer serializer = new JsonSerializer(); JToken toAdd; while (true) { //Parse console input while testing if (!reader.Read()) { break; } JToken jtoken = serializer.Deserialize <JToken>(reader); try { toAdd = aiPlayer.JsonCommand(jtoken, "no name", "less dumb", 1); if (toAdd.Type != JTokenType.Null) { finalList.Add(toAdd); } } catch (InvalidJsonInputException) { finalList.Add("GO has gone crazy!"); break; } } return(JsonConvert.SerializeObject(finalList)); }
/// <summary> /// Return a list of all eligible players for this match /// </summary> /// <param name="t">Team object</param> /// <param name="f">Fixture object</param> /// <returns>List of </returns> private List <AvailablePlayer> GetEligiblePlayers(Team t, Fixture f) { List <AvailablePlayer> retVal = new List <AvailablePlayer>(); PlayerAdapter pa = new PlayerAdapter(); List <Player> players = pa.GetPlayers(t.UniqueID); foreach (Player p in players) { // TODO: When we have injuries, remember to deal with these appropriately. AvailablePlayer ap = new AvailablePlayer(); ap.PlayerID = p.UniqueID; ap.Pos = p.Position; ap.Side = p.PreferredSide; ap.Rating = p.OverallRating; retVal.Add(ap); } return(retVal); }
//Parse json from a file and run it through Player //Returns output of Player.JsonCommand private string TestJson(string filePath, string aiType) { string json = ExtractJson(filePath); //Parse console input List <JToken> jTokenList = ParsingHelper.ParseJson(json); List <JToken> finalList = new List <JToken>(); PlayerAdapter aiPlayer = new PlayerAdapter(aiType); JToken toAdd; foreach (JToken jtoken in jTokenList) { toAdd = aiPlayer.JsonCommand(jtoken, "no name"); if (toAdd.Type != JTokenType.Null) { finalList.Add(toAdd); } } return(JsonConvert.SerializeObject(finalList)); }
private void Callbacks_EndRace(object sender, EndRaceEventArgs e) { RunCatchLog(() => { if (e.Rankings.Count > 0) { // this may take a while, so run it async on the thread pool ThreadPool.QueueUserWorkItem(UpdateRankingForChallenge, e.Challenge.UId); } if (e.Rankings.Count > 1) { // there must be at least 2 players to increase the wins for the first player if (e.Rankings[0].BestTime > 0) { uint wins = PlayerAdapter.IncreaseWins(e.Rankings[0].Login); OnPlayerWins(e.Rankings[0], wins); int maxRank = e.Rankings.Max(playerRank => playerRank.Rank); foreach (PlayerRank playerRank in e.Rankings) { if (playerRank.Rank <= 0) { continue; } if (!CheckpointsValid(playerRank.BestCheckpoints)) { HandleCheater(playerRank.Login, false); } else { PositionAdapter.AddPosition(playerRank.Login, e.Challenge.UId, Convert.ToUInt16(playerRank.Rank), Convert.ToUInt16(maxRank)); } } } } }, "Error in Callbacks_EndRace Method.", true); }
private AvailablePlayer FindBestPlayerForPosition(Point2 GridPos, List <AvailablePlayer> avail) { PlayerAdapter pa = new PlayerAdapter(); FormationAdapter fa = new FormationAdapter(); SuitablePlayerInfo suit = fa.SuitablePlayerPositions(GridPos); AvailablePlayer best = null; foreach (PlayerPosition pos in suit.Positions) { foreach (PlayerPositionSide side in suit.Sides) { best = (from ap in avail where ap.Side == side && ap.Pos == pos select ap).FirstOrDefault(); if (best != null) { break; } } if (best != null) { break; } } if (best == null) { best = (from ap in avail orderby ap.Rating descending select ap).FirstOrDefault(); } return(best); }
private void Marker_Drop(object sender, DragEventArgs e) { base.OnDrop(e); if (e.Data.GetDataPresent(DataFormats.StringFormat)) { int PlayerID = Convert.ToInt32((string)e.Data.GetData(DataFormats.StringFormat)); // Should be player ID Polygon DropControl = (Polygon)sender; //TextBlock DropControl = (TextBlock)sender; string[] coords = DropControl.Tag.ToString().Split(new string[] { "," }, StringSplitOptions.None); int xPos = Convert.ToInt32(coords[0]); int yPos = Convert.ToInt32(coords[1]); PlayerAdapter pa = new PlayerAdapter(); MarkerText[xPos, yPos].Text = pa.GetPlayer(PlayerID).DisplayName(PersonNameReturnType.LastnameInitialOptional); MarkerText[xPos, yPos].Visibility = Visibility.Visible; PlayerGridPositions[xPos, yPos] = PlayerID; // Scan other positions to ensure we don't duplicate the player for (int x = 0; x < GRIDWIDTH; x++) { for (int y = 0; y < GRIDHEIGHT; y++) { if (PlayerGridPositions[x, y] == PlayerID && !(x == xPos && y == yPos)) { MarkerText[x, y].Visibility = Visibility.Hidden; PlayerGridPositions[x, y] = -1; } } } ChangesNotSaved = true; } }
void Start() { player = GetComponentInParent<PlayerAdapter>(); spriteRenderer = GetComponentInChildren<SpriteRenderer>(); }
//TODO: Method to be re written when serialisation/deserialisation implemented. private void InstantiatePlayer(Game game) { GameObject player = Instantiate (Resources.Load ("Prefabs/Player"), game.Player.CurrentPosition, Quaternion.identity) as GameObject; player.name = "Player"; playerAdapter = player.GetComponent<PlayerAdapter> (); playerAdapter.Player = game.Player; game.Player.AddObserver (playerAdapter); if (playerAdapter.Player.CurrentArea != null) { AreaSystem[] adapters = GameObject.FindObjectsOfType<AreaSystem>(); playerAdapter.Player.CurrentArea = Array.Find(adapters, adapter => adapter.Area.AreaName == playerAdapter.Player.CurrentArea.AreaName).Area; } }
// Use this for initialization void Start() { ui = FindObjectOfType<RecyclePointUI>(); inventoryUI = FindObjectOfType<InventoryUIManager>(); gameProgress = FindObjectOfType<GameManager>(); player = FindObjectOfType<PlayerAdapter> (); }
void Start() { rBody = GetComponent<Rigidbody2D>(); anim = GetComponent<Animator>(); player = GetComponent<PlayerAdapter>(); }