本文整理汇总了C#中PlayerScript.SpawnVortex方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerScript.SpawnVortex方法的具体用法?C# PlayerScript.SpawnVortex怎么用?C# PlayerScript.SpawnVortex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerScript
的用法示例。
在下文中一共展示了PlayerScript.SpawnVortex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateCurrentQuadrant
public void CalculateCurrentQuadrant(PlayerScript playa, Vector2 mousePos, ArrayList mousepoints)
{
float xp = mousePos.x / Camera.main.pixelWidth;
float yp = mousePos.y / Camera.main.pixelHeight;
if(xp > 1)
xp = 1;
else if(xp < 0)
xp = 0;
if(yp > 1)
yp = 1;
else if(yp < 0)
yp = 0;
int xQuadrant = (int)(xp * (QuadrantDensity-1));
int yQuadrant = (int)(yp * (QuadrantDensity-1));
if(!QuadrantsTouched[xQuadrant, yQuadrant].touched)
timeBetweenDifferentQuadrants = 0.0f; //reset quandrant timer
QuadrantsTouched[xQuadrant, yQuadrant].touched = true;
QuadrantsTouched[xQuadrant, yQuadrant].timer = 100;
calculateLoopsTimer -= Time.fixedDeltaTime;
if(calculateLoopsTimer < 0.0f)
{
calculateLoopsTimer = 1.0f;
Camera camcam = Camera.main;
for(int i = 0; i < QuadrantDensity; ++i)
{
if(UnityEngine.Random.Range(0, 100) > 50)
continue;
float deltai = (float)i / (float)(QuadrantDensity-1);
for(int j = 0; j < QuadrantDensity; ++j)
{
float deltaj = (float)j / (float)(QuadrantDensity-1);
float compundedMangle = 0.0f;
float totalmangle = 0.0f;
float screenx = Camera.main.pixelWidth * deltai;
float screeny = Camera.main.pixelHeight * deltaj;
for (int mp = 1; mp < mousepoints.Count; ++mp)
{
Vector2 old = (Vector2)mousepoints[mp - 1];
Vector2 cur = (Vector2)mousepoints[mp];
float yDistCur = cur.y - screeny;
float xDistCur = cur.x - screenx;
float yDistOld = old.y - screeny;
float xDistOld = old.x - screenx;
float maxRadius = 55;
float minRadius = 5;
float curLen = (float)System.Math.Sqrt((xDistCur * xDistCur) + (yDistCur * yDistCur));
//float oldLen = (float)System.Math.Sqrt((xDistOld * xDistOld) + (yDistOld * yDistOld));
if (curLen > minRadius && curLen < maxRadius)
{
float degsCur = ToDegrees(Mathf.Atan2(yDistCur, xDistCur));
float degresOld = ToDegrees(Mathf.Atan2(yDistOld, xDistOld));
if (System.Math.Sign(degresOld) == System.Math.Sign(degsCur))
{
compundedMangle += System.Math.Abs(System.Math.Abs(degsCur) - System.Math.Abs(degresOld));
totalmangle += degsCur - degresOld;
}
}
}
QuadrantsTouched[i, j].mouseLoopsAround = Mathf.Max(0, totalmangle / 360.0f);
if(QuadrantsTouched[i, j].mouseLoopsAround > 1.0f) //two circles to make one appear!
{
if(this.TimeSinceLastTouchDown > 0.5f)
{
playa.SpawnVortex(camcam.ScreenToWorldPoint(new Vector2(screenx, screeny)));
QuadrantsTouched[i, j].mouseLoopsAround = 0;
return;
}
}
}
}
}
}