public override bool KeepBehaviorCheck(AiShip leader, AiShip subject) { try { // Optimize -- Make sure the target is the same as the leaders. if (leader.GetTarget() == null) return false; if (leader.GetTarget().gameObject.name != subject.GetTarget().gameObject.name) return false; Attributes subjectStats = subject.getAttributes(); // Get Percent / 100% using cross multiply double health = GetCurrentHealthPercentage(); // comparison of factions may not work, check later. if (health >= 25 && leader.GetTarget() != null) return true; } catch { if (!subject) return false; if (subject.GetMyFleet().fleetLeader is PlayerShip) return false; if (!leader) leader = (AiShip)subject.GetMyFleet().fleetLeader; } return false; }
public override bool KeepBehaviorCheck(AiShip leader, AiShip subject) { // Make sure leader is searching. //Object leaderBehavior = leader.GetBehavior(); //Object SearchBehavior = new Search(null); if (ship.getFleetLeader().GetBehavior() is Search) return true; //subject.SetBehavior(new DoNothing()); return false; }
public void RemoveAI(AiShip inShip) { fleet.Remove(inShip); if (fleetLeader == inShip && fleet.Count > 0) { ChangeLeader(fleet[0]); } CheckRemoveFleet(); }
public override bool KeepBehaviorCheck(AiShip leader, AiShip subject) { Attributes subjectStats = subject.getAttributes(); // Get Percent / 100% using cross multiply double health = GetCurrentHealthPercentage(); // If ship is not damaged and has no target, search. (For Fleet leaders and Solo Ships only). if (health < 65 && subject.Aggressors.Count == 0) return true; return false; }
public override bool KeepBehaviorCheck(AiShip leader, AiShip subject) { //Check if the behavior of the leader is the same as the subject. if (leader.GetBehavior().Equals(subject.GetBehavior()) && leader.ID != subject.ID) return true; AiShip enemyShip = leader.GetTarget().gameObject.GetComponent("AiShip") as AiShip; // For Leaders eyes Only if (leader.GetMyFleet().threat < (enemyShip.GetMyFleet().threat * 10)) return true; return false; }
public override bool KeepBehaviorCheck(AiShip leader, AiShip subject) { hasAggressors = false; Attributes subjectStats = subject.getAttributes(); // Get Percent / 100% using cross multiply double health = GetCurrentHealthPercentage(); if (subject.Aggressors.Count > 0) hasAggressors = true; // If still too close or too damaged, keep running. if (health < 35 && hasAggressors) return true; return false; }
public override bool KeepBehaviorCheck(AiShip leader, AiShip subject) { // Make sure the ship hasn't become the faction leader. if (leader.ID == subject.ID) return false; Attributes subjectStats = subject.getAttributes(); // Get Percent / 100% using cross multiply double health = GetCurrentHealthPercentage(); float distance = Vector3.Magnitude(subject.gameObject.transform.position - leader.gameObject.transform.position); // If still strong enough to fight and is far away from leader, regroup. if (health >= 25 && distance > 1100) return true; return false; }
public override bool KeepBehaviorCheck(AiShip leader, AiShip subject) { // Optimize -- Make sure there is a target first. if (subject.GetTarget() == null) return false; Attributes subjectStats = subject.getAttributes(); // Get Percent / 100% using cross multiply double health = GetCurrentHealthPercentage(); //Debug.Log("MAYBE TRUE"); // comparison of factions may not work, check later. if (health >= 15) return true; Debug.Log("SOLO FALSE"); return false; }
public override bool KeepBehaviorCheck(AiShip leader, AiShip subject) { // Optimize -- Make sure there is a target first. if (subject.GetTarget() == null) return false; Attributes subjectStats = subject.getAttributes(); // Get Percent / 100% using cross multiply double health = GetCurrentHealthPercentage(); AiShip targetShip = subject.GetTarget().gameObject.GetComponent("AiShip") as AiShip; string targetFaction = targetShip.getFaction(); // comparison of factions may not work, check later. if (health >= 25 && subject.getFaction() == targetFaction) return true; return false; }
public override bool KeepBehaviorCheck(AiShip leader, AiShip subject) { Attributes subjectStats = subject.getAttributes(); // Get Percent / 100% using cross multiply double health = (subjectStats.structureHealth * 100) / subjectStats.maxStructureHealth; float distance = 999999999999; // Figure out how far we are from the Aggressors foreach (GameObject go in subject.Aggressors.Keys) { float distanceBetween = Vector3.Magnitude(subject.gameObject.transform.position - go.transform.position); if (distance > distanceBetween) distance = distanceBetween; } // If still too close or too damaged, keep running. if (health < 15 && distance < 15000) return true; return false; }
public override bool KeepBehaviorCheck(AiShip leader, AiShip subject) { if (ship.Aggressors.Count > 0 ) { //Debug.Log("Search has aggressors :: " + ship.name); return false; } if (ship.target != beacon.transform && ship.target != null) { // if (ship.target != beacon.transform) // //Debug.Log("Search has target other than beacon"); // else // //Debug.Log("Search has target is null"); return false; } Attributes subjectStats = subject.getAttributes(); // Get Percent / 100% using cross multiply double health = GetCurrentHealthPercentage(); // If ship is not damaged and has no target, search. (For Fleet leaders and Solo Ships only). if (health >= 75 && subject.GetTarget() == beacon.transform) return true; //Debug.Log("Behavior Not Kept"); return false; }
public AiBehavior DetermineLeaderBehavior(AiShip inLeader) { return null; }
public abstract bool KeepBehaviorCheck(AiShip leader, AiShip subject);
public void SetShip(AiShip inShip) { this.ship = inShip; }
public void Draw(GraphicsDevice graphics, int width, int height, List <AiShip> ships, PlayerShip playerShip) { if (_renderTarget0 == null || _renderTarget0.Width != width || _renderTarget0.Height != height) { _renderTarget0?.Dispose(); _renderTarget1?.Dispose(); _renderTarget0 = new RenderTarget2D(graphics, width, height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents); _renderTarget1 = new RenderTarget2D(graphics, width, height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents); //Clear graphics.SetRenderTarget(_renderTarget0); graphics.Clear(Color.Black); graphics.SetRenderTarget(_renderTarget1); graphics.Clear(Color.Black); } _offframe = !_offframe; graphics.SetRenderTarget(_offframe ? _renderTarget1 : _renderTarget0); //Initialize if (_positions == null) { _positions = new Vector2[ships.Count + 1]; _lastPositions = new Vector2[ships.Count + 1]; _colors = new Vector3[ships.Count + 1]; //Ai ships for (var index = 0; index < ships.Count; index++) { AiShip ship = ships[index]; _colors[index] = ship.ColorV3; _lastPositions[index] = ship.Position; _positions[index] = ship.Position; } //Player ship _colors[ships.Count] = Vector3.One; _lastPositions[ships.Count] = playerShip.Position; _positions[ships.Count] = playerShip.Position; } for (var index = 0; index < ships.Count; index++) { AiShip ship = ships[index]; if (Vector2.DistanceSquared(ship.Position, _lastPositions[index]) > 49) { _lastPositions[index] = _positions[index]; _positions[index] = ship.Position; } } if (Vector2.DistanceSquared(playerShip.Position, _lastPositions[ships.Count]) > 49) { _lastPositions[ships.Count] = _positions[ships.Count]; _positions[ships.Count] = playerShip.Position; } //Colors[0] = Vector3.One; //Positions[0] = Mouse.GetState().Position.ToVector2(); _positionsParam.SetValue(_positions); _lastPositionsParam.SetValue(_lastPositions); _colorsParam.SetValue(_colors); _texParam.SetValue(_offframe ? _renderTarget0 : _renderTarget1); graphics.BlendState = BlendState.Opaque; _trailPass.Apply(); _fsq.RenderFullscreenQuad(graphics); }
public void setFleetLeader(AiShip inShip) { fleetLeader = inShip; }
public override bool KeepBehaviorCheck(AiShip leader, AiShip subject) { //Debug.Log(ship.name + " Checking Behavior for DoNothing @ " + Time.timeSinceLevelLoad); return false; }