예제 #1
0
        Unite getPosUnite(Position a)
        {
            Unite[] items = Unites();
            foreach (Unite t in items)
                if (cmpPos(t.Pos, a))
                    return t;

            throw new Exception(); //No unit
        }
예제 #2
0
 bool cmpPos(Position a, Position b)
 {
     return a.X == b.X && a.Y == b.Y;
 }
예제 #3
0
 int distPos(Position a, Position b)
 {
     return Math.Max(Math.Abs(a.X - b.X), Math.Abs(a.Y - b.Y));
 }
예제 #4
0
 public static extern Erreur AcheterObjet(Position cible, TypeObjet objet);
예제 #5
0
 public static extern Erreur Deguisement(Position cible, TypeUnite nouveau_type);
예제 #6
0
 public static extern Erreur Deplacer(Position cible, Position pos);
예제 #7
0
        public int Valeur; // <- la valeur de la piece.

        #endregion Fields

        #region Constructors

        public Piece()
        {
            PosPiece = new Position();
        }
예제 #8
0
 public static extern Erreur Enrouler(int id, Position point);
예제 #9
0
 public static extern Erreur Fusionner(int id1, Position pos1, int id2, Position pos2);
예제 #10
0
 public static extern Erreur CouperTraineeMoto(int id, Position entre, Position et);
예제 #11
0
 public static extern Erreur Deplacer(int id, Position de, Position vers);
예제 #12
0
 public static extern Erreur Attaquer(Position attaquant, Position cible);
예제 #13
0
 public static extern Erreur Relever(Position cible);
예제 #14
0
 public static extern Erreur Potion(Position cible);
예제 #15
0
        Position minDistPos(Position a, Position b, Position goalPos)
        {
            Position re = new Position();

            if (distPos(goalPos, a) > distPos(goalPos, b))
            {
                re.X = b.X;
                re.Y = b.Y;
            }
            else
            {
                re.X = a.X;
                re.Y = a.Y;
            }

            return re;
        }
예제 #16
0
 public static extern Erreur PoserPointCroisement(Position point);
예제 #17
0
        public void Jouer()
        {
            Unite[] tmpu = Unites();
            Unite uTiti = new Unite();    //Prevent warning
            foreach (Unite item in tmpu)
                if (item.Ennemi && item.VraiTypeUnite == TypeUnite.PERROQUET)
                {
                    uTiti = item;
                    break;
                }
            bool MADE_ACTIONS = true;
            while (NombrePc() > 0 && MADE_ACTIONS)
            {
                    Unite[] t = Unites();
                    MADE_ACTIONS = false;
                    if (t.Length > 0)
                    {
                        Unite min = null;
                        foreach (Unite item in t)
                            if (!item.Ennemi && item.VraiTypeUnite == item.TypeUniteActuel &&
                                 item.TypeUniteActuel == TypeUnite.CHAT && item.Ko < 0 && item.Pa > 0)
                                if (min != null)
                                    min = getPosUnite(minDistPos(min.Pos, item.Pos, uTiti.Pos));  //Seeking the closest cat to ennemy's titi
                                else
                                    min = item;

                        if (min != null)
                            if (distPos(min.Pos, uTiti.Pos) == 1 && Attaquer(min.Pos, uTiti.Pos) == Erreur.OK)
                                break;  //We wone
                            else    //We have to move our cat to the closest position to titi
                            {
                                Position closest = new Position();
                                closest.X = min.Pos.X;
                                closest.Y = min.Pos.Y;
                                TailleTerrain mapbound = TailleTerrainActuelle();
                                int minx = (min.Pos.X - min.Pa) >= mapbound.MinCoord ? min.Pos.X - min.Pa : mapbound.MinCoord;
                                int minyI = (min.Pos.Y - min.Pa) >= mapbound.MinCoord ? min.Pos.Y - min.Pa : mapbound.MinCoord;

                                int maxx = (min.Pos.X + min.Pa) < mapbound.MaxCoord ? min.Pos.X + min.Pa : mapbound.MaxCoord;
                                int maxy = (min.Pos.Y + min.Pa) < mapbound.MaxCoord ? min.Pos.Y + min.Pa : mapbound.MaxCoord;
                                for (; minx < maxx; minx++)
                                    for (int miny = minyI; miny < maxy; miny++)
                                    {
                                        Position tmppos = new Position();
                                        tmppos.X = minx;
                                        tmppos.Y = miny;
                                        try
                                        {
                                            getPosUnite(tmppos); //Will throw an error in case of no Unite
                                        }
                                        catch
                                        {
                                            closest = minDistPos(closest, tmppos, uTiti.Pos);
                                        }
                                    }
                                if (!cmpPos(min.Pos, closest))
                                {
                                        Deplacer(min.Pos, closest);
                                        MADE_ACTIONS = true;
                                }
                            }
                    }
            }
            try
            {
                Unite uniteonspawn = getPosUnite(PosRenfort(false));
                if (uniteonspawn.VraiTypeUnite == TypeUnite.PERROQUET)
                {
                    Position newpos = new Position();
                    newpos.X = uniteonspawn.Pos.X;
                    newpos.Y = uniteonspawn.Pos.Y;
                    newpos.X--;
                    Deplacer(uniteonspawn.Pos, newpos);
                }
            }
            catch
            {
                Renfort(TypeUnite.CHAT);      //Will be available next turn
            }
        }
예제 #18
0
 public static extern TypeBonus RegarderTypeBonus(Position pos);
예제 #19
0
 public static extern Erreur Utiliser(Position attaquant, Position cible);
예제 #20
0
 public static extern TypeCase RegarderTypeCase(Position pos);
예제 #21
0
        public int Team; // <- donne l'equipe du joueur

        #endregion Fields

        #region Constructors

        public Unite()
        {
            PosUnite = new Position();
        }
예제 #22
0
        public Position Pos; // <- position de la source d'énergie

        #endregion Fields

        #region Constructors

        public SourceEnergie()
        {
            Pos = new Position();
        }
예제 #23
0
 public static extern void AfficherPosition(Position v);
예제 #24
0
 public static extern Erreur Banzai(Position cible);