예제 #1
0
 public void FairePromotions()
 {
     for (int i = 0; i < TAILLE; i++)
     {
         if (Grille[i, 0] is Pion && !Grille[i, 0].EstBlanc)
         {
             Grille[i, 0] = new Dame(false);
             return; //micro-optimisation, si on appelle cette fonction à la fin de chaque tour
         }
         if (Grille[i, TAILLE - 1] is Pion && Grille[i, TAILLE - 1].EstBlanc)
         {
             Grille[i, TAILLE - 1] = new Dame(true);
         }
     }
 }
예제 #2
0
    public void SetUpOpponent(string piece, int number)
    {
        Piece  p  = null;
        Sprite sp = null;

        switch (piece)
        {
        case "Pion":
        {
            p = new Pion();
            if (manager.playerColor == Tile.Colors.Blanc)
            {
                sp = PionNoir;
            }
            else
            {
                sp = PionBlanc;
            }
            break;
        }

        case "Tour":
        {
            p = new Tour();
            if (manager.playerColor == Tile.Colors.Blanc)
            {
                sp = TourNoir;
            }
            else
            {
                sp = TourBlanc;
            }
            break;
        }

        case "Cavalier":
        {
            p = new Cavalier();
            if (manager.playerColor == Tile.Colors.Blanc)
            {
                sp = CavalierNoir;
            }
            else
            {
                sp = CavalierBlanc;
            }
            break;
        }

        case "Fou":
        {
            p = new Fou();
            if (manager.playerColor == Tile.Colors.Blanc)
            {
                sp = FouNoir;
            }
            else
            {
                sp = FouBlanc;
            }
            break;
        }

        case "Dame":
        {
            p = new Dame();
            if (manager.playerColor == Tile.Colors.Blanc)
            {
                sp = DameNoir;
            }
            else
            {
                sp = DameBlanc;
            }
            break;
        }
        }

        switch (number)
        {
        case 1:
        {
            OppP1 = p;
            OppP1Sprite.sprite = sp;
            break;
        }

        case 2:
        {
            OppP2 = p;
            OppP2Sprite.sprite = sp;
            break;
        }

        case 3:
        {
            OppP3 = p;
            OppP3Sprite.sprite = sp;
            break;
        }
        }
    }
예제 #3
0
    public Echiquier(int[] tabVal)
    {
        tab = new Piece[8, 8];

        for (int i = 0; i < tabVal.Length; i++)
        {
            int y = i >> 3; //optimisation
            int x = (i & (8 - 1));
            //match all white pawns
            switch (tabVal[i])
            {
            case PP:
            case P:
                tab[x, y] = new Pion(false, x, y, this);
                mine.Add(tab[x, y]);
                break;

            case TG:
            case TD:
                tab[x, y] = new Tour(false, x, y, this);
                mine.Add(tab[x, y]);
                break;

            case CG:
            case CD:
                tab[x, y] = new Cavalier(false, x, y, this);
                mine.Add(tab[x, y]);
                break;

            case F:
                tab[x, y] = new Fou(false, x, y, this);
                mine.Add(tab[x, y]);
                break;

            case D:
                tab[x, y] = new Dame(false, x, y, this);
                mine.Add(tab[x, y]);
                break;

            case R:

                tab[x, y] = new Roi(false, x, y, this);
                mine.Add(tab[x, y]);
                break;

            case -PP:
            case -P:
                tab[x, y] = new PionNoir(true, x, y, this);
                yours.Add(tab[x, y]);
                break;

            case -TG:
            case -TD:
                tab[x, y] = new Tour(true, x, y, this);
                yours.Add(tab[x, y]);
                break;

            case -CG:
            case -CD:
                tab[x, y] = new Cavalier(true, x, y, this);
                yours.Add(tab[x, y]);
                break;

            case -F:
                tab[x, y] = new Fou(true, x, y, this);
                yours.Add(tab[x, y]);
                break;

            case -D:
                tab[x, y] = new Dame(true, x, y, this);
                yours.Add(tab[x, y]);
                break;

            case -R:

                tab[x, y] = new Roi(true, x, y, this);
                yours.Add(tab[x, y]);
                break;

            default:
                tab[x, y] = new Piece(0, true, x, y, this);
                break;
            }
        }
    }