本文整理汇总了C++中CBotVar::SetValFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ CBotVar::SetValFloat方法的具体用法?C++ CBotVar::SetValFloat怎么用?C++ CBotVar::SetValFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBotVar
的用法示例。
在下文中一共展示了CBotVar::SetValFloat方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rMajObject
// routine pour mettre à jour l'instance de la classe Bot courante
void rMajObject( CBotVar* pThis, void* pUser )
{
if (!pThis->IsElemOfClass("object"))
return ;
CBotVar* pPos = pThis->GivItem("position");
CBotVar* pX = pPos->GivItem("x");
CBotVar* pY = pPos->GivItem("y");
CBotVar* pZ = pPos->GivItem("z");
// CBotVar* pPt = pThis->GivItem("transport");
CBotString p = pX->GivValString();
// pX->SetValFloat( pUser == (void*)1 ? (float)12.5 : (float)44.4 );
pZ->SetValFloat( (float)0 );
pY->SetValFloat( (float)-3.33 );
pX->SetValFloat( pX->GivValFloat() + 10 ) ;
// pX = pThis->GivItem( "xx" );
// pX->SetValFloat( (float)22 );
// crée une instance sur une classe object
// CBotVar* pAutre = CBotVar::Create("autre", CBotTypClass, "object");
// pAutre->SetUserPtr( (void*)3 );
// pPt->SetPointer( pAutre );
// pPt->SetPointer( NULL );
// delete pAutre;
}
示例2: rSpace
bool rSpace(CBotVar* var, CBotVar* result, int& exception, void* user)
{
CScript* script = ((CObject*)user)->RetRunScript();
CObject* pThis = (CObject*)user;
CBotVar* pSub;
Math::Vector center;
float rMin, rMax, dist;
rMin = 5.0f*UNIT;
rMax = 50.0f*UNIT;
dist = 4.0f*UNIT;
if ( var == 0 )
{
center = pThis->RetPosition(0);
}
else
{
if ( !GetPoint(var, exception, center) ) return true;
if ( var != 0 )
{
rMin = var->GivValFloat()*UNIT;
var = var->GivNext();
if ( var != 0 )
{
rMax = var->GivValFloat()*UNIT;
var = var->GivNext();
if ( var != 0 )
{
dist = var->GivValFloat()*UNIT;
var = var->GivNext();
}
}
}
}
script->m_main->FreeSpace(center, rMin, rMax, dist, pThis);
if ( result != 0 )
{
pSub = result->GivItemList();
if ( pSub != 0 )
{
pSub->SetValFloat(center.x/UNIT);
pSub = pSub->GivNext(); // "y"
pSub->SetValFloat(center.z/UNIT);
pSub = pSub->GivNext(); // "z"
pSub->SetValFloat(center.y/UNIT);
}
}
return true;
}
示例3: rSpace
BOOL rSpace(CBotVar* var, CBotVar* result, int& exception, void* user)
{
CBotVar* pSub;
float rMin, rMax, dist;
rMin = 5.0f*UNIT;
rMax = 50.0f*UNIT;
dist = 4.0f*UNIT;
if ( var == 0 )
{
// center = pThis->RetPosition(0);
}
else
{
if ( var != 0 )
{
rMin = var->GivValFloat()*UNIT;
var = var->GivNext();
if ( var != 0 )
{
rMax = var->GivValFloat()*UNIT;
var = var->GivNext();
if ( var != 0 )
{
dist = var->GivValFloat()*UNIT;
var = var->GivNext();
}
}
}
}
if ( result != 0 )
{
pSub = result->GivItemList();
if ( pSub != 0 )
{
pSub->SetValFloat(1);
pSub = pSub->GivNext(); // "y"
pSub->SetValFloat(2);
pSub = pSub->GivNext(); // "z"
// pSub->SetValFloat(3);
}
}
return TRUE;
}
示例4:
// exécution
BOOL rCPoint( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
{
CString s;
if ( pVar == NULL )return TRUE; // constructeur sans paramètres est ok
CBotVar* pX = pThis->GivItem("x");
pX->SetValFloat( pVar->GivValFloat() );
pVar = pVar->GivNext();
CBotVar* pY = pThis->GivItem("y");
pY->SetValFloat( pVar->GivValFloat() );
pVar = pVar->GivNext();
return TRUE; // pas d'interruption
}
示例5: Execute
bool CBotExprLitNum::Execute(CBotStack* &pj)
{
CBotStack* pile = pj->AddStack(this);
if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create("", m_numtype);
std::string nombre ;
if (m_token.GetType() == TokenTypDef)
{
nombre = m_token.GetString();
}
switch (m_numtype)
{
case CBotTypShort:
case CBotTypInt:
var->SetValInt(m_valint, nombre);
break;
case CBotTypFloat:
var->SetValFloat(m_valfloat);
break;
default:
assert(false);
}
pile->SetVar(var); // place on the stack
return pj->Return(pile); // it's ok
}
示例6: Execute
bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
{
int i = 0;
CBotDefParam* p = this;
while ( p != NULL )
{
// creates a local variable on the stack
CBotVar* newvar = CBotVar::Create(p->m_token.GetString(), p->m_type);
// serves to make the transformation of types:
if ( ppVars != NULL && ppVars[i] != NULL )
{
switch (p->m_type.GetType())
{
case CBotTypInt:
newvar->SetValInt(ppVars[i]->GetValInt());
break;
case CBotTypFloat:
newvar->SetValFloat(ppVars[i]->GetValFloat());
break;
case CBotTypString:
newvar->SetValString(ppVars[i]->GetValString());
break;
case CBotTypBoolean:
newvar->SetValInt(ppVars[i]->GetValInt());
break;
case CBotTypIntrinsic:
(static_cast<CBotVarClass*>(newvar))->Copy(ppVars[i], false);
break;
case CBotTypPointer:
case CBotTypArrayPointer:
{
newvar->SetPointer(ppVars[i]->GetPointer());
}
break;
default:
ASM_TRAP();
}
}
newvar->SetUniqNum(p->m_nIdent);
pj->AddVar(newvar); // add a variable
p = p->m_next;
i++;
}
return true;
}
示例7: RestoreState
bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
{
unsigned short w, wi, prv, st;
float ww;
CBotString name, s;
delete pVar;
pVar = NULL;
CBotVar* pNew = NULL;
CBotVar* pPrev = NULL;
while ( true ) // retrieves a list
{
if (!ReadWord(pf, w)) return false; // private or type?
if ( w == 0 ) return true;
CBotString defnum;
if ( w == 200 )
{
if (!ReadString(pf, defnum)) return false; // number with identifier
if (!ReadWord(pf, w)) return false; // type
}
prv = 100; st = 0;
if ( w >= 100 )
{
prv = w;
if (!ReadWord(pf, st)) return false; // static
if (!ReadWord(pf, w)) return false; // type
}
if ( w == CBotTypClass ) w = CBotTypIntrinsic; // necessarily intrinsic
if (!ReadWord(pf, wi)) return false; // init ?
if (!ReadString(pf, name)) return false; // variable name
CBotToken token(name, CBotString());
switch (w)
{
case CBotTypInt:
case CBotTypBoolean:
pNew = CBotVar::Create(&token, w); // creates a variable
if (!ReadWord(pf, w)) return false;
pNew->SetValInt(static_cast<short>(w), defnum);
break;
case CBotTypFloat:
pNew = CBotVar::Create(&token, w); // creates a variable
if (!ReadFloat(pf, ww)) return false;
pNew->SetValFloat(ww);
break;
case CBotTypString:
pNew = CBotVar::Create(&token, w); // creates a variable
if (!ReadString(pf, s)) return false;
pNew->SetValString(s);
break;
// returns an intrinsic object or element of an array
case CBotTypIntrinsic:
case CBotTypArrayBody:
{
CBotTypResult r;
long id;
if (!ReadType(pf, r)) return false; // complete type
if (!ReadLong(pf, id) ) return false;
// if (!ReadString(pf, s)) return false;
{
CBotVar* p = NULL;
if ( id ) p = CBotVarClass::Find(id) ;
pNew = new CBotVarClass(&token, r); // directly creates an instance
// attention cptuse = 0
if ( !RestoreState(pf, (static_cast<CBotVarClass*>(pNew))->m_pVar)) return false;
pNew->SetIdent(id);
if ( p != NULL )
{
delete pNew;
pNew = p; // resume known element
}
}
}
break;
case CBotTypPointer:
case CBotTypNullPointer:
if (!ReadString(pf, s)) return false;
{
pNew = CBotVar::Create(&token, CBotTypResult(w, s));// creates a variable
// CBotVarClass* p = NULL;
long id;
ReadLong(pf, id);
// if ( id ) p = CBotVarClass::Find(id); // found the instance (made by RestoreInstance)
// returns a copy of the original instance
CBotVar* pInstance = NULL;
if ( !CBotVar::RestoreState( pf, pInstance ) ) return false;
//.........这里部分代码省略.........