Exemplo n.º 1
0
        public PlayStageContext(GameStageContext context)
        {
            this.GameContext = context;
            this.Rnd         = new Random(context.GetHashCode());
            Size vp = context.Target.ViewportSize;

            this.ViewportRight    = vp.Width - 1;
            this.ViewportBottom   = vp.Height - 1;
            this.AliveAliensCount = AliensPerRow + AliensPerRow;

            //create and init aliens
            for (int i = 0; i < AliensPerRow; i++)
            {
                AlienBase la = this.LargeAliens[i] = new AlienLarge();
                la.XCenter = 4 + i * 5;
                la.YCenter = 5;

                AlienBase sa = this.SmallAliens[i] = new AlienSmall();
                sa.XCenter    = 4 + i * 5;
                sa.YCenter    = 2;
                sa.AlienBelow = la;
            }

            //create and init bombs
            for (int i = 0; i < BombsCount; i++)
            {
                this.Bombs[i] = new Bomb();
            }
        }
Exemplo n.º 2
0
        private void RestartLevel()
        {
            //init barriers
            for (int i = 0; i < BarriersCount; i++)
            {
                this.Barriers[i].BricksAlive = Barrier.AllBricks;
            }

            //init aliens
            this._aliveAliensCount = AliensPerRow + AliensPerRow;

            for (int i = 0; i < AliensPerRow; i++)
            {
                AlienBase alien = this.LargeAliens[i];
                alien.IsAlive = true;
                alien.Status  = AlienStatus.Walk1;
                alien.XCenter = 4 + i * 5;
                alien.YCenter = 5;

                alien         = this.SmallAliens[i];
                alien.IsAlive = true;
                alien.Status  = AlienStatus.Walk1;
                alien.XCenter = 4 + i * 5;
                alien.YCenter = 2;
            }

            //reset aliens' speed to the slowest
            this._clockMask = 0x0F;

            //do init the remaining parameters
            this.ResumeLevel();

            //shows the current level
            this._pausedClock = PausedTimeLong;
            this._pauseStage  = PauseStage.ShowLevel;
        }
Exemplo n.º 3
0
        public override void OnLoad(CompositionTargetBase target)
        {
            //create and init the play-stage context
            Size vp = target.ViewportSize;

            this.ViewportRight  = vp.Width - 1;
            this.ViewportBottom = vp.Height - 1;

            this._rectAlert = new Rectangle(
                2,
                2,
                this.ViewportRight - 4,
                this.ViewportBottom - 4);

            this.Context.Status = GameStatus.Playing;

            //create barriers
            for (int i = 0; i < BarriersCount; i++)
            {
                Barrier barrier = this.Barriers[i] = new Barrier();
                barrier.XLeft = 3 + i * 10;
                barrier.YTop  = 10;
            }

            //create aliens
            for (int i = 0; i < AliensPerRow; i++)
            {
                AlienBase la = this.LargeAliens[i] = new AlienLarge();
                AlienBase sa = this.SmallAliens[i] = new AlienSmall();
                sa.AlienBelow = la;
            }

            //create bombs
            for (int i = 0; i < BombsCount; i++)
            {
                this.Bombs[i] = new Bomb();
            }

            //collect renderables
            int rc = 0;

            for (int i = 0; i < BarriersCount; i++)
            {
                this._renderables[rc++] = this.Barriers[i];
            }

            this._renderables[rc++] = this.Ship;
            this._renderables[rc++] = this.Missile;
            this._renderables[rc++] = this.Saucer;

            for (int i = 0; i < AliensPerRow; i++)
            {
                this._renderables[rc++] = this.SmallAliens[i];
                this._renderables[rc++] = this.LargeAliens[i];
            }

            for (int i = 0; i < BombsCount; i++)
            {
                this._renderables[rc++] = this.Bombs[i];
            }

            //sets the number of ships available
            this.Context.ShipsLeft = 3;

            //reset the score
            this.Context.CurrentScore = 0;

            //reset the level counter
            this.Context.CurrentLevel = 1;

            this.RestartLevel();
        }