public bool ShootMissile() { if (_missile == null) { Rectangle inRect = ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).getRectangle(); _missile = GameObjMananger.getInstance().CreateMissile(new Rectangle(inRect.X + inRect.Width / 2 - 10 / 2, inRect.Y, 10, 16)); _missile.setStatus(false); Sound Effect = SoundManager.getInstance().Find(SoundName.Missile); Effect.PlaySound(); return(true); } else { if (!_missile.getStatus()) { _missile.Position.Y = Position.Y - 2; _missile.setStatus(true); Sound Effect = SoundManager.getInstance().Find(SoundName.Missile); Effect.PlaySound(); return(true); } } return(false); }
public override void VisitShield(Shield inShield) { if (inShield.CheckParts(this)) { ((Super)(GameObjMananger.getInstance().Find(GameObjName.Super))).ReloadBomb(this); } }
public Super CreateSuper() { Super temp = ((Super)(Find(GameObjName.Super))); if (temp != null) { ((Super)(Find(GameObjName.Super))).Purge(); } ColObj _colobj = new ColObj(Rectangle.Empty, ColObjName.Super, SpriteName.BBox); ColObjManager.getInstance().Add(_colobj); Super Obj; if (temp != null) { Obj = temp; Obj.BombPool = temp.BombPool; } else { Obj = new Super(GameObjName.Super, _colobj, new Vector2(0, 0)); Obj.BombPool = new BombReserve(); ColGroup Invaders = ColGroupManager.getInstance().find(ColGroupName.Alien); Invaders.Add(Obj); GameObjMananger.getInstance().Add(Obj); } Obj.Create(); return(Obj); }
public override void VisitSuper(Super inSuper) { if (inSuper.CheckColumns(this)) { ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).ReloadMissile(); } }
public override void VisitShield(Shield inShield) { if (inShield.CheckParts(this)) { ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).ReloadMissile(); } }
public void Create() { for (int i = 0; i < bufferSize; ++i) { Bombs.Add(GameObjMananger.getInstance().CreateBomb(new Rectangle(-1, -1, 0, 0))); } }
public bool CheckColumns(Missile inObj) { ListNode ptr = (ListNode)Columns.getActiveHead(); while (ptr != null) { Column temp = (Column)ptr.getData(); if (temp.iSCollide(inObj.getCollisionObjRectangle())) { bool Hit = temp.CheckAliens(inObj); if (((Column)ptr.getData()).isEmpty()) { Columns.Remove(ptr); GameObjMananger.getInstance().KillObject((Column)ptr.getData(), SpriteBatchName.Scene); } Rectangle X = UpdateSize(); if (X.Equals(Rectangle.Empty)) { GameManager.getInstance().NextLevel(); } return(Hit); } ptr = (ListNode)ptr.pNext; } return(false); }
public void ReCreate(NodeName PName) { Rectangle Rect = new Rectangle((int)Position.X, (int)Position.Y, 25, 25); Alien Obj = null; for (int i = 0; i < 5; ++i) { if (i == 0) { Obj = GameObjMananger.getInstance().CreateAliens(Rect, SpriteName.Squid, PName, 30); } else if (i <= 2) { Obj = GameObjMananger.getInstance().CreateAliens(Rect, SpriteName.Crab, PName, 20); } else if (i > 2) { Obj = GameObjMananger.getInstance().CreateAliens(Rect, SpriteName.Octopus, PName, 10); } Aliens.Add(Obj); Obj = null; Rect.Y += (5 + Rect.Height); } }
public bool CheckParts(GameObj inObj) { ListNode ptr = (ListNode)ShieldParts.getActiveHead(); while (ptr != null) { ShieldPart temp = (ShieldPart)ptr.getData(); if (temp.iSCollide(inObj.getCollisionObjRectangle())) { temp.Health--; switch (temp.Health) { case 3: temp.FlipSprite(SpriteName.ShieldPart2); break; case 2: temp.FlipSprite(SpriteName.ShieldPart3); break; default: ShieldParts.Remove(ptr); GameObjMananger.getInstance().KillObject((ShieldPart)ptr.getData(), SpriteBatchName.Shields); UpdateSize(); break; } return(true); } ptr = (ListNode)ptr.pNext; } return(false); }
public void Reset() { this.FlipSprite(SpriteName.Ufo); isDying = false; this.direction.X = 0; this.Position.X = -70; Random X = new Random(); int s = X.Next(3); switch (s) { case 0: score = 50; break; case 1: score = 100; break; case 2: score = 150; break; } Sound Effect = SoundManager.getInstance().Find(SoundName.UFOMove); Effect.PauseSoundLooped(); TimeSpan FrameInterval = new TimeSpan(0, 0, 20); UFO ufo = (UFO)GameObjMananger.getInstance().Find(GameObjName.UFO); TimeEventManager.getInstance().Add(TimeEventManager.getInstance().GetCurrentTime() + FrameInterval, ufo, delegate { Actions.Act(ufo); }); }
public void Action() { Step = true; int count = 0; UpdateMovement(ref count); Random R = new Random(); int Chosen = R.Next(count); Column inCol = (Column)Columns.getDatabyIndex(Chosen); BombPool.Update(inCol); Rectangle tempRect = UpdateSize(); UpdateCollisionObject(tempRect); UpdateAnimStep(); if (this.getCollisionObjRectangle().Y + this.getCollisionObjRectangle().Height >= 715) { ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).Status = playerStatus.Dead; GameManager.getInstance().Hit(); GameManager.getInstance().Hit(); GameManager.getInstance().Hit(); } }
public void GAMEOVER() { ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).score = currentPlayerScore; currentPlayerScore = 0; ScreenManager.Instance().CurrentScreen = Screen.GameOver; ScreenManager.Instance().switchScreen(); }
public void Reset() { Status = playerStatus.Live; lives = 2; score = 0; ((UI)(GameObjMananger.getInstance().Find(GameObjName.LivesUI))).ChangeText(lives); }
public void UpdateHIScore() { if (currentPlayerScore > currentHiScore) { currentHiScore = currentPlayerScore; ((UI)(GameObjMananger.getInstance().Find(GameObjName.HiScore))).ChangeText(currentHiScore); } }
public override void VisitBomb(Bomb inBomb) { ((Super)(GameObjMananger.getInstance().Find(GameObjName.Super))).ReloadBomb(inBomb); if (Status == playerStatus.Live) { TimeSpan FrameInterval = new TimeSpan(0); Animation An = AnimationManager.getInstance().Find(AnimName.ShipDeath); TimeEventManager.getInstance().Add(TimeEventManager.getInstance().GetCurrentTime() + FrameInterval, An, delegate { Actions.Animate(An, this); }); } }
public void StartTimedEvents() { TimeSpan FrameInterval = new TimeSpan(5750000); Super Super = (Super)GameObjMananger.getInstance().Find(GameObjName.Super); TimeEventManager.getInstance().Add(TimeEventManager.getInstance().GetCurrentTime() + FrameInterval, Super, delegate { Actions.Act(Super); }); FrameInterval = new TimeSpan(0, 0, 15); UFO ufo = (UFO)GameObjMananger.getInstance().Find(GameObjName.UFO); TimeEventManager.getInstance().Add(TimeEventManager.getInstance().GetCurrentTime() + FrameInterval, ufo, delegate { Actions.Act(ufo); }); }
public void NextLevel() { CurrLevel++; Difficulty = CurrLevel * 50; if (Difficulty > 200) { Difficulty = 200; } Super temp = GameObjMananger.getInstance().CreateSuper(); temp.direction.Y = 50; }
public void ReloadBomb(Bomb inBomb) { usedBomb--; Column temp = ((Column)(GameObjMananger.getInstance().Find(inBomb.ColumnName))); if (temp != null) { temp.Bomb_Active = false; } inBomb.setStatus(false); Add(inBomb); }
public void Create(Rectangle inRect) { Rectangle tempRect = inRect; bool toDraw = false;; for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; j++) { if (i != 7 && i != 8 && i != 9) { toDraw = true; } else if (j != 3 && j != 4 && j != 5 && j != 6) { toDraw = true; } if ((i == 0 && j == 0) || (i == 0 && j == 9)) { toDraw = false; } if ((i == 0 && j == 1) || (i == 0 && j == 8)) { toDraw = false; } if ((i == 1 && j == 0) || (i == 1 && j == 9)) { toDraw = false; } if (toDraw) { TextureSprite inSprite = new TextureSprite(tempRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.ShieldPart); ColObj _colobj = new ColObj(tempRect, ColObjName.ShieldPart, SpriteName.BBox); ShieldPart Obj = new ShieldPart(GameObjName.ShieldPart, _colobj, new Vector2(tempRect.X, tempRect.Y), inSprite); ColObjManager.getInstance().Add(_colobj); SpriteBatchManager.getInstance().Find(SpriteBatchName.Shields).Add(inSprite); GameObjMananger.getInstance().Add(Obj); ShieldParts.Add(Obj); } tempRect.X += 10; toDraw = false; } tempRect.X = inRect.X; tempRect.Y += 10; } }
public void Reset() { Sound Effect = SoundManager.getInstance().Find(SoundName.UFOMove); Effect.PauseSoundLooped(); CurrLevel = 0; Difficulty = CurrLevel * 2; ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).Reset(); ((UI)(GameObjMananger.getInstance().Find(GameObjName.Score))).ChangeText(0); getCurrentPlayerData(); GameObjMananger.getInstance().ResetLevel(); }
public void Initialize(GraphicsDeviceManager graphics, SpriteBatch spritebatch) { TextureManager.getInstance().Initialize(); TextureManager.getInstance().CreateGameTextures(); SoundManager.getInstance().Initialize(); SoundManager.getInstance().CreateSounds(); ImageManager.getInstance().Initialize(); ImageManager.getInstance().CreateGameImages(); SpriteManager.getInstance().Initialize(); SpriteManager.getInstance().CreateAllSprites(); AnimationManager.getInstance().Initialize(); AnimationManager.getInstance().CreateAnimations(); SpriteBatchManager.getInstance().Initialize(); SpriteBatchManager.getInstance().CreateAllSpriteBatches(graphics.GraphicsDevice); SpriteBatchManager.getInstance().CreateMenu(graphics.GraphicsDevice); ColObjManager.getInstance().Initialize(); GameObjMananger.getInstance().Initialize(); ColGroupManager.getInstance().Initialize(); ColGroupManager.getInstance().Create(); ColPairManager.getInstance().Initialize(); ColPairManager.getInstance().CreateCollisionPairs(); GameObjMananger.getInstance().CreateSuper(); GameObjMananger.getInstance().CreateLevel(graphics.GraphicsDevice); GameObjMananger.getInstance().CreateShield(); GameObjMananger.getInstance().CreateShip(); GameObjMananger.getInstance().CreateUI(); GameObjMananger.getInstance().CreateUfo(); InputManager.Instance().Initialize(); TimeEventManager.getInstance().Initialize(); TimeEventManager.getInstance().StartTimedEvents(); ScreenManager.Instance().CurrentScreen = Screen.MainMenu; ScreenManager.Instance().switchScreen(); getCurrentPlayerData(); CurrLevel = 0; Difficulty = CurrLevel * 2; }
public void Hit() { currentPlayerLives--; if (currentPlayerLives >= 0) { ((UI)(GameObjMananger.getInstance().Find(GameObjName.LivesUI))).ChangeText(currentPlayerLives); Lives l = (Lives)GameObjMananger.getInstance().Find(GameObjName.Life); if (l != null) { GameObjMananger.getInstance().KillObject(l, SpriteBatchName.Scene); } } }
public void reCreate() { Vector2 ColumnPos = new Vector2(50, 200); NodeName PName = NodeName.Col1; GameObjName ColumnName = GameObjName.Column1; for (int i = 0; i < 5; ++i) { Column Obj = GameObjMananger.getInstance().CreateColumns(new Vector2(ColumnPos.X, ColumnPos.Y), ColumnName, PName); Columns.Add(Obj); ColumnPos.X += 50; PName++; ColumnName++; } }
public void Purge() { ListNode ptr = null; do { ptr = (ListNode)Aliens.getActiveHead(); if (ptr != null) { Alien temp = (Alien)ptr.getData(); Aliens.Remove(ptr); GameObjMananger.getInstance().KillObject(temp, SpriteBatchName.Scene); } } while (ptr != null); }
public Ship CreateShip() { Rectangle inRect = new Rectangle(476, 715, 58, 32); TextureSprite Text = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Ship); ColObj _colobj = new ColObj(inRect, ColObjName.Ship, SpriteName.BBox); Ship Obj = new Ship(GameObjName.Ship, _colobj, new Vector2(inRect.X, inRect.Y), Text, ColGroupName.Ship); ColObjManager.getInstance().Add(_colobj); SpriteBatchManager.getInstance().Find(SpriteBatchName.Scene).Add(Text); ColGroupManager.getInstance().find(ColGroupName.Ship).Add(Obj); GameObjMananger.getInstance().Add(Obj); this.CreateMissile(new Rectangle(inRect.X + inRect.Width / 2 - 10 / 2, inRect.Y - 2, 10, 16)); return(Obj); }
public Lives CreateLives() { Rectangle inRect = new Rectangle(0, 0, 48, 32); TextureSprite Life = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Ship); Lives _Lives = new Lives(GameObjName.Life, new Vector2(75, 760), Life); SpriteBatchManager.getInstance().Find(SpriteBatchName.Scene).Add(Life); GameObjMananger.getInstance().Add(_Lives); inRect = new Rectangle(0, 0, 48, 32); Life = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Ship); _Lives = new Lives(GameObjName.Life, new Vector2(145, 760), Life); SpriteBatchManager.getInstance().Find(SpriteBatchName.Scene).Add(Life); GameObjMananger.getInstance().Add(_Lives); return(_Lives); }
public bool CheckAliens(ShieldPart inObj) { ListNode ptr = (ListNode)Aliens.getActiveHead(); while (ptr != null) { Alien temp = (Alien)ptr.getData(); if (temp.iSCollide(inObj.getCollisionObjRectangle())) { GameObjMananger.getInstance().KillObject(inObj, SpriteBatchName.Shields); return(true); } ptr = (ListNode)ptr.pNext; } return(false); }
public UFO CreateUfo() { Rectangle inRect = new Rectangle(-70, 120, 95 / 2, 46 / 2); TextureSprite Text = new TextureSprite(inRect, new Vector2(1, 1), 0.0f, 1.0f, SpriteName.Ufo); ColObj _colobj = new ColObj(inRect, ColObjName.UFO, SpriteName.BBox); ColObjManager.getInstance().Add(_colobj); UFO Obj = new UFO(GameObjName.UFO, _colobj, new Vector2(inRect.X, inRect.Y), Text, 100); SpriteBatchManager.getInstance().Find(SpriteBatchName.Scene).Add(Text); ColGroup Invaders = ColGroupManager.getInstance().find(ColGroupName.Ufo); Invaders.Add(Obj); GameObjMananger.getInstance().Add(Obj); return(Obj); }
public static void Animate(Animation Anim, UFO Ufo) { if (!Ufo.isDying) { Ufo.FlipSprite(Anim.getNextFrame()); TimeSpan FrameInterval = new TimeSpan(1750000); TimeEventManager.getInstance().Add(TimeEventManager.getInstance().GetCurrentTime() + FrameInterval, Anim, delegate { Actions.Animate(Anim, Ufo); }); Ufo.isDying = true; Sound Effect = SoundManager.getInstance().Find(SoundName.UFOKill); Effect.PlaySound(); } else { Ufo.Reset(); GameManager.getInstance().ScoreUp(Ufo.getScore()); UI Score = (UI)GameObjMananger.getInstance().Find(GameObjName.Score); Score.ChangeText(GameManager.getInstance().getCurrentScore()); } }
public void Update(GameTime gameTime) { currentPlayerStatus = ((Ship)(GameObjMananger.getInstance().Find(GameObjName.Ship))).Status; InputManager.Instance().Update(ScreenManager.Instance().CurrentScreen); if (currentPlayerStatus != playerStatus.Dead && ScreenManager.Instance().CurrentScreen == Screen.Game) { ColPairManager.getInstance().Collide(); GameObjMananger.getInstance().Update(gameTime); TimeEventManager.getInstance().Update(gameTime); AnimationManager.getInstance().Update(gameTime); UpdateHIScore(); } if (currentPlayerStatus == playerStatus.Dead && ScreenManager.Instance().CurrentScreen == Screen.Game) { GAMEOVER(); } }