/** * Removes the specified target */ public void RemoveTarget(string targetToRemove) { GuidList.GetGameObject(targetToRemove).transform.FindChild("Attack Pulse").gameObject.SetActive(false); int canceledShots = 0; int GuidIndex = 0; foreach (string targetGuid in Targets.Keys) { GuidIndex++; if (targetGuid.Equals(targetToRemove)) { break; } } int shotIndex = 0; foreach (int targetShots in Targets.Values) { shotIndex++; if (shotIndex == GuidIndex) { canceledShots = targetShots; break; } } Targets.Remove(targetToRemove); CurShotsTargeted -= canceledShots; }
public void DisplayWeapons(GameObject SelectedUnit) { CurrentUnitWeapons.Clear(); CurrentWeaponIndex = 1; foreach (Weapon weapon in SelectedUnit.GetComponent <AttackController>().GetWeapons().Values) { CurrentUnitWeapons.AddLast(weapon); } if (CurrentUnitWeapons.Count > 0) { CurrentWeaponTargets.Clear(); foreach (string targetGuid in CurrentUnitWeapons.First.Value.GetTargets().Keys) { if (GuidList.GetGameObject(targetGuid) != null) { CurrentWeaponTargets.AddLast(targetGuid); GuidList.GetGameObject(targetGuid).transform.FindChild("Attack Pulse").gameObject.SetActive(true); } } CurrentWeaponTargetShots.Clear(); foreach (int shots in CurrentUnitWeapons.First.Value.GetTargets().Values) { CurrentWeaponTargetShots.AddLast(shots); } CurrentTargetIndex = 1; } }
/** * This method determines if the target is in range. * * If an attack needs to factor in conditions such as weather and * terrain, that should be done in a class that inherits from this * base class. * * @return * A boolean of if the the target is in range */ public virtual bool TargetInRange(string Target) { // Check if the target is in range GameObject o = GuidList.GetGameObject(Owner); GameObject ta = GuidList.GetGameObject(Target); if (Vector3.Distance(o.transform.position, ta.transform.position) < Range) { // If the target is in range if (World.IsMarine) { Vector3 position = GuidList.GetGameObject(Owner).transform.position; Vector3 target = GuidList.GetGameObject(Target).transform.position; List <Terrain> tiles = getInterSectingTerrains((int)position.x, (int)position.y, (int)target.x, (int)target.y); foreach (Terrain t in tiles) { if (t.ModifierVisual == 1) { return(false); } } } return(true); } else { // If the target is not in range return(false); } }
public static MetaAttributeList GetAttributes(GuidList EntityID) { LoadProviders(); var rtrn = _provider.GetAttributes(EntityID); return(rtrn); }
/** * Deletes the current target and thereby cancels the planned attack */ public void ClearTarget() { ////Debug.Log ("Someone cleared the targets."); foreach (string targetToRemove in Targets.Keys) { GameObject tmp = GuidList.GetGameObject(targetToRemove); // Check if the target has been destroyed if (tmp != null) { // If it wasn't // Turn its targeted pulse off since the attack targeting it // has been canceled or executed. tmp.transform.FindChild("Attack Pulse").gameObject.SetActive(false); } } this.Targets.Clear(); CurShotsTargeted = 0; UIUnitInspectorController UIUnit = GameObject.Find("Canvas").GetComponent <UIUnitInspectorController>() as UIUnitInspectorController; if (UIUnit != null) { UIUnit.ClearTargets(); } }
public ActionResult ListOfStandardRelationsByIds(GuidList standardsIds) { MasterLocator = ServiceLocatorFactory.CreateMasterSysAdmin(); var academicBenchmarkRelatedStandards = AcademicBenchmarkLocator.StandardService.GetStandardsRelations(standardsIds); return(Json(academicBenchmarkRelatedStandards.Select(StandardRelationsViewData.Create))); }
public ActionResult TopicsByIds(GuidList topicsIds) { MasterLocator = ServiceLocatorFactory.CreateMasterSysAdmin(); var topics = AcademicBenchmarkLocator.TopicService.GetByIds(topicsIds); return(Json(topics.Select(TopicViewData.Create))); }
//TODO: impl some auth logic for these methods later public ActionResult StandardsByIds(GuidList standardsIds) { MasterLocator = ServiceLocatorFactory.CreateMasterSysAdmin(); var standards = AcademicBenchmarkLocator.StandardService.GetStandardInfosByIds(standardsIds); return(Json(standards.Select(StandardViewData.Create))); }
public override void SetEventString(GEvent e) { object[] eArguments = e.Arguments; string unitName = GetName((string)eArguments [0]); string enemyName = GetName((string)eArguments [1]); string rawName = ((AttackController)GuidList.GetGameObject((string)e.Arguments [0]).GetComponent <AttackController>()).GetWeapon((string)e.Arguments [2]).GetWeaponType(); rawName = rawName.Substring(0, rawName.Length - 4) + "name"; string weaponName = LanguageManager.instance.getString("Weapons", rawName); string[] teams = { GetTeam((string)eArguments [0]) }; string message = "Unit " + unitName + " targeted unit " + enemyName + " with " + weaponName + " and " + e.Arguments[3] + " shots."; string firerer = (string)eArguments [0]; string firing = (string)eArguments [2]; int shots = (int)eArguments [3]; Weapon w = ((AttackController)GuidList.GetGameObject(firerer).GetComponent <AttackController>()).GetWeapon(firing); if (w.GetCurAmmo() != 0) { e.String = EventLog.FormatEventString(teams, e.Timestamp, message); } else { e.String = "Unit " + unitName + " tried targeting unit " + enemyName + " with " + weaponName + " and " + e.Arguments[3] + " shots and failed."; e.String = EventLog.FormatEventString(teams, e.Timestamp, e.String); } }
/** * Stops inspecting the current unit and disables the inspector * */ public void StopInspecting() { Unit.transform.FindChild("Move Range Sprite").gameObject.SetActive(false); Unit.transform.FindChild("Attack Range Sprite").gameObject.SetActive(false); Unit.transform.FindChild("Radar Range Sprite").gameObject.SetActive(false); this.Unit = null; UnitWeaponsNavigator.SetActive(false); if (CurrentWeaponTargets.Count > 0) { for (int i = 0; i < CurrentWeaponTargets.Count; i++) { string targetGuid = CurrentWeaponTargets.First.Value; CurrentWeaponTargets.RemoveFirst(); if (GuidList.GetGameObject(targetGuid) != null) { GuidList.GetGameObject(targetGuid).transform.FindChild("Attack Pulse").gameObject.SetActive(false); } CurrentWeaponTargets.AddLast(targetGuid); } } WeaponTargetsNavigator.GetComponent <Text> ().text = ""; WeaponTargetsNavigator.transform.FindChild("Target Name").GetComponent <Text>().text = ""; WeaponTargetsNavigator.transform.FindChild("Shots Fired at Target").GetComponent <Text>().text = ""; CurrentWeaponTargets.Clear(); CurrentWeaponTargetShots.Clear(); CurrentUnitWeapons.Clear(); InspectorPanel.SetActive(false); }
// Update is called once per frame void Update() { if (Carrier != null) { Units = Carrier.GetComponent <ContainerController> ().GetUnits(); if (Units.Count > 0) { UnitNavigatorDisplay.GetComponent <Text>().text = "" + (CurrentUnitIndex + 1) + " of " + Units.Count; if (CurrentUnitIndex >= Units.Count || CurrentUnitIndex < 0) { CurrentUnitIndex = 0; } string UnitGUID = Units[CurrentUnitIndex]; UnitNameDisplay.GetComponent <Text>().text = GuidList.GetGameObject(UnitGUID).GetComponent <IdentityController>().GetName(); UnitPreviewDisplay.GetComponent <Image>().enabled = true; UnitPreviewDisplay.GetComponent <Image>().sprite = GuidList.GetGameObject(UnitGUID).GetComponent <SpriteRenderer>().sprite; } else { UnitNavigatorDisplay.GetComponent <Text>().text = "No Units"; UnitNameDisplay.GetComponent <Text>().text = ""; UnitPreviewDisplay.GetComponent <Image>().enabled = false; } } }
/** * Gets all the objects in the game that are associated with that team, * except for subs. * * @param team * The team to get the objects of * * @return * All the non-sub objects on the team. */ public static List <GameObject> GetNonSubsOnTeam(int team) { HashSet <GameObject> objs = new HashSet <GameObject> (GuidList.GetObjectsOnTeam(team)); objs.ExceptWith(GameObject.FindGameObjectsWithTag("Subsurface")); return(objs.ToList()); }
public static string GetTeam(string guid) { if (GuidList.GetGameObject(guid) == null) { return(""); } return(Team.Teams[GuidList.GetGameObject(guid).GetComponent <IdentityController>().GetTeam()].GetTeamName()); }
public MainWindowViewModel() { Guids = GuidList.Items.ToReadOnlyReactiveCollection() .AddTo(Disposables); AddNewGuidCommand = new ReactiveCommand() .WithSubscribe(() => GuidList.AddNewGuid()) .AddTo(Disposables); }
public static void Clear() { var gameObjects = GuidList.GetAllObjects(); foreach (GameObject unit in gameObjects) { // Clear code } }
public override void HandleEvent(GEvent e) { object[] args = e.Arguments; GameObject go = GuidList.GetGameObject((string)args[0]) as GameObject; Controller c = go.GetComponent((string)args[1]) as Controller; c.SetValue((string)args[2], args[3]); }
public InternalDetails() { DateNow = DateTime.Now; DateOfBirth = DateTime.Now; FromDate = DateTime.Now; UntilDate = DateTime.Now; SavedVariations = new GuidList(); SavedCriterias = new GuidList(); }
public override void HandleEvent(GEvent e) { //Call EmbarkerController.EmbarkEventHelper(string TargetGuid, string EmbarkerGuid); String SmallerUnitGuid = (string)e.Arguments [0]; String SuperUnitGuid = (string)e.Arguments [1]; EmbarkerController smaller = GuidList.GetGameObject(SmallerUnitGuid).GetComponent <EmbarkerController>(); smaller.EmbarkEventHelper(SuperUnitGuid, SmallerUnitGuid); }
public void DateTimeListSerializationTest() { GuidList dataToSerialize = new GuidList(); byte[] data = SerializationUtil.SerializeData(dataToSerialize); Assert.IsNotNull(data); Assert.AreNotEqual(0, data.Length); GuidList deserializedData = SerializationUtil.DeserializeData<GuidList>(data); Assert.IsNotNull(deserializedData); Assert.AreNotSame(dataToSerialize, deserializedData); }
public void GuidListConstructorTest() { GuidList list = new GuidList(true); Assert.IsTrue(list.IsUniqueList, "List Uniqueness Failure"); list = new GuidList(false); Assert.IsFalse(list.IsUniqueList, "List Uniqueness Failure"); list = new GuidList(); Assert.AreEqual(false, list.IsUniqueList, "List Uniqueness Failure"); }
public override void HandleEvent(GEvent e) { String SmallerUnitGuid = Convert.ToString(e.Arguments [0]); //Debug.Log ("YO IM HERE: " + SmallerUnitGuid); Point p = (Point)e.Arguments [1]; Vector3 pos = new Vector3(p.x, p.y, p.z); string parent = Convert.ToString(e.Arguments [2]); EmbarkerController smaller = (EmbarkerController)GuidList.GetGameObject(SmallerUnitGuid).GetComponent <EmbarkerController>(); smaller.LaunchEventHelper(SmallerUnitGuid, pos, parent); }
void ClientRemovedGuid(string guid) { playersThatResponded++; if (playersThatResponded >= playerCountForDelete) { GameObject go = GuidList.GetGameObject(guid); GuidList.RemoveGameObject(guid); Network.Destroy(go); } }
/** * Adds a Probe to this Helicopter. * @param probe * The probe to be added. */ public override void Receive(String probe) { if (!Embarkers.Contains(probe)) { try{ ((ProbeEmbarker)GuidList.GetGameObject(probe).GetComponent <ProbeEmbarker>()).Embark(((IdentityController)this.GetComponent <IdentityController>()).GetGuid()); this.Embarkers.Add(probe); } catch (KeyNotFoundException) { //Do nothing } } }
public override void HandleEvent(GEvent e) { string attackerGuid = (string)e.Arguments.GetValue(0); string targetGuid = (string)e.Arguments.GetValue(1); string weapon = (string)e.Arguments.GetValue(2); GameObject obj = GuidList.GetGameObject(attackerGuid); AttackController ac = (AttackController)obj.GetComponent("AttackController"); Weapon wep = ac.GetWeapon(weapon); wep.RemoveTarget(targetGuid); }
void Update() { if (null == unitCounts) { unitCounts = new Dictionary <string, int>(); } if ((null != lastName && null != MyName && !MyName.label.Equals(lastName)) || (-1 != TeamNumber && !thisbooleanshouldntexist)) { if (null != lastName && null != MyName) { lastName = MyName.label; } if (null == unitCounts) { unitCounts = new Dictionary <string, int>(); } if (null != MyName) { thisbooleanshouldntexist = true; if (!unitCounts.ContainsKey(MyName.label + TeamNumber)) { unitCounts.Add(MyName.label + TeamNumber, 1); } count = unitCounts[MyName.label + TeamNumber]++; } } StartIdent(); World.SetTeamColor(gameObject); World.UpdateObjectiveSprite(gameObject); if (badPos) { timeNow = Time.time; } if (gameObject.transform.localPosition.y == 35 && gameObject.transform.localPosition.x == 0 && gameObject.transform.localPosition.z == 0 && MyName == null) { badPos = true; } else { badPos = false; startTime = Time.time; } float number = Convert.ToSingle(Math.Floor((float)GuidList.GetAllObjects().Count));; if (badPos && ((timeNow - startTime) > (number))) { GameObject.Destroy(gameObject); } }
/** * Finds any runways that are in range of a given position * @param pos * The position to to check against. Intended to be the position of an air craft * * @param range * The range to campre with. Intended to be the CurrenRange of an AirCraft * * @return * A List of Runways that are in range of the position */ public static List <string> RunwaysInRange(Vector3 pos, float range) { List <string> runways = new List <string>(); foreach (string guid in Runways) { if (Vector3.Distance(GuidList.GetGameObject(guid).transform.position, pos) <= range) { runways.Add(guid); } } return(runways); }
public static string GetName(string guid) { if (GuidList.GetGameObject(guid) != null) { IdentityController current = GuidList.GetGameObject(guid).GetComponent <IdentityController>(); string localizedname = current.GetFullName(); //return "<color=#" + GetTeamColor(guid) + ">[[" + GetTeam(guid) + "]" + localizedname + "]</color>"; return("{(" + GetTeam(guid) + ")" + localizedname + "}"); } else { return(""); } }
/** * Gets a list of all objects visible to this unit without duplicates. * * @return * A list of all game objects visible to the team */ public List <GameObject> GetVisibleToTeam() { // Initialize a list for storing all visible objects, with duplicates HashSet <GameObject> visibleObjects = new HashSet <GameObject>(); ////Debug.Log("Team.GetVisibleToTeam: At start of foreach loop. # of Loops: " + GuidList.GetObjectsOnTeam(this.MyKey).Count ); // Iterate over all objects associated with the team foreach (GameObject obj in GuidList.GetObjectsOnTeam(this.MyKey)) { // Determines all objects visible to this object and add them to the list List <GameObject> visibletothisone = obj.GetComponent <DetectorController>().Ping(); ////Debug.Log("Team.GetVisibleToTeam: Inside of foreach loop. # of Units found by ping: " + visibletothisone.Count ); ////Debug.Log(visibletothisone.Count); visibleObjects.UnionWith(visibletothisone); } ////Debug.Log("Team.GetVisibleToTeam: At end of foreach loop. # of unique Units found: " + visibleObjects.Count ); // Check if friendly subs should be visible if (GlobalSettings.GetSubmarineSensorLinkState()) { // If friendly subs should be visible // Add all objects on the team visibleObjects.UnionWith(GuidList.GetObjectsOnTeam(MyKey)); } else { // If friendly subs should not be visible // Add all non-sub objects visibleObjects.UnionWith(GuidList.GetNonSubsOnTeam(MyKey)); } // Add all omnipresent objects visibleObjects.UnionWith(GuidList.GetOmnipresentObjects()); // Remove all invisible objects visibleObjects.ExceptWith(GuidList.GetInvisibleObjects()); // Convert back to a list and return. return(visibleObjects.ToList <GameObject>()); }
/** * Takes all the logical actions of Embarking a unit. * This method should only be called from the appropiate EventHandler. * * @param container * The container that this unit has been Embarked into. * * @param embarker * The Guid of this unit. Used as a shortcut to getting the Guid from this unit's IdentityController. */ public void EmbarkEventHelper(string container, string embarker) { IsInSomething = true; Parent = container; AirCraftMover acm; // If the Embarker is an Air Craft we need to 'refuel it' by resetting the appropriate variables if ((acm = (AirCraftMover)this.gameObject.GetComponent <AirCraftMover> ()) != null) { acm.Land(); } gameObject.GetComponent <CircleCollider2D> ().enabled = false; gameObject.GetComponent <SpriteRenderer> ().enabled = false; GuidList.GetGameObject(container).GetComponent <ContainerController> ().Add(embarker); }
public void SelectWeaponTarget() { GameObject newSelected = GuidList.GetGameObject(CurrentWeaponTargets.First.Value); if (GuidList.GetGameObject(Unit.GetComponent <IdentityController>().GetGuid()) != null) { Unit.GetComponent <UIUnitStateController>().GetSelect().GetComponent <SpriteRenderer>().enabled = false; Unit.GetComponent <UIUnitStateController>().SetSelected(false); if (CurrentWeaponTargets.Count > 0) { for (int i = 0; i < CurrentWeaponTargets.Count; i++) { string targetGuid = CurrentWeaponTargets.First.Value; CurrentWeaponTargets.RemoveFirst(); GuidList.GetGameObject(targetGuid).transform.FindChild("Attack Pulse").gameObject.SetActive(false); CurrentWeaponTargets.AddLast(targetGuid); } } CurrentWeaponTargets.Clear(); CurrentWeaponTargetShots.Clear(); CurrentUnitWeapons.Clear(); } gameObject.GetComponent <UIMainController>().SetSelectedUnit(newSelected); CurrentUnitWeapons.Clear(); CurrentWeaponIndex = 1; foreach (Weapon weapon in Unit.GetComponent <AttackController>().GetWeapons().Values) { CurrentUnitWeapons.AddLast(weapon); } if (CurrentUnitWeapons.Count > 0) { CurrentWeaponTargets.Clear(); foreach (string targetGuid in CurrentUnitWeapons.First.Value.GetTargets().Keys) { CurrentWeaponTargets.AddLast(targetGuid); GuidList.GetGameObject(targetGuid).transform.FindChild("Attack Pulse").gameObject.SetActive(true); } CurrentWeaponTargetShots.Clear(); foreach (int shots in CurrentUnitWeapons.First.Value.GetTargets().Values) { CurrentWeaponTargetShots.AddLast(shots); } } Unit.GetComponent <UIUnitStateController>().GetMouseOver().GetComponent <SpriteRenderer>().enabled = false; Unit.GetComponent <UIUnitStateController>().GetSelect().GetComponent <SpriteRenderer>().enabled = true; Unit.GetComponent <UIUnitStateController>().SetSelected(true); CurrentTargetIndex = 1; }
private void SaveObjects(string scenarioName) { _saveStatus = 0f; GuidList.CleanNullObjects(); ControllerShell.DumpGuidList(); _saveStatus += .25f; EnvironmentSettingsShell.DumpAll(); _saveStatus += .25f; Thread t = new Thread(() => MultiThreadedSave(scenarioName)); t.Start(); }
public ActionResult SuggestedApps(GuidList abIds, int?start, int?count, bool?myAppsOnly) { Trace.Assert(Context.PersonId.HasValue); var st = start ?? 0; var cnt = count ?? int.MaxValue; var suggestedApplications = MasterLocator.ApplicationService.GetSuggestedApplications(abIds, st, cnt); if (myAppsOnly.HasValue && myAppsOnly.Value) { suggestedApplications = suggestedApplications.Where(x => MasterLocator.ApplicationService.HasMyApps(x)).ToList(); } return(Json(suggestedApplications.Select(BaseApplicationViewData.Create))); }
public void SetTags(IEnumerable<TagDto> tags) { var currentListTags = GetIdTags(); var newListTags = new GuidList(); foreach (var tag in tags) { SetTag(tag); if (!(currentListTags.ContainsKey(tag.Name) || newListTags.ContainsKey(tag.Name))) { newListTags.Add(tag.Name, tag.Id); } } var query = new AllTagsQuery(); if (newListTags.Any()) _listTagsQueryHandler.ListPush(query, newListTags); }