Esempio n. 1
0
VOID TimerUpdate(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	if (wParam == TIMER_ID)
	{
		HeroUpdate();
		BackgroundUpdate();
		TerrianUpdate();
		if (GameStart)
		{
			GameStatusUpdate();
			OthersUpdate();
			CoinUpdate();
			MissileUpdate();
			LaserUpdate();
			BOOL judgecollision = CheckCollision();
			if (judgecollision)
			{
				m_hero.life--;
				if (!m_hero.life)
				{
					m_hero.alive = FALSE;
					IsOnFire = FALSE;
					//KillTimer(hWnd, TIMER_ID);
					//KillTimer(hWnd, SCORE_ID);
				}
				else
				{
					m_hero.invincible = 100;
					for (int i = 0; i < MAX_LASER_NUM; i++)
					{
						m_laser[i].blink = FALSE;
					}
				}
				m_missile.active = FALSE;
			}
		}
	}
	if (wParam == SCORE_ID)
	{
		//GameStatusUpdate();
		ScorePerFrame++;
		if (LaserRandom >= 9) LaserRandom -= 3;
		if (MissileRandom >= 90) MissileRandom -= 30;

	}
	if (wParam == ENDING_ID)
	{
		CharacterCount++;
	}
	InvalidateRect(hWnd, NULL, FALSE);
}
/*=============================================*/
void CLaserBase::Draw( CDirect3D & _d3d , LASER_COLOR _Color )
{


	bool PushFlag = false;
	if( m_pMouse->GetState( CMouse::B_LEFT  ) == CMouse::MST_HOLD ||
	  ( m_pMouse->GetState( CMouse::B_RIGHT ) == CMouse::MST_HOLD && ( this->GetName() == "AARL" || this->GetName() == "AGL" ) ) )
	{		 

		PushFlag = true;
		
		// レーザーの長さを調節する
		LaserUpdate();
		// レーザーのメッシュを取得
		CXFile **m_lpLaserEffect = m_pLaser->GetLaserXFile();

		// レーザー1の描画/////////////////////////////
		CMatrix mTrans;
		CMatrix mRot;
		CMatrix mWorld;
		CMatrix mParent;
		mParent = m_pPlayer->GetMatrix();
		//                              レーザーの発射位置の補正
		mTrans.SetTrans( m_vPos + D3DXVECTOR3( 0.077f , -0.097f , 2.0f ) );
		mWorld = mTrans * mParent;
		_d3d.SetWorldTrans( &mWorld );

		m_lpLaserEffect[0]->GetMaterial()->Diffuse.r = _Color.Red;
		m_lpLaserEffect[0]->GetMaterial()->Diffuse.g = _Color.Green;
		m_lpLaserEffect[0]->GetMaterial()->Diffuse.b = _Color.Blue;

		m_lpLaserEffect[0]->GetMaterial()->Ambient.r = _Color.Red;
		m_lpLaserEffect[0]->GetMaterial()->Ambient.g = _Color.Green;
		m_lpLaserEffect[0]->GetMaterial()->Ambient.b = _Color.Blue;

		m_lpLaserEffect[0]->GetMaterial()->Emissive.r = _Color.Red;
		m_lpLaserEffect[0]->GetMaterial()->Emissive.g = _Color.Green;
		m_lpLaserEffect[0]->GetMaterial()->Emissive.b = _Color.Blue;

		m_lpLaserEffect[0]->Draw( _d3d.GetDevice() );
		///////////////////////////////////////////////


		// レーザー2の描画////////////////////////////////////////////////////
		// テクスチャアニメ—ション=================
		m_pd3d->GetDevice()->SetTextureStageState( 0 , D3DTSS_TEXTURETRANSFORMFLAGS , D3DTTFF_COUNT2 );
		D3DXMATRIX mTex;
		D3DXMatrixIdentity( &mTex );
		// テクスチャの座標を移動する
		static float TextureAnimation = 1.0f;

		// レーザーを逆流する
		if( m_LaserReverseFlag ){ TextureAnimation += 0.017f; }
		// レーザーを吐き出す
		else{					  TextureAnimation -= 0.017f; }

		if( TextureAnimation < 0.0f ){ TextureAnimation += 1.0f; }
		if( TextureAnimation > 1.0f ){ TextureAnimation -= 1.0f; }

		mTex._31 = TextureAnimation;	//U
		mTex._32 = TextureAnimation/2;	//V
		m_pd3d->GetDevice()->SetTransform( D3DTS_TEXTURE0 , &mTex );
		m_pd3d->GetDevice()->SetTransform( D3DTS_WORLD , &mTrans );
		//==========================================

		// 行列を合成する
		mWorld = mTrans * mParent;
		_d3d.SetWorldTrans( &mWorld );

		m_lpLaserEffect[1]->GetMaterial()->Diffuse.r = _Color.Red;
		m_lpLaserEffect[1]->GetMaterial()->Diffuse.g = _Color.Green;
		m_lpLaserEffect[1]->GetMaterial()->Diffuse.b = _Color.Blue;

		m_lpLaserEffect[1]->GetMaterial()->Emissive.r = _Color.Red;
		m_lpLaserEffect[1]->GetMaterial()->Emissive.g = _Color.Green;
		m_lpLaserEffect[1]->GetMaterial()->Emissive.b = _Color.Blue;

		// 加算合成開始
		m_pd3d->GetDevice()->SetRenderState( D3DRS_DESTBLEND , D3DBLEND_ONE );
		// レーザーの描画
		m_lpLaserEffect[1]->Draw( _d3d.GetDevice() );
		// 加算合成終了
		m_pd3d->GetDevice()->SetRenderState( D3DRS_DESTBLEND , D3DBLEND_INVSRCALPHA );
		
		// テクスチャアニメーションの設定を元に戻す
		m_pd3d->GetDevice()->SetTextureStageState( 0 , D3DTSS_TEXTURETRANSFORMFLAGS , D3DTTFF_DISABLE );
		//////////////////////////////////////////////////////////////////////


		// ライトの更新//////////////////////////
		m_Light.Diffuse  = D3DXCOLOR( _Color.Red , _Color.Green , _Color.Blue , 1.0f );
		m_Light.Specular = D3DXCOLOR( _Color.Red , _Color.Green , _Color.Blue , 1.0f );
		m_Light.Ambient  = D3DXCOLOR( _Color.Red , _Color.Green , _Color.Blue , 1.0f );

		m_Light.Position = CDPConverter::toDirectX( RayPos.m_EndPoint );
		m_pd3d->GetCLightManager()->UpdateLight( m_Light , m_LightIndex , TRUE );
		/////////////////////////////////////////

	}
	else
	{
		// AGL起動時以外はライトを消す
		m_pd3d->GetCLightManager()->UpdateLight( m_Light , m_LightIndex , FALSE );
	}

	if( m_lpXFile == nullptr ){ return; }

	CMatrix mTrans;
	CMatrix mRot;
	CMatrix mWorld;

	CMatrix mParent;
	mParent = m_pPlayer->GetMatrix();
	mTrans.SetTrans( m_vPos );
	mRot.SetRotate( m_vRot );
	mWorld = mTrans * mRot * mParent;
	_d3d.SetWorldTrans( &mWorld );

	// レーザー銃の色を変更する
	float ColorPower = 0.9f;
	float ColorBase  = 0.05f;
	m_lpXFile->xData.Mat[0].Ambient.a = 1.0f;
	m_lpXFile->xData.Mat[0].Ambient.r = _Color.Red   * ColorPower + ColorBase;
	m_lpXFile->xData.Mat[0].Ambient.g = _Color.Green * ColorPower + ColorBase;
	m_lpXFile->xData.Mat[0].Ambient.b = _Color.Blue  * ColorPower + ColorBase;

	m_lpXFile->xData.Mat[0].Emissive.a = 1.0f;
	m_lpXFile->xData.Mat[0].Emissive.r = _Color.Red   * ColorPower + ColorBase;
	m_lpXFile->xData.Mat[0].Emissive.g = _Color.Green * ColorPower + ColorBase;
	m_lpXFile->xData.Mat[0].Emissive.b = _Color.Blue  * ColorPower + ColorBase;


	m_lpXFile->xData.Mat[1].Ambient.a = 1.0f;
	m_lpXFile->xData.Mat[1].Ambient.r = _Color.Red   * ColorPower + ColorBase;
	m_lpXFile->xData.Mat[1].Ambient.g = _Color.Green * ColorPower + ColorBase;
	m_lpXFile->xData.Mat[1].Ambient.b = _Color.Blue  * ColorPower + ColorBase;

	m_lpXFile->xData.Mat[1].Emissive.a = 1.0f;
	m_lpXFile->xData.Mat[1].Emissive.r = _Color.Red   * ColorPower + ColorBase;
	m_lpXFile->xData.Mat[1].Emissive.g = _Color.Green * ColorPower + ColorBase;
	m_lpXFile->xData.Mat[1].Emissive.b = _Color.Blue  * ColorPower + ColorBase;


	// AGL本体の描画
	m_lpXFile->Draw( _d3d.GetDevice() );

	// AGL本体のエフェクト
	if( PushFlag )
	{
		// 加算合成開始
		m_pd3d->GetDevice()->SetRenderState( D3DRS_DESTBLEND , D3DBLEND_ONE );
		m_lpAGLEffect->SetMaterial( m_Material );
		// AGL本体のエフェクトの描画
		//m_lpAGLEffect->Draw( _d3d.GetDevice() ); 
		// 加算合成終了
		m_pd3d->GetDevice()->SetRenderState( D3DRS_DESTBLEND , D3DBLEND_INVSRCALPHA );
	}


	// パーティクルの描画
	m_pParticleEmitter->DrawParticle();

}