示例#1
0
 private void CeaseFire()
 {
     _isShooting = false;
     _target     = null;
     _sightList.Clear();
     _isFollowing = false;
 }
示例#2
0
 private void Shoot(AIObject attack_aiobj)
 {
     if (_target != null)
     {
         _isShooting = true;
     }
 }
示例#3
0
 public void Select(AIObject item)
 {
     ClearSelect();
     _selectedObject = item;
     _selectedTeam   = item.Team;
     item.Selected   = true;
 }
示例#4
0
 public void ClearSelect()
 {
     foreach (AIObject aiobj in _aiobjects)
     {
         aiobj.Selected = false;
     }
     _selectedObject = null;
     _selectedTeam   = null;
 }
示例#5
0
 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);
 }
示例#6
0
 public bool Sees(AIObject seen_aiobj)
 {
     foreach (SeenAIObject obj in _sightList)
     {
         if (obj.aiobj == seen_aiobj)
         {
             return(true);
         }
     }
     return(false);
 }
示例#7
0
 private bool PreviousStateContains(AIObject aiobj)
 {
     foreach (AIObject obj in _aiobjects_prev)
     {
         if (obj == aiobj)
         {
             return(true);
         }
     }
     return(false);
 }
示例#8
0
 public bool IsAllowedToEnter(AIObject aiobj)
 {
     if (IsEmpty)
     {
         return(true);
     }
     else
     {
         //    return aiobj.Team.TeamType == TeamInside;
         return(false);
     }
 }
示例#9
0
        public AIStatic GetActualCover(AIObject aiobj)
        {
            AIStatic actual = GetNearestStatic(aiobj.Position, AIStaticType.Cover);

            if (actual.IsObjectLocatedInside(aiobj))
            {
                return(actual);
            }
            else
            {
                return(null);
            }
        }
示例#10
0
        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));
        }
示例#11
0
        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;
                    }
                }
            }
        }
示例#12
0
 public void Follow(AIObject aiobj_to_follow)
 {
     _target      = aiobj_to_follow;
     _isFollowing = true;
 }
示例#13
0
        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;
                    }
                }
            }
        }
示例#14
0
文件: AIObject.cs 项目: siupa/AIGame
 public void Follow(AIObject aiobj_to_follow)
 {
     _target = aiobj_to_follow;
     _isFollowing = true;
 }
示例#15
0
 public bool ObjectJustArrived(AIObject aiobj)
 {
     return(!PreviousStateContains(aiobj) && _aiobjects.Contains(aiobj));
 }
示例#16
0
 public AIStatic GetActualCover(AIObject aiobj)
 {
     AIStatic actual = GetNearestStatic(aiobj.Position, AIStaticType.Cover);
     if (actual.IsObjectLocatedInside(aiobj))
         return actual;
     else
         return null;
 }
示例#17
0
文件: AIObject.cs 项目: siupa/AIGame
 private void Shoot(AIObject attack_aiobj)
 {
     if (_target != null)
     {
         _isShooting = true;
     }
 }
示例#18
0
 public bool IsObjectLocatedInside(AIObject aiobj)
 {
     return((this.Position - aiobj.Position).Length() <= _radius);
 }
示例#19
0
文件: AIObject.cs 项目: siupa/AIGame
        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);
        }
示例#20
0
文件: AIObject.cs 项目: siupa/AIGame
 private void CeaseFire()
 {
     _isShooting = false;
     _target = null;
     _sightList.Clear();
     _isFollowing = false;
 }
示例#21
0
文件: AIObject.cs 项目: siupa/AIGame
 public bool Sees(AIObject seen_aiobj)
 {
     foreach (SeenAIObject obj in _sightList)
     {
         if (obj.aiobj == seen_aiobj)
             return true;
     }
     return false;
 }
示例#22
0
        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);
                    }
                }
            }
        }
示例#23
0
文件: AIObject.cs 项目: siupa/AIGame
 public SeenAIObject(float dist, AIObject obj)
 {
     distance = dist;
     aiobj = obj;
 }
示例#24
0
 public void ClearSelect()
 {
     foreach (AIObject aiobj in _aiobjects)
         aiobj.Selected = false;
     _selectedObject = null;
     _selectedTeam = null;
 }
示例#25
0
文件: AIStatic.cs 项目: siupa/AIGame
 private bool PreviousStateContains(AIObject aiobj)
 {
     foreach (AIObject obj in _aiobjects_prev)
     {
         if (obj == aiobj)
             return true;
     }
     return false;
 }
示例#26
0
 public void Select(AIObject item)
 {
     ClearSelect();
     _selectedObject = item;
     _selectedTeam = item.Team;
     item.Selected = true;
 }
示例#27
0
文件: AIStatic.cs 项目: siupa/AIGame
 public bool IsAllowedToEnter(AIObject aiobj)
 {
     if (IsEmpty)
         return true;
     else
         //    return aiobj.Team.TeamType == TeamInside;
         return false;
 }
示例#28
0
文件: AIStatic.cs 项目: siupa/AIGame
 public bool IsObjectLocatedInside(AIObject aiobj)
 {
     return (this.Position - aiobj.Position).Length() <= _radius;
 }
示例#29
0
文件: AIObject.cs 项目: siupa/AIGame
 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);
 }
示例#30
0
文件: AIStatic.cs 项目: siupa/AIGame
 public bool ObjectJustArrived(AIObject aiobj)
 {
     return !PreviousStateContains(aiobj) && _aiobjects.Contains(aiobj);
 }
示例#31
0
文件: AIStatic.cs 项目: siupa/AIGame
 public bool ObjectJustLeft(AIObject aiobj)
 {
     return PreviousStateContains(aiobj) && !_aiobjects.Contains(aiobj);
 }
示例#32
0
 public bool ObjectJustLeft(AIObject aiobj)
 {
     return(PreviousStateContains(aiobj) && !_aiobjects.Contains(aiobj));
 }
示例#33
0
 public SeenAIObject(float dist, AIObject obj)
 {
     distance = dist;
     aiobj    = obj;
 }