void CreatureManager::ShowCreatureInfo() { Block block = App::sInstance().GetMouseBlock(); if (block.xpos!=-1 && block.ypos!=-1) { Character* cha = GetEnemy(block.xpos,block.ypos); if(cha == NULL) { cha = GetFriend(block.xpos,block.ypos); if(cha == NULL) { TipWnd::sInstance().Clear(); TipWnd::sInstance().SetShow(false); return; } } //得到单位,显示其信息 char temp[256] = {0}; TipWnd::sInstance().Clear(); sprintf(temp," ID : %d",cha->GetID()); TipWnd::sInstance().AddText(temp,0xFFFFFFFF,-1,-1,eFontType_MSYaHei,eFontSize_FontMiddle); sprintf(temp," 坐标 : %d , %d",cha->GetBlock().xpos,cha->GetBlock().ypos); TipWnd::sInstance().AddText(temp,0xFFFFFFFF,-1,-1,eFontType_MSYaHei,eFontSize_FontMiddle); sprintf(temp," 生命值:%d",cha->GetHP()); TipWnd::sInstance().AddText(temp,0xFFFFFFFF,-1,-1,eFontType_MSYaHei,eFontSize_FontMiddle); TipWnd::sInstance().SetShow(true); TipWnd::sInstance().SetPos(block.xpos,block.ypos); } else { TipWnd::sInstance().Clear(); TipWnd::sInstance().SetShow(false); } }
void CreatureManager::CalculateResult(int src,int tar) { Character* cast = GetCreature(src); Character* target = GetCreature(tar); //首先计算命中与否 bool bhit = false; if(g_RandomInt(0,9) >= (int)(target->GetDodge()*10)) bhit = true; target->GetCounter() = true; if(bhit) { target->GetHP() -= cast->GetPreHurt(); cast->GetPreHurt() = 0; target->Attacked(); } else target->Defend(); }