Beispiel #1
0
        public void Initialize()
        {
            redFrame  = false;
            bombs     = new List <bomb>();
            velocity  = 20;
            direction = Direction.RIGHT;
            int startX = 100;
            int startY = 0;

            hasHammer = false;
            for (int i = 0; i < 5; i++)
            {
                Columns[i] = true;
                for (int j = 0; j < 3; j++)
                {
                    Minions[i, j] = new minion(new Point(startX + ((i + 1) * MinionWidth), startY + ((j) * MinionHeight)));
                }
            }

            timer3.Tick += new EventHandler(timer5_Tick);
            timer3.Start();

            timer2.Tick    += new EventHandler(timer4_Tick);
            timer2.Interval = 2000;
            timer2.Start();
            timer1       = new Timer();
            timer1.Tick += new EventHandler(timer1_Tick);
            timer1.Start();
            timer          = new Timer();
            timer.Tick    += new EventHandler(timer_Tick);
            timer.Interval = 25;
            timer.Enabled  = true;
            timer.Start();
        }
Beispiel #2
0
 public bool Hit(minion m)
 {
     if (position.X >= m.Position.X && position.X + 10 <= m.Position.X + 90 && position.Y <= m.Position.Y + 90 && position.Y >= m.Position.Y)
     {
         return(true);
     }
     return(false);
 }
Beispiel #3
0
        public Direction changeDirection(Direction direction)
        {
            int    lIndex = getLeftIndex();
            int    rIndex = getRightIndex();
            minion right  = null;
            minion left   = null;

            if (lIndex >= 0 && lIndex < 5 && rIndex >= 0 && rIndex < 5)
            {
                right = Minions[rIndex, 0];
                left  = Minions[lIndex, 0];
            }
            else
            {
                right = Minions[0, 0];
                left  = Minions[0, 0];
            }
            Direction updatedDirection = direction;

            if (direction == Direction.RIGHT)
            {
                if (right.Position.X + 20 > this.Width - 140)
                {
                    updatedDirection = Direction.LEFT;
                }
                if (direction != updatedDirection)
                {
                    MoveMinionsDown();
                }
                return(updatedDirection);
            }
            if (direction == Direction.LEFT)
            {
                if (left.Position.X - 20 < 0)
                {
                    updatedDirection = Direction.RIGHT;
                }
                if (direction != updatedDirection)
                {
                    MoveMinionsDown();
                }
                return(updatedDirection);
            }
            //unreachable code
            return(updatedDirection);
        }