#include "Collision.h" #include "gamedefine.h" QMutex mutex; EnemyCollision::EnemyCollision(QObject* parent) : QObject(parent), mPlayer(nullptr), mEnemyList(nullptr) { } EnemyCollision::~EnemyCollision(){ } void EnemyCollision::setupCollision(Player* player, QList *enemyList) { mPlayer = player; mEnemyList = enemyList; } void EnemyCollision::player_enemyCollision(Player &mPlayer,QList &mEnemyList) { QMutexLocker locker(&mutex); if(mPlayer.isInvincible) emit EnemyCollisionFinished("return");//判断无敌 int enemyNum = mEnemyList.size(); for(int i=0;igetAttackPoint()); emit EnemyCollisionFinished("hurt"); if(mPlayer.getHP() <= 0)//死亡 { emit EnemyCollisionFinished("dead"); } emit EnemyCollisionFinished("Invincibletime"); } } } void EnemyCollision::processCollisions() { if (!mPlayer || !mEnemyList) return; player_enemyCollision(*mPlayer, *mEnemyList); }