Пример #1
0
        // Create/update the BoxList and BoxDrawList
        private void CreateBoxList()
        {
            BoxList.Clear();
            BoxDrawList.Clear();

            // on créé un tableau contenant la liste des sommets du modèles
            ModelMeshPart portionMaillage     = Modèle.Meshes[0].MeshParts[0];
            int           tailleSommetEnFloat = portionMaillage.VertexBuffer.VertexDeclaration.VertexStride / sizeof(float);
            int           tailleTamponEnFloat = portionMaillage.VertexBuffer.VertexCount * tailleSommetEnFloat;

            // On va chercher le contenu du tampon de sommets (vertex buffer) en float pour que cela fonctionne
            // avec les différents formats de sommets (VertexPositionNormalTexture, VertexPositionTexture, VertexPositionColor...)
            float[] sommetsDuModèles = new float[tailleTamponEnFloat];
            portionMaillage.VertexBuffer.GetData <float>(sommetsDuModèles);
            int début = 0;

            //On crée une boîte de collision par maillage (un modèle contient de 1 à N maillages)
            foreach (ModelMesh maillage in Modèle.Meshes)
            {
                //On crée la boîte de collision (BoundingBox) correspondant à une partie du modèle et on l'ajoute à la liste des boîtes de collision
                BoundingBox boîteCollision = CalculerBoundingBox(maillage, sommetsDuModèles, tailleSommetEnFloat, ref début);
                BoxList.Add(boîteCollision);
                BoxDrawList.Add(CreateBoundingBoxBuffers(boîteCollision, Jeu.GraphicsDevice));
            }
        }
Пример #2
0
 private void btnSend_Click(object sender, RoutedEventArgs e)
 {
     if (NewBox != null)
     {
         BoxList.Add(NewBox);
         NewBox         = null;
         tbxLength.Text = null;
         tbxWidth.Text  = null;
         tbxHeight.Text = null;
         tbxWeight.Text = null;
         tbxPrice.Text  = null;
         lbxSendtPackets.Items.Refresh();
     }
 }
Пример #3
0
        public string GameOn(int coordinate, char symbol)
        {
            bool loop = true;

            do                                                //max 2 gånger: 1 varv - granska allt efter spelare; 2 varv - granskar allt efter datorn; då datorn hade sista drag loop = false
            {
                BoxList.Add(new BoxInfo(coordinate, symbol)); //upptagna boxes, varje gång efter drag

                bool continueGame = WinningMove(symbol);

                if (continueGame == false) //nån vann
                {
                    ActiveGameStatus.Text = $"Congratulation (( {symbol} )). You win!!!";
                    return(ActiveGameStatus.Status = "Winner");
                }

                if (BoxList.Count == 9) //alla boxes upptagna
                {
                    BordFull = true;
                    ActiveGameStatus.Text = "Game over. No winner.";
                    return(ActiveGameStatus.Status = "No winner");
                }

                if (symbol == 'x')//sista drag gjorts av spelare, dator måste spela
                {
                    var compMove = TicTacToeHelper.CompMove(BoxList);
                    coordinate = compMove.BoxCoordinate;
                    symbol     = compMove.Value;
                }
                else if (symbol == 'o')//sista drag gjorts av datorn, loop = false
                {
                    loop = false;
                }
            } while (loop);

            ActiveGameStatus.Text = "Next move, please...";//ingen vinnare, spelet sker
            return(ActiveGameStatus.Status = "Active");
        }