public void collision(Missile m)
        {
            if (!BasicObjet.colitionTest(this, m))
            {
                int decX = (int)(m.position.x - this.position.x);   //  _|_
                int decY = (int)(m.position.y - this.position.y);

                bool firstTouch=false;

                for (int i = 0; i < m.img.Width; i++)
                    for (int ip = 0; ip < m.img.Height; ip++)
                    {
                        if (Color.Black.B == m.img.GetPixel(i, ip).B)
                        {

                              if (0 <= (i + decX) && (i + decX) < img.Width &&
                                          0 <= (ip + decY) && (ip + decY) < img.Height &&
                                          img.GetPixel(i + decX, ip + decY).B == Color.Black.B)
                              {
                                if (!firstTouch)
                                {
                                    m.live--;
                                    firstTouch = !firstTouch;
                                }
                                    this.img.SetPixel(i + decX, ip + decY, Color.White);

                              }
                        }
                    }

            }
        }
 public static Missile create(Missile.MissileName m, float x, float y, PlayerShip player)
 {
     Missile node = new Missile(x, y, player);
     GameObject missile = GameObjectManager.find(GameObject.Name.Missiles);
     GameObjectManager.insert(node, missile);
     Debug.Assert(node.Spr != null);
     Instance.batch.attach(node.Spr);
     SpriteBatchManager.attachToGroup(node.ColObj.Spr, BatchGroup.BatchType.Collisions);
     return node;
 }
        /// <summary>
        /// add misile to the munition 
        /// </summary>
        /// <param name="mis"></param>
        /// <param name="num"></param>
        public void addMisile( Missile mis, int num )
        {
            List<Tuple<Missile, int[]>> a = this.listMissile.FindAll(pi => pi.Equals(mis));
            if (a != null && a.Count != 0)
            {

                foreach (Tuple<Missile, int[]> sa in a)
                {
                        sa.Item2[0] = sa.Item2[0] + num;
                }
            }
            else
            {
                if (mis != null && num > 0 || num == -1)
                {
                    int[] tab = new int[1];
                    tab[0] = num;
                    this.listMissile.Add(new Tuple<Missile, int[]>(mis, tab));
                }
            }
        }
        public override void Notify()
        {
            // Delete missile
            //Debug.WriteLine("ShipRemoveMissileObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            // At this point we have two game objects
            // Actually we can control the objects in the visitor
            // Alphabetical ordering... A is missile,  B is wall

            // This cast will throw an exception if I'm wrong
            this.pMissile = (Missile)this.pSubject.pObjA;
            this.pSubB    = this.pSubject.pObjB;


            if (pMissile.bMarkForDeath == false)
            {
                pMissile.bMarkForDeath = true;

                // Delay - remove object later
                // TODO - reduce the new functions
                ShipRemoveMissileObserver pObserver = new ShipRemoveMissileObserver(this);
                DelayedObjectManager.Attach(pObserver);
            }
        }
Example #5
0
 public ShipRemoveMissileObserverAltPair(ShipRemoveMissileObserverAltPair m)
 {
     Debug.Assert(m.pMissile != null);
     this.pMissile = m.pMissile;
 }
Example #6
0
 //-------------------------------------
 public virtual void VisitMissile(Missile m)
 {
     // no differed to subcass
     Debug.WriteLine("Visit by Missile not implemented");
     Debug.Assert(false);
 }
Example #7
0
 public abstract void Collision(Missile m);
Example #8
0
 public RemoveMissileObserver(RemoveMissileObserver m)
 {
     Debug.Assert(m != null);
     this.pMissile = m.pMissile;
 }
 protected abstract void OnCollision(Missile m, int numberOfPixelsInCollision);
Example #10
0
        // WÄ…tek wykonuje zadanie
        public void ThreadProc()
        {
            while (true)
            {
                Application.Current.Dispatcher.Invoke((Action)(() =>
                {
                    enemyShip.MoveTo(x, y);
                }));
                if (x < 10)//sprawdza czy statek doleciał do końca lini
                {
                    endLine = true;
                }
                if (x > 700)//sprawdza czy statek doleciał do końca lini
                {
                    endLine = true;
                }
                if (endLine == true && isMovingRigth == true)//jeśłi statek doleciał do końca lini sprawdza kierunek w którym leciał i zmienia go
                {
                    isMovingRigth = false;
                    endLine       = false;
                }
                if (endLine == true && isMovingRigth == false)
                {
                    isMovingRigth = true;
                    endLine       = false;
                }
                if (isMovingRigth == true)//ustalenie następnej pozycji statku
                {
                    x += enemyShip.GetSpeed();
                }
                if (isMovingRigth == false)//ustalenie następnej pozycji statku
                {
                    x -= enemyShip.GetSpeed();
                }


                Application.Current.Dispatcher.Invoke((Action)(() =>
                {
                    for (int i = 0; i < Globals.playerMissiles.Count(); i++)
                    {
                        //Sprawdzenie czy przeciwnik zostal trafiony rakietÄ… przez gracza
                        if (Globals.playerMissiles[i].y > y - 50 && Globals.playerMissiles[i].y <y + 50 &&
                                                                                                 Globals.playerMissiles[i].x> x - 50 && Globals.playerMissiles[i].x < x + 50) // WystÄ…pienie kolizji
                        {
                            //Sprawdzenie ile zycia posiada przeciwnik
                            if (enemyShip.GetLifes() > 0)
                            {
                                int gundmg = player.gundmg;
                                enemyShip.RemoveLife(gundmg);  // Usuniecie ilości życia równej obrażeniom gracza
                            }
                            else // Jezeli przeciwnik straci cale życie jest niszczony
                            {
                                enemyShip.GetImage().Source = null;
                                Globals.points++;

                                MainWindow.main.Dispatcher.Invoke(new Action(delegate()
                                {
                                    MainWindow.main.ScorePoints = Globals.points.ToString();
                                }));
                                // MainWindow.main.LifePoints = Globals.points.ToString();
                                dead = true;
                                Globals.shipCounter--;
                            }
                            Globals.playerMissiles[i].dynamicImage.Source = null;
                            Globals.playerMissiles.RemoveAt(i);
                            if (dead == true)
                            {
                                break;
                            }
                        }
                    }
                }));

                if (dead == true)
                {
                    break;
                }

                Thread.Sleep(100);
                missileCounter++;
                if (missileCounter % 50 == 0) // Pociski enemyShip
                {
                    Missile       miss    = new Missile(map, enemyShip.GetGunDmg());
                    FlyingMissile missile = new FlyingMissile(miss, this.x, this.y, player);
                    Thread        t       = new Thread(new ThreadStart(missile.ThreadProc));
                    t.Start();
                }
            }
        }
        public override void Execute()
        {
            GameObject pA = (GameObject)this.pAlien;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            float x = this.pAlien.x;
            float y = this.pAlien.y;

            AlienGrid pGrid = (AlienGrid)this.pAlien.pParent.pParent;

            pGrid.nNumActive--;

            pA.Remove();

            // TODO: Need a better way...
            if (privCheckParent(pB) == true)
            {
                GameObject pC = (GameObject)Iterator.GetParent(pB);
                pB.Remove();

                if (privCheckParent(pC) == true)
                {
                    pC.Remove();
                }
            }

            Missile pMissile = (Missile)this.pGameObj;
            Player  pPlayer  = pMissile.pPlayer;

            //
            Font.Name pFontName = Font.Name.Uninitialized;
            if (this.pGameObj is MissileCategory)
            {
                pPlayer.nPoints += this.pAlien.GetPoints();
                Font pScore = null;
                if (pPlayer.n == 1)
                {
                    pScore    = FontMan.Find(Font.Name.Score1Value);
                    pFontName = Font.Name.Score1Value;
                }
                if (pPlayer.n == 2)
                {
                    pScore    = FontMan.Find(Font.Name.Score2Value);
                    pFontName = Font.Name.Score2Value;
                }
                pScore.Set(pFontName,
                           pPlayer.nPoints.ToString(),
                           Glyph.Name.Consolas20pt,
                           pScore.pFontSprite.x,
                           pScore.pFontSprite.y);
            }

            //---------------------------------------------------------------------------------------------------------
            // Sound
            //---------------------------------------------------------------------------------------------------------
            SoundMan.PlaySound(Sound.Name.InvaderKilled);
            TimeEvent pTimeEvent = TimerMan.Find(TimeEvent.Name.ScenePlaySound);

            pTimeEvent.deltaTime -= 0.01f;

            //---------------------------------------------------------------------------------------------------------
            // Explosion
            //---------------------------------------------------------------------------------------------------------
            Explosion   explosion  = new Explosion(GameObject.Name.Explosion, GameSprite.Name.Explosion, x, y);
            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);

            explosion.ActivateGameSprite(pSB_Aliens);
            GameObjectMan.Attach(explosion);
            TimerMan.Add(TimeEvent.Name.RemoveExplosion, new RemoveExplosionCommand(explosion), 0.25f);

            //---------------------------------------------------------------------------------------------------------
            // Scene Transition
            //---------------------------------------------------------------------------------------------------------
            if (pGrid.nNumActive == 0 && pPlayer.nCurrLevel == 1)
            {
                PlayerMan.WriteHighScores();
                pPlayer.nCurrLevel++;
                SceneContext.GetState().Initialize();
                if (SceneContext.bMultiplayer)
                {
                    SceneContext.SetState(SceneContext.Scene.MultiPlay);
                }
                else
                {
                    SceneContext.SetState(SceneContext.Scene.SinglePlay);
                }
            }
            else if (pGrid.nNumActive == 0 && pPlayer.nCurrLevel == 2)
            {
                PlayerMan.WriteHighScores();
                SceneContext.SetState(SceneContext.Scene.Credits);
            }
        }
Example #12
0
        public override void VisitMissile(Missile m)
        {
            GameObject pGameObj = Iterator.GetChildGameObject(this);

            CollisionPair.Collide(m, pGameObj);
        }
Example #13
0
 public override void VisitMissile(Missile m)
 {
     // Missile vs Wall-Bottom
     //Does nothing, here to prevent crashing.
 }
Example #14
0
 public override void visitMissile(Missile v, CollisionPair p)
 {
     p.collision(v, (GameObject)this.child);
 }
Example #15
0
 public override void VisitMissile(Missile m)
 {
     // Missile vs WallRoot
     ColPair.Collide(m, (GameObject)this.pChild);
 }
        public void UpdatePlaying(GameTime currentTime) // Main gameplay
        {
            Ticks = Ticks + currentTime.ElapsedGameTime.TotalMilliseconds;

            // Invader movement
            if (Ticks > 500)
            {
                // Invader sideways movement
                for (int rows = 0; rows < 5; rows++)
                {
                    for (int cols = 0; cols < 11; cols++)
                    {
                        if (InvaderDir.Equals("Right"))
                        {
                            InvaderArray[rows, cols].X = InvaderArray[rows, cols].X + InvaderSpd;
                        }
                        if (InvaderDir.Equals("Left"))
                        {
                            InvaderArray[rows, cols].X = InvaderArray[rows, cols].X - InvaderSpd;
                        }
                    }
                }

                // Invader Limits
                string ChangeDir = "No";
                for (int rows = 0; rows < 5; rows++)
                {
                    for (int cols = 0; cols < 11; cols++)
                    {
                        if (InvaderLiving[rows, cols].Equals("Yes"))
                        {
                            if (InvaderArray[rows, cols].X + InvaderArray[rows, cols].Width > 870)
                            {
                                InvaderDir = "Left";
                                ChangeDir  = "Yes";
                            }

                            if (InvaderArray[rows, cols].X < 30)
                            {
                                InvaderDir = "Right";
                                ChangeDir  = "Yes";
                            }
                        }
                    }
                }

                // Invader downward movement
                if (ChangeDir.Equals("Yes"))
                {
                    for (int rows = 0; rows < 5; rows++)
                    {
                        for (int cols = 0; cols < 11; cols++)
                        {
                            InvaderArray[rows, cols].Y = InvaderArray[rows, cols].Y + 8;
                        }
                    }
                }


                Ticks = 0;
            }

            // Gunship control
            if (Keyboard.GetState().IsKeyDown(Keys.Right))
            {
                ShipXPos = ShipXPos + 3;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Left))
            {
                ShipXPos = ShipXPos - 3;
            }

            //Gunship limits
            if (ShipXPos < 15)
            {
                ShipXPos = 15;
            }

            if (ShipXPos > 780)
            {
                ShipXPos = 780;
            }

            // Firing missile
            if (ShotsFired != null) // Moves missile when it is visible
            {
                ShotsFired.Move();
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Space) & ShotsFired == null) // Fires missile when space is pressed
            {
                ShotsFired = new Missile(ShipXPos + 45, 565);
            }

            if (ShotsFired != null) // Deletes the missile when it passes the top of the screen
            {
                if (ShotsFired.GetMissilePos().Y < 0)
                {
                    ShotsFired = null;
                }
            }

            // Missile/invader collision detection
            if (ShotsFired != null)
            {
                MissileHitbox = new Rectangle((int)ShotsFired.GetMissilePos().X, (int)ShotsFired.GetMissilePos().Y,
                                              Missile.Width, Missile.Height);

                for (int rows = 0; rows < 5; rows++)
                {
                    for (int cols = 0; cols < 11; cols++)
                    {
                        if (InvaderLiving[rows, cols].Equals("Yes"))
                        {
                            if (MissileHitbox.Intersects(InvaderArray[rows, cols]))
                            {
                                ShotsFired = null;
                                InvaderLiving[rows, cols] = "No";
                                Score = Score + 50;
                            }
                        }
                    }
                }
            }

            // Gunship/Invader collision detection
            ShipHitbox = new Rectangle(ShipXPos, 565, Gunship.Width, Gunship.Height);

            for (int rows = 0; rows < 5; rows++)
            {
                for (int cols = 0; cols < 11; cols++)
                {
                    if (InvaderLiving[rows, cols].Equals("Yes"))
                    {
                        if (InvaderArray[rows, cols].Y + InvaderArray[rows, cols].Height > ShipHitbox.Y)
                        {
                            GameState = 3;
                        }
                    }
                }
            }

            // Speeds up invaders when they reach a certain point
            for (int rows = 0; rows < 5; rows++)
            {
                for (int cols = 0; cols < 11; cols++)
                {
                    if (InvaderLiving[rows, cols].Equals("Yes"))
                    {
                        if (InvaderArray[rows, cols].Y > 350)
                        {
                            InvaderSpd = 30;
                        }
                    }
                }
            }

            int Count = 0;

            for (int rows = 0; rows < 5; rows++)
            {
                for (int cols = 0; cols < 11; cols++)
                {
                    if (InvaderLiving[rows, cols].Equals("Yes"))
                    {
                        Count = Count + 1;
                    }
                }
            }

            // Finishes when all invaders killed
            if (Count == 0)
            {
                this.Exit();
            }
        }
Example #17
0
 public override void visitMissile(Missile m, CollisionPair p)
 {
     p.collision((GameObject)this.Child, m);
 }
Example #18
0
 public override void VisitMissile(Missile pMissile)
 {
     CollisionPair.Collide(pMissile, (GameObject)this.pChild);
 }
Example #19
0
 public override void VisitMissile(Missile m)
 {
 }
Example #20
0
 public virtual void VisitMissile(Missile m)
 {
     Debug.WriteLine("Visit by Missile not implemented");
     Debug.Assert(false);
 }
        protected virtual void PlayerTwoInit(GameManager pGameManager)
        {
            float levelSpeed = 0.75f / pGameManager.pActivePlayer.level;

            pGameManager.poPlayer2.pGrid = InvaderGridManager.GenerateGrid(pGameManager.pActivePlayer.level);
            //Debug.WriteLine("Generated Grid ({0}) for P2", pGameManager.poPlayer2.pGrid.GetHashCode());

            pGameManager.poPlayer2.pShieldZone = ShieldBuilder.CreateShieldZone(175, 300, 150, 4);

            //---------------------------------------------------------------------------------------------------------
            // Create GameSpace and Wall Objects
            //---------------------------------------------------------------------------------------------------------
            WallManager pWallMan = new WallManager();

            //Debug.WriteLine("WallLeft Consts x: {0}, y:{1}, width:{2}, height:{3}", Constants.leftWallXPos, Constants.leftWallYPos, Constants.leftWallWidth, Constants.leftWallHeight);
            //Debug.WriteLine("WallRight Consts x: {0}, y:{1}, width:{2}, height:{3}", Constants.rightWallXPos, Constants.rightWallYPos, Constants.rightWallWidth, Constants.rightWallHeight);
            //Debug.WriteLine("Ceiling Consts x: {0}, y:{1}, width:{2}, height:{3}", Constants.ceilingXPos, Constants.ceilingYPos, Constants.ceilingWidth, Constants.ceilingHeight);
            //Debug.WriteLine("Floor Consts x: {0}, y:{1}, width:{2}, height:{3}", Constants.floorXPos, Constants.floorYPos, Constants.floorWidth, Constants.floorHeight);

            //---------------------------------------------------------------------------------------------------------
            // Set up Sprite Animations
            //---------------------------------------------------------------------------------------------------------
            // Set up animations for the 3 basic Invaders
            AnimationSprite pSmInvaderAnim = new AnimationSprite(Sprite.Name.SmallInvader);

            pSmInvaderAnim.Attach(Image.Name.SmallInvader1);
            pSmInvaderAnim.Attach(Image.Name.SmallInvader2);

            AnimationSprite pMedInvaderAnim = new AnimationSprite(Sprite.Name.MediumInvader);

            pMedInvaderAnim.Attach(Image.Name.MediumInvader1);
            pMedInvaderAnim.Attach(Image.Name.MediumInvader2);

            AnimationSprite pLgInvaderAnim = new AnimationSprite(Sprite.Name.LargeInvader);

            pLgInvaderAnim.Attach(Image.Name.LargeInvader1);
            pLgInvaderAnim.Attach(Image.Name.LargeInvader2);

            // Add the Invader animations as timed events to the TimerManager
            TimerManager.Add(TimeEvent.Name.SmInvaderMarchAnimation, pSmInvaderAnim, levelSpeed);
            TimerManager.Add(TimeEvent.Name.MedInvaderMarchAnimation, pMedInvaderAnim, levelSpeed);
            TimerManager.Add(TimeEvent.Name.LgInvaderMarchAnimation, pLgInvaderAnim, levelSpeed);

            // Set up bomb animations
            AnimationSprite pBombZigZagAnim = new AnimationSprite(Sprite.Name.BombZigZag);

            pBombZigZagAnim.Attach(Image.Name.BombZigZag1);
            pBombZigZagAnim.Attach(Image.Name.BombZigZag2);
            pBombZigZagAnim.Attach(Image.Name.BombZigZag3);
            pBombZigZagAnim.Attach(Image.Name.BombZigZag4);

            AnimationSprite pBombDaggerAnim = new AnimationSprite(Sprite.Name.BombDagger);

            pBombDaggerAnim.Attach(Image.Name.BombDagger1);
            pBombDaggerAnim.Attach(Image.Name.BombDagger2);
            pBombDaggerAnim.Attach(Image.Name.BombDagger3);
            pBombDaggerAnim.Attach(Image.Name.BombDagger4);

            AnimationSprite pBombRollingAnim = new AnimationSprite(Sprite.Name.BombRolling);

            pBombRollingAnim.Attach(Image.Name.BombRolling1);
            pBombRollingAnim.Attach(Image.Name.BombRolling2);

            // Add the bomb animations as timed events to the TimerManager
            TimerManager.Add(TimeEvent.Name.BombAnimation, pBombZigZagAnim, 0.25f);
            TimerManager.Add(TimeEvent.Name.BombAnimation, pBombDaggerAnim, 0.25f);
            TimerManager.Add(TimeEvent.Name.BombAnimation, pBombRollingAnim, 0.25f);


            //---------------------------------------------------------------------------------------------------------
            // Set up TimedSoundEffects
            //---------------------------------------------------------------------------------------------------------
            TimedSoundEffects pGridMarchingSounds = new TimedSoundEffects();

            pGridMarchingSounds.Attach(Sound.Name.InvaderMarch4);
            pGridMarchingSounds.Attach(Sound.Name.InvaderMarch3);
            pGridMarchingSounds.Attach(Sound.Name.InvaderMarch2);
            pGridMarchingSounds.Attach(Sound.Name.InvaderMarch1);

            TimerManager.Add(TimeEvent.Name.GridMarchSoundEffects, pGridMarchingSounds, levelSpeed);

            //---------------------------------------------------------------------------------------------------------
            // Setting up the collisions for the player ship and missile
            //---------------------------------------------------------------------------------------------------------
            Ship    pShip    = ShipManager.ActivateShip();
            Missile pMissile = ShipManager.GetMissile();

            //---------------------------------------------------------------------------------------------------------
            // Add Collision Pairs and their Observers
            //---------------------------------------------------------------------------------------------------------
            // Applies to both players
            // ship vs left wall
            ColPair pShip_WallLeftColPair = ColPairManager.Add(ColPair.Name.Ship_WallLeft, pShip, pWallMan.GetWallLeft());

            Debug.Assert(pShip_WallLeftColPair != null);
            pShip_WallLeftColPair.Attach(new Ship_WallLeftObserver());
            // ship vs Right wall
            ColPair pShip_WallRightColPair = ColPairManager.Add(ColPair.Name.Ship_WallRight, pShip, pWallMan.GetWallRight());

            Debug.Assert(pShip_WallRightColPair != null);
            pShip_WallRightColPair.Attach(new Ship_WallRightObserver());
            // Missile vs Ceiling
            ColPair pMissile_CeilingColPair = ColPairManager.Add(ColPair.Name.Missile_Ceiling, pMissile, pWallMan.GetCeiling());

            Debug.Assert(pMissile_CeilingColPair != null);
            pMissile_CeilingColPair.Attach(new ShipMissileReadyObserver());
            pMissile_CeilingColPair.Attach(new ShipRemoveMissileObserver());

            //---------------------------------------------------------------------------------------------------------
            // Set up Random UFO Spawns
            //---------------------------------------------------------------------------------------------------------
            RandomlySpawnUFO pRandomUfoEvent = new RandomlySpawnUFO(30.0f, pMissile, pWallMan);

            TimerManager.Add(TimeEvent.Name.RandomlySpawnUFO, pRandomUfoEvent, 10.0f);


            //---------------------------------------------------------------------------------------------------------
            // Create Alien Grid and random bomb drops
            //---------------------------------------------------------------------------------------------------------
            BombFactory       pBombFactory     = new BombFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pGameManager.poPlayer2.pGrid, pWallMan);
            RandomlySpawnBomb pRandomBombEvent = new RandomlySpawnBomb(2.0f, pBombFactory);

            TimerManager.Add(TimeEvent.Name.RandomBombSpawn, pRandomBombEvent, 2.0f);

            // Applies to players seperately
            // Set up timing for Grid and UFO motion
            TimeBasedMover pGridMover = new TimeBasedMover(pGameManager.poPlayer2.pGrid);

            TimerManager.Add(TimeEvent.Name.TimedGridMover, pGridMover, levelSpeed);

            //---------------------------------------------------------------------------------------------------------
            // Create the Shields
            //---------------------------------------------------------------------------------------------------------

            // Applies to each player seperately
            // grid vs leftwall
            ColPair pGrid_WallLeftColPair = ColPairManager.Add(ColPair.Name.Grid_WallLeft, pGameManager.poPlayer2.pGrid, pWallMan.GetWallLeft());

            Debug.Assert(pGrid_WallLeftColPair != null);
            pGrid_WallLeftColPair.Attach(new Grid_WallLeftObserver());
            // Grid vs rightwall
            ColPair pGrid_WallRightcolPair = ColPairManager.Add(ColPair.Name.Grid_WallRight, pGameManager.poPlayer2.pGrid, pWallMan.GetWallRight());

            Debug.Assert(pGrid_WallRightcolPair != null);
            pGrid_WallRightcolPair.Attach(new Grid_WallRightObserver());
            // Grid vs ship
            ColPair pShip_GridColPair = ColPairManager.Add(ColPair.Name.Ship_Grid, pShip, pGameManager.poPlayer2.pGrid);

            Debug.Assert(pShip_GridColPair != null);
            pShip_GridColPair.Attach(new RemoveShipObserver());
            // Grid vs Missile
            ColPair pMissile_GridColPair = ColPairManager.Add(ColPair.Name.Missile_Grid, pMissile, pGameManager.poPlayer2.pGrid);

            Debug.Assert(pMissile_GridColPair != null);
            pMissile_GridColPair.Attach(new ShipRemoveMissileObserver());
            pMissile_GridColPair.Attach(new ShipMissileReadyObserver());
            pMissile_GridColPair.Attach(new RemoveInvaderObserver());
            pMissile_GridColPair.Attach(new AwardPointsObserver());
            // Grid vs Shields
            ColPair pGrid_ShieldZoneColPair = ColPairManager.Add(ColPair.Name.Grid_ShieldZone, pGameManager.poPlayer2.pGrid, pGameManager.poPlayer2.pShieldZone);

            pGrid_ShieldZoneColPair.Attach(new RemoveShieldBrickObserver());

            // Missile vs Shields
            ColPair pMissile_ShieldZoneColPair = ColPairManager.Add(ColPair.Name.Missile_ShieldZone, pMissile, pGameManager.poPlayer2.pShieldZone);

            pMissile_ShieldZoneColPair.Attach(new ShipMissileReadyObserver());
            pMissile_ShieldZoneColPair.Attach(new ShipRemoveMissileObserver());
            pMissile_ShieldZoneColPair.Attach(new RemoveShieldBrickObserver());


            // STORE Current State of managers into manager mementos
            pGameManager.poPlayer2.ArchiveManagerStates(pGameManager.pGame.GetTime());
        }
Example #22
0
        public override void VisitMissile(Missile pMissile)
        {
            GameObject pGameObj = (GameObject)this.GetFirstChild();

            ColPair.FwdCollide(pGameObj, pMissile);
        }
 public override void Collision(Missile m)
 {
     //throw new NotImplementedException();
 }
Example #24
0
        public override void VisitMissile(Missile m)
        {
            GameObject pGameObject = (GameObject)Iterator.GetChild(this);

            ColPair.Collide(m, pGameObject);
        }
Example #25
0
 public override void visitMissile(Missile v, CollisionPair p)
 {
     p.notify(this, v);
 }
Example #26
0
 public override void VisitMissile(Missile m)
 {
     // does nothing
     //its okay
 }
Example #27
0
        // The thread performs the task
        public void ThreadProc()
        {
            while (true)
            {
                Application.Current.Dispatcher.Invoke((Action)(() =>
                {
                    enemyShip.MoveTo(x, y);
                }));
                if (x < 10)
                {
                    endLine = true;
                }
                if (x > 700)
                {
                    endLine = true;
                }
                if (endLine == true && isMovingRigth == true)
                {
                    isMovingRigth = false;
                    endLine       = false;
                }
                if (endLine == true && isMovingRigth == false)
                {
                    isMovingRigth = true;
                    endLine       = false;
                }
                if (isMovingRigth == true)
                {
                    x += enemyShip.GetSpeed();
                }
                if (isMovingRigth == false)
                {
                    x -= enemyShip.GetSpeed();
                }


                Application.Current.Dispatcher.Invoke((Action)(() =>
                {
                    for (int i = 0; i < Globals.playerMissiles.Count(); i++)
                    {
                        //Check if enemyShip was hitted by player bullet
                        if (Globals.playerMissiles[i].y > y - 50 && Globals.playerMissiles[i].y <y + 50 &&
                                                                                                 Globals.playerMissiles[i].x> x - 50 && Globals.playerMissiles[i].x < x + 50) // Collision appears
                        {
                            //Check how many lifes enemyShip gotS
                            if (enemyShip.GetLifes() > 0) // If has more than 0 lifes
                            {
                                int gundmg = player.gundmg;
                                enemyShip.RemoveLife(gundmg);  // Remove 1 life
                                //Debug.WriteLine("EnemyShip lost lifes, now:" + enemyShip.GetLifes());
                            }
                            else // If enemyShip has no life destroy him
                            {
                                //Debug.WriteLine("EnemyShip destroyed, " + enemyShip.GetLifes());

                                enemyShip.GetImage().Source = null;
                                Globals.points++;

                                MainWindow.main.Dispatcher.Invoke(new Action(delegate()
                                {
                                    MainWindow.main.ScorePoints = Globals.points.ToString();
                                }));
                                // MainWindow.main.LifePoints = Globals.points.ToString();
                                dead = true;
                                Globals.shipCounter--;
                            }
                            Globals.playerMissiles[i].dynamicImage.Source = null;
                            Globals.playerMissiles.RemoveAt(i);
                            if (dead == true)
                            {
                                break;
                            }
                        }
                    }
                }));

                if (dead == true)
                {
                    break;
                }

                Thread.Sleep(100);
                missileCounter++;
                if (missileCounter % 50 == 0) // Pociski enemyShip
                {
                    Missile       miss    = new Missile(map, enemyShip.GetGunDmg());
                    FlyingMissile missile = new FlyingMissile(miss, this.x, this.y, player);
                    Thread        t       = new Thread(new ThreadStart(missile.ThreadProc));
                    t.Start();
                }
            }
        }
 public RemoveMissileAndBombObserver(Bomb pBomb, Missile pMissile)
 {
     this.pBomb    = pBomb;
     this.pMissile = pMissile;
 }
Example #29
0
 public override void VisitMissile(Missile m)
 {
     //Missile vs AlienColumn
     ColPair.Collide(m, (GameObject)this.pChild);
 }
Example #30
0
 public override void Collision(Missile m)
 {
 }
Example #31
0
        /// <summary>
        /// Update game
        /// </summary>
        public void Update(double deltaT)
        {
            if (currentState == GameState.Intro)
            {
                //Play "IntroMusic" sound
                Sounds[17].settings.volume = 200;
                Sounds[17].controls.play();
                if (Intro.timeIntro.ElapsedMilliseconds > 2000.0)
                {
                    if (Intro.timeIntro.ElapsedMilliseconds > 4400.0)
                    {
                        intro.Move(3000, deltaT);
                    }

                    if (Intro.timeIntro.ElapsedMilliseconds > 9200.0)
                    {
                        currentState = GameState.Menu;
                        Intro.timeIntro.Reset();
                    }
                }
            }
            else if (currentState == GameState.Menu)
            {
                mainMenu.Blink();
                if (KeyDownPressed && mainMenu.currentSelection < MainMenu.DifficultyState.Hard)
                {
                    mainMenu.currentSelection++;
                    KeyDownPressed = false;

                    //Play "Down" sound
                    Sounds[7].settings.volume = 100;
                    Sounds[7].controls.play();
                }
                if (KeyUpPressed && mainMenu.currentSelection > MainMenu.DifficultyState.Easy)
                {
                    mainMenu.currentSelection--;
                    KeyUpPressed = false;

                    //Play "Up" sound
                    Sounds[8].settings.volume = 100;
                    Sounds[8].controls.play();
                }
                if (KeyEnterPressed)
                {
                    mainMenu.LevelSelection();
                    if (mainMenu.currentSelection == MainMenu.DifficultyState.Easy)
                    {
                        //Play "Easy" sound
                        Sounds[9].settings.volume = 100;
                        Sounds[9].controls.play();
                    }
                    if (mainMenu.currentSelection == MainMenu.DifficultyState.Medium)
                    {
                        //Play "Medium" sound
                        Sounds[10].settings.volume = 100;
                        Sounds[10].controls.play();
                    }
                    if (mainMenu.currentSelection == MainMenu.DifficultyState.Hard)
                    {
                        //Play "Hard" sound
                        Sounds[11].settings.volume = 100;
                        Sounds[11].controls.play();
                    }


                    currentState = GameState.Play;
                }
            }
            else if (currentState == GameState.Play)
            {
                Sounds[17].controls.stop();
                KeyEnterPressed = false;

                //Play the level music
                if (mainMenu.currentSelection == MainMenu.DifficultyState.Easy)
                {
                    Sounds[12].settings.volume = 100;
                    Sounds[12].controls.play();
                }
                else if (mainMenu.currentSelection == MainMenu.DifficultyState.Medium)
                {
                    Sounds[13].settings.volume = 100;
                    Sounds[13].controls.play();
                }
                else if (mainMenu.currentSelection == MainMenu.DifficultyState.Hard)
                {
                    Sounds[14].settings.volume = 100;
                    Sounds[14].controls.play();
                }

                //move left
                if (KeyLeftPressed)
                {
                    if (playerShip != null)
                    {
                        if (playerShip.Position.x <= 0)
                        {
                            playerShip.Position.x = 0;
                        }
                        else
                        {
                            playerShip.MoveLeft(deltaT, playerSpeed);
                        }
                    }
                }

                //move right
                if (KeyRightPressed)
                {
                    if (playerShip != null)
                    {
                        if (playerShip.Position.x >= game.gameSize.Width - playerShip.imageWidth)
                        {
                            playerShip.Position.x = game.gameSize.Width - playerShip.imageWidth;
                        }
                        else
                        {
                            playerShip.MoveRight(deltaT, playerSpeed);
                        }
                    }
                }

                //Draw missile
                if (KeySpacePressed)
                {
                    if (playerMissile == null)
                    {
                        playerMissile = new Missile(new Vecteur2D(200, 200),
                                                    new Vecteur2D(0, 0),
                                                    1);
                        playerMissile.Position.x = playerShip.Position.x + playerShip.imageWidth / 2 - 1;
                        playerMissile.Position.y = playerShip.Position.y - playerMissile.imageHeight;

                        //Play "pew" sound
                        Sounds[0].settings.volume = 100;
                        Sounds[0].controls.play();
                    }
                }

                //Move Player missile
                if (playerMissile != null)
                {
                    playerMissile.Move(deltaT, playerMissile.Vitesse.y);
                }


                //Test Player missile collision
                if (playerMissile != null)
                {
                    foreach (Bunker b in bunkers)
                    {
                        b.Collision(playerMissile);
                    }

                    if (enemyBlock.Collision(playerMissile))
                    {
                        //Play "Boom" sound
                        Sounds[2].settings.volume = 100;
                        Sounds[2].controls.play();
                    }

                    // maybe dead
                    if (!playerMissile.Alive)
                    {
                        playerMissile = null;
                    }
                }

                //Pause the game
                if (KeyPPressed)
                {
                    if (currentState == GameState.Play)
                    {
                        Sounds[12].settings.volume = 20;

                        Sounds[13].settings.volume = 20;

                        Sounds[14].settings.volume = 20;

                        currentState = GameState.Pause;
                        KeyPPressed  = false;
                    }
                }

                //Random enemy shoots
                if (enemyBlock != null)
                {
                    foreach (SpaceShip s in enemyBlock.Ships)
                    {
                        enemyBlock.RandomShoot(s, deltaT);
                    }
                }

                //Move Enemy Block and enemy's missiles
                if (enemyBlock != null)
                {
                    enemyBlock.Move(deltaT);

                    List <Missile> index       = new List <Missile>();
                    List <Bunker>  indexBunker = new List <Bunker>();;

                    foreach (Missile m in missiles)
                    {
                        m.Move(deltaT, m.Vitesse.y);

                        foreach (Bunker b in bunkers)
                        {
                            if (b.Collision(m))
                            {
                                index.Add(m);
                            }
                        }

                        if (playerShip.Collision(m))
                        {
                            playerShip.Position = new Vecteur2D(gameSize.Width / 2 - space_invaders.Properties.Resources.ship1.Width / 2,
                                                                gameSize.Height - space_invaders.Properties.Resources.ship1.Height);
                            index.Add(m);

                            //Play "Touched" sound
                            Sounds[6].settings.volume = 100;
                            Sounds[6].controls.play();
                        }
                    }

                    if (index.Count != 0)
                    {
                        foreach (Missile m in index)
                        {
                            missiles.Remove(m);
                        }
                    }

                    foreach (Bunker b in bunkers)
                    {
                        if (enemyBlock.Collision(b))
                        {
                            indexBunker.Add(b);
                        }
                    }

                    if (indexBunker.Count != 0)
                    {
                        foreach (Bunker b in indexBunker)
                        {
                            bunkers.Remove(b);
                        }
                    }
                }

                //Move Bonus
                if (bonus.Count != 0)
                {
                    foreach (Bonus b in bonus)
                    {
                        b.Move(deltaT);
                    }

                    int index = -1;

                    foreach (Bonus b in bonus)
                    {
                        if (b.Collision(playerShip))
                        {
                            playerBonus = b;
                            index       = bonus.IndexOf(b);

                            //Play "Suck" sound
                            Sounds[3].settings.volume = 100;
                            Sounds[3].controls.play();
                        }
                        else if (b.Position.y > gameSize.Height)
                        {
                            index = bonus.IndexOf(b);
                        }
                    }

                    if (index != -1)
                    {
                        bonus.RemoveAt(index);
                    }
                }

                //Use Bonus
                if (KeyBPressed)
                {
                    if (playerBonus != null)
                    {
                        if (playerMissile == null)
                        {
                            playerBonus.action();

                            if (playerBonus.bonusName == "DoublePoints")
                            {
                                //Play "DoublePoints" sound
                                Sounds[1].settings.volume = 100;
                                Sounds[1].controls.play();
                                bonus3Activated = true;
                            }

                            if (playerBonus.bonusName == "InstantKill")
                            {
                                //Play "Bop" sound
                                Sounds[5].settings.volume = 100;
                                Sounds[5].controls.play();
                            }

                            if (playerBonus.bonusName == "BigMissile")
                            {
                                //Play "BigPew" sound
                                Sounds[4].settings.volume = 100;
                                Sounds[4].controls.play();
                            }


                            playerBonus = null;
                            KeyBPressed = false;
                        }
                    }
                }

                //Increment bonus3's time
                if (bonus3Activated)
                {
                    timeBonus.Start();

                    if (timeBonus.ElapsedMilliseconds > 5000.0)
                    {
                        bonus3Activated = false;
                        timeBonus.Reset();
                        playerScore.BonusFactor = 1;
                    }
                }

                //Win the game
                if (!enemyBlock.Alive)
                {
                    currentState = GameState.Win;
                }

                //Lost the game
                if (!playerShip.Alive || (enemyBlock.Position.y + enemyBlock.Size.Height) >= playerShip.Position.y)
                {
                    currentState = GameState.Lost;
                }

                //Check player's lives
                if (!playerShip.Alive)
                {
                    playerShip = null;
                }
            }
            else if (currentState == GameState.Pause)
            {
                //Unpause game
                if (KeyPPressed)
                {
                    currentState = GameState.Play;
                    KeyPPressed  = false;
                }
            }
            else if (currentState == GameState.Win)
            {
                //Stop game music
                Sounds[12].controls.stop();

                Sounds[13].controls.stop();

                Sounds[14].controls.stop();

                //Play "WinMusic" sound

                /*if (timeWinMusic.ElapsedMilliseconds < 9000.0)
                 * {
                 *  Sounds[15].settings.volume = 100;
                 *  Sounds[15].controls.play();
                 * }
                 *
                 * timeWinMusic.Start();
                 *
                 * if (timeWinMusic.ElapsedMilliseconds > 9500.0)
                 * {
                 *  Sounds[15].settings.volume = 0;
                 *  Sounds[15].controls.stop();
                 * }*/
                if (!winMusicPlayed)
                {
                    Sounds[15].settings.volume = 100;
                    Sounds[15].controls.play();
                    winMusicPlayed = true;
                }


                if ((winScreen.Position.y + winScreen.imageHeight / 2) < gameSize.Height / 2)
                {
                    winScreen.Move(deltaT);
                }

                // Choose after game end
                winScreen.Blink();
                if (KeyDownPressed && winScreen.currentSelection < Win.AfterState.Quit)
                {
                    winScreen.currentSelection++;
                    KeyDownPressed = false;

                    //Play "Down" sound
                    Sounds[7].settings.volume = 100;
                    Sounds[7].controls.play();
                }
                if (KeyUpPressed && winScreen.currentSelection > Win.AfterState.MainMenu)
                {
                    winScreen.currentSelection--;
                    KeyUpPressed = false;

                    //Play "Up" sound
                    Sounds[8].settings.volume = 100;
                    Sounds[8].controls.play();
                }

                if (KeyEnterPressed)
                {
                    winScreen.AfterSelection();
                    KeyEnterPressed = false;
                }
            }
            else if (currentState == GameState.Lost)
            {
                //Stop game music
                Sounds[12].controls.stop();

                Sounds[13].controls.stop();

                Sounds[14].controls.stop();

                //Play "LostMusic" sound

                /*if (timeLostMusic.ElapsedMilliseconds < 2650.0)
                 * {
                 *  Sounds[16].settings.volume = 100;
                 *  Sounds[16].controls.play();
                 * }
                 *
                 * timeLostMusic.Start();
                 *
                 * if (timeLostMusic.ElapsedMilliseconds > 2650.0)
                 * {
                 *  Sounds[16].settings.volume = 0;
                 *  Sounds[16].controls.stop();
                 * }*/

                if (!lostMusicPlayed)
                {
                    Sounds[16].settings.volume = 100;
                    Sounds[16].controls.play();
                    lostMusicPlayed = true;
                }

                if ((lostScreen.Position.y + lostScreen.imageHeight / 2) < gameSize.Height / 2)
                {
                    lostScreen.Move(deltaT);
                }

                // Choose after game end
                lostScreen.Blink();
                if (KeyDownPressed && lostScreen.currentSelection < Lost.AfterState.Quit)
                {
                    lostScreen.currentSelection++;
                    KeyDownPressed = false;

                    //Play "Down" sound
                    Sounds[7].settings.volume = 100;
                    Sounds[7].controls.play();
                }
                if (KeyUpPressed && lostScreen.currentSelection > Lost.AfterState.MainMenu)
                {
                    lostScreen.currentSelection--;
                    KeyUpPressed = false;

                    //Play "Up" sound
                    Sounds[8].settings.volume = 100;
                    Sounds[8].controls.play();
                }

                if (KeyEnterPressed)
                {
                    lostScreen.AfterSelection();
                    KeyEnterPressed = false;
                }
            }
        }
Example #32
0
 public RemoveMissileObserver()
 {
     this.pMissile = null;
 }
 public SuperMissile(Vecteur2D vit, int li, bool user,Bitmap img)
     : base(new Vecteur2D(0,0), vit, li, user, img)
 {
     this.brotherRight = new Missile( vit + new Vecteur2D(30, 30), li, user, img);
     this.brotherLeft  = new Missile( vit + new Vecteur2D(-30, 30), li, user, img);
 }
Example #34
0
        /// <summary>
        /// Determines Collision between player ship and a missile
        /// </summary>
        /// <param name="m">Colliding missile</param>
        public bool Collision(Missile m)
        {
            if (m.Position.x > Position.x + imageWidth)
            {
                return(false);
            }
            else if (m.Position.y > Position.y + imageHeight)
            {
                return(false);
            }
            else if (Position.x > m.Position.x + m.imageWidth)
            {
                return(false);
            }
            else if (Position.y > m.Position.y + m.imageHeight)
            {
                return(false);
            }
            else
            {
                Vecteur2D[] v = new Vecteur2D[m.imageWidth * m.imageHeight];

                for (int i = 0; i < m.imageWidth; i++)
                {
                    for (int j = 0; j < m.imageHeight; j++)
                    {
                        v[(i * m.imageHeight) + j] = new Vecteur2D((i + m.Position.x) - Position.x, (j + m.Position.y) - Position.y);
                    }
                }

                Color currentcolor;

                Vecteur2D currentV = new Vecteur2D();

                for (int i = 0; i < v.Length; i++)
                {
                    if (v[i].y >= 0 && v[i].x > 0 && v[i].x < imageWidth && v[i].y < imageHeight)
                    {
                        currentcolor = image.GetPixel((int)v[i].x, (int)v[i].y);
                        if (currentcolor == Color.FromArgb(255, 0, 0, 0))
                        {
                            currentV.x = v[i].x;
                            currentV.y = v[i].y;
                            i          = v.Length;
                        }
                    }
                }

                if (currentV.x != 0 || currentV.y != 0)
                {
                    for (int i = (int)currentV.y; i < imageHeight; i++)
                    {
                        currentcolor = image.GetPixel((int)currentV.x, i);

                        if (currentcolor == Color.FromArgb(0, 255, 255, 255))
                        {
                            currentV.y = i - 1;
                            i          = imageHeight;
                        }
                    }

                    for (int i = 0; i < m.imageWidth; i++)
                    {
                        if (currentV.y > 0 && currentV.x > 0 && (i + currentV.x) < imageWidth)
                        {
                            currentcolor = image.GetPixel((int)(i + currentV.x), (int)currentV.y);

                            if (currentcolor == Color.FromArgb(255, 0, 0, 0))
                            {
                                Lives--;
                                m.Lives--;
                                return(true);
                            }
                        }
                    }
                }
                return(false);
            }
        }
Example #35
0
 public override void visitMissile(Missile v, CollisionPair p)
 {
 }
Example #36
0
 public override void VisitMissile(Missile m)
 {
     // Missile vs ShieldGrid
     ColPair.Collide(m, (GameObject)this.pChild);
 }
Example #37
0
 public virtual void VisitMissile(Missile m)
 {
     Debug.Assert(false);
 }
Example #38
0
 /// <summary>
 /// Update game
 /// </summary>
 public void Update(double deltaT)
 {
     // keyboard events
     if (keyPressed.Contains(Keys.Space))
     {
         if (playerMissile == null)
         {
             playerMissile = new Missile(new Vecteur2D(playerShip.position.x + 30, playerShip.position.y + 50), new Vecteur2D(0, -5), 1);
         }
     }
     if (playerMissile != null)
     {
         if (playerMissile.position.y > 0)
         {
             playerMissile.move();
             bunkers.ForEach(delegate (Bunker bunker)
             {
                 if (bunker.collision(playerMissile.position.x, playerMissile.position.y))
                 {
                     playerMissile = null;
                     bunkertoremove.Add(bunker);
                 }
             });
         }
         else
         {
             playerMissile = null;
         }
     }
     if (keyPressed.Contains(Keys.Right))
     {
         if (playerShip.position.x < gameSize.Width - 65)
         {
             playerShip.MoveRight(deltaT);
         }
         //if (ball != null)
         // {
         // ball.MoveRight(deltaT);
         // if (!ball.Alive)
         // ball = null;
         // }
     }
     if (keyPressed.Contains(Keys.Left))
     {
         if (playerShip.position.x > 0)
         {
             playerShip.MoveLeft(deltaT);
         }
         // if (ball != null)
         // {
         // ball.MoveLeft(deltaT);
         // if (!ball.Alive)
         // {
         // ball = null;
         //}
         //  }
     }
     //move ball
     // if (ball != null)
     // {
     // ball.Move(deltaT);
     // maybe dead
     //  if (!ball.Alive)
     //  ball = null;
     // }
 }
Example #39
0
 public virtual void visitMissile(Missile v, CollisionPair p)
 {
     Debug.Assert(false, "Shouldn't have been called");
 }
Example #40
0
 /// <summary>
 /// Lors d'un collision entre un missile et le buncker, on enleve le nombre de pixels en collision
 /// </summary>
 /// <param name="m">Objet misile</param>
 /// <param name="numberOfPixelsInCollision">Nombre de pixel en collision</param>
 protected override void OnCollision(Missile m, int numberOfPixelsInCollision)
 {
     m.Lives -= numberOfPixelsInCollision;
 }
Example #41
0
 /// <summary>
 /// Update game
 /// </summary>
 public void Update(double deltaT)
 {
     // keyboard events
     if (keyPressed.Contains(Keys.Space))
     {
         if (playerMissile == null)
         {
             playerMissile = new Missile(new Vecteur2D(playerShip.position.x + 30, playerShip.position.y + 50), new Vecteur2D(0, -5), 1);
             //System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"../../shoot.mp3");
             //player.Play();
         }
     }
     if (playerMissile != null && bunker != null)
     {
         if (playerMissile.position.y > 0)
         {
             playerMissile.move();
             //bunkers.ForEach(delegate (Bunker bunker)
             for(int i=0; i < bunkers.Count; i++)
             {
                 if(bunker != null && playerMissile != null)
                 {
                     if (bunker.collision(playerMissile.position.x, playerMissile.position.y))
                     {
                         playerMissile = null;
                         bunkertoremove.Add(bunker);
                     }
                 }
             }
         }
         else
         {
             playerMissile = null;
         }
     }
     if (keyPressed.Contains(Keys.Right))
     {
         if (playerShip.position.x < gameSize.Width - 65)
         {
             playerShip.MoveRight(deltaT);
         }
         //if (ball != null)
         // {
         // ball.MoveRight(deltaT);
         // if (!ball.Alive)
         // ball = null;
         // }
     }
     if (keyPressed.Contains(Keys.Left))
     {
         if (playerShip.position.x > 0)
         {
             playerShip.MoveLeft(deltaT);
         }
         // if (ball != null)
         // {
         // ball.MoveLeft(deltaT);
         // if (!ball.Alive)
         // {
         // ball = null;
         //}
         //  }
     }
     //move ball
     // if (ball != null)
     // {
     // ball.Move(deltaT);
     // maybe dead
     //  if (!ball.Alive)
     //  ball = null;
     // }
 }