本文整理汇总了C#中SPoint.GetDir方法的典型用法代码示例。如果您正苦于以下问题:C# SPoint.GetDir方法的具体用法?C# SPoint.GetDir怎么用?C# SPoint.GetDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPoint
的用法示例。
在下文中一共展示了SPoint.GetDir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rebound
public bool Rebound(float rAng)
{
//returns true of a rebound occurs
//called automatically in Stage.CollisionDetect(...)
//returns false when no rebound occurs
if (!fHelper.airborne)
return false;
SPoint nVec = new SPoint(Mathf.Cos(rAng-Mathf.PI/2), Mathf.Sin(rAng-Mathf.PI/2));//should be normalized already
float two_n_dot_d = 2*(nVec.x*GetVel().x + nVec.y*GetVel().y);
SPoint rVec = new SPoint(GetVel().x - two_n_dot_d*nVec.x, GetVel().y - two_n_dot_d*nVec.y);
float rDotN = rVec.x*nVec.x + rVec.y+nVec.y ;//angle of reflection
float b_r=0;
float fVel = GetVelF ()-tu_vRoThresh;//speed in units
if (fVel > 0) { //if player is moving faster than the 'roll' threshhold
b_r = (GetVelF())/ (tu_vReThresh-tu_vRoThresh);
//bounce angle between 1 and 0, to determine how shallow to bounce
if(b_r>1.0f)//simple sanity checks
b_r=1.0f;
else if(b_r<0)
b_r=0;
}
//now determine rVec.
//interpolate between rVec (max reflection)
//and sVec(sliding)
SPoint sVec = new SPoint ();
sVec.x = Mathf.Cos (rAng)*fVel;
sVec.y = Mathf.Sin (rAng)*fVel;
// if (GetVel ().x > 0)
// sVec.x = sVec.x * -1;//for facing in opposite direction
SPoint cVel=new SPoint();//to combine
cVel.x = rVec.x*b_r+sVec.x*(1.0f-b_r);
cVel.y = rVec.y*b_r+sVec.y*(1.0f-b_r);
if (cVel.x < 0)
cVel.x = cVel.x;
cVel.x = cVel.x * tu_bncRat;//bounce ratio here
cVel.y = cVel.y * tu_bncRat;//bounce ratio here
//Check for a tech
float stAng=0;
if (gCont.LStickTapped()) {
SPoint stInv = new SPoint(-gCont.lStick.x, -gCont.lStick.y);
stAng = stInv.GetDir ();
if(Mathf.Abs (stAng-nVec.GetDir())<(Mathf.PI/4) ){
cVel.x = cVel.x*0.1f;
cVel.y = cVel.y*0.1f;
}
}
//if(rDotN> stats.tumble.thresh){
if( (fVel>0)){
stats.motion.vel = new SPoint(cVel.x, cVel.y);
//TurnCheck(GetVel().x);
if((Mathf.Abs(rAng) < Mathf.PI/3)||(Mathf.Abs(rAng-Mathf.PI) < Mathf.PI/3)||(Mathf.Abs(rAng+Mathf.PI) < Mathf.PI/3) ){ //landing on a flat-ish ground
if(!stats.tumble.tmr.IsReady()){
fHelper.Animate("Slam", false, 0);
Land (rAng);
float spd = Mathf.Sqrt(stats.motion.vel.SqDistFromOrigin());
}else
return false;//just land
}else
if(!stats.tumble.tmr.IsReady())
fHelper.Animate("WallSlam", false, 0);
else
return false;//just land
}else
return false;
stats.tumble.rbdCount++;
return true;
}