Exemplo n.º 1
0
        public override void Live()//Update
        {
            counter++;
            if (Energy > 15000)
            {
                isCharging = false;
                MoveToPosition(MotherNature.LastFrameDuration, goToPosition);//Avance d'un tick en direction de la destination
                CheckFor();
            }
            else
            if (Energy > 5000 && !isCharging)
            {
                MoveToPosition(MotherNature.LastFrameDuration, goToPosition);//Avance d'un tick en direction de la destination
                if ((counter % 3) == 0)
                {
                    CheckFor();
                }
            }
            else
            {
                isCharging = true;
                Resource red = GoToResource(new Point(X, Y), true, true);
                if (red != null)
                {
                    Point goPos = new Point(red.Location.X, red.Location.Y);
                    Speed.X = goPos.X - X;
                    Speed.Y = goPos.Y - Y;
                    bool arrivedToPosition = ((goPos.X - X) < 2 && (goPos.X - X) > -2) && ((goPos.Y - Y) < 2 && (goPos.Y - Y) > -2);
                    bool canMove           = !arrivedToPosition && (Energy > 2000);
                    if (canMove)
                    {
                        Move();
                    }
                    if (arrivedToPosition)
                    {
                        if ((counter % 3) == 0)
                        {
                            Pickup(red);
                        }
                        else
                        {
                            if (!(EatFromBag(1, MotherNature.DigestionFor.Energy)))
                            {
                                DesactivateRessource(red);
                            }
                        }
                    }
                }
            }

            foreach (Ant enemy in EnemiesAroundMe())
            {
                SoldierAnt.PointAnEnemy(enemy, 1);
            }
        }
Exemplo n.º 2
0
        public override void Live()
        {
            double distMin = 5000;

            inc++;
            if (inc == 3)
            {
                foreach (Ant enemy in EnemiesAroundMe())
                {
                    SoldierAnt.PointAnEnemy(enemy, 3);
                }
                inc = 0;
            }

            if (BlockedBy == this)
            {
                Logger.WriteLogFile("RED Je suis bloquer");
            }



            if (BrickBag == 50)
            {
                Speed.X = MyColony.Location.X - X;
                Speed.Y = MyColony.Location.Y - Y;
                Move();
                Logger.WriteLogFile("RED je pose une brique, j'en ai " + BrickBag);
                Build();
                Logger.WriteLogFile("RED j'ai poser une brique, j'en ai " + BrickBag);
            }



            List <Brick> brickpositions = BricksAroundMe();

            if (brickpositions.Count() > 0)
            {
                Brick closest = brickpositions[0];
                foreach (Brick brickporche in brickpositions)
                {
                    if (Helpers.Distance(SDLocation, brickporche.Location) < distMin)
                    {
                        closest = brickporche;
                        distMin = Helpers.Distance(SDLocation, brickporche.Location);
                    }
                }

                int   xPos     = closest.Location.X;
                int   yPos     = closest.Location.Y;
                int   xMyPos   = Convert.ToInt32(X);
                int   yMyPos   = Convert.ToInt32(Y);
                float distance = Math.Abs(xPos - xMyPos) + Math.Abs(yPos - yMyPos);

                if (distance < 2.0f)
                {
                    ScoutAnt.DesactivateRessource(closest);
                    Logger.WriteLogFile("RED patate");
                    Pickup(closest);
                }
                else
                {
                    Speed.X = closest.Location.X - X;
                    Speed.Y = closest.Location.Y - Y;
                    Move();
                }
            }
            else
            {
                Resource procheSelonScouts = ScoutAnt.GoToResource(new Point(X, Y), true, false);

                if (procheSelonScouts != null)
                {
                    goToPosition = new Point(procheSelonScouts.Location.X, procheSelonScouts.Location.Y);
                }


                Speed.X = goToPosition.X - X;
                Speed.Y = goToPosition.Y - Y;
                Move();
            }
            Move();
        }
Exemplo n.º 3
0
        public override void Live()
        {
            tick++;
            if (charging)
            {
                if (MyColony.FoodStore > 1000)
                {
                    EatFromStore(45, MotherNature.DigestionFor.Strength);
                }
                charging = false;
            }
            else
            {
                if (sortirImpasse)
                {
                    if ((tick % 10) == 0)
                    {
                        Random r = new Random();
                        goToPosition = new Point(X + r.Next(-100, 100), Y + r.Next(-100, 100));
                    }
                    Speed.X = goToPosition.X - X;
                    Speed.Y = goToPosition.Y - Y;
                    Move();
                    if ((tick % 25) == 0)
                    {
                        if (BlockedBy == null)
                        {
                            sortirImpasse = false;
                        }
                    }
                }
                bool  attackQueen = false;
                Queen qu          = null;
                foreach (Queen queen in listOfQueen)
                {
                    int distance = Math.Abs(Convert.ToInt32(queen.X) - Convert.ToInt32(X)) + Math.Abs(Convert.ToInt32(queen.Y) - Convert.ToInt32(Y));
                    if (distance < 100)
                    {
                        qu          = queen;
                        attackQueen = true;
                    }
                }
                if (attackQueen)
                {
                    int distance = Math.Abs(Convert.ToInt32(qu.X) - Convert.ToInt32(X)) + Math.Abs(Convert.ToInt32(qu.Y) - Convert.ToInt32(Y));
                    if (distance > 30)
                    {
                        Logger.WriteLogFile("ATTAKING A QUEEN! ( RED COLONY )");
                        Speed.X = qu.X - X;
                        Speed.Y = qu.Y - Y;
                        Move();
                    }
                    else
                    {
                        Logger.WriteLogFile("QUEEN IS DEAD! ( RED COLONY )");
                        qu.Die();
                        listOfQueen.Remove(qu);
                    }


                    /*goToPosition = new Point(qu.X, qu.Y);
                     * int distance = Math.Abs(Convert.ToInt32(goToPosition.X) - Convert.ToInt32(X)) + Math.Abs(Convert.ToInt32(goToPosition.Y) - Convert.ToInt32(Y));
                     * if (distance < 40)
                     * {
                     *  Hit(enemyToTarget);
                     *  Logger.WriteLogFile("RED COLONY FORCE: ATTAQUE :" + enemyToTarget.Fullname + " PV:" + enemyToTarget.Energy + " Distance" + distance);
                     * }
                     * else
                     * {
                     *  Speed.X = goToPosition.X - X;
                     *  Speed.Y = goToPosition.Y - Y;
                     *  Move();
                     * }*/
                }
                else
                {
                    if (enemyRepered.Count > 0)
                    {
                        if (enemyToTarget == null || enemyToTarget.Energy < 1 || ((tick % 7) == 0))
                        {
                            /*SELECT PART*/
                            int   optimal    = 0;
                            int   counter    = 0;
                            float importance = 0;
                            int   distLast   = 100000;

                            foreach (EnemyListedActu enemyTest in enemyRepered)
                            {
                                if (enemyTest.importance > importance)
                                {
                                    if (enemyTest.fourmis.Energy >= 0)
                                    {
                                        importance = enemyTest.importance;
                                        optimal    = counter;
                                    }
                                }
                                if (enemyTest.importance == importance)
                                {
                                    int distActu = Math.Abs(Convert.ToInt32(enemyTest.fourmis.X) - Convert.ToInt32(X)) + Math.Abs(Convert.ToInt32(enemyTest.fourmis.Y) - Convert.ToInt32(Y));
                                    if (distLast >= distActu)
                                    {
                                        if (enemyTest.fourmis.Energy >= 0)
                                        {
                                            importance = enemyTest.importance;
                                            optimal    = counter;
                                        }
                                    }
                                }
                                counter++;
                            }
                            enemyToTarget = enemyRepered[optimal].fourmis;
                        }
                        if (BlockedBy != null)
                        {
                            sortirImpasse = true;
                        }
                        else
                        {
                            goToPosition = new Point(enemyToTarget.X, enemyToTarget.Y);
                        }
                        int distance = Math.Abs(Convert.ToInt32(goToPosition.X) - Convert.ToInt32(X)) + Math.Abs(Convert.ToInt32(goToPosition.Y) - Convert.ToInt32(Y));
                        if (distance < 40)
                        {
                            Hit(enemyToTarget);
                            Logger.WriteLogFile("RED COLONY FORCE: ATTAQUE :" + enemyToTarget.Fullname + " PV:" + enemyToTarget.Energy + " Distance" + distance);
                        }
                        else
                        {
                            Speed.X = goToPosition.X - X;
                            Speed.Y = goToPosition.Y - Y;
                            Move();
                        }
                    }
                    else
                    {
                        goToPosition = pointOfAction;
                        int distance = Math.Abs(Convert.ToInt32(goToPosition.X) - Convert.ToInt32(X)) + Math.Abs(Convert.ToInt32(goToPosition.Y) - Convert.ToInt32(Y));
                        if (distance > 40)
                        {
                            if (BlockedBy != null)
                            {
                                sortirImpasse = true;
                            }
                            Speed.X = goToPosition.X - X;
                            Speed.Y = goToPosition.Y - Y;
                            Move();
                        }
                    }
                }
                if ((tick % 3) == 0)
                {
                    foreach (Ant enemy in EnemiesAroundMe())
                    {
                        SoldierAnt.PointAnEnemy(enemy, 2);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public override void Live()
        {
            inc++;
            if (inc == 3)
            {
                foreach (Ant enemy in EnemiesAroundMe())
                {
                    SoldierAnt.PointAnEnemy(enemy, 4);     // defense
                }
                inc = 0;
            }

            if (Energy < 20000)
            {
                nouriture = 1;
            }

            if (nouriture > 0)
            {
                EatFromBag(2, MotherNature.DigestionFor.Energy);
                nouriture++;
                if (nouriture == 10)
                {
                    nouriture = 0;
                }
            }
            if (BlockedBy != null && unblock < 15)
            {
                Move();
                unblock++;
            }
            else
            {
                unblock = 0;

                if (FoodBag > 48)
                {
                    if (X != MyColony.Location.X && Y != MyColony.Location.Y)
                    {
                        Speed.X = MyColony.Location.X - X;
                        Speed.Y = MyColony.Location.Y - Y;
                        Move();
                    }
                    else
                    {
                        canDumpFood = true;
                    }
                }
                if (canDumpFood == true)
                {
                    MyColony.DumpFood(this);        //drop food
                    if (FoodBag < 4)
                    {
                        canDumpFood = false;
                    }
                }
                else
                {
                    List <Food> foodposition = FoodAroundMe();
                    if (foodposition.Count() > 0)
                    {
                        Food closest = foodposition[0];
                        foreach (Food foodproche in foodposition)   //find zone
                        {
                            if (Helpers.Distance(SDLocation, foodproche.Location) < disMin)
                            {
                                closest = foodproche;
                                disMin  = Helpers.Distance(SDLocation, foodproche.Location);
                            }
                        }
                        int   xPos     = closest.Location.X;
                        int   yPos     = closest.Location.Y;
                        int   xMyPos   = Convert.ToInt32(X);
                        int   yMyPos   = Convert.ToInt32(Y);
                        float distance = Math.Abs(xPos - xMyPos) + Math.Abs(yPos - yMyPos);

                        if (distance < 2.0f)
                        {
                            ScoutAnt.DesactivateRessource(closest);
                            Pickup(closest);
                        }
                        else
                        {
                            Speed.X = closest.Location.X - X;
                            Speed.Y = closest.Location.Y - Y;
                            Move();
                        }
                    }
                    else
                    {
                        Resource procheSelonScouts = ScoutAnt.GoToResource(new Point(X, Y), true, true);

                        if (procheSelonScouts != null)
                        {
                            goToPosition = new Point(procheSelonScouts.Location.X, procheSelonScouts.Location.Y);
                        }


                        Speed.X = goToPosition.X - X;
                        Speed.Y = goToPosition.Y - Y;
                        Move();
                    }
                }
            }
        }