3DAnimation.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:58k
- #include "stdafx.h"
- #include "XMudClient.h"
- #include "D3DRMScreen.h"
- #include "3DSound.h"
- #include "3DFunction.h"
- #include "MainScreen.h"
- #include "MenuCreateNew.h"
- #include "Internetmsg.h"
- D3DVECTOR g_CameraPosition;
- extern LPDIRECT3DRMFRAME3 g_lpplayer;
- extern LPDIRECT3DRMFRAME3 g_pChaseFrame;
- extern LPDIRECT3DRMFRAME3 g_sFrame;
- extern LPDIRECT3DRM3 g_lpD3DRM;
- extern PathInfo info;
- extern rmfullglobals myglobs;
- extern int g_playerState;
- extern BOOL g_GetSameMove;
- extern CMainScreen m_MainScreen;
- extern CRITICAL_SECTION csAnimation;
- extern CList <animationCallbackArgs *, animationCallbackArgs *> animationlist;
- extern CList<CPlayerInfo*,CPlayerInfo*>playerlist;
- extern int g_nReceiveMsgState,g_nGameState,nSpareTime,nRecTimes;
- float g_fightreadyDelta = 4.00f/40.0f;
- BOOL bRestartAlready=FALSE;
- extern SOCKET hLCltForRSvrSock;
- void __cdecl animationCallback(LPDIRECT3DRMFRAME3 obj, LPVOID arg,
- D3DVALUE delta)
- {
- D3DVECTOR *path;
- animationCallbackArgs* cb;
- animationCallbackArgs* cbfight;
- D3DVECTOR playerpos,sFramepos,pSoundPos,tmpSoundPos,camerapos;
- D3DVECTOR Npcposite;
- int i,j,k;
- BOOL bM = FALSE;
- TFightTag *lpFightTag;
-
- g_lpplayer->GetPosition(myglobs.scene, &playerpos);
-
- EnterCriticalSection(&csAnimation);
- j = animationlist.GetCount();
- if(j < 2)
- {
- bM = TRUE;
- j = 3;
- }
- for(i=0;i<j;i++)
- {
- if ( bM )
- cb = animationlist.GetHead();
- else
- cb = animationlist.GetAt(animationlist.FindIndex(i));
-
- obj = cb->frame3obj;
- if( i != 0 ){
- if(cb->cXFileType == "NPC"){
- switch( cb->PlayerState ){
- case STOP:
- {
- cb->animset->SetTime(cb->time);
- cb->time += (g_fightreadyDelta*delta);
- if(cb->time > STOP_START + NUM_STOP_FRAMES) {
- cb->time = STOP_START;
- }else{
- if(cb->way!=-1) {
- if(!m_MainScreen.bSelectOne) {
- cb->time = LEFTGO_START;
- cb->PlayerState = LEFTGO;
- }
- }else {
- cb->frame3obj->GetPosition(myglobs.scene,&Npcposite);
- g_pChaseFrame->SetPosition(myglobs.scene,Npcposite.x,Npcposite.y,playerpos.z);
- cb->frame3obj->LookAt(g_pChaseFrame,myglobs.scene,D3DRMCONSTRAIN_Z);
- }
- }
- }
- break;
-
- case LEFTGO:
- {
- cb->animset->SetTime(cb->time);
- cb->time += (g_fightreadyDelta*delta)*2;
- if(cb->time > LEFTGO_START + NUM_LEFTGO_FRAMES){
- Npcposite = GetNextPosite(cb->frame3obj,cb);
-
- g_pChaseFrame->SetPosition( myglobs.scene,Npcposite.x, Npcposite.y, Npcposite.z);
- cb->frame3obj->LookAt( g_pChaseFrame, myglobs.scene,D3DRMCONSTRAIN_Z);
- cb->frame3obj->SetPosition( myglobs.scene,Npcposite.x, Npcposite.y, Npcposite.z);
-
- cb->time = RIGHTGO_START;
- cb->PlayerState = RIGHTGO;
- }
- if(m_MainScreen.bSelectOne)
- {
- if(m_MainScreen.szSelectEName == cb->cXFileName)
- {
- cb->time = STOP_START;
- cb->PlayerState = STOP;
- }
- }
- }
- break;
- case RIGHTGO:
- {
- cb->animset->SetTime(cb->time);
- cb->time += (g_fightreadyDelta*delta)*2;
- if(cb->time > RIGHTGO_START + NUM_RIGHTGO_FRAMES){
- Npcposite = GetNextPosite(cb->frame3obj,cb);
-
- g_pChaseFrame->SetPosition( myglobs.scene,Npcposite.x, Npcposite.y, Npcposite.z);
- cb->frame3obj->LookAt( g_pChaseFrame, myglobs.scene,D3DRMCONSTRAIN_Z);
- cb->frame3obj->SetPosition( myglobs.scene,Npcposite.x, Npcposite.y, Npcposite.z);
-
- cb->time = LEFTGO_START;
- cb->PlayerState = LEFTGO;
- }
- if(m_MainScreen.bSelectOne)
- {
- if(m_MainScreen.szSelectEName == cb->cXFileName)
- {
- cb->time = STOP_START;
- cb->PlayerState = STOP;
- }
- }
- }
- break;
- case FIGHTREADY:
- {
- cb->animset->SetTime(cb->time);
- cb->time += (g_fightreadyDelta*delta);
- if( cb->time > FIGHTREADY_START + NUM_FIGHTREADY_FRAMES)
- {
- k = cb->fightopplist.GetCount();
- if(k==0)break;
- k = rand()%k;
- lpFightTag = cb->fightopplist.GetAt(cb->fightopplist.FindIndex(k));
- cbfight = animationlist.GetAt(lpFightTag->tagPosite);
- switch(rand()%10)
- {
- case 0:
- {
- cb->time = HAND_START;
- cb->PlayerState = HAND;
-
- switch( rand() % 2 )
- {
- case 0:
- cbfight->time = WOUND_START;
- if( cbfight->cXFileName.IsEmpty() )
- g_playerState = WOUND;
- else
- cbfight->PlayerState = WOUND;
- break;
- case 1:
- cbfight->time = GURAD_START;
- if( cbfight->cXFileName.IsEmpty() )
- g_playerState = GURAD;
- else
- cbfight->PlayerState = GURAD;
- break;
- }
- }
- break;
- case 1:
- {
- cb->time = FOOT_START;
- cb->PlayerState = FOOT;
-
- switch( rand() % 2 )
- {
- case 0:
- cbfight->time = WOUND_START;
- if( cbfight->cXFileName.IsEmpty() )
- g_playerState = WOUND;
- else
- cbfight->PlayerState = WOUND;
- break;
- case 1:
- cbfight->time = GURAD_START;
- if( cbfight->cXFileName.IsEmpty() )
- g_playerState = GURAD;
- else
- cbfight->PlayerState = GURAD;
- break;
- }
- }
- break;
- case 2://NPC