コード例 #1
0
CEntity * CEntitiesFactory::SpawnEntity(const SEntityParams * params) {
	CEntity * et = new CEntity(params->GetSide(), m_world);
	if(params->GetType() == EET_SHIP) {
		//hotfix: create controls and register to InputManager if not AI
		AddComponents(et, params);
		//if (!static_cast<const SShipParams *>(params)->IsAI()) {
		InitEntityControls(et);

		/* LOOKING INSIDE init_world.json and setting position/rotation */
		CCompTransform * transform = new CCompTransform(et, 0, 0, 0);
		et->AddComponent(transform); //will be set when init_world.json is parsed

		FILE * wFile = fopen("data/conf/init_world.json", "rb");
		char buffer[65536];
		assert(wFile != nullptr && "CEntitiesFactory::SpawnEntity()");
		rapidjson::FileReadStream is(wFile, buffer, sizeof(buffer));
		rapidjson::Document cDoc;
		cDoc.ParseStream<0, rapidjson::UTF8<>, rapidjson::FileReadStream>(is);
		assert(!cDoc.HasParseError());

		rapidjson::Value player;
		if (et->GetSide() == EGS_PLAYER_1) {
			player = cDoc["player1"];
		} else if (et->GetSide() == EGS_PLAYER_2) {
			player = cDoc["player2"];
		}

		for (rapidjson::Value::ConstMemberIterator itr = player.MemberBegin();
		itr != player.MemberEnd(); ++itr) {
			if (!strcmp(itr->name.GetString(), "position")) {
				SSetPosMsg posMsg(itr->value["x"].GetFloat(), itr->value["y"].GetFloat());
				et->ReceiveMessage(posMsg);
			} else if (!strcmp(itr->name.GetString(), "rotation")) {
				SSetRotMsg rotMsg(itr->value.GetFloat());
				et->ReceiveMessage(rotMsg);
			}
		}
		fclose(wFile);
	} else if(params->GetType() == EET_PROJECTILE) {
		AddComponents(et, params);
	} else if (params->GetType() == EET_EXPLOSION) {
		AddComponents(et, params);
	} else if (params->GetType() == EET_DECOY) {
		AddComponents(et, params);
	} else if (params->GetType() == EET_BOT) {
		AddComponents(et, params);
	}

	return et;
}
コード例 #2
0
void RPeninputServerImpl::DimUiLayoutL(TBool aFlag)
    {
    TInt priority = iPriority;

    TPckgC<TBool> msg(aFlag);
    TIpcArgs arg;    
    arg.Set(KMsgSlot0,&msg);

    TPckgC<TInt> prioriryMsg(priority);//p
    arg.Set(KMsgSlot1,&prioriryMsg);
    
    TInt bmpHandle = -1;
    TPckg<TInt> handleMsg(bmpHandle);
    arg.Set(KMsgSlot2,&handleMsg);
    
    TRect extend;
    TPckg<TRect> posMsg(extend);  
    arg.Set(KMsgSlot3,&posMsg);
    
    if (iInternalPopup)
        {
        SendReceive(EPeninputRequestInternalDimLayout,arg);    
        }
    else
        {
        SendReceive(EPeninputRequestDimLayout,arg);    
        }
   
    if(aFlag)
        {
        //show the background control
        if(!iBackgroundCtrl)
            {
            iBackgroundCtrl = CPenUiBackgroundWnd::NewL(CCoeEnv::Static()->RootWin(),bmpHandle);
            }
        if(iBackgroundCtrl)
            iBackgroundCtrl->Show(extend, iGlobalNotes, 
                iInternalPopup,priority, iResourceChange);    
        }
    else //undim the window
        {
        if(iBackgroundCtrl)
            iBackgroundCtrl->Hide();    
        }
    }