void UnitTestAlgoComputer::testFindMove()
{
    _pgn = new PGNReaderWriter (_CRepFiles+QString (QTest::currentDataTag()));

    QVERIFY2((_pgn != 0), "Fail instance PGNReaderWriter");

    QFETCH(int, NoPartie);
    QFETCH(int, DemiMoveAlgo);
    QFETCH(int,TypeMoveAFaire);
    QFETCH(int, MoveAlgo_OldX);
    QFETCH(int, MoveAlgo_OldY);
    QFETCH(int, MoveAlgo_NewX);
    QFETCH(int, MoveAlgo_NewY);
    _DemiMoveAlgo = DemiMoveAlgo;
    _MoveAlgo = sMove (Queen,
                       MoveAlgo_OldX,
                       MoveAlgo_OldY,
                       MoveAlgo_NewX,
                       MoveAlgo_NewY,
                       0,
                       false);
    _TypeMoveAFaire = eTypeMoveAlgo (TypeMoveAFaire);
    _pgn->LoadGame(*this, NoPartie);
    QVERIFY2 (_ListCommandesPlay.count() >= _DemiMoveAlgo, "Erreur config data!");
}
Esempio n. 2
0
 void Add(T &&e)
 {
     GrowCapacity(1);
     sPlacementNew<T>(Last);
     *Last = sMove(e);
     Last++;
 }
void FacadeControllerComponent::OnInitialize()
{
    btTransform  start_trans;
    start_trans.setIdentity();
    start_trans.setOrigin(BtOgre::Convert::toBullet(GetNode()->GetPosition(Node::SCENE)));
    start_trans.setRotation(BtOgre::Convert::toBullet(GetNode()->GetRotation(Node::SCENE)));

    btScalar character_height = 1.75;
    btScalar character_width = 0.44;
    btConvexShape* capsule = new btCapsuleShape(character_width, character_height);

    mBtGhostObject = std::shared_ptr<btPairCachingGhostObject>(new btPairCachingGhostObject());
    mBtGhostObject->setWorldTransform(start_trans);
    mBtGhostObject->setCollisionShape(capsule);
    mBtGhostObject->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT);
    mBtGhostObject->setUserPointer(nullptr);
    mBtController = std::shared_ptr<btKinematicCharacterController>
        (new btKinematicCharacterController(mBtGhostObject.get(), capsule, 1));

    GetNode()->GetScene()->GetPhysicsWorld()->GetBulletWorld()->addCollisionObject(mBtGhostObject.get());
    GetNode()->GetScene()->GetPhysicsWorld()->GetBulletWorld()->addAction(mBtController.get());

    Agent* agent = mAgent.get();
    bool result = true;

    if(agent != nullptr)
    {
        if(agent->OnInitialize())
        {
            if(!QObject::connect(agent, SIGNAL(sMove(Ogre::Vector3)), this, SLOT(_OnMoveChange(Ogre::Vector3))))
            {
                Logger::Get().Error("Failed to connect signal sMove.");
                result = false;
            }
            if(!QObject::connect(agent, SIGNAL(sLook(const Ogre::Radian&, const Ogre::Radian&, const Ogre::Radian&)), 
                                  this, SLOT(_OnLook(const Ogre::Radian&, const Ogre::Radian&, const Ogre::Radian&))))
            {
                Logger::Get().Error("Failed to connect signal sLook.");
                result = false;
            }
            if(!QObject::connect(agent, SIGNAL(sJump(bool)), this, SLOT(_OnJump())))
            {
                Logger::Get().Error("Failed to connect signal sJump.");
                result = false;
            }
        }
        else
        {
            result = false;
        }
    }
Esempio n. 4
0
 bool Rem(const T &e)
 {
     for(T *i=First;i<Last;i++)
     {
         if(*i==e)
         {
             Last--;
             *i = sMove(*Last);
             Last->~T();
             return true;
         }
     }
     return false;
 }
Esempio n. 5
0
void Player::onInitialize() {
    mController = new FPSPlayerComponent(2, "controller");
    mMesh = new dt::MeshComponent("player", "", "player_mesh");
    mStatus = new StatusComponent(100, 100);
    mCamera = new dt::CameraComponent("main_camera");
    mWalkingSound = new dt::SoundComponent("walk.wav", "player_walking_sound");
    mJumpingSound = new dt::SoundComponent("jump.wav", "player_jump_sound");

    const Weapon* weapon = mController->getWeaponInUse();

    //this->addComponent(mMesh);
    this->addComponent(mStatus);
    this->addComponent(mCamera);
    this->addComponent(mController);
    this->addComponent(mWalkingSound);
    this->addComponent(mJumpingSound);

    dt::GuiRootWindow& win = dt::GuiManager::get()->getRootWindow();
    mHUDAmmo = win.addChildWidget(new dt::GuiButton("HUD_ammo"));
    mHUDHealth = win.addChildWidget(new dt::GuiButton("HUD_health"));
    mHUDClip = win.addChildWidget(new dt::GuiButton("HUD_clip"));
    auto screen_rect = win.getMyGUIWidget()->getAbsoluteRect();

    mHUDHealth->setSize(100, 30);
    mHUDAmmo->setSize(100, 30);
    mHUDClip->setSize(100, 30);

    mHUDHealth->setPosition(10, screen_rect.height() - 50);
    mHUDAmmo->setPosition(screen_rect.width() - 110, screen_rect.height() - 90);
    mHUDClip->setPosition(screen_rect.width() - 110, screen_rect.height() - 50);

    dt::GuiManager::get()->setMouseCursorVisible(false);

    if(mIsControllable)
        mController->enable();
    else
        mController->disable();

    mWalkingSound->getSound().setLoop(true);
    mJumpingSound->setVolume(20);

    _refreshHealth(0, 100);
    if(weapon != nullptr) {
        _onWeaponChanged(weapon);
    }

    if(!QObject::connect(mController, SIGNAL(sWeaponChanged(const Weapon*)), 
                         this,        SLOT(_onWeaponChanged(const Weapon*)), Qt::DirectConnection)) {
            dt::Logger::get().debug(QString("Failed to connect the controller's sWeaponChanged") +
                QString("signal with the player's _OnWeaponChanged"));
    }

    if(!QObject::connect(mController, SIGNAL(sMove()),
                         this,        SLOT(_onWalk()), Qt::DirectConnection)) {
        dt::Logger::get().debug(QString("Failed to connect the controller's sMove with the player's _OnWalk"));
    }

    if(!QObject::connect(mController, SIGNAL(sStop()),
                         this,        SLOT(_onStop()), Qt::DirectConnection)) {
        dt::Logger::get().debug(QString("Failed to connect the controller's sStop with the player's _OnStop()"));
    }

    if(!QObject::connect(mController, SIGNAL(sJump()),
                         this,        SLOT(_onJump()), Qt::DirectConnection)) {
        dt::Logger::get().debug(QString("Failed to connect the controller's sStop with the player's _OnStop()"));
    }

    mController->setMouseSensitivity(1);
}
Esempio n. 6
0
 void RemAt(sPtr pos)
 {
     Last--;
     First[pos] = sMove(*Last);
     Last->~T();
 }