private void collide(GameTime gameTime) { ennemiesCollision(); shieldCollision(); obstaclesCollision(); if (!lvlOver && Engine2D.testCollision(who, tardis.tardisBbox)) { who.enterTardis(); tardis.dematerialise(gameTime); this.timer = 0f; this.lvlOver = true; } }
private void obstaclesCollision() { foreach (Obstacle obs in obstacles) { if (Engine2D.testCollision(who, obs.Bbox)) { who.State = Status.BLOCKED; who.Velocity = new Vector2(0, who.Velocity.Y); Vector2 bounce = who.Position; Vector2 backSlide = new Vector2(-0.1f, 0); while (who.Position.X > bounce.X - 2) { who.Position += backSlide; } } else { who.State = Status.FREE; } } }
private void ennemiesCollision() { foreach (Foe baddy in baddies) { if (Engine2D.testCollision(who, baddy.Bbox)) { Exit(); } if (baddy is Cyberman) { if (Engine2D.testSonicAttack(who.SonicBbox, baddy.Bbox)) { baddy.kill(); } if (Engine2D.testCollision(baddy, this.tardis.shieldBbox)) { baddy.kill(); } } else if (baddy is Dalek) { if (Engine2D.testLaserAttack(who.Bbox, (Dalek)baddy) && who.DoctorMouvement != Mouvement.GLISSADE) { Exit(); who.State = Status.DEAD; } } else if (baddy is WeepingAngel) { if (Engine2D.testCollision(baddy, this.tardis.shieldBbox)) { baddy.State = Status.BLOCKED; } } } }