Пример #1
0
 public void CreateNewMap(int size, LibraySample libraySample)
 {
     this.Map1 = new Map(size, libraySample);
     this.Map1.CreateMapWithSamples();
     this.Map2 = new Map(size, libraySample);
     this.Map2.CreateMapWithSamples();
 }
Пример #2
0
        public void DrawCurrentMeasure(Map map, Point location)
        {
            HatchBrush brushMeasure = new HatchBrush(HatchStyle.LightDownwardDiagonal, Color.Silver, Color.Transparent);
            HatchBrush brushPlayedTime = new HatchBrush(HatchStyle.Weave, Color.Purple, Color.Transparent);

            location.Offset(new Point(0, (map.Size+2)*sampleSize));
            for (int layer = 0; layer < map.LayerCells.Keys.Count; layer++)
            {
                //--- Nombre de cases sur la couche
                int numberOfCellOnLayer = layer * 8;

                if (numberOfCellOnLayer == 0)
                    numberOfCellOnLayer = 1;
                //---

                //--- Beat  de la couche
                int layerBeat = r.Beat % numberOfCellOnLayer;
                //---

                //---
                int minPlayedCell = (layerBeat / 4) * 4;
                //---

                for (int i = 0; i < map.LayerCells[layer].Count; i++)
                {
                    Cell cell = map.LayerCells[layer][i];

                    if (cell.IsInPlayedTime)
                    {
                        if (!cell.IsEmpty)
                        {
                            gImgMap.FillRectangle(new SolidBrush(cell.Sample.SampleModel.Color),
                                location.X + (cell.NumberOnLayer - minPlayedCell) * sampleSize,
                                location.Y + layer * sampleSize,
                                sampleSize, sampleSize);
                        }

                        if (cell.IsOnMeasure)
                            gImgMap.FillRectangle(brushMeasure, location.X + (cell.NumberOnLayer - minPlayedCell) * sampleSize, location.Y + layer * sampleSize, sampleSize, sampleSize);

                        gImgMap.FillRectangle(brushPlayedTime, location.X + (cell.NumberOnLayer - minPlayedCell) * sampleSize, location.Y + layer * sampleSize, sampleSize, sampleSize);

                        if (cell.IsEmitting)
                            gImgMap.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.Red)), location.X + (cell.NumberOnLayer - minPlayedCell) * sampleSize + sampleSize / 4, location.Y + layer * sampleSize + sampleSize / 4, sampleSize / 2, sampleSize / 2);
                    }
                }
            }
        }
Пример #3
0
        private void UpdateMap(Map map)
        {
            for (int x = 0; x < map.Size; x++)
            {
                for (int y = 0; y < map.Size; y++)
                {
                    if (map.Cells[x, y] != null)
                    {
                        map.Cells[x, y].IsEmitting = false;
                        map.Cells[x, y].IsInPlayedTime = false;

                        //=== Détermination des Cellules jouées dans le temps courant

                        //--- Nombre de cases sur la couche
                        int numberOfCellOnLayer = map.Cells[x, y].Layer * 8;
                        //---

                        if (numberOfCellOnLayer == 0)
                            numberOfCellOnLayer = 1;

                        //--- Beat  de la couche
                        int layerBeat = Beat % numberOfCellOnLayer;
                        //---

                        //---
                        int minPlayedCell = (layerBeat / 4) * 4;
                        int maxPlayedCell = ((layerBeat / 4) + 1) * 4;

                        if (map.Cells[x, y].NumberOnLayer >= minPlayedCell &&
                            map.Cells[x, y].NumberOnLayer < maxPlayedCell)
                        {
                            map.Cells[x, y].IsInPlayedTime = true;

                        }
                        //===
                    }
                }
            }

            for (int layer = 0; layer < map.Size / 2; layer++)
            {
                //--- Nombre de cases sur la couche
                int numberOfCellOnLayer = (map.Size / 2 - layer) * 8;
                //---

                //--- Beat  de la couche
                int layerBeat = Beat % numberOfCellOnLayer;
                //---

                //--- Couche de l'instrument principal
                if (layer == (map.Size / 2) - 2 && layerBeat == 0)
                {
                    map.DrainPlayedSample();
                }
                //---

                //--- Point de départ (coin haut/gauche de la couche)
                Point pos = new Point();
                pos.Offset(layer, layer);
                //---

                //--- Calcul de la longueur d'un côté
                int sideLength = map.Size - layer * 2;
                //---

                //--- Détermination du côté courant
                int currentSide = (layerBeat - 1) / (sideLength - 1);
                //---

                if (currentSide == 0)
                {
                    pos.X += layerBeat;
                }
                else if (currentSide == 1)
                {
                    pos.X += sideLength - 1;
                    pos.Y += layerBeat - sideLength + 1;
                }
                else if (currentSide == 2)
                {
                    pos.X += (sideLength - 1) * 3 - layerBeat;
                    pos.Y += sideLength - 1;
                }
                else if (currentSide == 3)
                {
                    pos.Y += (sideLength - 1) * 4 - layerBeat;
                }

                if (map.Cells[pos.X, pos.Y] != null)
                {
                    map.Cells[pos.X, pos.Y].IsEmitting = true;

                    if (
                        //layer ==0 &&
                        !map.Cells[pos.X, pos.Y].IsEmpty)
                    {
                        PlaySample(map.Cells[pos.X, pos.Y].Sample);

                        int sampleId = map.Cells[pos.X, pos.Y].Sample.SampleModel.SampleModelId;

                        map.PlayedSample[sampleId]++;

                        //if (!PlayedSample.ContainsKey(sampleId))
                        //    PlayedSample.Add(sampleId, 0);

                        //PlayedSample[sampleId] = PlayedSample[sampleId] + 1;
                    }
                }

            }
        }
Пример #4
0
        private void DrawPlayedSample(Map map, Point location)
        {
            int sampleModelNumber = 0;
            foreach (int sampleId in map.PlayedSample.Keys)
            {
                Rectangle rec = new Rectangle(location.X, location.Y + map.Size * sampleSize + 20 + sampleModelNumber * sampleSize / 3, sampleSize / 3 * map.PlayedSample[sampleId], sampleSize / 3);

                gImgMap.FillRectangle(new SolidBrush(map.CurrentLibrarySample.ListSampleModel[sampleId].Color), rec);

                sampleModelNumber++;
            }
        }
Пример #5
0
 private Point ConvertPoint(Map map, Point point)
 {
     Point pointRet = new Point();
     return pointRet;
 }
Пример #6
0
        public void DrawMap(Map map, Point location)
        {
            HatchBrush brushMeasure = new HatchBrush(HatchStyle.LightDownwardDiagonal, Color.Silver, Color.Transparent);
            HatchBrush brushPlayedTime = new HatchBrush(HatchStyle.Weave, Color.Purple, Color.Transparent);

            for (int x = 0; x < map.Size; x++)
            {
                for (int y = 0; y < map.Size; y++)
                {
                    if (!map.Cells[x, y].IsEmpty)
                    {
                        gImgMap.FillRectangle(new SolidBrush(map.Cells[x, y].Sample.SampleModel.Color), location.X + x * sampleSize, location.Y + y * sampleSize, sampleSize, sampleSize);

                        //gImgMap.DrawString(map.Cells[x, y].NumberOnLayer.ToString(), font, Brushes.Black, location.X + ((float)x + 0.3f) * (float)sampleSize, location.Y + ((float)y + 0.2f) * (float)sampleSize);
                    }

                    if (map.Cells[x, y].IsOnMeasure)
                        gImgMap.FillRectangle(brushMeasure, location.X + x * sampleSize, location.Y + y * sampleSize, sampleSize, sampleSize);

                    //if (!map.Cells[x, y].IsEmpty)
                    //    gImgMap.DrawString(map.Cells[x, y].NumberOnLayer.ToString(), font, Brushes.Black, location.X + ((float)x + 0.3f) * (float)sampleSize, location.Y + ((float)y + 0.2f) * (float)sampleSize);

                    if (map.Cells[x, y].IsInPlayedTime)
                        gImgMap.FillRectangle(brushPlayedTime, location.X + x * sampleSize, location.Y + y * sampleSize, sampleSize, sampleSize);

                    if (map.Cells[x, y].IsEmitting)
                        gImgMap.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.Red)), location.X + x * sampleSize + sampleSize / 4, location.Y + y * sampleSize + sampleSize / 4, sampleSize / 2, sampleSize / 2);

                    gImgMap.DrawRectangle(Pens.DarkGray, location.X + location.X * sampleSize, location.Y + location.Y * sampleSize, sampleSize, sampleSize);
                }
            }

            for (int layer = 0; layer < map.Size / 2; layer++)
            {
                Pen pen = new Pen(Color.Black, 3f);

                gImgMap.DrawRectangle(pen, location.X + layer * sampleSize, location.Y + layer * sampleSize, (map.Size - layer * 2) * sampleSize, (map.Size - layer * 2) * sampleSize);
            }
        }