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); } }
/** * 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); }
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); } }
// 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; } } }
/** * 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(); } }
/** * 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 static string GetTeam(string guid) { if (GuidList.GetGameObject(guid) == null) { return(""); } return(Team.Teams[GuidList.GetGameObject(guid).GetComponent <IdentityController>().GetTeam()].GetTeamName()); }
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 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 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); } }
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); }
/** * 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 } } }
/** * 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(""); } }
/** * 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; }
/** * Determines what objects are visible to this user * * @returns * A list of all game objects visible to this user */ public List <GameObject> GetUnitsVisibleToMe() { // A set of all objects that the user should be able to see HashSet <GameObject> visibleObjects = new HashSet <GameObject>(); // Check the permission level of the user if (MyPermissionLevel == PermissionLevel.Admin || MyPermissionLevel == PermissionLevel.Spectator) { // If the user is an Admin or a Spectator // Add all objects to their visible objects list visibleObjects.UnionWith(GuidList.GetAllObjects()); } else if (MyPermissionLevel == PermissionLevel.User) { // If the user is a User // Check if the user is a sub player and sub players currently // only see what their sub can see. if (SubPlayer && !GlobalSettings.GetSubmarineSensorLinkState()) { // If this user only sees what the sub sees // Add the results of the sub's Ping visibleObjects.UnionWith(GuidList.GetGameObject(SubUnit).GetComponent <DetectorController>().Ping()); // Add the sub itself. visibleObjects.Add(GuidList.GetGameObject(SubUnit)); // Add all omnipresent objects visibleObjects.UnionWith(GuidList.GetOmnipresentObjects()); // Remove all invisible objects visibleObjects.ExceptWith(GuidList.GetInvisibleObjects()); } else { // If the user sees everything the team sees // Get a list of everything the team sees. visibleObjects.UnionWith(Team.GetTeam(TeamNumber).GetVisibleToTeam()); } } return(visibleObjects.ToList <GameObject>()); }
public void ClearTargets() { if (CurrentWeaponTargets.Count > 0) { for (int i = 0; i < CurrentWeaponTargets.Count; i++) { string targetGuid = CurrentWeaponTargets.First.Value; CurrentWeaponTargets.RemoveFirst(); GameObject go = GuidList.GetGameObject(targetGuid); if (go != null) { GuidList.GetGameObject(targetGuid).transform.FindChild("Attack Pulse").gameObject.SetActive(false); } CurrentWeaponTargets.AddLast(targetGuid); } } CurrentWeaponTargets.Clear(); CurrentWeaponTargetShots.Clear(); }
/** * Removes a unit from this Container, changes state of unit to unembarked, and moves it to the given position. * @param unit * The unit to be removed */ public void Launch(String unit, Vector3 pos) { float PercentHealth = ((HealthController)this.gameObject.GetComponent("HealthController")).GetCurrentPercentHealth(); //TODO: determine if we want the health restriction for just aircraft or all contained units if (PercentHealth >= GlobalSettings.GetHealthThresholdForNoDetectors()) { GameObject u = GuidList.GetGameObject(unit); if (Vector3.Distance(pos, this.transform.position) < u.GetComponent <MoverController>().MoveRange) { // throw the UnitUnEmbarksEvent event object[] arguments = new object[3]; arguments[0] = unit; arguments[1] = new Point((int)pos.x, (int)pos.y, (int)pos.z); arguments[2] = this.gameObject.GetComponent <IdentityController>().GetGuid(); EventManager.Instance.AddEvent(EventFactory.CreateEvent(GEventType.UnitUnEmbarksEvent, arguments, 1)); } } }
public void PreviousWeapon() { if (Unit != null && CurrentUnitWeapons.Count > 0) { foreach (string targetGuid in CurrentWeaponTargets) { if (GuidList.GetGameObject(targetGuid) != null) { GuidList.GetGameObject(targetGuid).transform.FindChild("Attack Pulse").gameObject.SetActive(false); } } Weapon currentWeapon = CurrentUnitWeapons.Last.Value; CurrentUnitWeapons.RemoveLast(); CurrentUnitWeapons.AddFirst(currentWeapon); CurrentWeaponIndex--; if (CurrentWeaponIndex > CurrentUnitWeapons.Count) { CurrentWeaponIndex = 1; } else if (CurrentWeaponIndex < 1) { CurrentWeaponIndex = CurrentUnitWeapons.Count; } 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; } }
/* * Sets the container to contain this unit, and changes state, if the unit is within range of the target container. * * @param parent * The container that will contain this unit. */ public void Embark(String parent) { //Debug.Log ("HERE:" + parent); GameObject g = GuidList.GetGameObject(parent); if (g.GetComponent <ContainerController> ().GetInUse()) { if (Vector3.Distance(this.transform.position, GuidList.GetGameObject(parent).transform.position) < this.gameObject.GetComponent <MoverController> ().MoveRange) { // throw the UnitEmbarksEvent event object[] arguments = new object[2]; arguments [0] = this.gameObject.GetComponent <IdentityController> ().GetGuid(); arguments [1] = GuidList.GetGameObject(parent).GetComponent <IdentityController> ().GetGuid(); Parent = parent; //Debug.Log ("HEREERE: " + Parent); EventManager.Instance.AddEvent(EventFactory.CreateEvent(GEventType.UnitEmbarksEvent, arguments, 1)); } gameObject.GetComponent <CircleCollider2D> ().enabled = false; gameObject.GetComponent <SpriteRenderer> ().enabled = false; } }
public override void HandleEvent(GEvent e) { string firerer = (string)e.Arguments [0]; string target = (string)e.Arguments [1]; string firing = (string)e.Arguments [2]; int shots = (int)e.Arguments [3]; //Debug.Log(firerer + " " + target + " " + firing + " " + shots); float PercentHealth = ((HealthController)GuidList.GetGameObject(firerer).GetComponent("HealthController")).GetCurrentPercentHealth(); if (PercentHealth < GlobalSettings.GetHealthThresholdForNoWeapons()) { //Debug.Log ("Unable to target weapon since unit is very damaged"); } else { Weapon w = ((AttackController)GuidList.GetGameObject(firerer).GetComponent <AttackController>()).GetWeapon(firing); w.SetTarget(target, shots); //Debug.Log ("Weapon " + firing + " Targeted with " + shots +" shots"); } }
// Update is called once per frame void Update() { if (Unit != null) { UnitWeaponsNavigator.SetActive(true); InspectorPanel.transform.FindChild("Position Label").gameObject.SetActive(true); if (gameObject.GetComponent <UIMainController>().GetUser() != null && gameObject.GetComponent <UIMainController>().GetUser().TeamNumber == Unit.GetComponent <IdentityController>().GetTeam()) { UnitWeaponsNavigator.SetActive(true); if (Unit.GetComponent <ContainerController>() != null) { CarrierInfoButton.SetActive(true); } if (Unit.GetComponent <EmbarkerController>() != null) { EmbarkButton.SetActive(true); } InspectorPanel.transform.FindChild("Weapons Label").gameObject.SetActive(true); InspectorPanel.transform.FindChild("Health Label").gameObject.SetActive(true); InspectorPanel.transform.FindChild("Move Range Label").gameObject.SetActive(true); InspectorPanel.transform.FindChild("Move Button").gameObject.SetActive(true); } else { UnitWeaponsNavigator.SetActive(false); CarrierInfoButton.SetActive(false); EmbarkButton.SetActive(false); InspectorPanel.transform.FindChild("Move Button").gameObject.SetActive(false); InspectorPanel.transform.FindChild("Weapons Label").gameObject.SetActive(false); InspectorPanel.transform.FindChild("Health Label").gameObject.SetActive(false); InspectorPanel.transform.FindChild("Move Range Label").gameObject.SetActive(false); } } else { InspectorPanel.transform.FindChild("Health Label").gameObject.SetActive(false); InspectorPanel.transform.FindChild("Position Label").gameObject.SetActive(false); InspectorPanel.transform.FindChild("Weapons Label").gameObject.SetActive(false); InspectorPanel.transform.FindChild("Move Range Label").gameObject.SetActive(false); UnitWeaponsNavigator.SetActive(false); InspectorPanel.transform.FindChild("Move Button").gameObject.SetActive(false); CarrierInfoButton.SetActive(false); } // Display all relevant information in inspector panel if (Unit == null) { UnitNameDisplay.GetComponent <Text> ().text = ""; UnitHealthDisplay.GetComponent <Text> ().text = ""; UnitPositionDisplay.GetComponent <Text> ().text = ""; UnitMoveRangeDisplay.GetComponent <Text> ().text = ""; } else { if (gameObject.GetComponent <UIMainController>().GetUser() != null && gameObject.GetComponent <UIMainController>().GetUser().TeamNumber == Unit.GetComponent <IdentityController>().GetTeam()) { if (Unit.tag.Equals("Air")) { UnitMoveRangeDisplay.GetComponent <Text> ().text = "" + Unit.GetComponent <AirCraftMover>().GetCurrentRange(); } else { UnitMoveRangeDisplay.GetComponent <Text> ().text = "" + Unit.GetComponent <MoverController>().GetMoveRange(); } UnitHealthDisplay.GetComponent <Text> ().text = Unit.GetComponent <HealthController>().CurrentHealth.ToString() + " / " + Unit.GetComponent <HealthController>().MaxHealth.ToString(); } else { UnitHealthDisplay.GetComponent <Text> ().text = ""; UnitMoveRangeDisplay.GetComponent <Text> ().text = ""; } UnitNameDisplay.GetComponent <Text> ().text = Unit.GetComponent <IdentityController>().GetFullName(); string xPos = System.Convert.ToString(Unit.transform.position.x); string yPos = System.Convert.ToString(Unit.transform.position.y); // Trim coordinates to 7 characters each if (xPos.Length > 7) { xPos = xPos.Remove(7); } if (yPos.Length > 7) { yPos = yPos.Remove(7); } UnitPositionDisplay.GetComponent <Text> ().text = "(" + xPos + ", " + yPos + ")"; // Display weapons and targets if (CurrentUnitWeapons.Count > 0) { UnitWeaponsNavigator.transform.FindChild("Weapons Navigator").GetComponent <Text>().text = CurrentWeaponIndex + " of " + CurrentUnitWeapons.Count; UnitWeaponsNavigator.transform.FindChild("Weapon Type").GetComponent <Text>().text = LanguageManager.instance.getString(Unit.tag.Equals("Marine") ? "Marine_Weapon" : "Weapons", CurrentUnitWeapons.First.Value.GetName().Substring(0, CurrentUnitWeapons.First.Value.GetName().LastIndexOf("-"))); UnitWeaponsNavigator.transform.FindChild("Range").GetComponent <Text>().text = "" + CurrentUnitWeapons.First.Value.GetRange(); UnitWeaponsNavigator.transform.FindChild("Damage").GetComponent <Text>().text = "" + CurrentUnitWeapons.First.Value.GetDamage(); UnitWeaponsNavigator.transform.FindChild("Accuracy").GetComponent <Text>().text = "" + CurrentUnitWeapons.First.Value.GetHitChance(); if (CurrentUnitWeapons.First.Value.GetCurAmmo() == -1) { WeaponAmmoDisplay.GetComponent <Text>().text = "INFINITE"; } else { WeaponAmmoDisplay.GetComponent <Text>().text = CurrentUnitWeapons.First.Value.GetCurAmmo() + " / " + CurrentUnitWeapons.First.Value.GetMaxAmmo(); } UnitWeaponsNavigator.transform.FindChild("Total Shots Fired").GetComponent <Text>().text = CurrentUnitWeapons.First.Value.GetCurShotsTargeted() + " of " + CurrentUnitWeapons.First.Value.GetMaxShots(); 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(true); } CurrentWeaponTargets.AddLast(targetGuid); } WeaponTargetsNavigator.GetComponent <Text>().text = CurrentTargetIndex + " of " + CurrentWeaponTargets.Count; try{ GameObject Target = GuidList.GetGameObject(CurrentWeaponTargets.First.Value); if (Target != null) { WeaponTargetsNavigator.transform.FindChild("Target Name").GetComponent <Text>().text = Target.GetComponent <IdentityController>().GetFullName(); } else { WeaponTargetsNavigator.transform.FindChild("Target Name").GetComponent <Text>().text = ""; } } catch (KeyNotFoundException e) { WeaponTargetsNavigator.transform.FindChild("Target Name").GetComponent <Text>().text = ""; } WeaponTargetsNavigator.transform.FindChild("Shots Fired at Target").GetComponent <Text>().text = "" + CurrentWeaponTargetShots.First.Value; } else { WeaponTargetsNavigator.GetComponent <Text>().text = "No Targets"; WeaponTargetsNavigator.transform.FindChild("Target Name").GetComponent <Text>().text = ""; WeaponTargetsNavigator.transform.FindChild("Shots Fired at Target").GetComponent <Text>().text = ""; } } } }
public static string GetTeamColor(string guid) { Color c = Team.Teams[GuidList.GetGameObject(guid).GetComponent <IdentityController>().GetTeam()].GetTeamColor(); return(((int)(c.r)).ToString("X2") + ((int)(c.g)).ToString("X2") + ((int)(c.b)).ToString("X2") + "FF"); }
/* * Releases the unit from its container at the parent units position. * */ public void LaunchEventHelper(string embarker, Vector3 pos, string parent) { IsInSomething = false; // Offset unit so it can be selected, values based on current unit size in editor int XRandom = UnityEngine.Random.Range(0, 2); int YRandom = UnityEngine.Random.Range(0, 2); int XOffset, YOffset; Parent = Parent; if (gameObject.GetComponent <MarineMover> () != null) { if (XRandom == 0) { XOffset = -1; } else { XOffset = 1; } if (YRandom == 0) { YOffset = -1; } else { YOffset = 1; } gameObject.transform.position = GuidList.GetGameObject(Parent).transform.position + new Vector3(XOffset, YOffset, 0); } else { if (XRandom == 0) { XOffset = -5; } else { XOffset = 5; } if (YRandom == 0) { YOffset = -5; } else { YOffset = 5; } float f = gameObject.transform.position.z; if (GuidList.GetGameObject(Parent) != null) { gameObject.transform.position = GuidList.GetGameObject(Parent).transform.position + new Vector3(XOffset, YOffset, 0); gameObject.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, f); } } gameObject.GetComponent <CircleCollider2D> ().enabled = true; gameObject.GetComponent <SpriteRenderer> ().enabled = true; if (GuidList.GetGameObject(Parent) != null) { GuidList.GetGameObject(Parent).GetComponent <ContainerController> ().Remove(embarker); } Parent = ""; }
public override void HandleEvent(GEvent e) { HealthController Unit = (HealthController)GuidList.GetGameObject((string)e.Arguments [0]).GetComponent("HealthController"); Unit.DamageUnit((float)e.Arguments[1], GetTeam((string)e.Arguments [0])); }
void SettingObject(string b) { selectedObj = GuidList.GetGameObject(b); }
/** * Adds a unit to this container if it is within range to do so. * @param unit * The unit to be added. */ public virtual void Receive(String unit) { GuidList.GetGameObject(unit).GetComponent <EmbarkerController> ().Embark(this.gameObject.GetComponent <IdentityController>().MyGuid); }