本文整理汇总了C++中GameWorld函数的典型用法代码示例。如果您正苦于以下问题:C++ GameWorld函数的具体用法?C++ GameWorld怎么用?C++ GameWorld使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GameWorld函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CEntity
CElectro::CElectro(CGameWorld *pGameWorld, vec2 Start, vec2 End, vec2 Offset, int Left)
: CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
{
m_Render = !Left;
m_Pos = Start;
m_End = End;
m_EvalTick = Server()->Tick();
GameWorld()->InsertEntity(this);
if (Left > 0)
{
vec2 P = Start + End;
P /= 2.0f;
vec2 R = vec2(frandom()-frandom(), frandom()-frandom())*42.0f;
GameServer()->Collision()->IntersectLine(P, P+R+Offset, 0x0, &P);
//P += vec2(frandom()-frandom(), frandom()-frandom())*42.0f;
//P += Offset;
new CElectro(GameWorld(), Start, P, Offset * 0.5f, Left-1);
new CElectro(GameWorld(), P, End, Offset * 0.5f, Left-1);
/*
float a = Angle + (frandom()-frandom()) * 1.11f;
float l = 40.0f;
//vec2 P2 = vec2(sin(a) * l, cos(a) * l);
vec2 P2 = vec2(cosf(a), sinf(a)) * l;
new CElectro(GameWorld(), P, P + P2, Angle, 0);
*/
}
}
开发者ID:Siile,项目名称:CSTT,代码行数:35,代码来源:electro.cpp
示例2: r3dOutToLog
BOOL obj_ServerSiegeObjective::OnCreate()
{
parent::OnCreate();
ObjFlags |= OBJFLAG_SkipCastRay;
Status = SS_ACTIVE;
NetworkLocal = true;
NetworkID = gSiegeObjMgr.RegisterSiegeObjective(this) + NETID_SIEGEOBJ_START;
r3dOutToLog("SiegeObj %d at %f %f %f\n", NetworkID, GetPosition().x, GetPosition().y, GetPosition().z);
if(m_BlueSpawnHashID == -1)
r3dError("Blue spawn isn't set for siege objective\n");
if(m_RedSpawnHashID == -1)
r3dError("Red spawn isn't set for siege objective\n");
{
GameObject* obj = GameWorld().GetObjectByHash(m_BlueSpawnHashID);
if(obj == NULL)
r3dError("Blue spawn hash ID doesn't map to any object\n");
if(obj->Class->Name != "obj_ControlPoint")
r3dError("Blue spawn isn't obj_ControlPoint\n");
m_BlueCP = (obj_ServerControlPoint*)obj;
}
{
GameObject* obj = GameWorld().GetObjectByHash(m_RedSpawnHashID);
if(obj == NULL)
r3dError("Red spawn hash ID doesn't map to any object\n");
if(obj->Class->Name != "obj_ControlPoint")
r3dError("Red spawn isn't obj_ControlPoint\n");
m_RedCP = (obj_ServerControlPoint*)obj;
}
return 1;
}
开发者ID:Mateuus,项目名称:server,代码行数:35,代码来源:obj_ServerSiegeObjective.cpp
示例3: LoadLevel_Objects
int LoadLevel_Objects( float BarRange )
{
char fname[MAX_PATH];
sprintf(fname, "%s\\LevelData.xml", r3dGameLevel::GetHomeDir());
r3dFile* f = r3d_open(fname, "rb");
if ( ! f )
return 0;
char* fileBuffer = new char[f->size + 1];
fread(fileBuffer, f->size, 1, f);
fileBuffer[f->size] = 0;
pugi::xml_document xmlLevelFile;
pugi::xml_parse_result parseResult = xmlLevelFile.load_buffer_inplace(fileBuffer, f->size);
fclose(f);
if(!parseResult)
r3dError("Failed to parse XML, error: %s", parseResult.description());
pugi::xml_node xmlLevel = xmlLevelFile.child("level");
g_leveldata_xml_ver->SetInt( 0 );
if( !xmlLevel.attribute("version").empty() )
{
g_leveldata_xml_ver->SetInt( xmlLevel.attribute("version").as_int() );
}
if( g_level_settings_ver->GetInt() < 2 || g_level_settings_ver->GetInt() >=3 )
{
GameWorld().m_MinimapOrigin.x = xmlLevel.attribute("minimapOrigin.x").as_float();
GameWorld().m_MinimapOrigin.z = xmlLevel.attribute("minimapOrigin.z").as_float();
GameWorld().m_MinimapSize.x = xmlLevel.attribute("minimapSize.x").as_float();
GameWorld().m_MinimapSize.z = xmlLevel.attribute("minimapSize.z").as_float();
if(g_level_settings_ver->GetInt() < 2 )
{
r_shadow_extrusion_limit->SetFloat(xmlLevel.attribute("shadowLimitHeight").as_float());
if(!xmlLevel.attribute("near_plane").empty())
{
r_near_plane->SetFloat(xmlLevel.attribute("near_plane").as_float());
r_far_plane->SetFloat(xmlLevel.attribute("far_plane").as_float());
}
}
}
if(GameWorld().m_MinimapSize.x == 0 || GameWorld().m_MinimapSize.z == 0)
{
GameWorld().m_MinimapSize.x = 100;
GameWorld().m_MinimapSize.z = 100;
}
GameWorld().numbuilding = 0;
#ifdef WO_SERVER
GameWorld().spawncar = xmlLevel.attribute("spawncar").as_int();
#endif
LoadLevelObjects ( xmlLevel, BarRange );
// delete only after we are done parsing xml!
delete [] fileBuffer;
return 1;
}
开发者ID:Mateuus,项目名称:devsrc,代码行数:59,代码来源:GameLevel_IO.cpp
示例4: GameServer
void CHealth::Tick()
{
CCharacter *m_Chr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, 0);
CCharacter *m_Ownerchar = GameServer()->GetPlayerChar(m_Owner);
if(!m_Ownerchar)
{
GameWorld()->DestroyEntity(this); // maybe bug :(
return;
}
m_Pos = m_Ownerchar->m_Pos - vec2(0, 45);
if(GameServer()->m_World.m_Paused == true || !m_Ownerchar->Core()->m_ProtectedBy)
GameWorld()->DestroyEntity(this);
}
开发者ID:Schwertspize,项目名称:speedfng,代码行数:15,代码来源:health.cpp
示例5: CreateAllGameObjectsAndCollections
void CreateAllGameObjectsAndCollections(LevelGeometry &lg)
{
// Submit level objects triangles
GameObject *obj = 0;
int k = 0;
lg.meshes.Reserve(lg.meshes.Count() + GameWorld().GetNumObjects() + GameWorld().GetStaticObjectCount() + gCollectionsManager.GetElementsCount());
for( ObjectIterator iter = GameWorld().GetFirstOfAllObjects(); iter.current ; iter = GameWorld().GetNextOfAllObjects( iter ) )
{
GameObject* obj = iter.current;
if (!obj->isActive() || obj->ObjFlags & OBJFLAG_SkipCastRay)
{
continue;
}
// if it's a mesh objects
if (!obj->isObjType(OBJTYPE_Mesh) || !obj->PhysicsObject)
{
continue;
}
// If it is inside or intersect of tile bb
const r3dBoundBox &bb = obj->GetBBoxWorld();
if (!gConvexRegionsManager.IsIntersectSomeRegion(bb))
continue;
lg.meshes.Resize(lg.meshes.Count() + 1);
CreateGeometryFromPhysxActor(obj->PhysicsObject->getPhysicsActor(), lg.meshes.GetLast());
}
// Submit collection elements
for (uint32_t i = 0; i < gCollectionsManager.GetElementsCount(); ++i)
{
CollectionElement *ce = gCollectionsManager.GetElement(i);
if (!ce || !ce->physObj)
continue;
// If it is inside or intersect of tile bb
const r3dBoundBox &bb = ce->GetWorldAABB();
if (!gConvexRegionsManager.IsIntersectSomeRegion(bb))
continue;
lg.meshes.Resize(lg.meshes.Count() + 1);
CreateGeometryFromPhysxActor(ce->physObj->getPhysicsActor(), lg.meshes.GetLast());
}
}
开发者ID:Mateuus,项目名称:devsrc,代码行数:48,代码来源:NavGenerationHelpers.cpp
示例6: CEntity
CMine::CMine(CGameWorld *pGameWorld, vec2 Pos, int Owner)
: CEntity(pGameWorld, CGameWorld::ENTTYPE_PROJECTILE)
{
m_Pos = Pos;
m_Owner = Owner;
GameWorld()->InsertEntity(this);
}
开发者ID:kurosio,项目名称:xpanic-remake,代码行数:7,代码来源:mine.cpp
示例7: CEntity
CPickup::CPickup(CGameWorld *pGameWorld, int Type, int SubType)
: CEntity(pGameWorld, CGameWorld::ENTTYPE_PICKUP)
{
m_Type = Type;
m_Subtype = SubType;
m_ProximityRadius = PickupPhysSize;
// MineTee
m_TimerOwnerTake = Server()->Tick();
m_Vel = vec2(1.0f, 0.0f);
m_Amount = 0;
if (m_Type == POWERUP_BLOCK)
m_DestroyTick = Server()->Tick()+Server()->TickSpeed()*5;
else if (m_Type == POWERUP_FOOD || m_Type == POWERUP_DROPITEM)
m_DestroyTick = Server()->Tick()+Server()->TickSpeed()*25;
else
m_DestroyTick = -1;
//
Reset();
GameWorld()->InsertEntity(this);
}
开发者ID:H-M-H,项目名称:MineTee,代码行数:25,代码来源:pickup.cpp
示例8: Draw
void CameraHUD :: Draw()
{
assert(bInited);
if ( !bInited ) return;
r3dSetFiltering( R3D_POINT );
r3dRenderer->pd3ddev->SetRenderState( D3DRS_ALPHATESTENABLE, FALSE );
r3dRenderer->pd3ddev->SetRenderState( D3DRS_ALPHAREF, 1 );
r3dRenderer->SetMaterial(NULL);
r3dRenderer->SetRenderingMode(R3D_BLEND_ALPHA);
// floatTextMgrDraw();
//Font_Label->PrintF(20,20,r3dColor(255,255,255), "fps %f\n%fms\n%d", 1.0f/r3dGetFrameTime(), r3dGetFrameTime()*1000.0f,Mod);
#ifndef FINAL_BUILD
GameObject* TargetObj = GameWorld().GetObject(UI_TargetObjID);
if(TargetObj && r_hide_icons->GetInt() == 0)
{
Font_Label->PrintF(20,60,r3dColor(255,255,255), "OBJ: %s", TargetObj->Name.c_str());
}
#endif
#ifndef FINAL_BUILD
LevelEditor.Process(!enablemouselook);
#endif
r3dRenderer->pd3ddev->SetRenderState( D3DRS_ALPHATESTENABLE, FALSE );
r3dRenderer->pd3ddev->SetRenderState( D3DRS_ALPHAREF, 1 );
}
开发者ID:Mateuus,项目名称:srcundead,代码行数:34,代码来源:HUD_Spectator.cpp
示例9: GameWorld
BOOL obj_Grenade::OnCreate()
{
const GameObject* owner = GameWorld().GetObject(ownerID);
if(!owner)
return FALSE;
m_isSerializable = false;
ReadPhysicsConfig();
PhysicsConfig.group = PHYSCOLL_PROJECTILES;
PhysicsConfig.isFastMoving = true;
r3d_assert(m_Ammo);
r3d_assert(m_Weapon);
parent::OnCreate();
m_CreationTime = r3dGetTime() - m_AddedDelay;
m_CreationPos = GetPosition();
if(m_Ammo->getParticleTracer())
m_ParticleTracer = (obj_ParticleSystem*)srv_CreateGameObject("obj_ParticleSystem", m_Ammo->getParticleTracer(), GetPosition() );
SetBBoxLocal( GetObjectMesh()->localBBox ) ;
UpdateTransform();
m_FireDirection.y += 0.1f; // to make grenade fly where you point
m_AppliedVelocity = m_FireDirection*m_Weapon->m_AmmoSpeed;
SetVelocity(m_AppliedVelocity);
return TRUE;
}
开发者ID:Mateuus,项目名称:devsrc,代码行数:32,代码来源:Grenade.cpp
示例10: GameWorld
void
GameObject::SetTransparentShadowCasting( bool enabled )
{
if( enabled )
{
// first set flag, then provoke adding
PrivateFlags |= PRIVFLAG_TransparentShadowCaster ;
GameWorld().UpdateTransparentShadowCaster( this ) ;
}
else
{
// first provoke removal, then clear flag
GameWorld().UpdateTransparentShadowCaster( this ) ;
PrivateFlags &= ~PRIVFLAG_TransparentShadowCaster ;
}
}
开发者ID:Mateuus,项目名称:devsrc,代码行数:16,代码来源:GameObj.cpp
示例11: r3dGetTime
BOOL obj_ServerAutoTurret::Update()
{
float curTime = r3dGetTime();
bool ownerAlive = true;
// check if owner is still alive, if dead - kill it
{
GameObject* owner = GameWorld().GetObject(ownerID);
if(owner && owner->isObjType(OBJTYPE_Human))
{
obj_ServerPlayer* plr = (obj_ServerPlayer*)owner;
if(!isConsumableVersion) // consumable version stays alive even if owner gets killed
ownerAlive = !plr->isDead;
}
else
ownerAlive = false;
}
if(gServerLogic.gameStartCountdown>0 || !ownerAlive || requestKill) // remove all on round start
{
// destroy
PKT_S2C_DestroyNetObject_s n;
n.spawnID = toP2pNetId(NetworkID);
gServerLogic.p2pBroadcastToActive(NULL, &n, sizeof(n));
return FALSE;
}
return parent::Update();
}
开发者ID:Mateuus,项目名称:server,代码行数:30,代码来源:obj_ServerAutoTurret.cpp
示例12: CLaser
void CMod_Weapon_Laser::CreateProjectile(vec2 Pos, vec2 Direction)
{
new CLaser(GameWorld(), Pos, Direction, GameServer()->Tuning()->m_LaserReach, Player()->GetCID());
CModAPI_WorldEvent_Sound(GameServer(), WorldID())
.Send(Character()->GetPos(), SOUND_LASER_FIRE);
}
开发者ID:teeworlds-modapi,项目名称:mod-target,代码行数:7,代码来源:laser.cpp
示例13: CEntity
CSpawProtect::CSpawProtect(CGameWorld *pGameWorld, int Owner)
: CEntity(pGameWorld, CGameWorld::ENTTYPE_PICKUP)
{
m_Owner = Owner;
GameWorld()->InsertEntity(this);
}
开发者ID:Bloodwork28,项目名称:teeworlds-uTown,代码行数:7,代码来源:spawnprotect.cpp
示例14: Server
void CLaser::DoBounce()
{
m_EvalTick = Server()->Tick();
if(m_Energy < 0)
{
GameWorld()->DestroyEntity(this);
return;
}
vec2 To = m_Pos + m_Dir * m_Energy;
if(GameServer()->Collision()->IntersectLine(m_Pos, To, 0x0, &To))
{
if(!HitCharacter(m_Pos, To))
{
// intersected
m_From = m_Pos;
m_Pos = To;
vec2 TempPos = m_Pos;
vec2 TempDir = m_Dir * 4.0f;
GameServer()->Collision()->MovePoint(&TempPos, &TempDir, 1.0f, 0);
m_Pos = TempPos;
m_Dir = normalize(TempDir);
m_Energy -= distance(m_From, m_Pos) + GameServer()->Tuning()->m_LaserBounceCost;
m_Bounces++;
if(m_Bounces > GameServer()->Tuning()->m_LaserBounceNum)
m_Energy = -1;
tu::CEvent_Sound(GameServer()).World(GameWorld()->m_WorldID)
.Send(m_Pos, SOUND_LASER_BOUNCE);
}
}
else
{
if(!HitCharacter(m_Pos, To))
{
m_From = m_Pos;
m_Pos = To;
m_Energy = -1;
}
}
}
开发者ID:teeworlds-modapi,项目名称:teeworlds,代码行数:47,代码来源:laser.cpp
示例15: CEntity
CHealth::CHealth(CGameWorld *pGameWorld, vec2 Pos, int Owner, int Type)
: CEntity(pGameWorld, CGameWorld::ENTTYPE_PICKUP)
{
m_Owner = Owner;
m_Pos = Pos;
GameWorld()->InsertEntity(this);
}
开发者ID:Schwertspize,项目名称:speedfng,代码行数:8,代码来源:health.cpp
示例16: GameServer
void CBarrier::Tick()
{
m_LifeSpan--;
if(m_LifeSpan < 0)
{
GameServer()->m_World.DestroyEntity(this);
}
else
{
// Find other players
for(CCharacter *p = (CCharacter*) GameWorld()->FindFirst(CGameWorld::ENTTYPE_CHARACTER); p; p = (CCharacter *)p->TypeNext())
{
if(!p->IsInfected()) continue;
vec2 IntersectPos = closest_point_on_line(m_Pos, m_Pos2, p->m_Pos);
float Len = distance(p->m_Pos, IntersectPos);
if(Len < p->m_ProximityRadius+g_BarrierRadius)
{
//Check for portal traps
if(p->GetClass() != PLAYERCLASS_UNDEAD && (Server()->Tick() - p->m_PortalTick) < Server()->TickSpeed()/2)
{
CPlayer* pPortalPlayer = GameServer()->m_apPlayers[p->m_LastPortalOwner];
if(pPortalPlayer)
{
pPortalPlayer->IncreaseScore(1);
}
}
//Check for hook traps. The case when the player is frozen is in the function Die()
if(!p->IsFrozen())
{
for(CCharacter *pHook = (CCharacter*) GameWorld()->FindFirst(CGameWorld::ENTTYPE_CHARACTER); pHook; pHook = (CCharacter *)pHook->TypeNext())
{
if(p->GetPlayer() && pHook->GetPlayer() && pHook->m_Core.m_HookedPlayer == p->GetPlayer()->GetCID() && pHook->GetPlayer()->GetCID() != m_Owner)
{
pHook->GetPlayer()->IncreaseScore(1);
}
}
}
p->Die(m_Owner, WEAPON_HAMMER);
}
}
}
}
开发者ID:AlphaDEXi,项目名称:teeworlds-infclass,代码行数:46,代码来源:barrier.cpp
示例17: GameServer
/* INFECTION MODIFICATION START ***************************************/
void CCharacter::OpenClassChooser()
{
GameServer()->SendBroadcast("Choose your class", m_pPlayer->GetCID());
if(!m_pClassChooser)
{
m_pClassChooser = new CClassChooser(GameWorld(), m_Pos, m_pPlayer->GetCID());
}
}
开发者ID:Schwertspize,项目名称:teeworlds-infclass,代码行数:9,代码来源:character.cpp
示例18: CEntity
CBuyHealth::CBuyHealth(CGameWorld *pGameWorld, vec2 Pos)
: CEntity(pGameWorld, CGameWorld::ENTTYPE_PROJECTILE)
{
m_Pos = Pos;
GameWorld()->InsertEntity(this);
for(int i = 0; i < 2; i++)
m_IDs[i] = Server()->SnapNewID();
}
开发者ID:Bloodwork28,项目名称:teeworlds-uTown,代码行数:9,代码来源:health.cpp
示例19: GameWorld
BOOL obj_Bullet::Update()
{
parent::Update();
const GameObject* owner = GameWorld().GetObject(ownerID);
if( m_CreationTime+5.0f < r3dGetTime() ) // Bullets should only live for 5 seconds.
{
// yeah your dead.
if(owner && owner->NetworkLocal)
{
PKT_C2C_PlayerHitNothing_s n;
p2pSendToHost(owner, &n, sizeof(n), true);
}
return false;
}
r3dVector dir = (GetPosition() - oldstate.Position);
if(dir.Length()==0)
dir = m_FireDirection;
// perform collision check
m_AppliedVelocity += r3dVector(0, -9.81f, 0) * m_Weapon->m_AmmoMass * r3dGetFrameTime();
r3dPoint3D motion = m_AppliedVelocity * r3dGetFrameTime();
float motionLen = motion.Length();
motion.Normalize();
PxU32 collisionFlag = COLLIDABLE_STATIC_MASK;
if(owner && owner->NetworkLocal)
collisionFlag |= (1<<PHYSCOLL_NETWORKPLAYER);
PxSphereGeometry sphere(0.0025f); // Make it tiny. 5 milimeter diameter
PxTransform pose(PxVec3(GetPosition().x, GetPosition().y, GetPosition().z), PxQuat(0,0,0,1));
PxSweepHit hit;
PxSceneQueryFilterData filter(PxFilterData(collisionFlag, 0, 0, 0), PxSceneQueryFilterFlag::eSTATIC|PxSceneQueryFilterFlag::eDYNAMIC);
if(g_pPhysicsWorld->PhysXScene->sweepSingle(sphere, pose, PxVec3(motion.x, motion.y, motion.z), motionLen, PxSceneQueryFlag::eINITIAL_OVERLAP|PxSceneQueryFlag::eIMPACT|PxSceneQueryFlag::eNORMAL, hit, filter))
{
// if the hit is the final stop.
if ( OnHit(hit) ) {
return false;
}
}
else
{
// perform movement
SetPosition(GetPosition() + m_AppliedVelocity * r3dGetFrameTime());
}
if(m_ParticleTracer)
m_ParticleTracer->SetPosition(GetPosition());
return true;
}
开发者ID:Mateuus,项目名称:newsrcundead,代码行数:56,代码来源:Bullet.cpp
示例20: CEntity
CWall::CWall(CGameWorld *pGameWorld, vec2 Pos, vec2 Pos2, int Owner)
: CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
{
m_Pos = Pos;
m_Pos2 = Pos2;
m_Owner = Owner;
m_ID2 = Server()->SnapNewID();
m_Lifespan = (float)(20*50);
GameWorld()->InsertEntity(this);
}
开发者ID:Bloodwork28,项目名称:teeworlds-uTown,代码行数:10,代码来源:wall.cpp
注:本文中的GameWorld函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论