Esempio n. 1
0
 /// <summary>
 /// Füllt das Teil t mit den entsprechenden Segmenten
 /// </summary>
 /// <param name="t">Das zu füllende Teil</param>
 public static void fillTeil(TTeil t)
 {
     t.SegmentArray[0, 0] = true;
     t.SegmentArray[0, 1] = true;
     t.SegmentArray[0, 2] = true;
     t.SegmentArray[0, 3] = true;
 }
Esempio n. 2
0
        /// <summary>
        /// Zeigt das nächste Teil an
        /// </summary>
        /// <param name="t">Das nächste Teil</param>
        /// <param name="c">Die Farbe des nächsten Teils</param>
        public override void displayNext(TTeil t, Color c)
        {
            this._Form.paNext.Refresh();
            Graphics g = this._Form.paNext.CreateGraphics();

            TVisualTeil.drawTeil(g, t, c, this._Segment);
        }
Esempio n. 3
0
        /// <summary>
        /// Prüft, ob das Teil mit anderen bereits gefallenen Segmenten kollidiert, wenn es entsprechend der Vorgabe verschoben wird
        /// </summary>
        /// <param name="t">Das fallende Teil</param>
        /// <param name="deltaSektor">Verschiebung im Sektor</param>
        /// <param name="deltaSchicht">Verschiebung in der Schicht</param>
        /// <returns><c>true</c> bei Kollision; <c>false</c> sonst</returns>
        private bool collidesWith(TTeil t, int deltaSektor, int deltaSchicht)
        {
            int positionSektor  = calcNewSektor(t.PositionSektor, deltaSektor);
            int positionSchicht = t.PositionSchicht + deltaSchicht;

            for (int i = 0; i < TTeil.MaxBreite; i++)
            {
                for (int k = 0; k < TTeil.MaxHoehe; k++)
                {
                    if (t.hasSegment(i, k))
                    //Das Teil hat an dieser Stelle ein Segment
                    {
                        int pos     = calcNewSektor(positionSektor, i);
                        int schicht = positionSchicht - k;

                        if (schicht >= 0 &&
                            this.Spielfeld[pos, schicht])                             //Überschneidung gefunden
                        {
                            return(true);
                        }
                    }
                }
            }

            //Keine Überschneidung gefunden
            return(false);
        }
Esempio n. 4
0
 /// <summary>
 /// Kopiert dieses Objekt in das andere
 /// </summary>
 /// <param name="other">Das andere Objekt, in das kopiert wird</param>
 public void copyTo(TTeil other)
 {
     for (int i = 0; i < TTeil.MaxBreite; i++)
     {
         for (int k = 0; k < TTeil.MaxHoehe; k++)
         {
             other.SegmentArray[i, k] = this.SegmentArray[i, k];
         }
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Wird aufgerufen, wenn das Panel mit der Anzeige des nächsten Teils neu gezeichnet wird
 /// </summary>
 void paNext_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
 {
     if (this._Arena != null && !this._Arena.myArena.isPause)
     {
         Graphics g = e.Graphics;
         TTeil    t = this._Data.NextFallingTeil;
         Color    c = this._Data.NextFallingColor;
         TVisualTeil.drawTeil(g, t, c, this._Segment);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Setzt alles zurück
        /// </summary>
        public void reset()
        {
            this.NextFallingTeil = new TTeil();
            this.NextFallingTeil.randomize(this._MyRandom);
            this.NextFallingTeil.move(0, TTeil.MaxHoehe);

            this.FallingTeil = new TTeil();
            this.FallingTeil.randomize(this._MyRandom);
            this.FallingTeil.move(0, TArena.AnzahlSchichten - 1);

            this.NextFallingColor = TTeil.createRandomColor(this._MyRandom);
            this.FallingColor     = TTeil.createRandomColor(this._MyRandom);
        }
Esempio n. 7
0
 /// <summary>
 /// Zeichnet das Teil mit allen seinen Segmenten
 /// </summary>
 /// <param name="g">Graphics-Objekt zum Zeichnen</param>
 /// <param name="t">Das zu zeichnende Teil</param>
 /// <param name="c">Die Farbe des Teils</param>
 /// <param name="segment">Das Segment-Objekt, mit dem gezeichnet wird</param>
 public static void drawTeil(Graphics g, TTeil t, Color c, TSegmentBase segment)
 {
     for (int i = 0; i < TTeil.MaxBreite; i++)
     {
         for (int k = 0; k < TTeil.MaxHoehe; k++)
         {
             if (t.hasSegment(i, k))
             {
                 int positionSektor  = (t.PositionSektor + i) % TArena.AnzahlSektoren;
                 int positionSchicht = t.PositionSchicht - k;
                 segment.drawSegment(positionSektor, positionSchicht, g, c);
             }
         }
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Das fallende Teil wird zufällig zu einem neuen
        /// Teil und an die Startposition gesetzt
        /// </summary>
        public void startNewFallingTeil()
        {
            this.NextFallingTeil.copyTo(this.FallingTeil);
            this.NextFallingTeil.Clear();
            this.NextFallingTeil.randomize(this._MyRandom);
            this.NextFallingTeil.move(0, TTeil.MaxHoehe);
            this.FallingTeil.move(0, TArena.AnzahlSchichten - 1);
            this.FallingColor     = this.NextFallingColor;
            this.NextFallingColor = TTeil.createRandomColor(this._MyRandom);

            if (this.OnDataChanged != null)
            {
                this.OnDataChanged();
            }
        }
Esempio n. 9
0
        }         //Ende Methode myPanel_Paint

        /// <summary>
        /// Speichert das Teil, das unten angekommen ist
        /// </summary>
        /// <param name="t">Das zu speichernde Teil</param>
        public void saveTeil(TTeil t)
        {
            for (int i = 0; i < TTeil.MaxBreite; i++)
            {
                for (int k = 0; k < TTeil.MaxHoehe; k++)
                {
                    if (t.hasSegment(i, k))
                    //Das Teil hat an dieser Stelle ein Segment
                    {
                        int pos = this.myArena.calcNewSektor(t.PositionSektor, i);
                        this.SpielfeldFarben[pos, t.PositionSchicht - k] = this._SharedData.FallingColor;
                    }
                }
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Löscht das Teil und alle seine Segmente
 /// </summary>
 /// <param name="g">Graphics-Objekt zum Zeichnen</param>
 /// <param name="t">Das zu zeichnende Teil</param>
 /// <param name="backColor">Hintergrundfarbe des Panels</param>
 /// <param name="arena">Verweis auf die Arena</param>
 /// <param name="segment">Verweis auf das Segment zum Zeichnen</param>
 public static void deleteTeil(Graphics g, TTeil t, Color backColor, TVisualArena arena, TSegmentBase segment)
 {
     for (int i = 0; i < TTeil.MaxBreite; i++)
     {
         for (int k = 0; k < TTeil.MaxHoehe; k++)
         {
             if (t.hasSegment(i, k))
             {
                 int positionSektor  = (t.PositionSektor + i) % TArena.AnzahlSektoren;
                 int positionSchicht = t.PositionSchicht - k;
                 segment.deleteSegment(positionSektor, positionSchicht, g, backColor);
                 arena.repairNachbarn(positionSektor, positionSchicht, g);
             }
         }
     }
 }
Esempio n. 11
0
 /// <summary>
 /// Speichert das Teil, das unten angekommen ist
 /// </summary>
 /// <param name="t">Das zu speichernde Teil</param>
 public void saveTeil(TTeil t)
 {
     for (int i = 0; i < TTeil.MaxBreite; i++)
     {
         for (int k = 0; k < TTeil.MaxHoehe; k++)
         {
             if (t.hasSegment(i, k))
             //Das Teil hat an dieser Stelle ein Segment
             {
                 int pos     = calcNewSektor(t.PositionSektor, i);
                 int schicht = t.PositionSchicht - k;
                 if (schicht > 0)
                 {
                     this.Spielfeld[pos, schicht] = true;
                 }
             }
         }
     }
 }
Esempio n. 12
0
 /// <summary>
 /// Füllt das Teil t mit den entsprechenden Segmenten
 /// </summary>
 /// <param name="t">Das zu füllende Teil</param>
 public static void fillTeil(TTeil t)
 {
     t.SegmentArray[0, 0] = true;
     t.SegmentArray[1, 0] = true;
     t.SegmentArray[2, 0] = true;
 }
Esempio n. 13
0
 /// <summary>
 /// Zeigt das nächste Teil an
 /// </summary>
 /// <param name="t">Das nächste Teil</param>
 /// <param name="c">Die Farbe des nächsten Teils</param>
 public abstract void displayNext(TTeil t, Color c);