Пример #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);