На сложном уровне нажал 465 раз и не продвинулся дальше трети экрана. Это такой прикол?
А код имхо говнокод. Нельзя каждую итерацию объекты искать, это медленно очень. Ну и соответственно нет привязки к о времени => нет гарантии, что игра у всех будет одинаково работать.
public int clicks;
public override void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
this.clicks++;
if (((SpeedTank)GameObject.FindGameObjectWithTag("Difficult").GetComponent(typeof(SpeedTank))).startspeed == 1 && ((SpeedTank)GameObject.FindGameObjectWithTag("Difficult").GetComponent(typeof(SpeedTank))).easyin == 1)
{
float z = this.transform.position.z + 0.3f;
Vector3 position = this.transform.position;
float num = position.z = z;
Vector3 vector = this.transform.position = position;
}
if (((SpeedTank)GameObject.FindGameObjectWithTag("Difficult").GetComponent(typeof(SpeedTank))).startspeed == 2 && ((SpeedTank)GameObject.FindGameObjectWithTag("Difficult").GetComponent(typeof(SpeedTank))).mediumin == 1)
{
float z2 = this.transform.position.z + 0.2f;
Vector3 position2 = this.transform.position;
float num2 = position2.z = z2;
Vector3 vector2 = this.transform.position = position2;
}
if (((SpeedTank)GameObject.FindGameObjectWithTag("Difficult").GetComponent(typeof(SpeedTank))).startspeed == 3 && ((SpeedTank)GameObject.FindGameObjectWithTag("Difficult").GetComponent(typeof(SpeedTank))).hardin == 1)
{
float z3 = this.transform.position.z + 0.1f;
Vector3 position3 = this.transform.position;
float num3 = position3.z = z3;
Vector3 vector3 = this.transform.position = position3;
}
if (((SpeedTank)GameObject.FindGameObjectWithTag("Difficult").GetComponent(typeof(SpeedTank))).startspeed == 4)
{
float z4 = this.transform.position.z + 0.6f;
Vector3 position4 = this.transform.position;
float num4 = position4.z = z4;
Vector3 vector4 = this.transform.position = position4;
}
}
else
{
float z5 = this.transform.position.z - 0.01f;
Vector3 position5 = this.transform.position;
float num5 = position5.z = z5;
Vector3 vector5 = this.transform.position = position5;
}
}
Теперь я знаю, что js генерит говнокод)))
наверняка вот это:
float z = this.transform.position.z + 0.3f;
Vector3 position = this.transform.position;
float num = position.z = z;
Vector3 vector = this.transform.position = position;
было вот этим:
transform.position.z += 0.3f;
Три лишних переменных, жуть