示例#1
0
        public void CollidedWith(IHandleCollisions gameObject)
        {
            switch (gameObject)
            {
            case Player.Player player:
                break;

            case Bullet bullet:
                _gameContext.GameAudio.PlaySoundEffect(_gameContext.AssetManager.GetSoundEffect(GameConstants.MeteorConstants.Audio.HitSoundEffectName));
                Damage(bullet.CollisionDamageAmount);
                break;

            case HealthPack healthPack:
                break;

            case Meteor meteor:
                //ToDo do something here to stop meteors overlapping
                break;

            case Enemy enemy:
                //Damage(enemy.CollisionDamageAmount);
                break;
            }
            Console.WriteLine($"{GetType()} collided with {gameObject.GetType()}");
        }
示例#2
0
        public void CollidedWith(IHandleCollisions gameObject)
        {
            switch (gameObject)
            {
            case Player.Player player:
                //ToDo swap for appropriate sfx (enemy collided with player)
                _gameContext.GameAudio.PlaySoundEffect(_gameContext.AssetManager.GetSoundEffect(GameConstants.ProjectileConstants.Bullet3Constants.Audio.ShootSoundEffectName));
                Damage(player.CollisionDamageAmount);
                break;

            case Bullet bullet:
                //ToDo swap for appropriate sfx (enemy collided with bullet)
                _gameContext.GameAudio.PlaySoundEffect(_gameContext.AssetManager.GetSoundEffect(GameConstants.ProjectileConstants.Bullet3Constants.Audio.ShootSoundEffectName));
                Damage(bullet.CollisionDamageAmount);
                break;

            case HealthPack healthPack:
                break;

            case Enemy enemy:
                //ToDo do something here to stop enemies overlapping
                break;

            case Meteor meteor:
                //ToDo swap for appropriate sfx (enemy collided with meteor)
                //_gameContext.GameAudio.PlaySoundEffect(_gameContext.AssetManager.GetSoundEffect(GameConstants.Projectiles.Bullet3.Audio.ShootSoundEffectName));
                //Damage(meteor.CollisionDamageAmount);
                break;
            }
            Console.WriteLine($"{GetType()} collided with {gameObject.GetType()}");
        }
示例#3
0
        public void CollidedWith(IHandleCollisions gameObject)
        {
            Console.WriteLine($"{GetType()} collided with {gameObject.GetType()}");

            //ToDo Assign and use collision layers
            if (gameObject is Player.Player)
            {
                IsActive = false;
                PlayCollectedSoundEffect();
            }
        }
示例#4
0
文件: Organism.cs 项目: skasti/Cells
 private void AddCollisionHandler(IHandleCollisions collisionHandler)
 {
     if (_collisionHandlers.ContainsKey(collisionHandler.CollidesWith))
     {
         _collisionHandlers[collisionHandler.CollidesWith].Add(collisionHandler);
     }
     else
     {
         _collisionHandlers.Add(collisionHandler.CollidesWith, new List <IHandleCollisions> {
             collisionHandler
         });
     }
 }
示例#5
0
 public void RegisterEntity(IHandleCollisions entity)
 {
     _entitiesToAdd.Add(entity);
 }