/// <summary> /// Use for a 'step by step' search only. This method is alternate to SearchPath. /// Initializes AStar before performing search steps manually with NextStep. /// </summary> /// <exception cref="ArgumentNullException">StartNode and EndNode cannot be null.</exception> /// <param name="StartNode">The node from which the path must start.</param> /// <param name="EndNode">The node to which the path must end.</param> public void Initialize(Node StartNode, Node EndNode) { if (StartNode == null || EndNode == null) { throw new ArgumentNullException(); } _Closed.Clear(); _Open.Clear(); Track.Target = EndNode; _Open.Add(new Track(StartNode)); _NbIterations = 0; _LeafToGoBackUp = null; }
public bool ContainsPoint(List <Point2> _polygon, Point2 _target) { int len = _polygon.Count; for (int i = 0; i < len; i++) { m_rowPoints.Add(_polygon[i]); } //ShowPoints("-----polygon points-----"); m_rowPoints.Add(_target); //sort from left to right m_rowPoints.QuickSort(); //ShowPoints("-----sorted points-----"); //sweep from left to right int _bufLen = m_rowPoints.Count; bool _result = false; for (int i = 0; i < _bufLen; i++) { Point2 _pI = m_rowPoints[i]; if (_pI == _target) { _result = m_sweepLine0.InoutOf(_target) == InOut.In; break; } Point2 _pIL = _pI.m_left; Point2 _pIR = _pI.m_right; Vector2 _pIV = _pI.getValue(); Vector2 _toLeft = _pIL.getValue() - _pIV; Vector2 _toRight = _pIR.getValue() - _pIV; if (_toLeft.x > 0 && _toRight.x > 0) //Open Site,add double slope { m_sweepLine0.OpenRegion(_pI); } else if (_toLeft.x < 0 && _toRight.x < 0) //Close Site,remove double slopes { m_sweepLine0.CloseRegion(_pI, _toLeft, _toRight); } else //Turn Site,add single slope { m_sweepLine0.TurnReion(_pI); } } m_rowPoints.Clear(); m_sweepLine0.Clear(); return(_result); }
public void Should_Sort_Using_Shell_Sort() { // Arrange var records = new SortableList(); records.SetSortingStrategy(new ShellSort()); records.Add("Clara"); records.Add("Bella"); records.Add("Abigail"); Assert.IsTrue(records.List[0] == "Clara"); // Act records.Sort(); // Assert Assert.IsTrue(records.List[0] == "Abigail"); Assert.IsTrue(records.List[1] == "Bella"); Assert.IsTrue(records.List[2] == "Clara"); }
private void AddItemToGroup(SerializableDictionary <string, SortableList <IHistoryItem> > groupedByDate, HistoryItem item) { string intervalName = HistoryIntervals.GetDateIntervalName(item.Date); SortableList <IHistoryItem> timeIntervalItems = GetTimeIntervalItems(intervalName, groupedByDate); if (!timeIntervalItems.Contains(item)) // add each item only once { timeIntervalItems.Add(item); } }
public void Should_Sort_Using_Quick_Sort() { // Arrange var records = new SortableList(); records.SetSortingStrategy(new QuickSort()); records.Add("C"); records.Add("B"); records.Add("A"); Assert.IsTrue(records.List[0] == "C"); // Act records.Sort(); // Assert Assert.IsTrue(records.List[0] == "A"); Assert.IsTrue(records.List[1] == "B"); Assert.IsTrue(records.List[2] == "C"); }
public SortableList <FavoriteConfigurationElement> ToList() { SortableList <FavoriteConfigurationElement> favorites = new SortableList <FavoriteConfigurationElement>(); foreach (FavoriteConfigurationElement favorite in this) { favorites.Add(favorite); } return(favorites); }
private void CheckAddRegion(SlopeRegion _region) { if (_region.m_slope != float.MaxValue) { m_sweepRegions.Add(_region); } else { SlopeRegion.Pool.GiveBack(_region); } }
private static SortableList<FavoriteConfigurationElement> GetReceivedFavorites(ArrayList favorites) { var importedFavorites = new SortableList<FavoriteConfigurationElement>(); foreach (object item in favorites) { SharedFavorite favorite = item as SharedFavorite; if (favorite != null) importedFavorites.Add(ImportSharedFavorite(favorite)); } return importedFavorites; }
public SortableList <T> ApplyFilter(Func <T, bool> func) { SortableList <T> newList = new SortableList <T>(); foreach (var item in this.Where(func)) { newList.Add(item); } return(newList); }
private static SortableList <FavoriteConfigurationElement> GetReceivedFavorites(ArrayList favorites) { var importedFavorites = new SortableList <FavoriteConfigurationElement>(); foreach (object item in favorites) { SharedFavorite favorite = item as SharedFavorite; if (favorite != null) { importedFavorites.Add(ImportSharedFavorite(favorite)); } } return(importedFavorites); }
private LocatedQuest _determineBestNearestQuestToDo() { Dictionary <int, NonPlayerEntity> npcs = new Dictionary <int, NonPlayerEntity>(); List <QuestDefinition> quests = new List <QuestDefinition>(_questRep.FindByLevelRange(_character.PrimaryLevel, _character.PrimaryLevel + 1)); //determine distance from current location SortableList locatedQuests = new SortableList(new LocatedQuestComparer()); locatedQuests.KeepSorted = true; locatedQuests.AddDuplicates = true; foreach (QuestDefinition quest in quests) { if (_character.CompletedQuests.Count(q => q.Id == quest.Id) > 0) { continue; } if (quest.StarterId > 0) { if (!npcs.ContainsKey(quest.StarterId)) { NonPlayerEntity npc = _npeRep.GetAll().FirstOrDefault(npe => npe.RomId == quest.StarterId); if (npc != null) { npcs.Add(quest.StarterId, npc); } } if (npcs.ContainsKey(quest.StarterId)) { NonPlayerEntity npc = npcs[quest.StarterId]; Vector3 loc = new Vector3(npc.X, npc.Y, npc.Z); LocatedQuest lQ = new LocatedQuest() { Location = loc, Quest = quest, Starter = npc, Distance = _state.Location.Distance(loc) }; locatedQuests.Add(lQ); ////////store quest, item +locations....... } } } if (locatedQuests.Count > 0) { return((LocatedQuest)locatedQuests[0]); } return(null); }
private static SortableList <FavoriteConfigurationElement> SelectFavoritesFromHistoryItems(SortableList <HistoryItem> groupedByDate) { FavoriteConfigurationElementCollection favorites = Settings.GetFavorites(false); SortableList <FavoriteConfigurationElement> selection = new SortableList <FavoriteConfigurationElement>(); foreach (HistoryItem favoriteTouch in groupedByDate) { FavoriteConfigurationElement favorite = favorites[favoriteTouch.Name]; if (favorite != null && !selection.Contains(favorite)) { selection.Add(favorite); } } return(selection); }
private static SortableList <IFavorite> SelectFavoritesFromHistoryItems( SortableList <IHistoryItem> groupedByDate) { var selection = new SortableList <IFavorite>(); foreach (IHistoryItem favoriteTouch in groupedByDate) { IFavorite favorite = favoriteTouch.Favorite; if (favorite != null && !selection.Contains(favorite)) // add each favorite only once { selection.Add(favorite); } } return(selection); }
public SerializableDictionary <string, SortableList <HistoryItem> > GroupByDate() { Kohl.Framework.Logging.Log.Info("Grouping history items by date."); SerializableDictionary <string, SortableList <HistoryItem> > groupedByDate = this.InitializeGroups(); foreach (string name in this.Keys) //name is the favorite name { foreach (HistoryItem item in this[name]) //each history item per favorite { SortableList <HistoryItem> timeIntervalItems = this.GetTimeIntervalItems(item.DateGroup, groupedByDate); if (!timeIntervalItems.Contains(item)) { timeIntervalItems.Add(item); } } } return(groupedByDate); }
public XmlRemoteValueList FilterList(string WineName, string WineVintage, string WineType, string WineRegion, string WineCountry, XmlRemoteValueList Wines) { SortableList NewWines = new SortableList(); for (int ii = 0; ii < Wines.List.Count; ii++) { bool StatOK = true; String Country = ((PropertySet)Wines.List[ii]).Entries["Locale"].ToString(); String Type = ((PropertySet)Wines.List[ii]).Entries["Type"].ToString(); String Vintage = ((PropertySet)Wines.List[ii]).Entries["Vintage"].ToString(); String Name = ((PropertySet)Wines.List[ii]).Entries["Wine"].ToString(); if (WineName.Length > 0 && !Name.ToLower().Contains(WineName.ToLower())) { StatOK = false; } if (WineVintage.Length > 0 && !Vintage.ToLower().Contains(WineVintage.ToLower())) { StatOK = false; } if (WineType.Length > 0 && !Type.ToLower().Contains(WineType.ToLower())) { StatOK = false; } if (WineCountry.Length > 0 && !Country.ToLower().Contains(WineCountry.ToLower())) { StatOK = false; } if (WineRegion.Length > 0 && !Country.ToLower().Contains(WineRegion.ToLower())) { StatOK = false; } if (StatOK) { NewWines.Add(Wines.List[ii]); } } Wines.List = NewWines; return(Wines); }
private static SortableList<IFavorite> SelectFavoritesFromHistoryItems( SortableList<IHistoryItem> groupedByDate) { var selection = new SortableList<IFavorite>(); foreach (IHistoryItem favoriteTouch in groupedByDate) { IFavorite favorite = favoriteTouch.Favorite; if (favorite != null && !selection.Contains(favorite)) // add each favorite only once selection.Add(favorite); } return selection; }
private void btnSearch_Click(object sender, EventArgs e) { ClearBind(); List<string> arFilter = GetFilters(null); string sExclude = tbExclude.Text; string[] arExclude = null; if (!string.IsNullOrEmpty(sExclude)) arExclude = sExclude.Split('|'); string sSql = "Select * From Win32_Service"; sSql += ConvertFilter2Str(arFilter); var qry = new SelectQuery(sSql); var searcher = new ManagementObjectSearcher(qry); ManagementObjectCollection serviceGetter = searcher.Get(); //主业务对象 _arBiz = new SortableList<WmiServiceObj>(); //显示行序号 int[] iOrder = {0}; foreach ( WmiServiceObj objWmi in serviceGetter.Cast<ManagementBaseObject>() .Select(mobj => new WmiServiceObj(mobj, iOrder[0], arExclude)) .Where(objWmi => !objWmi.BSkipReadConfig)) { _arBiz.Add(objWmi); iOrder[0] += 1; } BindBiz(true); }
public Controls_PageView(string PageName) { XmlUtil x_util = new XmlUtil(); Util util = new Util(); //get page image Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID]; PageImage.ImageUrl = util.GetAppPageImage(State, State["PageViewAppID"].ToString(), PageName); PageImage.ID = PageName + "_PageImage"; PageImage.Attributes.Add("onclick", "goToPage('" + PageName + "');"); PageImage.Attributes.Add("onmouseover", "this.style.cursor='pointer';"); PageImage.Attributes.Add("onmouseout", "this.style.cursor='arrow';"); if (State["UseFullPageImage"] != null) { PageImage.Width = 320; PageImage.Height = 460; } //get page fields XmlDocument doc = x_util.GetStagingAppXml(State); RadTreeNode PageRoot = new RadTreeNode(PageName); PageRoot.CssClass = "RadTreeView"; PageRoot.ImageUrl = "../images/ascx.gif"; PageRoot.Category = "page"; PageRoot.Font.Size = FontUnit.Point(12); OnePageView.Nodes.Add(PageRoot); //do all fields XmlNode page = doc.SelectSingleNode("//pages/page/name[. ='" + PageName + "']").ParentNode; XmlNode fields = page.SelectSingleNode("fields"); if (fields != null) { //sort fields first SortedList list = new SortedList(); SortableList<StoryBoardField> nameList = new SortableList<StoryBoardField>(); foreach (XmlNode child in fields.ChildNodes) { Hashtable dict = new Hashtable(); dict["field_type"] = child.Name; XmlNode id_node = child.SelectSingleNode("id"); dict["id"] = id_node; string input_field = id_node.InnerText.Trim(); if (child.SelectSingleNode("left") != null) dict["left"] = child.SelectSingleNode("left").InnerText; else dict["left"] = "0"; if (child.SelectSingleNode("top") != null) dict["top"] = child.SelectSingleNode("top").InnerText; else dict["top"] = "0"; dict["width"] = child.SelectSingleNode("width").InnerText; dict["height"] = child.SelectSingleNode("height").InnerText; string field_type = dict["field_type"].ToString(); if (field_type == "button" || field_type == "image_button" || field_type == "table" || field_type == "switch") { if(child.SelectSingleNode("submit") != null) dict["submit"] = child.SelectSingleNode("submit").InnerText; } if (field_type == "table" ) { XmlNodeList sub_fields = child.SelectNodes("table_fields/table_field/name"); ArrayList table_list = new ArrayList(); foreach (XmlNode sub_field in sub_fields) { table_list.Add(sub_field.InnerText); } dict["sub_fields"] = table_list; } else if (field_type == "picker") { XmlNodeList sub_fields = child.SelectNodes("picker_fields/picker_field/name"); ArrayList picker_list = new ArrayList(); foreach (XmlNode sub_field in sub_fields) { picker_list.Add(sub_field.InnerText); } dict["sub_fields"] = picker_list; } list[input_field] = dict; nameList.Add(new StoryBoardField(id_node.InnerText.Trim(), Convert.ToInt32(dict["top"].ToString()), Convert.ToInt32(dict["left"].ToString()))); } nameList.Sort("Top", true); foreach (StoryBoardField input_field in nameList) { Hashtable dict = (Hashtable)list[input_field.FieldName]; string field_type = dict["field_type"].ToString(); RadTreeNode field_node = util.CreateFieldNode(PageRoot, input_field.FieldName, field_type); field_node.Value = "left:" + dict["left"].ToString() + ";top:" + dict["top"].ToString() + ";width:" + dict["width"].ToString() + ";height:" + dict["height"].ToString() ; if (dict["submit"] != null && dict["submit"].ToString().Length > 0 && dict["submit"].ToString() != ";") { field_node.BackColor = Color.PeachPuff; string[] submit = dict["submit"].ToString().Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); string target_page_name = null; //this code is compatible with both old and new syntax if (submit[0].StartsWith("post") && (submit[0].Contains("response_page:") || submit[0].Contains("response_page~"))) { target_page_name = submit[0].Substring(19); field_node.Value += ";next_page:" + target_page_name; } else if (submit[0].StartsWith("next_page")) { if (submit[0].Contains("next_page:page~")) target_page_name = submit[0].Substring(15); else target_page_name = submit[0].Substring(10); field_node.Value += ";next_page:" + target_page_name; } } if (field_type == "table" || field_type == "picker") { ArrayList sub_field_list = (ArrayList)dict["sub_fields"]; foreach (string sub_field_name in sub_field_list) { RadTreeNode sub_field_node = util.CreateFieldNode(field_node, sub_field_name, field_type); } } } } OnePageView.ExpandAllNodes(); OnePageView.OnClientMouseOver = "onPageViewMouseOver"; OnePageView.OnClientMouseOut = "onPageViewMouseOut"; }
private static SortableList<FavoriteConfigurationElement> SelectFavoritesFromHistoryItems(SortableList<HistoryItem> groupedByDate) { FavoriteConfigurationElementCollection favorites = Settings.GetFavorites(false); SortableList<FavoriteConfigurationElement> selection = new SortableList<FavoriteConfigurationElement>(); foreach (HistoryItem favoriteTouch in groupedByDate) { FavoriteConfigurationElement favorite = favorites[favoriteTouch.Name]; if (favorite != null && !selection.Contains(favorite)) selection.Add(favorite); } return selection; }
/// <summary> /// Entry point for the SortableList use case. /// </summary> public static void Main() { try { Console.WriteLine("You create a new SortableList."); SortableList SL = new SortableList(); Console.Write("You set the KeepSorted property to false and you fill it with the strings X, B, A, D: "); SL.KeepSorted = false; SL.Add("X"); SL.Add("B"); SL.Add("A"); SL.Add("D"); Console.WriteLine(SL); Console.Write("You can insert or set elements where you want since KeepSorted==false. Let's set 'C' to index 4: "); SL[3] = "C"; Console.WriteLine(SL); Console.Write("You decide to sort the list: "); SL.Sort(); Console.WriteLine(SL); Console.Write("You now set the KeepSorted property to true and add some new strings: "); SL.KeepSorted = true; SL.Add("J"); SL.Add("E"); SL.Add("E"); SL.Add("B"); SL.Add("X"); SL.Add("E"); SL.Add("E"); Console.WriteLine(SL); Console.WriteLine("'E' is found at index " + SL.IndexOf("E").ToString()); Console.WriteLine("Is the list containing an 'X' value ?: " + SL.Contains("X").ToString()); Console.WriteLine("Is the list containing an 'M' value ?: " + SL.Contains("M").ToString()); Console.Write("You limit the number of occurrences of 'E' to 2: "); SL.LimitNbOccurrences("E", 2); Console.WriteLine(SL); Console.Write("After all you do not want any duplicates: "); SL.RemoveDuplicates(); Console.WriteLine(SL); Console.Write("You set the AddDuplicates property to false and try to add J and E again: "); SL.AddDuplicates = false; SL.Add("J"); SL.Add("E"); Console.WriteLine(SL); Console.WriteLine("Now you create another SortableList but this time you give it an IComparer class which is the anti-alphabetical order."); SL = new SortableList(new AntiAlphabeticalComparer()); Console.Write("You fill the list by adding a range of vowels in alphabetical order. Result: "); string[] Vowels = new string[] { "A", "E", "I", "O", "U" }; SL.AddRange(Vowels); Console.WriteLine(SL); Console.Write("Serialize and Deserialize: "); Stream StreamWrite = File.Create("SortableListSaved.bin"); BinaryFormatter BinaryWrite = new BinaryFormatter(); BinaryWrite.Serialize(StreamWrite, SL); StreamWrite.Close(); Stream StreamRead = File.OpenRead("SortableListSaved.bin"); BinaryFormatter BinaryRead = new BinaryFormatter(); SortableList SL2 = (SortableList)BinaryRead.Deserialize(StreamRead); StreamRead.Close(); Console.WriteLine(SL2); } catch (Exception e) { Console.Write("Error :\n\n" + e.ToString()); } Console.ReadLine(); }
public List <MapLink> BuildRouteToNearestType(MapPoint start, EntityTypes entityType) { List <MapLink> result = new List <MapLink>(); mapNode beginning = null; mapNode ending = null; PlottedMapPoint pStart = (PlottedMapPoint)_mappedPoints[start.Id]; if ((pStart.EntityTypes & entityType) == entityType) { return(result); } Dictionary <int, mapNode> nodes = new Dictionary <int, mapNode>(); beginning = new mapNode(pStart, 0); nodes.Add(pStart.MapPoint.Id, beginning); foreach (DictionaryEntry entry in _mappedPoints) { if (nodes.ContainsKey(((PlottedMapPoint)entry.Value).MapPoint.Id)) { continue; } mapNode node = new mapNode((PlottedMapPoint)entry.Value, double.MaxValue); nodes.Add(node.MapPoint.MapPoint.Id, node); } SortableList openList = new SortableList(new MapNodeComparer()); openList.KeepSorted = true; openList.AddDuplicates = true; openList.Add(beginning); Dictionary <int, mapNode> closedList = new Dictionary <int, mapNode>(); bool found = false; while ((!found) && (openList.Count > 0)) { mapNode current = (mapNode)openList[0]; if ((current.MapPoint.EntityTypes & entityType) == entityType) { found = true; ending = current; } else { closedList.Add(current.MapPoint.MapPoint.Id, current); openList.Remove(current); foreach (MapLink link in current.MapPoint.Links) { PlottedMapPoint end = (PlottedMapPoint)_mappedPoints[link.End.Id]; mapNode nEnd = nodes[link.End.Id]; double distance = 0; if (link.LinkType == LinkType.Teleport) { distance = 2000 + current.distance; } else { distance = current.Location.Distance(end.Location) + current.distance; } if (distance < nEnd.distance) { nEnd.distance = distance; nEnd.Parent = current; nEnd.link = link; if ((!closedList.ContainsKey(end.MapPoint.Id)) && (!_sortedListContains(openList, nEnd))) { openList.Add(nEnd); } } } } } if (found) { mapNode node = ending; while (node != beginning) { result.Insert(0, node.link); node = node.Parent; } } return(result); }
private void SpawnCharacter(int i_TeamIndex, int i_TeamSize, int i_SpawnIndex, int i_PhotonPlayerId, tnCharacterDescription i_CharacterDescription) { if (m_CharacterPrefab == null || i_CharacterDescription == null) { return; } int descriptorCharacterId = i_CharacterDescription.characterId; int descriptorOnlinePlayerIndex = i_CharacterDescription.onlinePlayerIndex; int descriptorPlayerId = i_CharacterDescription.playerId; string[] spawnPointsNames = SpawnPoints.GetSpawnPoints(i_TeamIndex, i_TeamSize); if (spawnPointsNames == null) { return; } if (i_SpawnIndex < 0 || i_SpawnIndex >= spawnPointsNames.Length) { return; } string spawnPointName = spawnPointsNames[i_SpawnIndex]; GameObject spawnPointGo = GameObject.Find(spawnPointName); if (spawnPointGo == null) { return; } TSTransform2D spawnPoint = spawnPointGo.GetComponent <TSTransform2D>(); if (spawnPoint == null) { return; } tnCharacterData characterData = tnGameData.GetCharacterDataMain(descriptorCharacterId); if (characterData == null) { return; } tnTeamsModule teamsModule = GameModulesManager.GetModuleMain <tnTeamsModule>(); if (teamsModule == null) { return; } tnTeamDescription teamDescription = teamsModule.GetTeamDescription(i_TeamIndex); if (teamDescription == null) { return; } int teamId = teamDescription.teamId; Color teamColor = teamDescription.teamColor; tnTeamData teamData = tnGameData.GetTeamDataMain(teamId); if (teamData == null) { return; } bool isLocal = (PhotonNetwork.offlineMode) ? true : tnGameModulesUtils.IsLocalPlayer(descriptorOnlinePlayerIndex); bool isHuman = (PhotonNetwork.offlineMode) ? (descriptorPlayerId != Hash.s_NULL) : (descriptorOnlinePlayerIndex >= 0); Vector3 spawnPosition = spawnPoint.position.ToVector(); Quaternion spawnRotation = Quaternion.Euler(0f, 0f, spawnPoint.rotation.AsFloat()); // Spawn character. GameObject characterInstance = Instantiate <GameObject>(m_CharacterPrefab); characterInstance.name = characterData.displayName; characterInstance.transform.position = spawnPosition; characterInstance.transform.rotation = spawnRotation; // Configure TSTransform TSTransform2D tsTransform = characterInstance.GetComponent <TSTransform2D>(); if (tsTransform != null) { tsTransform.position = spawnPoint.position; tsTransform.rotation = spawnPoint.rotation; } // Configure depth2d. tnDepth2d depth2d = characterInstance.GetComponent <tnDepth2d>(); if (depth2d != null) { depth2d.SetOffset(spawnPointGo.transform.position.z); } // Configure character stats database. tnStatsDatabase teamStats = teamData.teamStats; tnStatsContainer statsContainer = characterInstance.GetComponent <tnStatsContainer>(); if (statsContainer != null) { statsContainer.SetStatsDatabase(teamStats); } // Configure character view. tnCharacterViewController characterViewController = characterInstance.GetComponent <tnCharacterViewController>(); if (characterViewController != null) { // Base color. characterViewController.SetBaseColor(teamColor); // Charging force bar. characterViewController.SetChargingForceBarColor(teamColor); // Energy bar. characterViewController.SetEnergyBarColor(teamColor); // Flag. characterViewController.SetFlagSprite(teamData.baseSprite); // Animator characterViewController.SetAnimatorController(characterData.animatorController); // Set facing right. characterViewController.SetFacingRight((spawnPoint.position.x < 0f)); // Player color. characterViewController.TurnOffColor(); characterViewController.SetArrowVisible(false); characterViewController.SetArrowColor(Color.white); if (isLocal) { if (PhotonNetwork.offlineMode) { if (isHuman) { tnPlayerData playerData = tnGameData.GetPlayerDataMain(descriptorPlayerId); if (playerData != null) { Color playerColor = playerData.color; characterViewController.SetPlayerColor(playerColor); characterViewController.SetArrowVisible(true); characterViewController.SetArrowColor(playerColor); } } } else { List <int> onlinePlayersKeys = tnGameData.GetOnlinePlayersKeysMain(); if (onlinePlayersKeys != null) { if (descriptorOnlinePlayerIndex >= 0 && descriptorOnlinePlayerIndex < onlinePlayersKeys.Count) { int onlinePlayerKey = onlinePlayersKeys[descriptorOnlinePlayerIndex]; tnOnlinePlayerData onlinePlayerData = tnGameData.GetOnlinePlayerDataMain(onlinePlayerKey); if (onlinePlayerData != null) { Color playerColor = onlinePlayerData.color; characterViewController.SetPlayerColor(playerColor); characterViewController.SetArrowVisible(true); characterViewController.SetArrowColor(playerColor); } } } } } } // Input: NOTE that current aiFacotry assumes that all AI are handled by the same client. // If you want to support AI in multiplayer you should change the ai factory implementation. // Now multiplayer isn't implemented, so now, if you're using AI, you are playing offline --> All AIs are yours. if (isLocal) { tnInputFiller inputFiller = null; tnRumbleController rumbleController = null; int localPlayerIndex; bool localPlayerIndexFound = tnGameModulesUtils.OnlineToLocalPlayerIndex(descriptorOnlinePlayerIndex, out localPlayerIndex); if (localPlayerIndexFound || PhotonNetwork.offlineMode) { tnLocalPartyModule localPartyModule = GameModulesManager.GetModuleMain <tnLocalPartyModule>(); int playerId = (PhotonNetwork.offlineMode) ? descriptorPlayerId : ((localPartyModule != null) ? localPartyModule.GetPlayerId(localPlayerIndex) : Hash.s_NULL); tnPlayerData playerData = tnGameData.GetPlayerDataMain(playerId); if (playerData != null) { string playerInputName = playerData.playerInputName; string wifiPlayerInputName = playerData.wifiPlayerInputName; PlayerInput playerInput = InputSystem.GetPlayerByNameMain(playerInputName); WiFiPlayerInput wifiPlayerInput = WiFiInputSystem.GetPlayerByNameMain(wifiPlayerInputName); if (playerInput != null) { inputFiller = new tnPlayerInputFiller(playerInput); rumbleController = new tnRumbleController(playerInput); m_LocalPlayersInput.Add(playerInput); } else { if (wifiPlayerInput != null) { inputFiller = new tnWiFiPlayerInputFiller(wifiPlayerInput); m_LocalWifiPlayersInput.Add(wifiPlayerInput); } } } else { tnAIInputFiller aiInputFiller = CreateAIInputFiller(i_TeamIndex, i_SpawnIndex, characterInstance); inputFiller = aiInputFiller; List <tnAIInputFiller> aiList = m_LocalAI[i_TeamIndex]; aiList.Add(aiInputFiller); } } // Bind input filler to character instance. if (inputFiller != null) { tnInputController inputController = new tnInputController(inputFiller); inputController.SetRumbleController(rumbleController); AddInputController(inputController); tnCharacterInput characterInput = characterInstance.GetComponent <tnCharacterInput>(); if (characterInput != null) { characterInput.Bind(inputController); } } // Add rumble component. if (isHuman) { tnRumbleParams rumbleParams = Resources.Load <tnRumbleParams>(s_RumbleParams_ResourcePath); if (rumbleParams != null) { tnRumble rumbleComponent = characterInstance.GetComponent <tnRumble>(); if (rumbleComponent == null) { rumbleComponent = characterInstance.AddComponent <tnRumble>(); } rumbleComponent.SetParams(rumbleParams); } } // Input Delay. int delay = (TrueSyncManager.isOfflineMain) ? m_OfflinePlayerInputDelay : 0; if (!isHuman) { tnMatchSettingsModule matchSettingsModule = GameModulesManager.GetModuleMain <tnMatchSettingsModule>(); int aiLevelIndex = (matchSettingsModule != null) ? matchSettingsModule.aiLevelIndex : (tnGameData.aiLevelCountMain / 2); tnAILevel aiLevel = tnGameData.GetAILevelMain(aiLevelIndex); if (aiLevel != null) { delay = aiLevel.inputDelay; } } // Register on player input collector. RegisterObjectOnInputCollector(characterInstance, delay); } // Configure character info. tnCharacterInfo characterInfo = characterInstance.GetComponent <tnCharacterInfo>(); if (characterInfo == null) { characterInfo = characterInstance.AddComponent <tnCharacterInfo>(); } int characterIndex = m_Characters.Count; characterInfo.SetCharacterIndex(characterIndex); characterInfo.SetCharacterId(descriptorCharacterId); characterInfo.SetTeamIndex(i_TeamIndex); characterInfo.SetTeamId(teamId); characterInfo.SetTeamColor(teamColor); // Callback. OnCharacterSpawned(i_TeamIndex, characterIndex, characterInstance); // Add characters to lists. m_Characters.Add(characterInstance); if (isLocal) { m_LocalCharacters.Add(characterInstance); } List <GameObject> team = m_Teams[i_TeamIndex]; team.Add(characterInstance); // Create character result. tnCharacterResults characterResults = CreateCharacterResults(descriptorCharacterId); characterResults.isHuman = isHuman; tnTeamResults teamResults = GetTeamResultsByIndex(i_TeamIndex); if (teamResults != null) { teamResults.AddCharacterResults(characterResults); } m_CharactersResults.Add(characterResults); // Track character result. StateTracker.AddTracking(characterResults); // Configure TrueSyncObject. TrueSyncObject trueSyncObject = characterInstance.GetComponent <TrueSyncObject>(); if (trueSyncObject != null) { trueSyncObject.SetOwnerId(i_PhotonPlayerId); TrueSyncManager.RegisterTrueSyncObjectMain(trueSyncObject); } }
private void ProceesTeam(int i_TeamIndex, tnTeamDescription i_TeamDescription) { if (i_TeamDescription == null) { return; } int teamId = i_TeamDescription.teamId; tnTeamData teamData = tnGameData.GetTeamDataMain(teamId); if (teamData == null) { return; } m_TeamsIds.Add(teamId); // Get team size. int teamSize = i_TeamDescription.charactersCount; // Create team results. tnTeamResults teamResults = CreateTeamResults(teamId); m_TeamsResults.Add(teamResults); StateTracker.AddTracking(teamResults); // Callback. OnCreateTeam(i_TeamIndex, i_TeamDescription); for (int characterIndex = 0; characterIndex < teamSize; ++characterIndex) { tnCharacterDescription characterDescription = (PhotonNetwork.offlineMode) ? i_TeamDescription.GetCharacterDescriptionBySpawnOrder(characterIndex) : i_TeamDescription.GetCharacterDescription(characterIndex); if (characterDescription == null) { continue; } int disconnectedPlayerPhotonId = -1; int photonPlayerId; if (PhotonNetwork.offlineMode) { photonPlayerId = 0; // 0 is the default value related to a fake "Local_Player". See TrueSyncController::Initialize. } else { int onlinePlayerIndex = characterDescription.onlinePlayerIndex; tnGameModulesUtils.GetPhotonPlayerOwnerId(onlinePlayerIndex, out photonPlayerId); // Check if the owner of this character is still connected. If not, reset photon player id. PhotonPlayer owner = PhotonUtils.GetPhotonPlayer(photonPlayerId); disconnectedPlayerPhotonId = (owner == null) ? photonPlayerId : -1; photonPlayerId = (owner != null) ? photonPlayerId : -1; } // If photon player id is valid, spawn character. if (photonPlayerId >= 0) { SpawnCharacter(i_TeamIndex, teamSize, characterIndex, photonPlayerId, characterDescription); } else { Debug.LogWarning("[tnMatchController] Character skipped for photon player id " + disconnectedPlayerPhotonId + "."); } } }
internal SortableList<FavoriteConfigurationElement> ToList() { var favorites = new SortableList<FavoriteConfigurationElement>(); foreach (FavoriteConfigurationElement favorite in this) { favorites.Add(favorite); } return favorites; }
private SortableList<StatsDomainObject> GetStats(string mode, string filterTourType) { SortableList<StatsDomainObject> list = new SortableList<StatsDomainObject>(); switch (mode) { case "Fighter": list = Registry.Instance.GetPilotStats(PilotName).FighterStatsList; break; case "Attack": list = Registry.Instance.GetPilotStats(PilotName).AttackStatsList; break; case "Bomber": list = Registry.Instance.GetPilotStats(PilotName).BomberStatsList; break; case "Vehicle/Boat": list = Registry.Instance.GetPilotStats(PilotName).VehicleBoatStatsList; break; } SortableList<StatsDomainObject> filteredList = new SortableList<StatsDomainObject>(); foreach (StatsDomainObject statsObj in list) { if (statsObj.TourType == filterTourType) filteredList.Add(statsObj); } if (filteredList.Count > 0) { filteredList.SortList("TourNumber", ListSortDirection.Ascending); } return filteredList; }
static void _callerQ_Load_Notify(object sender, EventArgs e) { SortableList<CallRecord> overdueItems = new SortableList<CallRecord>(); foreach (CallRecord record in Settings.Default.Queue) { if (record.NotifyDate < DateTime.Now.AddMinutes(2) && !record.WasNotified && record.IsActive) { overdueItems.Add(record); } } if (overdueItems.Count > 0) { overdueItems.Sort("NotifyDate", System.ComponentModel.ListSortDirection.Ascending); foreach (CallRecord record in overdueItems) { using (Notifier notifier = new Notifier()) { notifier.ShowDialog(record); } } } Settings.Save(); SetNotification(); }