Example #1
0
        public bool OnCollision(DrawableSceneComponent dsc)
        {
            Ground g = dsc as Ground;

            if (g != null)
            {
                return(true);
            }
            Levels.Characters.Hero h = dsc as Levels.Characters.Hero;
            if (life <= 0)
            {
                if (h != null)
                {
                    if (hasPaint)
                    {
                        Levels.Characters.Hero.IncreaseLife();
                        hasPaint     = false;
                        this.Visible = false;
                    }
                }
                return(false);
            }
            AI.AIMonster ai = dsc as AI.AIMonster;
            if (ai != null)
            {
                return(true);
            }
            if (h == null)
            {
                if (dsc.PhysicsBody.LinearVelocity.Length() * dsc.PhysicsBody.Mass > minLinearMoment)
                {
                    life--;
                    if (life == 0)
                    {
                        Message m = new Message
                        {
                            MessageType  = MessageTypes.die,
                            timeDelivery = 0,
                            to           = this
                        };
                        AIManager.messageQueue.sendMessage(m);
                    }
                    return(false);
                }
            }
            return(true);
        }
Example #2
0
 /// <summary>
 /// Handles collisions of Hero with AIEntities
 /// </summary>
 public bool OnCollision(Scenes.DrawableSceneComponent dsc)
 {
     AI.AIMonster monster = dsc as AI.AIMonster;
     if (monster == null)
     {
         return(true);
     }
     if (monster.life > 0)
     {
         DecreaseLife();
         return(true);
     }
     else
     {
         return(true);
     }
 }