private void UpdateGeneralCollision(GameObject gameObject, GameObject colidedWith) { //player collision Player gameObjectAsPlayer = gameObject as Player; if (gameObjectAsPlayer != null) { //boxes collision if (colidedWith.tags.Contains("box")) { if (CollisionManager.GameObjectTouch(gameObjectAsPlayer, colidedWith)) { gameObjectAsPlayer.push(colidedWith); } } //enemies collision Enemy enemy = colidedWith as Enemy; if (enemy != null) { if (CollisionManager.GameObjectTouch(enemy, gameObjectAsPlayer)) { gameObjectAsPlayer.DealDamage(enemy); } } } //projectiles collision Projectile projectile = gameObject as Projectile; if (projectile != null) { //enemy collision Enemy enemy = colidedWith as Enemy; if (enemy != null) { if (CollisionManager.GameObjectCollision(enemy, projectile)) { projectile.Colide(enemy); } } //player collision (pvp!) Player colidedWithAsPlayer = colidedWith as Player; if (colidedWithAsPlayer != null && colidedWithAsPlayer != projectile.source) { if (CollisionManager.GameObjectCollision(colidedWithAsPlayer, projectile)) { projectile.Colide(colidedWithAsPlayer); } } } }
public bool CollisionCheck(GameObject gameObject, Rectangle gameObjectBounds) { foreach (GameObject currentGameObject in map.gameObjectList) { if (CollisionManager.GameObjectCollision(gameObject, currentGameObject, gameObjectBounds, currentGameObject.core))//new Rectangle((int)currentGameObject.position.X, (int)currentGameObject.position.Y, currentGameObject.core.Width, currentGameObject.core.Height))) { if (!gameObject.passable && !currentGameObject.passable) { return(true); } } } return(false); }
private static void UpdateMineCollision(GameObject gameObject, GameObject colidedWith) { //mine and hostile Hostile hostile = colidedWith as Hostile; if (hostile != null) { Mine mine = gameObject as Mine; if (CollisionManager.GameObjectCollision(hostile, mine, false) && hostile != mine.source) { hostile.DealDamage(mine.source, false, mine.strength); mine.Kill(); } } }
private void PortalCollision(GameObject portal, GameObject colidedWith) { Window window = colidedWith as Window; Sprite sprite = colidedWith as Sprite; if (window == null && sprite != null) { if (CollisionManager.GameObjectCollision(portal, sprite)) { MapCollection.classic.RemoveObject(sprite); MapCollection.tower.AddObject(sprite); sprite.Reset(); } } }
private void UpdatePickupCollision(GameObject gameObject, GameObject colidedWith) { Player player = colidedWith as Player; if (player != null) { Pickup pickUp = gameObject as Pickup; if (CollisionManager.GameObjectCollision(pickUp, player)) { Game.content.Load <SoundEffect>("Audio\\Waves\\confirm").Play(); player.pack.AddItem(ItemCollection.CopyItem(pickUp.item)); pickUp.Kill(); } } }
private void GroundSwitchCollision(GameObject groundSwitch, GameObject colidedWith) { if (colidedWith.tags.Contains("box")) { bool blockKilled = false; if (!blockKilled) { if (CollisionManager.GameObjectCollision(colidedWith, groundSwitch)) { block.Kill(); blockKilled = true; } else { block.Revive(); } } } }
private void RunningSwitchCollision(GameObject runningSwitch, GameObject colidedWith) { //running switch and player Player player = colidedWith as Player; if (player != null) { int collisionID = map.gameObjectList.IndexOf(runningSwitch); if (CollisionManager.GameObjectCollision(player, runningSwitch)) { if (!player.collisionsList.Contains(collisionID)) { player.FlipRunning(); player.collisionsList.Add(collisionID); } } else { player.collisionsList.Remove(collisionID); } } }