collideWith() public method

public collideWith ( Unit otherUnit ) : bool
otherUnit Unit
return bool
コード例 #1
0
        public bool checkCollisionWithBullet(Unit unit)
        {
            // If shot is still in play, check for collisions
            for (int j = 0; j < monsters.Count; ++j)
            {
                if (monsters[j].unit.alive && unit.collideWith(monsters[j].unit))
                {
                    monsters[j].health -= myGame.difficultyConstants.MONSTER_HEALTH_PER_BULLET;
                    hpBillBoardSystem.setTexture(j);

                    if (monsters[j].health <= 0)
                    {
                        monsters[j].Die();
                        monsters[j].unit.alive = false;
                        myGame.mediator.fireEvent(MyEvent.M_DIE);
                    }
                    else
                    {
                        monsters[j].TakeDamage();
                        ((MonsterUnit)monsters[j].unit).moving = true;
                    }
                    return true;
                }
            }
            return false;
        }
コード例 #2
0
        public bool checkCollisionWithBullet(Unit unit)
        {
            // If shot is still in play, check for collisions
            for (int j = 0; j < monsters.Count; ++j)
            {
                if (monsters[j].unit.alive && unit.collideWith(monsters[j].unit))
                {
                    myGame.mediator.fireEvent(MyEvent.M_HIT);
                    monsters[j].health -= monsters[j].monsterUnit.monsterConstants.MONSTER_HEALTH_PER_BULLET;
                    hpBillBoardSystem.setTexture(j);

                    if (monsters[j].health <= 0)
                    {
                        monsters[j].Die();
                        monsters[j].unit.alive = false;
                        myGame.mediator.fireEvent(MyEvent.M_DIE, "Score", monsters[j].getScore());
                    }
                    else
                    {
                        monsters[j].TakeDamage();
                        ((MonsterUnit)monsters[j].unit).moving = true;
                    }
                    return(true);
                }
            }
            return(false);
        }
コード例 #3
0
 public bool checkCollisionWithBullet(Unit unit)
 {
     // If shot is still in play, check for collisions
     for (int j = 0; j < firstAidKits.Count; ++j)
     {
         if (unit.collideWith(firstAidKits[j].unit))
         {
             addHealth(j);
             return true;
         }
     }
     return false;
 }
コード例 #4
0
 /// <summary>
 /// if the unit(player or bullet) collide with the first aid add the health
 /// </summary>
 /// <param name="unit">Unit to check collision with</param>
 public bool checkCollisionWithBullet(Unit unit)
 {
     // If shot is still in play, check for collisions
     for (int j = 0; j < firstAidKits.Count; ++j)
     {
         if (unit.collideWith(firstAidKits[j].unit))
         {
             addHealth(j);
             return(true);
         }
     }
     return(false);
 }