예제 #1
0
        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);
                    }
                }
            }
        }
예제 #2
0
 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);
 }
예제 #3
0
        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();
                }
            }
        }
예제 #4
0
        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();
                }
            }
        }
예제 #5
0
        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();
                }
            }
        }
예제 #6
0
 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();
             }
         }
     }
 }
예제 #7
0
        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);
                }
            }
        }