public void UpdateFactionColor() { FactionController factionController = _targetPlayer.GetComponent <FactionController>(); Image img = GetComponent <Image>(); img.color = factionController.GetFactionColor(); }
/// <summary> /// Called when a unit is to enter/attack this tower. /// See documenation for full explaination and metrics. /// If unit is friendly, stationed units is increased. /// Raises ChangedFaction and AttackedByUnit events. /// </summary> /// <param name="unit">Unit.</param> public void UnitEntered(UnitBehavior unit) { if (unit.Faction == Faction) { // Friendly units are transfered to this towers group unit.TransferGroup(stationedGroup); unit.gameObject.SetActive(false); } else { // Hostile units damage this towers stationed unit group int strength = FactionController.GetAttackStrengthForFaction(unit.Faction); stationedGroup.Damage(strength); // Change tower's faction if last unit was killed if (stationedGroup.Empty) { TowerController.ConvertTowerToFaction(this, unit.Faction); if (ChangedFaction != null) { ChangedFaction(Faction); SetGraphic(); } } unit.ImpactKill(); if (AttackedByUnit != null) { AttackedByUnit(unit); } } }
/// <summary> /// Returns true if the from's units can reach the to tower /// </summary> public static bool DistanceCheck(TowerBehavior from, TowerBehavior to) { float timeAlive = Game.TowerInfo.DefaultUnitKillTime; Vector3 destinationFinalPos; if (to.GetComponent <OrbitMotion>() != null) { destinationFinalPos = to.Orbit.CalculatePositionWithMoreUpTime(timeAlive); } else { destinationFinalPos = to.transform.position; } float distance = (to.transform.position - from.transform.position).magnitude; float maxDistanceTravel = timeAlive * FactionController.GetSpeedForFaction(from.Faction); if (maxDistanceTravel < distance) { return(false); } return(true); }
private void saveButton_Click(object sender, EventArgs e) { Faction newFaction = new Faction(); newFaction.FactionName = factionNameText.Text; newFaction.FactionIcon = iconUrlText.Text; newFaction.FactionImage = imgUrlText.Text; newFaction.FactionStrip = stripUrlText.Text; newFaction.FactionReverseIcon = reverseIconUrlText.Text; newFaction.FactionCommand = commandImgUrlText.Text; newFaction.FactionGamePlay = gamePlayText.Text; newFaction.FactionLore = loreText.Text; newFaction.DetailedIcon = detailedIconUrlText.Text; FactionController factionController = new FactionController(); factionController.InsertFaction(newFaction); factionNameText.Clear(); iconUrlText.Clear(); imgUrlText.Clear(); stripUrlText.Clear(); reverseIconUrlText.Clear(); commandImgUrlText.Clear(); gamePlayText.Clear(); loreText.Clear(); detailedIconUrlText.Clear(); }
public static void Init() { VehicleController.LoadVehicles(); FactionController.LoadFactions(); HouseController.LoadHouses(); BusinessController.LoadBusinesses(); }
// Raise warning if more than one UIController exists. void Awake() { if (current != null) { Debug.LogWarning("Multiple UIControllers created. Replacing current."); } current = this; }
private void Validate() { errorList.Clear(); lvlCtrl = GameObject.FindObjectOfType <LevelController>(); valid = true; if (lvlCtrl == null) { errorList.Add("Error: No Level Controller in scene."); } else { levelData = lvlCtrl.CurrentLevel; if (levelData == null) { errorList.Add("Error: No Level Data in level controller."); valid = false; } else { Debug.Log(levelData.Prefab.name); levelFab = GameObject.Find(levelData.Prefab.name); if (levelFab == null) { errorList.Add("Error: Level Prefab not in scene"); valid = false; } else { facCtrl = levelFab.GetComponentInChildren <FactionController>(); if (facCtrl == null) { errorList.Add("Error: No Faction Controller in level."); valid = false; } towerCtrl = levelFab.GetComponentInChildren <TowerController>(); if (towerCtrl == null) { errorList.Add("Error: No Tower Controller in level."); valid = false; } unitCtrl = levelFab.GetComponentInChildren <UnitController>(); if (unitCtrl == null) { errorList.Add("Error: No Unit Controller in level."); valid = false; } } } } }
void Start() { _systemFactionChangedSignal += TransferSystemFaction; _regimentMovedSignal += RegimentMoved; if (isLocalPlayer) { PlayerName = _localPlayerManager.PlayerName; FactionController factC = gameObject.GetComponent <FactionController>(); factC.SetFromString(_localPlayerManager.PlayerFactionString); } _signalDispatcher.DispatchPlayerJoined(this); }
//function called of the class to start a multi Attack //on a personal note, this was done quickly for PAX //after pax i will be changing the syntax for this public static bool StartOverLoadAttack(TowerBehavior destination, List <MultiAttackInfo> Info) { //saftey Check, this shouldn't go off, but just incase foreach (MultiAttackInfo info in Info) { if (info.Percent <= 0) { return(false); } } //if the original Attacking tower (1) is closer if (Vector3.Distance(Info[1].AI.myTower.transform.position, destination.transform.position) <= Vector3.Distance(Info[0].AI.myTower.transform.position, destination.transform.position)) { //send the units from 0 to 1 Info[0].AI.StartAttack(Info[1].AI.myTower, Info[0].Percent, 1f); //determine time for the attacking tower to wait for float distance = Vector3.Distance(Info[0].AI.myTower.transform.position, Info[1].AI.myTower.transform.position); float speed = FactionController.GetSpeedForFaction(FactionController.OtherFaction1); float time = (distance / speed) + 1.1f; //1.01f to wait for other towers timer //have 1 wait for 0 IEnumerator coroutine = Info[1].AI.StartOverloadAttack(destination, Info[1].Percent, time); AIController.CallCoroutine(coroutine); } //if the second tower is closer else { //send the units from the original attacker(1) to the new one (0) Info[1].AI.StartAttack(Info[0].AI.myTower, Info[1].Percent, 1f); //determine time for the attacking tower to wait for float distance = Vector3.Distance(Info[1].AI.myTower.transform.position, Info[0].AI.myTower.transform.position); float speed = FactionController.GetSpeedForFaction(FactionController.OtherFaction1); float time = (distance / speed) + 1.1f; //1.01f to wait for other towers timer //Have 0 wait for 1 IEnumerator coroutine = Info[0].AI.StartOverloadAttack(destination, Info[0].Percent, time); AIController.CallCoroutine(coroutine); } return(true); }
/// <summary> /// Returns the Number of Units Needed to successfully defend a tower /// </summary> public static int NumUnitsNeededToDefend(TowerBehavior defendingTower, int attackingFaction, int numAttackingUnits) { int strength = FactionController.GetAttackStrengthForFaction(attackingFaction); int unitsNeeded = 0; int endurance = defendingTower.StationedGroup.Endurance; for (int i = 0; i < numAttackingUnits; i++) { endurance -= strength; if (endurance <= 0) { unitsNeeded++; endurance += defendingTower.CurrentStats.Endurance; } } return(unitsNeeded + 1); }
public void InitializeAgent() { if (this.agentSerial == "") { this.agentSerial = randomValuesGenerator.GetOpenSerialNumber(); } myFactionController = gameObject.GetComponentInParent <FactionController>(); if (this.faction == "") { this.faction = myFactionController.FactionName; } if (this.agentCallsign == "") { string digits = randomValuesGenerator.GetOpenSerialNumber().Substring(2); string callsign = myFactionController.GetDigraph() + digits; this.agentCallsign = callsign; } }
/// <summary> /// Returns True if the attacking Units will take over a tower /// </summary> public static bool SimulateAttack(int numUnitsAttacking, TowerBehavior destination, int AttackingFaction, out int UnitsLeft) { UnitsLeft = numUnitsAttacking; //how many stationUnits does the destination have int defendingUnits = destination.StationedUnits; //what is the current endurance of the destination tower int currentEndurance = destination.StationedGroup.Endurance; //strength of soldiers int strength = FactionController.GetAttackStrengthForFaction(AttackingFaction); //Simulate attacking for (int i = 0; i < numUnitsAttacking; i++) { currentEndurance -= strength; UnitsLeft--; if (currentEndurance <= 0) { currentEndurance += destination.CurrentStats.Endurance; defendingUnits--; } //if the player is out of units stop the loop if (defendingUnits <= 0) { break; } } //if the there are defending Units leftover, we have failed the attack if (defendingUnits > 0) { return(false); } //we have succeeded the attack in defending Units is 0 or less return(true); }
void Awake() { // Redundant Reset ConvergenceController.DestoryConvergenceController(); Time.timeScale = 1.0f; FactionController.SetDefaultFactions(); // Raise warning if more than one LevelController exists. if (current != null) { Debug.LogWarning("Multiple LevelControllers created. Replacing current."); } current = this; // Check Game for level list if (!Game.HasLevelList()) { Game.SetLevelList(DefaultList); } // Check Game for a selected level var selectedLevel = Game.CurrentLevel; // If Game has one, else use one assigned in editor if (selectedLevel != null) { CurrentLevel = selectedLevel; } // If there isn't one and CurrentLevel is still null (i.e. nothing assigned in editor) error is raised. if (CurrentLevel == null) { Debug.LogError("Attempting to start game without any level data."); return; } }
private void createRegion(List <Vector2> regionPoints, StarSystem target, bool buildOnServer) { GameObject createdSystem = Container.InstantiatePrefab(_settings.StarSystemPrefab); createdSystem.transform.position = new Vector3(target.X, 0, target.Y); createdSystem.name = "Star_" + target.Name; // Might be building on the client in offline mode if (buildOnServer) { NetworkServer.Spawn(createdSystem.gameObject); } createdSystem.GetComponentsInChildren <Text>()[0].text = target.Name; TerritoryController tc = createdSystem.GetComponent <TerritoryController>(); foreach (Vector2 point in regionPoints) { tc.Points.Add(point); } StarSystemController ssCon = createdSystem.gameObject.GetComponent <StarSystemController>(); ssCon.StarName = target.Name; // Set the starting faction FactionController factCtrl = createdSystem.gameObject.GetComponent <FactionController>(); switch (target.Faction) { case "s": factCtrl.CurrentFaction = Faction.Steiner; break; case "m": factCtrl.CurrentFaction = Faction.Marik; break; case "l": factCtrl.CurrentFaction = Faction.Liao; break; case "d": factCtrl.CurrentFaction = Faction.Davion; break; case "k": factCtrl.CurrentFaction = Faction.Kurita; break; case "c": factCtrl.CurrentFaction = Faction.Comstar; break; default: factCtrl.CurrentFaction = Faction.None; break; } StarSystemData sysData = createdSystem.gameObject.GetComponent <StarSystemData>(); sysData.OrigX = target.OrigX; sysData.OrigY = target.OrigY; sysData.StarClass = target.StarClass; if (target.DataAvailable) { sysData.IsDataKnown = true; sysData.PlanetsKnown = target.PlanetsKnown; sysData.PlanetsUnknown = target.PlanetsUnknown; sysData.Gravity = target.Gravity; sysData.Atmosphere = target.Atmosphere; sysData.Water = target.Water; sysData.Climate = target.Climate; sysData.Terrain = target.Terrain; sysData.Development = target.Development; sysData.HasFlag = target.HasFlag; } }
/* Faction Entity Functions */ public static void Add(FactionController faction) { Factions.Add(faction); }
// null static current in preparation for next UnitController void OnDestroy() { current = null; }
public static void Remove(FactionController faction) { Factions.Remove(faction); }