} // end of Move //public void Update(Canvas theCanvas) public void Update(IGameEntityMgr theMgr) { // check for collision with the player ship if (theMgr.DetectCollision(this, theMgr.PlayerShip)) { this.Explode(); theMgr.RemainingHits--; } if (exploded) // if its true { theMgr.RemoveEnemy(this); } else { missileTimer++; if ((missileTimer >= 48) && (Canvas.GetLeft(this) < 700)) { missileTimer = 0; Fire(theMgr); } Move(Direction.Left); if (Canvas.GetLeft(this) < -100) { //theCanvas.Children.Remove(this); theMgr.RemoveGameEntity(this); } } // end if(exploded) } // end of Update
//public void Fire(Canvas theCanvas) public void Fire(IGameEntityMgr theMgr) { Missile myMissile = new Missile(Canvas.GetLeft(this) + 30, Canvas.GetTop(this) + 15); //theCanvas.Children.Add(myMissile); theMgr.AddGameEntity(myMissile); }
//public void Update(Canvas theCanvas) public void Update(IGameEntityMgr theMgr) { Move(Direction.Left); if (Canvas.GetLeft(this) < -25) { //theCanvas.Children.Remove(this); theMgr.RemoveGameEntity(this); } }
} // end of Update //public void Fire(Canvas theCanvas) public void Fire(IGameEntityMgr theMgr) { // same as player, only opposite direction enemyMissile myMissile = new enemyMissile(Canvas.GetLeft(this), Canvas.GetTop(this) + (this.ActualHeight / 2)); //theCanvas.Children.Add(myMissile); theMgr.AddGameEntity(myMissile); } // end of Fire
//public void Update(Canvas theCanvas) public void Update(IGameEntityMgr theMgr) { Move(Direction.Right); if (Canvas.GetLeft(this) > 1500) { //theCanvas.Children.Remove(this); theMgr.RemoveGameEntity(this); } else { /* for (Ship theShip in theMgr.PlayerShip) { if (theMgr.DetectCollision(theShip, this)) { theMgr.RemoveGameEntity(this); } } */ // check for collisions enemy foreach (enemyShip theEnemy in theMgr.Enemies) { if(theMgr.DetectCollision(theEnemy, this)) { theMgr.RemoveGameEntity(this); theEnemy.Explode(); //MessageBox.Show("Collision detected"); } //else if (theMgr.DetectCollision(theEnemy, this)) //{ // theMgr.RemoveGameEntity(this); // theEnemy.Explode(); //} } }//end else }
//public void Update(Canvas theCanvas) public void Update(IGameEntityMgr theMgr) { Move(Direction.Right); if (Canvas.GetLeft(this) > 1500) { //theCanvas.Children.Remove(this); theMgr.RemoveGameEntity(this); } else { /* * for (Ship theShip in theMgr.PlayerShip) * { * if (theMgr.DetectCollision(theShip, this)) * { * theMgr.RemoveGameEntity(this); * } * } */ // check for collisions enemy foreach (enemyShip theEnemy in theMgr.Enemies) { if (theMgr.DetectCollision(theEnemy, this)) { theMgr.RemoveGameEntity(this); theEnemy.Explode(); //MessageBox.Show("Collision detected"); } //else if (theMgr.DetectCollision(theEnemy, this)) //{ // theMgr.RemoveGameEntity(this); // theEnemy.Explode(); //} } }//end else }
/// //public void Update(Canvas theCanvas) public void Update(IGameEntityMgr theMgr) { }
//public void Update(Canvas theCanvas) public void Update(IGameEntityMgr theMgr) { // check for collision with the player ship if (theMgr.DetectCollision(this, theMgr.PlayerShip)) { this.Explode(); theMgr.RemainingHits--; } if (exploded) // if its true { theMgr.RemoveEnemy(this); } else { missileTimer++; if ((missileTimer >= 48) && (Canvas.GetLeft(this) < 700)) { missileTimer = 0; Fire(theMgr); } Move(Direction.Left); if (Canvas.GetLeft(this) < -100) { //theCanvas.Children.Remove(this); theMgr.RemoveGameEntity(this); } } // end if(exploded) }
//public void Fire(Canvas theCanvas) public void Fire(IGameEntityMgr theMgr) { // same as player, only opposite direction enemyMissile myMissile = new enemyMissile(Canvas.GetLeft(this), Canvas.GetTop(this) + (this.ActualHeight / 2) ); //theCanvas.Children.Add(myMissile); theMgr.AddGameEntity(myMissile); }