private void reactionToShip(Ship s, Bomb b, Vector2 _point) { if (s.type == GameObjType.p1ship) { GameObjManager.Instance().remove(batchEnum.ships, s); BombManager.Instance().removeBomb(b, s.spriteRef.pos, s.spriteRef.color); hit(PlayerID.one); ScoreManager.Instance().p2Kill(); playShipHitSound(); playBombHitSound(); } else if (s.type == GameObjType.p2ship) { GameObjManager.Instance().remove(batchEnum.ships, s); BombManager.Instance().removeBomb(b, s.spriteRef.pos, s.spriteRef.color); hit(PlayerID.two); ScoreManager.Instance().p1Kill(); playShipHitSound(); playBombHitSound(); } else { } playShipHitSound(); }
private void createBomb(PlayerID _id, Ship s) { BombData data = BombManager.Instance().getNextBomb(_id); bombID = data.ID; bombsprite = data.sprite; spriteRef = new Sprite_Proxy(bombsprite, (int)s.spriteRef.pos.X, (int)s.spriteRef.pos.Y, 0.5f, Color.White); SBNode bombBatch = SpriteBatchManager.Instance().getBatch(batchEnum.bomb); bombBatch.addDisplayObject(spriteRef); orgPos = spriteRef.pos; if (_id == PlayerID.one) { image1 = ImageManager.Instance().getImage(ImageEnum.bluebomb1); image2 = ImageManager.Instance().getImage(ImageEnum.bluebomb2); } else { image1 = ImageManager.Instance().getImage(ImageEnum.greenbomb1); image2 = ImageManager.Instance().getImage(ImageEnum.greenbomb2); } spriteRef.sprite.image = image1; curImage = 0; state = BombState.alive; }
private void bombAnim(object obj) { if (state == BombState.alive) { flipSprite(); // local data for my call back (I call it monkey) CallBackData monoData = (CallBackData)obj; // get the current time TimeSpan totTime = Timer.GetCurrentTime() - monoData.deltaTime; if (totTime.TotalSeconds > 5) { BombManager.Instance().removeBomb(this); } else { // Update my target time for next TimeEvent monoData.targetTime = Timer.GetCurrentTime() + new TimeSpan(0, 0, 0, 0, 300); // just increment count to show off monoData.count += 10; // install next TimeEvent Timer.Add(monoData.targetTime, obj, bombAnim); } } else { } }
private void reactionToBomb(Missile m, Bomb b, Vector2 _point) { BombManager.Instance().removeBomb(b, b.spriteRef.pos, b.spriteRef.color); GameObjManager.Instance().remove(batchEnum.missiles, m); PlayerManager.getPlayer(m.owner).increaseNumMissiles(); }