public SpaceUnit GetRandomEnemyTarget() { ShipManager enemyManager = GetRandomEnemyShipManager(); if (enemyManager != null) { SpaceUnit target = enemyManager.GetRandomShip(); if (target != null) { return(target); } target = enemyManager.GetRandomStation(); if (target != null) { return(target); } target = enemyManager.GetRandomFighter(); if (target != null) { return(target); } return(null); } return(null); }
public static Matrix <SpaceUnit> GetRectFillInvalid(this Matrix <SpaceUnit> mat, Region region) { var t = new Matrix <SpaceUnit>(region.Height, region.Width); var r = 0; var c = 0; for (var i = region.Top; i < region.Bottom; i++, r++, c = 0) { for (var j = region.Left; j < region.Right; j++, c++) { if (i >= 0 && i < mat.Columns && j >= 0 && j < mat.Rows) { t[r, c] = mat[i, j]; } else { t[r, c] = new SpaceUnit { Position = new Point(-1, -1) } } } } ; return(t); }
public void SetParentForAttachedWeapons(SpaceUnit parentUnit) { foreach (AttachedWeapon weapon in Weapons) { weapon.SetParent(parentUnit); } }
void DealDamage(SpaceUnit target, float damage) { Vector3 Position; if (hitEffect != null) { Position = hitEffect.transform.position; } else { Position = target.transform.position; } if (target is Ship) { (target as Ship).TakeDamage(attachedWeapon, Position, transform.position, damage, ignoreShields, ignoreArmor, ignoreArmorRating); } else if (target is Station) { (target as Station).TakeDamage(attachedWeapon, Position, transform.position, damage, ignoreShields, ignoreArmor, ignoreArmorRating); } else if (target is Fighter) { (target as Fighter).TakeDamage(attachedWeapon, damage, ignoreShields, ignoreArmor, ignoreArmorRating); } }
public void SetTargetForAllShips(SpaceUnit target) { bool enemy = isEnemy(target); foreach (Ship ship in Ships) { if (!ship.isDestroyed() && ship != target) { ship.SetNewTarget(target, enemy); } } foreach (FighterWing fighterWing in FighterWings) { if (!fighterWing.OwnsUnit(target as Fighter)) { fighterWing.SetNewTarget(target, enemy); } } if (enemy) { foreach (Station station in Stations) { if (!station.isDestroyed() && station != target) { station.SetNewTarget(target, enemy); } } } }
public void RemoveFromSelection(SpaceUnit unit) { if (unit is Ship) { SelectedShips.Remove(unit as Ship); RemoveShipFromSelectionGroups(unit as Ship); foreach (ShipManager manager in EnemyShipManagers) { if (manager.UnOwnedSelectedShip == unit) { manager.UnOwnedSelectedShip = null; } } } else if (unit is Station) { SelectedStations.Remove(unit as Station); RemoveStationFromSelectionGroups(unit as Station); foreach (ShipManager manager in EnemyShipManagers) { if (manager.UnOwnedSelectedStation == unit) { manager.UnOwnedSelectedStation = null; } } } }
public void SetTargetForSelectedShips(SpaceUnit target) { bool enemy = isEnemy(target); foreach (Ship ship in SelectedShips) { if (ship != target) { ship.SetNewTarget(target, enemy); } } foreach (FighterWing fighterWing in SelectedFighterWings) { if (!fighterWing.OwnsUnit(target as Fighter)) { fighterWing.SetNewTarget(target, enemy); } } if (enemy) { foreach (Station station in SelectedStations) { if (station != target) { station.SetNewTarget(target, enemy); } } } }
void ParentAttachedWeapons(SpaceUnit parentUnit) { ForeSection.SetParentForAttachedWeapons(parentUnit); AftSection.SetParentForAttachedWeapons(parentUnit); PortSection.SetParentForAttachedWeapons(parentUnit); StarboardSection.SetParentForAttachedWeapons(parentUnit); CenterSection.SetParentForAttachedWeapons(parentUnit); }
public void SetNewTarget(SpaceUnit target, bool isEnemy) { targetUnit = target; foreach (Fighter unit in Fighters) { unit.SetNewTarget(target, isEnemy); } }
public void SetNewGoalPosition(Vector3 Position) { targetUnit = null; foreach (Fighter unit in Fighters) { unit.SetNewGoalPosition(Position); } ResourceManager.CreateClickPing(Position); }
private void save_Click(object sender, EventArgs e) { SpaceUnit sp = new SpaceUnit(); sp.Name = txtName.Text; sp.BuildingId = _buildingId; da.AddSpaceUnit(sp); this.Close(); }
public override void GetKill(SpaceUnit killedUnit) { if (killedUnit is Ship) { stationData.GetKill((killedUnit as Ship).GetShipData()); } else if (killedUnit is Station) { stationData.GetKill((killedUnit as Station).stationData); } }
public bool isEnemy(SpaceUnit target) { if (shipManager != null) { return(shipManager.isEnemy(target)); } else { return(false); } }
public void CaptureUnit(SpaceUnit unit) { if (unit is Ship) { CaptureShip(unit as Ship); } else if (unit is Station) { CaptureStation(unit as Station); } }
public bool isEnemy(SpaceUnit target) { if (target == null) { return(false); } if (GetShipManager() != null) { return(GetShipManager().isEnemy(target)); } return(false); }
public void TurnOn(float time, Color color, SpaceUnit target) { gameObject.SetActive(true); timer = time; Color = color; Target = target; objectTarget = true; lineRenderer.startColor = Color; lineRenderer.endColor = Color; lineRenderer.SetPosition(0, transform.position); lineRenderer.SetPosition(1, transform.position); }
public bool isEnemy(SpaceUnit target) { ShipManager targetManager = target.GetShipManager(); if (EnemyShipManagers.Contains(targetManager)) { return(true); } else { return(false); } }
override public void Fire(SpaceUnit target) { if (fireTimer <= 0) { Vector3 dir = (target.position - transform.position).normalized; GameObject beamObj = new GameObject(); LaserBeam beam = beamObj.AddComponent<LaserBeam>(); beam.team = unit.team; beam.origin = transform.position; beam.direction = dir; beam.range = range; beam.speed = projectileSpeed; fireTimer += 1 / fireRate; } }
public void AddSpaceUnit(SpaceUnit unit) { if (unit is Ship) { AddShip(unit as Ship); } else if (unit is Station) { AddStation(unit as Station); } else if (unit is Fighter) { AddFighter(unit as Fighter); } }
public override void GetKill(SpaceUnit killedUnit) { if (killedUnit is Fighter) { shipData.AddExperience((killedUnit as Fighter).GetKillExperience()); } else { if (killedUnit is Ship) { shipData.GetKill((killedUnit as Ship).GetShipData()); } else if (killedUnit is Station) { shipData.GetKill((killedUnit as Station).stationData); } } }
public void RemoveUnit(SpaceUnit unit) { if (unit is Ship) { SelectedShips.Remove(unit as Ship); Ships.Remove(unit as Ship); RemoveShipFromSelectionGroups(unit as Ship); } else if (unit is Station) { SelectedStations.Remove(unit as Station); Stations.Remove(unit as Station); RemoveStationFromSelectionGroups(unit as Station); } else if (unit is Fighter) { Fighters.Remove(unit as Fighter); } }
public virtual void SetNewTarget(SpaceUnit target, bool Enemy) { if (target != null) { Target = target; TargetIsEnemy = Enemy; if (shipOrderLine != null) { if (Enemy) { shipOrderLine.TurnOn(1.0f, ResourceManager.gameConstants.Highlight_Enemy.GetColor(), target); } else { shipOrderLine.TurnOn(1.0f, ResourceManager.gameConstants.Highlight_Player.GetColor(), target); } } } }
public void ReplaceTarget(SpaceUnit oldTarget, SpaceUnit newTarget) { foreach (Ship ship in Ships) { if (ship.isDestroyed()) { continue; } if (ship.GetTarget() == oldTarget) { ship.SetNewTarget(newTarget, true); } } foreach (FighterWing fighterWing in FighterWings) { if (fighterWing.GetUnitCount() > 0 && fighterWing.GetFirstFighter().GetTarget() == oldTarget) { fighterWing.SetNewTarget(newTarget, true); } } }
public void Update() { if (AIControl && EnemyShipManagers.Count > 0) { if (AI_Timer > 0) { AI_Timer -= Time.deltaTime; } else { AI_Timer = 1f; if (enemyTarget == null) { enemyTarget = GetRandomEnemyTarget(); if (enemyTarget != null) { SetTargetForAllShips(enemyTarget); } } else if (enemyTarget != null) { if (enemyTarget.isDestroyed()) { enemyTarget = null; } else if (enemyTarget is Ship) { if ((enemyTarget as Ship).IsCloaked()) { enemyTarget = null; } } } } } }
virtual public void Fire(SpaceUnit target) { // Nothing }
public DiskSpaceHealthCheck(long treshold = 100000000, SpaceUnit unit = SpaceUnit.Byte) { _defaultTreshold = treshold * (long)unit; _data.Add(REQUIRED_SPACE, _defaultTreshold); }
private void PassiveAttackUpdate() { if (target != null && ((target.position - position).magnitude > enemyCheckRange || false)) { target = null; } if ((position - standPoint).magnitude > standReturnRange) { MoveOrder(standPoint, defaultWayPointRange); } if (enemyCheckTimer > 0) { enemyCheckTimer -= U.limitedDeltaTime; } else if (state == UnitState.IDLE || state == UnitState.MOVING) { if (target == null) { SpaceUnit enemy = EnemyCheck(); if (enemy != null) { target = enemy; foreach (Weapon weapon in weapons) { weapon.Attack(target); } } } if (target != null && state == UnitState.IDLE && (target.position - position).magnitude > startChaseRange) { wayPoints = new Queue<Vector3>(); Vector3 chasePos = target.position + (position - target.position).normalized * chaseRange; wayPoints.Enqueue(chasePos); wayPointRange = defaultWayPointRange; } enemyCheckTimer += enemyCheckInterval; } if (target != null && state == UnitState.IDLE && ((target.position - position).magnitude > enemyCheckRange || (position - standPoint).magnitude > returnRange || false)) { MoveOrder(standPoint, defaultWayPointRange); } }
override public void Attack(SpaceUnit target) { firing = true; this.target = target; }
virtual public void Attack(SpaceUnit target) { // Nothing }
public UnitWingsParentComponent(SpaceUnit parentUnit, UnitData parentUnitData) { Parent = parentUnit; ParentData = parentUnitData; }
public void SetParent(SpaceUnit parent) { parentUnit = parent; }
public void GetKill(SpaceUnit target) { parentUnit.GetKill(target); }
public TargetInfo(SpaceUnit target, Vector2 direction, float rangeSqr) { Target = target; Direction = direction; RangeSqr = rangeSqr; }
public virtual void GetKill(SpaceUnit killedUnit) { }
public virtual void CancelOrders() { Target = null; }