Ejemplo n.º 1
0
        public Invader InvaderHit(int row, int column)    // indexer declaration
        {
            int CurrentRow    = 0;
            int CurrentColumn = 0;

            foreach (Invader[] Invader in InvaderRows)
            {
                if (CurrentRow == row)
                {
                    for (int j = 0; j < Invader.Length; j++)
                    {
                        if (j == column)
                        {
                            Invader[j].BeenHit = true;
                        }

                        CurrentColumn += 1;
                    }
                    CurrentRow += 1;
                }
            }

            // Incase somthing happens and it can't return a invader
            Invader inv = new Invader(gif1, gif1);

            return(inv);
        }
Ejemplo n.º 2
0
        public Invader GetFirstInvader()
        {
            int oneGo = 0;

            Invader TheInvader = new Invader(gif1, gif1);

            foreach (Invader[] inv in InvaderRows)
            {
                if (oneGo == 0)
                {
                    int i = 0;
                    TheInvader = inv[i];
                }
                oneGo++;
            }

            return(TheInvader);
        }
Ejemplo n.º 3
0
        ///
        /// So this will
        ///

        public InvaderControl(int Col, int Row, string gif1, string gif2)
        {
            this.Column = Col;
            this.Rows   = Row;


            // For each row create an array of invaders that are equal to the amount of columns
            for (int i = 0; i < this.Rows; i++)
            {
                Invader[] InvaderRow = new Invader[this.Column - 1];

                for (int j = 0; j < InvaderRow.Length; j++)
                {
                    InvaderRow[j] = new Invader(gif1, gif2);
                }


                InvaderRows.Add(InvaderRow);
            }


            int rowNum = 1;

            foreach (Invader[] Invader in InvaderRows)
            {
                for (int j = 0; j < Invader.Length; j++)
                {
                    Invader[j]            = new Invader(gif1, gif2);
                    Invader[j].Position.X = (rowNum * 2) * Invader[j].GetBounds().Width + 50;
                    Invader[j].Position.Y = (j * 2) * Invader[j].GetBounds().Height + 30;
                    Invader[j].SetCounter(rowNum * 50);

                    if (j == Invader.Length - 1)
                    {
                        LastPosition = Invader[j].Position;
                    }
                }
                rowNum++;
            }
        }