Exemplo n.º 1
0
 public void ActivateTeam(Colony.AntTeams team, Vector2 pos)
 {
     ChangeTeam(team);
     base.Activate();
     this._Position = pos;
     this.SetOrbitPoint(pos);
     ChangeOrbit();
 }
Exemplo n.º 2
0
 public void AddAnt(Colony.AntTeams team, Vector2 pos, int amt = 1)
 {
     for (int i = 0; i < amt; i++)
     {
         AntList.Find(x => x._CurrentState == Sprite.SpriteState.kStateInActive)
         .ActivateTeam(team, pos);
     }
 }
Exemplo n.º 3
0
        public List <Colony> FindColoniesNear(Vector2 pos, Colony.AntTeams team, int range = 15)
        {
            List <Colony> colonies = new List <Colony>();

            colonies.AddRange(ColonyList.FindAll(x => x.myTeam != team && x._CurrentState == Sprite.SpriteState.kStateActive));

            //got active ants not on the sent in team
            List <Colony> ColonyInRange = new List <Colony>();

            ColonyInRange.AddRange(colonies.FindAll(x => x._Position.X >= (pos.X - range) &&
                                                    x._Position.X <= (pos.X + range) &&
                                                    x._Position.Y >= (pos.Y - range) &&
                                                    x._Position.Y <= (pos.Y + range)));
            return(ColonyInRange);
        }
Exemplo n.º 4
0
        private List <Ant> FindAntsNear(Vector2 pos, Colony.AntTeams team, int range = 15)
        {
            List <Ant> ants = new List <Ant>();

            ants.AddRange(ActiveAnts.FindAll(x => x.myTeam != team));

            //got active ants not on the sent in team
            List <Ant> antsInRange = new List <Ant>();

            antsInRange.AddRange(ants.FindAll(x => x._Position.X >= (pos.X - range) &&
                                              x._Position.X <= (pos.X + range) &&
                                              x._Position.Y >= (pos.Y - range) &&
                                              x._Position.Y <= (pos.Y + range)));
            return(antsInRange);
        }
Exemplo n.º 5
0
        public Colony FindClosestColony(Vector2 pos, Colony.AntTeams team)
        {
            Colony closest = ColonyList.Find(x => x._CurrentState == Sprite.SpriteState.kStateActive && x.myTeam == team);
            float  dist    = Vector2.Distance(pos, closest._Position);

            foreach (Colony c in ColonyList.FindAll(x => x._CurrentState == Sprite.SpriteState.kStateActive && x.myTeam == team))
            {
                if (Vector2.Distance(pos, c._Position) < dist)
                {
                    dist    = Vector2.Distance(pos, c._Position);
                    closest = c;
                }
            }

            return(closest);
        }
Exemplo n.º 6
0
        public void ChangeTeam(Colony.AntTeams team)
        {
            myTeam = team;
            if (team == Colony.AntTeams.kTeamBrown)
            {
                this._Texture = _BrownTex;
            }
            else if (team == Colony.AntTeams.kTeamGreen)
            {
                this._Texture = _GreenTex;
            }
            else if (team == Colony.AntTeams.kTeamNone)
            {
                this._Texture = _NoneTex;
            }


            frameHeight = _Texture.Height;
            frameWidth  = _Texture.Width;
        }
Exemplo n.º 7
0
 public void PlaceColony(Vector2 pos, Colony.AntTeams team)
 {
     ColonyList.Find(x => x._CurrentState == Sprite.SpriteState.kStateInActive)
     .ActivateTeam(team, pos);
 }
Exemplo n.º 8
0
 public List <Colony> GetColoniesOnTeam(Colony.AntTeams team)
 {
     return(ColonyList.FindAll(x => x._CurrentState == Sprite.SpriteState.kStateActive && x.myTeam == team));
 }
Exemplo n.º 9
0
        protected override void UpdateActive(GameTime gt)
        {
            currentAnts = 0;
            List <Ant> attchedAnts = new List <Ant>();
            int        GreenCount  = 0;
            int        BrownCount  = 0;
            double     speed       = 50;

            foreach (Ant a in antsAttached)
            {
                if (a._BoundingBox.Intersects(this._BoundingBox))
                {
                    currentAnts++;
                    attchedAnts.Add(a);
                    if (a.myTeam == Colony.AntTeams.kTeamBrown)
                    {
                        BrownCount++;
                    }
                    else if (a.myTeam == Colony.AntTeams.kTeamGreen)
                    {
                        GreenCount++;
                    }
                }
            }
            antsAttached.Clear();
            antsAttached.AddRange(attchedAnts);

            bool flipped = false;

            if (GreenCount > BrownCount)
            {
                if (myTeam == Colony.AntTeams.kTeamBrown)
                {
                    flipped = true;
                }
                myTeam = Colony.AntTeams.kTeamGreen;
            }
            else if (BrownCount > GreenCount)
            {
                if (myTeam == Colony.AntTeams.kTeamGreen)
                {
                    flipped = true;
                }
                myTeam = Colony.AntTeams.kTeamBrown;
            }


            if (currentAnts >= 1)
            {
                speed = (currentAnts / weight) * 50;

                if (speed > 50)
                {
                    speed = 50;
                }
                if (!FindColony && targetColony == null)
                {
                    FindColony = true;
                }


                if (currentAnts >= (weight * 2))
                {
                    speed *= 2;
                }
                if (targetColony != null)
                {
                    if (targetColony._Position.X < this._Position.X)
                    {
                        this._Position.X -= (float)(speed * gt.ElapsedGameTime.TotalSeconds);
                    }
                    else
                    {
                        this._Position.X += (float)(speed * gt.ElapsedGameTime.TotalSeconds);
                    }

                    if (targetColony._Position.Y < this._Position.Y)
                    {
                        this._Position.Y -= (float)(speed * gt.ElapsedGameTime.TotalSeconds);
                    }
                    else
                    {
                        this._Position.Y += (float)(speed * gt.ElapsedGameTime.TotalSeconds);
                    }

                    if (this._BoundingBox.Intersects(targetColony._BoundingBox))
                    {
                        atColony = true;
                    }
                }
            }
            base.UpdateActive(gt);
        }
Exemplo n.º 10
0
 public List <Ant> GetAntsOnTeam(Colony.AntTeams team)
 {
     return(ActiveAnts.FindAll(x => x.myTeam == team));
 }