本文整理汇总了C++中CUnit::GetMapPixelPosTopLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ CUnit::GetMapPixelPosTopLeft方法的具体用法?C++ CUnit::GetMapPixelPosTopLeft怎么用?C++ CUnit::GetMapPixelPosTopLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUnit
的用法示例。
在下文中一共展示了CUnit::GetMapPixelPosTopLeft方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CclCreateMissile
/**
** Create a missile on the map
**
** @param l Lua state.
**
*/
static int CclCreateMissile(lua_State *l)
{
LuaCheckArgs(l, 6);
const std::string name = LuaToString(l, 1);
const MissileType *mtype = MissileTypeByIdent(name);
if (!mtype) {
LuaError(l, "Bad missile");
}
PixelPos startpos, endpos;
if (!lua_istable(l, 2) || lua_rawlen(l, 2) != 2) {
LuaError(l, "incorrect argument !!");
}
lua_rawgeti(l, 2, 1);
startpos.x = LuaToNumber(l, -1);
lua_pop(l, 1);
lua_rawgeti(l, 2, 2);
startpos.y = LuaToNumber(l, -1);
lua_pop(l, 1);
if (!lua_istable(l, 3) || lua_rawlen(l, 3) != 2) {
LuaError(l, "incorrect argument !!");
}
lua_rawgeti(l, 3, 1);
endpos.x = LuaToNumber(l, -1);
lua_pop(l, 1);
lua_rawgeti(l, 3, 2);
endpos.y = LuaToNumber(l, -1);
lua_pop(l, 1);
const int sourceUnitId = LuaToNumber(l, 4);
const int destUnitId = LuaToNumber(l, 5);
const bool dealDamage = LuaToBoolean(l, 6);
CUnit *sourceUnit = sourceUnitId != -1 ? &UnitManager.GetSlotUnit(sourceUnitId) : NULL;
CUnit *destUnit = destUnitId != -1 ? &UnitManager.GetSlotUnit(destUnitId) : NULL;
if (sourceUnit != NULL) {
startpos += sourceUnit->GetMapPixelPosTopLeft();
}
if (destUnit != NULL) {
endpos += destUnit->GetMapPixelPosTopLeft();
}
Missile *missile = MakeMissile(*mtype, startpos, endpos);
if (!missile) {
return 0;
}
if (dealDamage) {
missile->SourceUnit = sourceUnit;
}
missile->TargetUnit = destUnit;
return 0;
}
示例2: CclCreateMissile
/**
** Create a missile on the map
**
** @param l Lua state.
**
*/
static int CclCreateMissile(lua_State *l)
{
const int arg = lua_gettop(l);
if (arg < 6 || arg > 7) {
LuaError(l, "incorrect argument");
}
const std::string name = LuaToString(l, 1);
const MissileType *mtype = MissileTypeByIdent(name);
if (!mtype) {
LuaError(l, "Bad missile");
}
PixelPos startpos, endpos;
CclGetPos(l, &startpos.x, &startpos.y, 2);
CclGetPos(l, &endpos.x, &endpos.y, 3);
const int sourceUnitId = LuaToNumber(l, 4);
const int destUnitId = LuaToNumber(l, 5);
const bool dealDamage = LuaToBoolean(l, 6);
const bool mapRelative = arg == 7 ? LuaToBoolean(l, 7) : false;
CUnit *sourceUnit = sourceUnitId != -1 ? &UnitManager.GetSlotUnit(sourceUnitId) : nullptr;
CUnit *destUnit = destUnitId != -1 ? &UnitManager.GetSlotUnit(destUnitId) : nullptr;
if (mapRelative == false) {
if (sourceUnit != nullptr) {
startpos += sourceUnit->GetMapPixelPosTopLeft();
}
if (destUnit != nullptr) {
endpos += destUnit->GetMapPixelPosTopLeft();
}
}
//Wyrmgus start
// Missile *missile = MakeMissile(*mtype, startpos, endpos);
Missile *missile = MakeMissile(*mtype, startpos, endpos, 0);
//Wyrmgus end
if (!missile) {
return 0;
}
if (dealDamage) {
missile->SourceUnit = sourceUnit;
}
missile->TargetUnit = destUnit;
return 0;
}