Beispiel #1
0
        private void allMove(object sender, EventArgs e)
        {
            if (life > 0 && !win)
            {
                // make update on the position of all elements in game scene
                int i, j;

                i = 0;
                while (i < balls.Count)
                {
                    Ball ball = balls[i];
                    if (isCollision(ball, myHero) && shield == 0)
                    {
                        life--;
                        balls.AddRange(ball.Split());
                        balls.Remove(ball);
                        shield = 15;
                        break;
                    }

                    if (shield > 0)
                    {
                        shield--;
                    }

                    j = 0;
                    while (j < bullets.Count)
                    {
                        Bullet b = bullets[j];
                        if (!ball.Destroyed && !b.Destroyed && isCollision(ball, b))
                        {
                            balls.AddRange(ball.Split());
                            balls.Remove(ball);
                            b.Destroyed = true;
                        }
                        j++;
                    }

                    i++;
                }

                i = 0;
                while (i < bullets.Count)
                {
                    Bullet b = bullets[i];

                    if (b.Destroyed)
                    {
                        bullets.Remove(b);
                    }

                    i++;
                }

                if (balls.Count == 0)
                {
                    win = true;
                }

                // fire the change event to notify the view
                foreach (GameObject obj in this.gameObjects)
                {
                    obj.move(currentView.ClientRectangle.Width - obj.Position.Width, currentView.ClientRectangle.Height);
                }
            }
            foreach (GameObject obj in this.gameObjects)
            {
                IEG3080.DrawObjectEventArgs objArg = new IEG3080.DrawObjectEventArgs(obj.ImageSrc, obj.Position.X, obj.Position.Y, obj.Position.Width, obj.Position.Height);
                ModelUpdateEvent(this, objArg);
            }
        }
Beispiel #2
0
        private void allMove(object sender, EventArgs e)
        {
            if (life > 0 && !win)
            {
                // make update on the position of all elements in game scene
                int i, j;

                i = 0;
                while (i < balls.Count)
                {
                    Ball ball = balls[i];
                    if (isCollision(ball, myHero) && shield == 0)
                    {
                        life--;
                        balls.AddRange(ball.Split());
                        balls.Remove(ball);
                        shield = 15;
                        break;
                    }

                    if (shield > 0)
                        shield--;

                    j = 0;
                    while (j < bullets.Count)
                    {
                        Bullet b = bullets[j];
                        if (!ball.Destroyed && !b.Destroyed && isCollision(ball, b))
                        {
                            balls.AddRange(ball.Split());
                            balls.Remove(ball);
                            b.Destroyed = true;
                        }
                        j++;
                    }

                    i++;
                }

                i = 0;
                while (i < bullets.Count)
                {
                    Bullet b = bullets[i];

                    if (b.Destroyed)
                    {
                        bullets.Remove(b);
                    }

                    i++;
                }

                if (balls.Count == 0)
                    win = true;

                // fire the change event to notify the view
                foreach (GameObject obj in this.gameObjects)
                {
                    obj.move(currentView.ClientRectangle.Width - obj.Position.Width, currentView.ClientRectangle.Height);
                }
            }
            foreach (GameObject obj in this.gameObjects)
            {
                IEG3080.DrawObjectEventArgs objArg = new IEG3080.DrawObjectEventArgs(obj.ImageSrc, obj.Position.X, obj.Position.Y, obj.Position.Width, obj.Position.Height);
                ModelUpdateEvent(this, objArg);
            }
        }