예제 #1
0
    public static void Play(Point point, int player)
    {
        if (PlayablePoint.Contains(point))
        {
            int   UP            = 0;
            Point pointAudessus = point.Neighbor(UP);
            PlayablePoint.Remove(point);
            if (BoardPoint.Contains(pointAudessus))
            {
                PlayablePoint.Add(pointAudessus);
            }

            // mise à jour de DicoPointPawn
            Pawn pawn = DicoPointPawn[point];
            pawn.SetColor(Couleurs[player]);
            pawn.SetPlayer(player);
            DicoPointPawn.Remove(point);
            DicoPointPawn.Add(point, pawn);

            /*
             * // visualisation de PlayablePoint, pour debug
             * foreach (Point p in PlayablePoint) {
             *  DicoPointPawn[p].SetColor(Couleurs[playable]);
             *  }
             */

            // mise à jour de PlayedPoint
            PlayedPoint.Add(point);
        }
    }
예제 #2
0
    // end of start()

    public static void SetNewGame()
    {
        // remise des pions de Board à leur couleur de base
        foreach (Point point in BoardPoint)
        {
            Pawn pawn = DicoPointPawn[point];
            SetColor(pawn, boardColor);
        }

        // purge des coups déjà joués
        PlayedPoint.Clear();

        // purge de la liste des Points Playable
        PlayablePoint.Clear();

        // création de la liste des Points Playable
        foreach (Point point in BoardPoint)
        {
            if (point.q == 0)
            {
                PlayablePoint.Add(point);
                Pawn pawn = DicoPointPawn[point];
                //SetColor(pawn, Color.white);
            }
        }
        IsRunningGame = true;
        GameOver      = false;
    }
예제 #3
0
 public static void SetColor(Pawn pawn, Color color)
 {
     if (pawn.myGO != null)
     {
         pawn.myGO.GetComponent <Renderer>().material.SetColor("_Color", color);
     }
 }
예제 #4
0
 public static void SetColor(List <Point> liste, Color color)
 {
     foreach (Point point in liste)
     {
         if (DicoPointPawn.ContainsKey(point))
         {
             Pawn pawn = DicoPointPawn[point];
             SetColor(pawn, color);
         }
     }
 }
예제 #5
0
    public static string ToString(Point point)
    {
        string stringToReturn = "";

        if (DicoPointPawn.ContainsKey(point))
        {
            Pawn pawn = DicoPointPawn[point];
            stringToReturn = stringToReturn + " ( " + point.p + " , " + point.q + ", " + pawn.Player + " ) -";
        }
        return(stringToReturn);
    }
예제 #6
0
    public static int TestWinner(Point point)
    {
        // recherche d'une ligne de 4 Squares contigus affectés au même joueur
        int  toBeReturned = 0;
        Pawn pawn         = DicoPointPawn[point];

        if (Value(point, pawn.Player) > 3)
        {
            toBeReturned = pawn.Player;
        }
        return(toBeReturned);
    }
예제 #7
0
    // Use this for initialization
    void Start()
    {
        MessageDisplay = GameObject.Find("Message");

        BoardPoint = new List <Point>();
        Couleurs   = new Dictionary <int, Color> {
            { human, humanColor },
            { computer, computerColor },
            { board, boardColor },
            { playable, playableColor }
        };

        // initialisation de DicoPointPawn et PlayablePoint
        DicoPointPawn = new Dictionary <Point, Pawn>();
        PlayablePoint = new List <Point>();
        PlayedPoint   = new List <Point>();

        // création de Boardpoint
        for (int ligne = 0; ligne < nbColonnes; ligne++)
        {
            for (int colonne = 0; colonne < nbLignes; colonne++)
            {
                Point point = new Point(ligne, colonne);
                BoardPoint.Add(point);
            }
        }

        // création de DicoPointPawn
        foreach (Point point in BoardPoint)
        {
            GameObject go   = (GameObject)Instantiate(PawnPrefab);
            Pawn       pawn = new Pawn(point.p, point.q, 1f, board, 0, go);
            SetColor(pawn, Couleurs[board]);
            DicoPointPawn.Add(point, pawn);
        }

        // création de la liste des Points Playable
        foreach (Point point in BoardPoint)
        {
            if (point.q == 0)
            {
                PlayablePoint.Add(point);
                Pawn pawn = DicoPointPawn[point];
                // SetColor(pawn, Color.white);
            }
        }
        IsRunningGame = true;
        GameOver      = false;
    }