📄 game.java
字号:
return true;
else
return false;
}
void ChkInbndClock()
{
if(m_bBallOB == true && m_iOffenseTeamIndex != - 99 && ChkOBPlay(m_iOffenseTeamIndex)== true && m_iInbndSecs <= 0)
{
DoAfterInbndViolation();
return;
}
}
void ChkBkCrtClock()
{
if(m_bBallBackCourt == true && m_iBkCrtSecs <= 0)
{
DoAfterHalfCourtViolation();
return;
}
}
boolean ChkGameClock()
{
if(m_iQtrTime <= 0)
{
switch(GetState())
{
case 2 :
case 8 :
case 4 :
case 7 :
break;
default :
if(GetPosZ()<= 2 << 10)
{
if(m_iQtrNum == 1 || m_iQtrNum == 3)
{
DoEndQuarter();
}
else if(m_iQtrNum == 2)
DoEndHalf();
else
{
if(GetTotalScore(m_iHomeTeamIndex)== GetTotalScore(m_iAwayTeamIndex)&& m_iQtrNum < 16 - 1)
{
DoEndQuarter();
}
else
{
DoEndGame();
return true;
}
}
m_iQtrNum++;
}
break;
}
}
return false;
}
void ChkShotClock()
{
if(m_iShotSecs <= 750)
{
/*if(Basketball.GetState()!= 0x0001)
Basketball.Play(m_pSndHorn, 0);*/
DoResetShotClock();
switch(GetState())
{
case 2 :
case 8 :
case 4 :
break;
default :
DoShotClockViolation();
break;
}
}
else if(m_bResetShotClock)
{
DoResetShotClock();
}
}
void updateCommentary(int iDeltaT)
{
m_iCommentaryTime -= iDeltaT;
m_iCommentaryOffsetX -= 1;
}
void updatePlayers(int iDeltaT)
{
if(m_iOffenseTeamIndex != - 99)
updateOffense(m_iOffenseTeamIndex);
for(int i = 0; i < 10; i++)
{
m_pPlayers[i].PreUpdate(iDeltaT);
}
for(int j = 0; j < 10; j++)
{
for(int k = 0; k < 10; k++)
{
if(k == j)
continue;
if(m_pPlayers[j].ChkPlayerCol(m_pPlayers[k])== true)
{
break;
}
}
if(m_pPlayers[j].ChkBallCol()== true)
{
if(m_pPlayers[j].ChkPassTarget()== false)
{
if(m_iOffenseTeamIndex != - 99 && ChkOBPlay(m_iOffenseTeamIndex)== false && m_pPlayers[j].GetTeam()!= m_iOffenseTeamIndex)
DoTurnOver();
}
else
{
m_pPlayers[j].SetPassTarget(false, null);
}
}
m_pPlayers[j].PostUpdate();
}
}
void updateBackBoard(int iDeltaT)
{
if(GetState()== 4)
{
m_iRimState = 1;
}
if(m_iRimState == 1)
{
int iObjIndex = 14;
if(GetPosY()< 0)
{
iObjIndex = 13;
}
if(m_iRimAnim < 18 - 1)
{
if(m_iRimAnim == 5)
{
DoAfterBasket();
}
m_iRimAnim++;
}
else
{
m_iRimAnim = 0;
m_iRimState = 0;
}
int iFrame = RIM_ANIM[m_iRimAnim];
m_pObjList[iObjIndex].SetFrame(RIM_FRAMES[iFrame][0], RIM_FRAMES[iFrame][1], RIM_FRAMES[iFrame][2], RIM_FRAMES[iFrame][3], RIM_FRAMES[iFrame][4], RIM_FRAMES[iFrame][5], 0);
}
}
void updateOffscreenIndicators()
{
if(m_pUserPlayer == null)
return;
RenderObj pUserObj = m_pUserPlayer.GetObj();
int iObjX = pUserObj.GetScreenX();
int iObjY = pUserObj.GetScreenY();
int iObjDestX = pUserObj.GetDestX();
int iObjDestY = pUserObj.GetDestY();
int iPosX = iObjX;
int iPosY = iObjY;
int iDir = 0;
boolean bDraw = false;
if(iObjX > 176)
{
iPosX = 176;
iPosY += iObjDestY;
bDraw = true;
iDir = 2;
}
else if(iObjX + iObjDestX < 0)
{
iPosX = 0;
iPosY += iObjDestY;
bDraw = true;
iDir = 6;
}
if(iObjY > 208)
{
iPosY = 208;
bDraw = true;
if(iDir == 2)
iDir = 3;
else if(iDir == 6)
iDir = 5;
else
iDir = 4;
}
else if(iObjY + iObjDestY <(11 - 2))
{
iPosY =(11 - 2);
bDraw = true;
if(iDir == 2)
iDir = 1;
else if(iDir == 6)
iDir = 7;
else
iDir = 0;
}
m_bDrawOffscreenIndicators = bDraw;
m_iIndicatorX = iPosX;
m_iIndicatorY = iPosY;
m_iIndicatorDir = iDir;
}
void CalcRebounders()
{
int iIndexDist[][]= new int[3][2];
for(int z = 0; z < 3; z++)
{
iIndexDist[z][0]= 0;
iIndexDist[z][1]= 99999;
}
int iNumRebounders = 0;
int fBallX = GetPosX();
int fBallY = GetPosY();
for(int i = 0; i < 10; i++)
{
int fPlayerX = m_pPlayers[i].GetPosX();
int fPlayerY = m_pPlayers[i].GetPosY();
int iDistX =(fBallX - fPlayerX)>> 10;
int iDistY =(fBallY - fPlayerY)>> 10;
int iDist =(iDistX * iDistX)+(iDistY * iDistY);
for(int j = 0; j < 3; j++)
{
if(iDist < iIndexDist[j][1])
{
iIndexDist[j][0]= i;
iIndexDist[j][1]= iDist;
iNumRebounders++;
break;
}
}
}
for(int k = 0; k < 10; k++)
{
m_pPlayers[k].SetReboundBall(false);
}
for(int l = 0; l < iNumRebounders && l < 3; l++)
{
m_pPlayers[iIndexDist[l][0]].SetReboundBall(true);
}
}
void CalcRebound()
{
Player pRebounders[]= new Player[3];
int iNumRebounders = 0;
int fBallX = GetPosX();
int fBallY = GetPosY();
for(int i = 0; i < 10 && iNumRebounders < 3; i++)
{
if(m_pPlayers[i].GetAnimState()== 6)
{
int fPlayerX = m_pPlayers[i].GetPosX();
int fPlayerY = m_pPlayers[i].GetPosY();
int iDistX =(fBallX - fPlayerX)>> 10;
int iDistY =(fBallY - fPlayerY)>> 10;
int iDist =(iDistX * iDistX)+(iDistY * iDistY);
if(iDist < 16)
{
pRebounders[iNumRebounders]= m_pPlayers[i];
iNumRebounders++;
}
}
}
if(iNumRebounders > 0)
{
boolean bTipp = false;
if(GetState()== 7)
bTipp = true;
int iChanceVal = 0;
int iReboundRat[]= new int[3];
for(int i = 0; i < iNumRebounders; i++)
{
iReboundRat[i]+=((i > 0)? iReboundRat[i - 1]: 0);
iReboundRat[i]+= pRebounders[i].GetStatRebound();
iChanceVal += iReboundRat[i];
}
int iRand = Basketball.GetRand()% iChanceVal;
int iLowRat = 0;
int iReboundIndex = 0;
for(int j = 0; j < iNumRebounders; j++)
{
if(iRand < iReboundRat[j]&& iRand > iLowRat)
iReboundIndex = j;
iLowRat += iReboundRat[j];
}
if(bTipp == true)
{
SetState(0);
TouchBall(pRebounders[iReboundIndex]);
int fVelX = pRebounders[iReboundIndex].GetPlayerOffenseDir()* -3000;
int fVelY = pRebounders[iReboundIndex].GetPlayerOffenseDir()* -18000;
int fVelZ = 3000;
SetVelocity(fVelX, fVelY, fVelZ);
}
else
{
pRebounders[iReboundIndex].SetHasBall(true);
pRebounders[iReboundIndex].GiveRebound();
SetController(pRebounders[iReboundIndex]);
if(pRebounders[iReboundIndex].GetTeam()!= m_iOffenseTeamIndex)
DoTurnOver();
}
if(bTipp == true)
m_iTeamThatWonTippOff = GetTeamOffset(pRebounders[iReboundIndex].GetTeam());
}
}
void ChkTurnOvers()
{
if(m_iOffenseTeamIndex != - 99 && GetTurnOverFlag(m_iOffenseTeamIndex)== true)
{
DoTurnOver();
}
}
int GetOffenseDir(int iTeamIndex)
{
if(iTeamIndex == m_iHomeTeamIndex)
{
if(m_iQtrNum < 3)
return 1;
else
return - 1;
}
else
{
if(m_iQtrNum < 3)
return - 1;
else
return 1;
}
}
void DoAfterOB()
{
SetVelocity(0, 0, 0);
SetController(null);
SetState(5);
m_iOffenseTeamIndex = m_pPlayerLastTouch.GetTeam();
AddToTurnOvers(m_iOffenseTeamIndex, 1);
m_iOffenseDir = GetOffenseDir(m_iOffenseTeamIndex);
SwitchOffenseTeam();
SetControlTeam(m_iOffenseTeamIndex);
int fOutboundX = GetOutbound(0);
int fOutboundY = GetOutbound(1);
if(Basketball.ABS(fOutboundY)>= 94 / 2 << 10)
{
int iDir = 1;
if(fOutboundY < 0)
iDir = -1;
SetVelocity(0, 0, 0);
SetPosition((0 << 10), iDir *(42 << 10), 0);
SetController(null);
SetState(5);
if(m_iOffenseTeamIndex == m_iUserTeamIndex)
SetNextOffensePlay(m_iOffenseTeamIndex, 15);
else
SetNextOffensePlay(m_iOffenseTeamIndex, 11);
}
else
{
SetPosition(fOutboundX, fOutboundY, 0);
if(m_iOffenseTeamIndex == m_iUserTeamIndex)
SetNextOffensePlay(m_iOffenseTeamIndex, 17);
else
SetNextOffensePlay(m_iOffenseTeamIndex, 16);
}
m_bBallBackCourt = true;
DoResetBkCourClock();
DoResetInbndsClock();
DoResetShotClock();
m_iClockState = 1;
ClrInput();
CreateOverlay(36);
}
void DoAfterInbndViolation()
{
ClrInput();
DoAfterOB();
CreateOverlay(37);
}
void DoAfterBackCourtViolation()
{
int iSideX = 1;
if(GetPosX()< 0)
iSideX = -1;
ClrInput();
SetOutbound(25 << 10,(- m_iOffenseDir * 5)<< 10);
DoAfterOB();
CreateOverlay(38);
}
void DoAfterHalfCourtViolation()
{
int iSideX = 1;
if(GetPosX()< 0)
iSideX = -1;
ClrInput();
SetOutbound(25 << 10,(- m_iOffenseDir * 5)<< 10);
DoAfterOB();
CreateOverlay(39);
}
void DoShotClockViolation()
{
ClrInput();
DoClockViolation();
CreateOverlay(35);
}
void DoAfterBasket()
{
m_iPaintFlags |= 0x02 | 0x01 | 0x04;
m_iOffenseTeamIndex = GetOffenseTeam(m_iOffenseDir);
SetShooterGood();
AddToScore(m_iOffenseTeamIndex, GetShotValue());
SetVelocity(0, 0, 0);
SetPosition((0 << 10), m_iOffenseDir *(42 << 10),(30 << 10)- 5000);
SetController(null);
SetState(5);
SwitchOffenseTeam();
SetControlTeam(m_iOffenseTeamIndex);
if(m_iOffenseTeamIndex == m_iUserTeamIndex)
SetNextOffensePlay(m_iOffenseTeamIndex, 15);
else
SetNextOffensePlay(m_iOffenseTeamIndex, 11);
DoResetBkCourClock();
DoResetInbndsClock();
DoResetShotClock();
m_bPlayCrowd = true;
m_iClockState = 0;
}
void DoResetInbndsClock()
{
m_iInbndSecs = 7000;
}
void DoResetBkCourClock()
{
m_iBkCrtSecs = 8000;
}
void DoResetShotClock()
{
m_iShotSecs = 24200;
}
void DoClockViolation()
{
SetVelocity(0, 0, 0);
SetPosition((0 << 10), m_iOffenseDir *(42 << 10),((30 << 10)- 5000)/ 2);
SetController(null);
SetState(5);
AddToTurnOvers(m_iOffenseTeamIndex, 1);
SwitchOffenseTeam();
if(m_iOffenseTeamIndex == m_iUserTeamIndex)
SetNextOffensePlay(m_iOffenseTeamIndex, 15);
else
SetNextOffensePlay(m_iOffenseTeamIndex, 11);
DoResetBkCourClock();
DoResetInbndsClock();
DoResetShotClock();
m_iClockState = 1;
ClrInput();
}
int GetUserPlay()
{
if(m_iUserTeamIndex == m_iOffenseTeamIndex)
return GetTeamOffensePlay(m_iUserTeamIndex);
else
return GetTeamDefensePlay(m_iUserTeamIndex)+ 10;
}
void ChangeUserPlay(int iPlay)
{
if(m_iUserTeamIndex == m_iOffenseTeamIndex && iPlay < 10)
{
SetNextOffensePlay(m_iUserTeamIndex, iPlay);
SetTeamOffenseAI(m_iUserTeamIndex, iPlay);
}
else if(m_iUserTeamIndex != m_iOffenseTeamIndex && iPlay >= 10)
{
SetNextDefensePlay(m_iUserTeamIndex, iPlay - 10);
}
}
void DoTurnOver()
{
ClrInput();
SwitchOffenseTeam();
m_iOffenseTeamIndex = GetControlTeam();
m_iOffenseDir = GetTeamOffenseDir(m_iOffenseTeamIndex);
SetCameraDir(m_iOffenseDir);
SetTurnOverFlag(m_iHomeTeamIndex, false);
SetTurnOverFlag(m_iAwayTeamIndex, false);
if(GetPosY()* m_iOffenseDir > -5)
{
SetNextOffensePlay(m_iOffenseTeamIndex, 13);
}
else
{
SetNextOffensePlay(m_iOffenseTeamIndex, 14);
}
if(GetPosY()* m_iOffenseDir < 0)
m_bBallBackCourt = true;
DoResetShotClock();
DoResetBkCourClock();
}
void DoEndQuarter()
{
m_bReady = false;
Basketball.myCanvas.setUpdate(false);
ClrInput();
StartQtr();
CreateOverlay(34);
}
void DoEndHalf()
{
m_bReady = false;
Basketball.myCanvas.setUpdate(false);
for(int i = 0; i < 5; i++)
{
m_pPlayers[i + 0].SetOffenseDir(- 1);
m_pPlayers[i + 5].SetOffenseDir(1);
}
StartQtr();
CreateOverlay(34);
ClrInput();
}
void DoEndGame()
{
Basketball.myCanvas.killTimers(this);
m_bGameOver = true;
UnLoadGameResSmall();
FrontEnd.LoadFrontEndOnlyArt();
CreateOverlay(10);
}
void DoTippOff()
{
SetVelocity(0, 0, 55000);
SetPosition(0, 0, 25 << 10);
SetController(null);
SetState(7);
DoResetBkCourClock();
DoResetInbndsClock();
DoResetShotClock();
m_bBallBackCourt = true;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -