本文整理汇总了C#中PlayerData.getLives方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerData.getLives方法的具体用法?C# PlayerData.getLives怎么用?C# PlayerData.getLives使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerData
的用法示例。
在下文中一共展示了PlayerData.getLives方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DestroyCar
public void DestroyCar(PlayerData data, bool respawn = false)
{
if (data.getLives() > 0)
{
lastDeath = data.getID();
string explPrefab = "Prefabs/FX/Explosions/Explosion";
if (data.GetGameObject().name.IndexOf("Van - Classic") != -1)
explPrefab = "Prefabs/FX/Explosions/RaceVanExplosion";
if (data.GetGameObject().name.IndexOf("Van - Turbo") != -1)
explPrefab = "Prefabs/FX/Explosions/RaceVan#2Explosion";
if (data.GetGameObject().name.Length >= 8 && data.GetGameObject().name.IndexOf("Car - Classic") != -1)
explPrefab = "Prefabs/FX/Explosions/ClasicMGTExplosion";
if (data.GetGameObject().name.Length >= 8 && data.GetGameObject().name.IndexOf("Car - Racing") != -1)
explPrefab = "Prefabs/FX/Explosions/RaceMGTEExplosion";
var expl = (GameObject)Instantiate(Resources.Load(explPrefab), data.GetGameObject().transform.position, Quaternion.identity);
expl.transform.parent = explHolder.transform;
if (data.IsAI())
data.GetGameObject().GetComponent<AIController>().stopPlanner();
Destroy(data.GetGameObject());
if(respawn)
{
StartCoroutine(TriggerRespawn(data));
}
}
}
示例2: SpawnCar
public void SpawnCar(PlayerData data)
{
if (data.GetGameObject() != null)
{
return;
}
data.reduceLives();
if (data.getLives() > 0)
{
Vector3 startPoint = myCamera.GetLeadingPlayerPosition();
var trackPiece = Data.GetCurrentTrackPiece();
if (trackPiece.name.Substring(0, 7) == "Track_D") // If TrackPiece where road is separated - wait for 1sec before respawning
{
Ray targetRay = new Ray(new Vector3(myCamera.GetLeadingPlayerPosition().x - 50, 0.5f, myCamera.GetLeadingPlayerPosition().z), new Vector3(1, 0, 0));
RaycastHit[] hits = Physics.RaycastAll(targetRay, 180, 1 << LayerMask.NameToLayer("AIGuide"));
Vector3[] targetPos = new Vector3[hits.Length];
for (int i = 0; i < hits.Length; i++)
targetPos[i] = hits[i].point;
if (targetPos.Length == 0)
{
Debug.LogError("Could not find Spawnpoint");
startPoint = myCamera.GetLeadingPlayerPosition();
}
else if (targetPos.Length == 1 || Vector3.Distance(targetPos[0], myCamera.GetLeadingPlayerPosition()) < Vector3.Distance(targetPos[1], myCamera.GetLeadingPlayerPosition()))
startPoint = targetPos[0];
else
startPoint = targetPos[1];
}
startPoint.z -= 7.5f;
float xPos = 0.0f;
List<float> listOfXPos = new List<float>();
foreach (var pData in Data.GetPlayerData())
{
if (pData.GetGameObject() != null && pData != data)
{
listOfXPos.Add(pData.GetGameObject().transform.position.x);
}
}
float maxDist = 5.0f;
for (int i = 0; i < trackPiece.transform.childCount; i++)
{
if (trackPiece.transform.GetChild(i).name.Substring(0, 4) == "Road" || (trackPiece.transform.GetChild(i).name.Length >= 8 && trackPiece.transform.GetChild(i).name.Substring(0, 8) == "CityRoad"))
{
trackPiece = trackPiece.transform.GetChild(i).gameObject;
break;
}
}
for (int i = 0; i < trackPiece.GetComponent<MeshRenderer>().bounds.extents.x; i++)
{
bool possible = true;
foreach (float otherCarXPos in listOfXPos)
{
if (i > otherCarXPos - maxDist && i < otherCarXPos + maxDist)
{
possible = false;
}
}
if (possible)
{ xPos = i; break; }
possible = true;
foreach (float otherCarXPos in listOfXPos)
{
if (-i > otherCarXPos - maxDist && -i < otherCarXPos + maxDist)
{
possible = false;
}
}
if (possible)
{ xPos = -i; break; }
}
startPoint.x = xPos;
startPoint.y = 0.5f;
var spawnVel = Vector3.zero;
if (myCamera.leadingGameObject != null)
spawnVel = myCamera.leadingGameObject.GetComponent<Rigidbody>().velocity;
var newCar = (GameObject)Instantiate(data.GetPrefab(), startPoint, Quaternion.Euler(0, 180, 0));
newCar.GetComponent<Rigidbody>().velocity = spawnVel;
newCar.GetComponent<CarController>().myPlayerData = data;
data.AttachGameObject(newCar);
}
else
{
var allPD = Data.GetPlayerData();
int bodyCount = 0;
int winnerNumber = 0;
for (int i = 0; i < allPD.Length; i++)
{
if (allPD[i].getLives() <= 0)
bodyCount++;
else
winnerNumber = i + 1;
//.........这里部分代码省略.........