예제 #1
0
    void World::update(bool noclip)
    {
        mTicksSinceLastAnimUpdate++;
        mTicksPassed++;

        bool advanceAnims;


                        
        for(size_t i = 0; i < mActors.size(); i++)
        {
            Actor * actor = mActors[i];
            size_t animDivisor =actor->mAnimTimeMap[actor->getAnimState()];
            if(animDivisor == 0)
            {
                animDivisor=12;
            }
            advanceAnims  = !(mTicksPassed % (ticksPerSecond/animDivisor));
            actorMapRemove(mActors[i]);
            actor->update(noclip);
            if(advanceAnims)
            {

                if(!actor->mAnimPlaying && !actor->isDead())
                {
                    actor->mFrame = fmod((actor->mFrame + 1), (double)(actor->getCurrentAnim().animLength));
                }

                else if(actor->mAnimPlaying && actor->mFrame <= actor->getCurrentAnim().animLength-1)
                {
                    actor->mFrame++;
                }

                else if(actor->mAnimPlaying && actor->mFrame == actor->getCurrentAnim().animLength)
                {
                    actor->mAnimPlaying = false;
                }

                else if(!actor->mAnimPlaying && actor->mFrame < actor->getCurrentAnim().animLength-1)
                {
                    actor->mFrame++;
                }
            }            
            actorMapInsert(actor);
        }

        actorMapClear();
        for(size_t i = 0; i < mActors.size(); i++)
            actorMapInsert(mActors[i]);
    }
예제 #2
0
    void World::setLevel(int32_t levelNum)
    {
        if(levelNum != 0)
            mCurrentPlayer->mInDungeon=true;
        else
            mCurrentPlayer->mInDungeon=false;

        if(levelNum >= (int32_t)mLevels.size() || levelNum < 0)
            return;

        clear();

        mCurrentLevel = &mLevels[levelNum];
        mCurrentLevelIndex = levelNum;

        const std::vector<Level::Monster>& monsters = mCurrentLevel->getMonsters();

        for(size_t i = 0; i < monsters.size(); i++)
        {
            DiabloExe::Monster monster =  mDiabloExe.getMonster(monsters[i].name);
            ActorStats * stats = new ActorStats(monster);

            Monster * monsterObj = new Monster(monster, Position(monsters[i].xPos, monsters[i].yPos), stats);
            //stats->setActor(monsterObj);
            mActors.push_back(monsterObj);
        }

        actorMapClear();

        // insert actors into 2d map
        for(size_t i = 0; i < mActors.size(); i++)
            actorMapInsert(mActors[i]);

        if(levelNum == 0)
            addNpcs();

        FAAudio::AudioManager::playLevelMusic(levelNum, *Engine::ThreadManager::get());
    }
예제 #3
0
 void GameLevel::actorMapRefresh()
 {
     actorMapClear();
     for (size_t i = 0; i < mActors.size(); i++)
         actorMapInsert(mActors[i]);
 }