private void CeaseFire() { _isShooting = false; _target = null; _sightList.Clear(); _isFollowing = false; }
private void Shoot(AIObject attack_aiobj) { if (_target != null) { _isShooting = true; } }
public void Select(AIObject item) { ClearSelect(); _selectedObject = item; _selectedTeam = item.Team; item.Selected = true; }
public void ClearSelect() { foreach (AIObject aiobj in _aiobjects) { aiobj.Selected = false; } _selectedObject = null; _selectedTeam = null; }
public void Attack(AIObject attack_aiobj) { this.Status = AIMovementStatus.Run; _target = attack_aiobj; _holdFire = false; Follow(attack_aiobj); Shoot(attack_aiobj); _actualAction = AIAction.Attack; OccupyBy(AIAction.Attack); }
public bool Sees(AIObject seen_aiobj) { foreach (SeenAIObject obj in _sightList) { if (obj.aiobj == seen_aiobj) { return(true); } } return(false); }
private bool PreviousStateContains(AIObject aiobj) { foreach (AIObject obj in _aiobjects_prev) { if (obj == aiobj) { return(true); } } return(false); }
public bool IsAllowedToEnter(AIObject aiobj) { if (IsEmpty) { return(true); } else { // return aiobj.Team.TeamType == TeamInside; return(false); } }
public AIStatic GetActualCover(AIObject aiobj) { AIStatic actual = GetNearestStatic(aiobj.Position, AIStaticType.Cover); if (actual.IsObjectLocatedInside(aiobj)) { return(actual); } else { return(null); } }
private bool IsInRange(AIObject aiobj) { // check if the object is on a proper side of the view matrix Vector3 v1 = ViewDirection; Vector3 v2 = Target.Position - Position; v1.Normalize(); v2.Normalize(); if (Vector3.Dot(v1, v2) < 0) { return(false); } return ((aiobj.Position - Position).Length() <= _sightRange && Sees(aiobj)); }
public void SelectTeam(AITeamType team) { ClearSelect(); foreach (AITeam t in _teams) { if (t.TeamType == team) { _selectedTeam = t; } } foreach (AIObject aiobj in _aiobjects) { if (aiobj.Team == _selectedTeam) { aiobj.Selected = true; if (aiobj.IsLeader) { _selectedObject = aiobj; aiobj.Selected = true; } } } }
public void Follow(AIObject aiobj_to_follow) { _target = aiobj_to_follow; _isFollowing = true; }
public void SelectTeam(AITeamType team) { ClearSelect(); foreach (AITeam t in _teams) { if(t.TeamType == team) _selectedTeam = t; } foreach (AIObject aiobj in _aiobjects) { if (aiobj.Team == _selectedTeam) { aiobj.Selected = true; if (aiobj.IsLeader) { _selectedObject = aiobj; aiobj.Selected = true; } } } }
public bool ObjectJustArrived(AIObject aiobj) { return(!PreviousStateContains(aiobj) && _aiobjects.Contains(aiobj)); }
public AIStatic GetActualCover(AIObject aiobj) { AIStatic actual = GetNearestStatic(aiobj.Position, AIStaticType.Cover); if (actual.IsObjectLocatedInside(aiobj)) return actual; else return null; }
public bool IsObjectLocatedInside(AIObject aiobj) { return((this.Position - aiobj.Position).Length() <= _radius); }
private bool IsInRange(AIObject aiobj) { // check if the object is on a proper side of the view matrix Vector3 v1 = ViewDirection; Vector3 v2 = Target.Position - Position; v1.Normalize(); v2.Normalize(); if (Vector3.Dot(v1, v2) < 0) return false; return (aiobj.Position - Position).Length() <= _sightRange && Sees(aiobj); }
public bool Sees(AIObject seen_aiobj) { foreach (SeenAIObject obj in _sightList) { if (obj.aiobj == seen_aiobj) return true; } return false; }
private void UpdateInput() { MouseState mouseState = Mouse.GetState(); // SELECT if (AIGame.LeftButtonJustPressed()) { bool was_selected = false; foreach (AIObject aiobj in _aiobjects) { Ray pickRay = MathExtra.CalculateCursorRay(AIGame.camera.ProjectionMatrix, AIGame.camera.ViewMatrix); float?rayLength = aiobj.BoundingBox.Intersects(pickRay); if (rayLength != null) { if (Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift)) { SelectTeam(aiobj.Team.TeamType); aiobj.Team.OperateAsAUnit = true; } else { Select(aiobj); } was_selected = true; } } if (!was_selected) { ClearSelect(); } } // MOVE OR ATTACK if (AIGame.RightButtonJustPressed() && AIGame.camera.CurrentBehavior == Camera.Behavior.FreeView) { if (_selectedObject == null) { return; } AIObject temp_aiobj = null; float? rayLength; foreach (AIObject aiobj in _aiobjects) { Ray pickRay = MathExtra.CalculateCursorRay(AIGame.camera.ProjectionMatrix, AIGame.camera.ViewMatrix); rayLength = aiobj.BoundingBox.Intersects(pickRay); if (rayLength != null) { temp_aiobj = aiobj; } } _selectedObject.CancelPreviousActions(); // only move if (temp_aiobj == null) { _selectedObject.MoveTo(AIGame.terrain.groundCursorPosition * Settings.TERRAIN_TEXTURE_SIZE); if (_selectedObject.IsLeader && _selectedTeam.KeepFormation && _selectedTeam.Formation != AIFormation.Spread) { _selectedTeam.ToFormation(_selectedTeam.Formation); } if (_selectedTeam.KeepFormation && _selectedObject == _selectedTeam.Leader) { if (_selectedTeam.Leader.HasJustStopped) { _selectedTeam.ToFormation(_selectedTeam.Formation); } } _selectedObject.IsFollowing = false; _selectedObject.Target = null; } // attack else { if (_selectedObject.Team != temp_aiobj.Team) { _selectedObject.Attack(temp_aiobj); } else { _selectedObject.Follow(temp_aiobj); } } } }
public SeenAIObject(float dist, AIObject obj) { distance = dist; aiobj = obj; }
public void ClearSelect() { foreach (AIObject aiobj in _aiobjects) aiobj.Selected = false; _selectedObject = null; _selectedTeam = null; }
private bool PreviousStateContains(AIObject aiobj) { foreach (AIObject obj in _aiobjects_prev) { if (obj == aiobj) return true; } return false; }
public bool IsAllowedToEnter(AIObject aiobj) { if (IsEmpty) return true; else // return aiobj.Team.TeamType == TeamInside; return false; }
public bool IsObjectLocatedInside(AIObject aiobj) { return (this.Position - aiobj.Position).Length() <= _radius; }
public bool ObjectJustArrived(AIObject aiobj) { return !PreviousStateContains(aiobj) && _aiobjects.Contains(aiobj); }
public bool ObjectJustLeft(AIObject aiobj) { return PreviousStateContains(aiobj) && !_aiobjects.Contains(aiobj); }
public bool ObjectJustLeft(AIObject aiobj) { return(PreviousStateContains(aiobj) && !_aiobjects.Contains(aiobj)); }