private void BulletCollide(float deltatime) { foreach (VerticalWall v in WallGeneration.VerWallList1) { if (_hitbox.DetectCollision(v._hitbox)) { _parent.RemoveChild(this); } } foreach (HorizontalWall h in WallGeneration.HorWallList1) { if (_hitbox.DetectCollision(h._hitbox)) { _parent.RemoveChild(this); } } foreach (Enemy e in Enemy.Enemies1) { if (_hitbox.DetectCollision(e._hitbox)) { e.Damage(1); _parent.RemoveChild(this); } } }
public void Detection(float deltime) { if (_num == 1 && _box.DetectCollision(Axis.hitbox.ElementAt(0))) { Parent.RemoveChild(this); } else if (_num == 0 && _box.DetectCollision(Axis.hitbox.ElementAt(1))) { Parent.RemoveChild(this); } }
//Checks to see if the ladder is touching hte player private void Touch(float deltaTime) { if (_hitbox == null) { return; } if (_hitbox.DetectCollision(Player.Instance.HitBox)) { Player.Instance.TakeDamage(); } }
//destroys both tanks when they collide public void tankOnTankCollision(float deltaTime) { foreach (Tank t in PlayerList) { if (playerNum != t.playerNum) { if (_pHitbox.DetectCollision(t._pHitbox) == true) { Parent.RemoveChild(t); Parent.RemoveChild(this); } } } }
//destroys tank if hit buy opponents bullet public void tankOnBulletCollision(float deltaTime) { foreach (Tank t in Tank.PlayerList) { if (playerNum != t.getPlayerNum()) { if (_bHitbox.DetectCollision(t.getTankHitbox()) == true) { Parent.RemoveChild(t); Parent.RemoveChild(this); } } } }
public void CollidewithTank(float deltatime) { if (hitbox.DetectCollision(Program.player1.hitbox)) { // Destroy(); this does not work as it destroys the player when the game starts } }
public void BounceCheck(float deltatime) { if (_hitbox.Right >= 1280) { XVelocity = -XVelocity / 2; //X = 1232; } else if (_hitbox.Left <= 0) { XVelocity = -XVelocity / 2; //X = 6; } if (_hitbox.Bottom >= 760) { YVelocity = -YVelocity / 2; //Y = 720; } else if (_hitbox.Top <= 0) { YVelocity = -YVelocity / 2; //Y = 6; } foreach (VerticalWall v in WallGeneration.VerWallList1) { if (_hitbox.DetectCollision(v._hitbox)) { XVelocity = -XVelocity; } } foreach (HorizontalWall h in WallGeneration.HorWallList1) { if (_hitbox.DetectCollision(h._hitbox)) { YVelocity = -YVelocity; } } foreach (Enemy e in Enemy.Enemies1) { if (_hitbox.DetectCollision(e._hitbox)) { XVelocity = -XVelocity; YVelocity = -YVelocity; } } }
public void Collideswithtank(float deltatime) { //_hitbox.DetectCollision(Program.tank.Hitbox); if (_hitbox.DetectCollision(Program.tank2.Hitbox)) { Parent.RemoveChild(Program.tank2); } }
// Checks the Pilot's Tank Collision public bool DetectCollision(AABB other) { if (_hitbox.DetectCollision(other)) { RemoveChild(_hitbox); RemoveChild(_texture); RemoveChild(tankBarrel); if (Parent != null) { Parent.RemoveChild(this); } return(true); } else { return(false); } }
//Detects if the shell collides with a tank public void DetectHit(float deltaTime) { AABB _checkBox1 = TankBase.hitboxes.ElementAt(0); AABB _checkBox2 = TankBase.hitboxes.ElementAt(1); //Checks if the Player 2 shell collided with the Player 1 tank if (_checkBox1.Parent.Parent.Parent != null && _playerNum == 1 && _shellHitbox.DetectCollision(_checkBox1)) { Parent.RemoveChild(_checkBox1.Parent.Parent); Parent.RemoveChild(this); } //Checks if the Player 1 shell collided with the Player 2 tank else if (_checkBox2.Parent.Parent.Parent != null && _playerNum == 0 && _shellHitbox.DetectCollision(_checkBox2)) { Parent.RemoveChild(_checkBox2.Parent.Parent); Parent.RemoveChild(this); } }
//checks if there is a collision with the player private void playerCollide(float deltatime) { //check player collision if (Hitbox.DetectCollision(Player.Instance.HitBox())) { //trigger player hit behavior Player.Instance.Playerhit(); } }
public void OnColide(float deletatime) //if the player collides with a bullet this will trigger { //the tanks will send in a integer called playernumber down to hear which will prevent the bullets from destroying there own tank if (hitbox.DetectCollision(Program.player1.hitbox) && _playernumber != 1) { Program.player1.Destroy(); } if (hitbox.DetectCollision(Program.player2.hitbox) && _playernumber != 2) { Program.player2.Destroy(); } if (X > Game.gameWidth || Y > Game.gameHeight || X < 0 || Y < 0) //if the bullet leaves the screen the game will destroy it { destroy(); } }
//Checks if the enemy has touched the sword protected void Touch(float deltaTime) { if (_hitbox.DetectCollision(Sword.Instance._hitbox) && Iframes.Seconds >= 2f) { Iframes.Restart(); _health -= Sword.Instance.Damage; if (_health <= 0) { Die(); } } }
public bool DetectCollision(AABB other, int damage) { if (_hitbox.DetectCollision(other)) { Health -= damage; return(true); } else { return(false); } }
public void CheckCollision(float deltaTime) { if (Parent != null) { foreach (Actor hitCheck in Parent.GetChildren) { if (hitCheck is Debris && !(_origin is Debris)) { Debris debris = (Debris)hitCheck; if (debris.DetectCollision(_hitbox)) { Destroy(); if (debris is Satellite) { Ship.Score += 150; } else { Ship.Score += 100; } } } if (hitCheck is Ship && !(_origin is Ship)) { Ship ship = (Ship)hitCheck; if (ship.DetectCollision(_hitbox, _damage)) { Destroy(); } } if (hitCheck is Bullet) { Bullet bullet = (Bullet)hitCheck; if (bullet._origin is Ship && !(_origin is Ship)) { if (_hitbox.DetectCollision(bullet._hitbox)) { Destroy(); bullet.Destroy(); Ship.Score += 10; } } } } } }
//Checks to see if the player is touching the collectable private void Touch(float deltaTime) { if (_hitbox == null) { return; } if (_hitbox.DetectCollision(Player.Instance.HitBox)) { RemoveChild(_hitbox); _hitbox = null; RemoveChild(_sprite); _timer.Restart(); } }
public virtual bool DetectCollision(AABB other) { if (_hitbox.DetectCollision(other)) { RemoveChild(_hitbox); if (Parent != null) { Parent.RemoveChild(this); } return(true); } else { return(false); } }
//checks astroid collision private void BulletCollide(float deltatime) { //scan astroid list for collisions foreach (Astroid a in Game.AstroidList) { //remove astroid and bullet if (_hitbox.DetectCollision(a.Hitbox)) { //destroy astroid Parent.RemoveChild(a); //destroy bullet Parent.RemoveChild(this); //incrament score Game.score += 10 * Game.difficulty; } } }
//destroys opponents bullets if they hit sansbullet public override void bulletOnBulletCollision(float deltaTime) { Actor Root = Parent as Actor; foreach (Actor b in Root.GetChildren()) { if (b is Bullet) { Bullet bullet = b as Bullet; if (bullet.playerNum == playerNum) { return; } else if (_bHitbox.DetectCollision(bullet._bHitbox) == true) { Parent.RemoveChild(b); Parent.RemoveChild(this); } } } }
public override void Update(float deltaTime) { _tankBox.DetectCollision(Program.box); Moveforward(); base.Update(deltaTime); }
// Checks enemy Tanks Collision public bool CollisionCheck(AABB other) { return(_hitbox.DetectCollision(other)); }