Help converting C# to Javascript.

I found a script floating around in C# and I need help converting it. I have tried to change as much as I could from the original but It comes up with millions of errors, anyone willing to help?

The Most Messy Script You Will See In Your Existence!!!:

var Started : boolean;
var RotationSpeed : float;
var MaxSpeed : float;
var Accel : float;
var InvAccel : float;
var IdleInvAccel : float;
var SideEnergyLoss : float;
var FrontEnergyLoss : float;
var FrontAngle : float;
var MovingSpeed : float;
var Energy : float;
var MaxEnergy : int;
var Yconstant : float;
var Exploded : boolean;
var Explosion : Transform;
	{
		this.MaxEnergy == 1000;
	}
	function Start(){
		this.Started = false;
		this.Exploded = false;
		this.MovingSpeed = (float)0;
		this.Energy = (float)this.MaxEnergy;
		this.Yconstant = this.transform.position.y;
	}
	function Update(){
	{
			if (Input.GetAxis("Vertical"))
			{
				this.MovingSpeed += this.Accel;
				this.MovingSpeed = Mathf.Clamp(this.MovingSpeed, -this.MaxSpeed, this.MaxSpeed);
			}
			else
			{
				if (Input.GetAxis("Vertical"))
				{
					this.MovingSpeed -= this.InvAccel;
					this.MovingSpeed = Mathf.Clamp(this.MovingSpeed, -this.MaxSpeed, this.MaxSpeed);
				}
				else
				{
					if (this.MovingSpeed >= (float)0)
					{
						this.MovingSpeed -= this.IdleInvAccel;
						this.MovingSpeed = Mathf.Clamp(this.MovingSpeed, (float)0, this.MaxSpeed);
					}
					else
					{
						this.MovingSpeed += this.IdleInvAccel;
						this.MovingSpeed = Mathf.Clamp(this.MovingSpeed, -this.MaxSpeed, (float)0);
					}
				}
			}
			CharacterController characterController = (CharacterController)this.GetComponent(typeof(CharacterController));
			characterController.Move(this.transform.forward * this.MovingSpeed * Time.deltaTime);
			float y = this.Yconstant;
			Vector3 position = this.transform.position;
			float num = position.y = y;
			Vector3 vector = this.transform.position = position;
			if (Mathf.Abs(Input.GetAxis("Horizontal")))
			{
				this.transform.Rotate(new Vector3((float)0, Input.GetAxis("Horizontal") * this.RotationSpeed * Time.deltaTime, (float)0), Space.Self);
			}
		}
	}
	function OnControllerColliderHit(ControllerColliderHit hit)
	{
		GameObject gameObject = hit.gameObject;
		float f = Vector3.Angle(this.transform.forward, hit.point - this.transform.position);
		if (gameObject.tag == "Walls")
		{
			float num = 0f;
			float num2 = Mathf.Abs(this.MovingSpeed);
			if (Mathf.Abs(f) <= this.FrontAngle)
			{
				num = this.FrontEnergyLoss;
			}
			else
			{
				num = this.SideEnergyLoss;
			}
			this.energy -= num * (num2 / this.MaxSpeed) * Time.deltaTime;
			if (this.energy < (float)0)
			{
				this.energy = (float)0;
			}
			if (this.energy == (float)0)
			{
				{
					this.Exploded = true;
					this.Started = false;
					int i = 0;
					Component[] componentsInChildren = this.GetComponentsInChildren(typeof(MeshRenderer));
					int length = componentsInChildren.Length;
					while (i < length)
					{
						((MeshRenderer)componentsInChildren*).enabled = false;*
  •  				i++;*
    
  •  			}*
    
  •  			int j = 0;*
    
  •  			Component[] componentsInChildren2 = this.GetComponentsInChildren(typeof(ParticleSystemRenderer));*
    
  •  			int length2 = componentsInChildren2.Length;*
    
  •  			while (j < length2)*
    
  •  			{*
    
  •  				((ParticleSystemRenderer)componentsInChildren2[j]).particleSystem.Stop();*
    
  •  				j++;*
    
  •  			}*
    
  •  			UnityEngine.Object.Instantiate(this.PrefabExplosion, this.transform.position, this.transform.localRotation);*
    
  •  		}*
    
  •  	}*
    
  •  }*
    
  • }*
  • function getEnergyLevel()*
  • {*
  •  return this.Energy;*
    
  • }*
  • function Main()*
  • {*
  • }*
    }

I hope this will help you out a bit:
If you get any errors, please let me know :slight_smile:

public bool started = false;
public float rotationSpeed;
public float maxSpeed;
public float accel;
public float invAccel;
public float idleInvAccel;
public float sideEnergyLoss;
public float frontEnergyLoss;
public float frontAngle;
public float movingSpeed = 0f;
public float energy;
public int maxEnergy = 1000;
public float yConstant;
public bool exploded = false;
public Transform explosion;
    
    void Start(){
       energy = maxEnergy;
       yConstant = this.transform.position.y;
    }
    void Update()
    {
         if (Input.GetAxis("Vertical"))
         {
          movingSpeed += accel;
          movingSpeed = Mathf.Clamp(movingSpeed, -maxSpeed, maxSpeed);
         }
         else if (Input.GetAxis("Vertical"))
         {
             movingSpeed -= invAccel;
             movingSpeed = Mathf.Clamp(movingSpeed, -maxSpeed, maxSpeed);
          }
          else if (movingSpeed >= 0f)
          {
                 movingSpeed -= idleInvAccel;
                 movingSpeed = Mathf.Clamp(movingSpeed, 0f, maxSpeed);
              }
              else
              {
                 movingSpeed += idleInvAccel;
                 movingSpeed = Mathf.Clamp(movingSpeed, -maxSpeed, 0f);
              }
          }
         }
         CharacterController characterController = (CharacterController)this.GetComponent(typeof(CharacterController));
         characterController.Move(this.transform.forward * movingSpeed * Time.deltaTime);
         float y = yConstant;
         Vector3 position = this.transform.position;
         float num = position.y = y;
         Vector3 vector = this.transform.position = position;
         if (Mathf.Abs(Input.GetAxis("Horizontal")))
         {
          this.transform.Rotate(new Vector3((float)0, Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime, 0f), Space.Self);
         }
       }
    }
    void OnControllerColliderHit(ControllerColliderHit hit)
    {
       GameObject gameObject = hit.gameObject;
       float f = Vector3.Angle(this.transform.forward, hit.point - this.transform.position);
       if (gameObject.tag == "Walls")
       {
         float num = 0f;
         float num2 = Mathf.Abs(movingSpeed);
         if (Mathf.Abs(f) <= frontAngle)
         {
          num = frontEnergyLoss;
         }
         else
         {
          num = sideEnergyLoss;
         }
         energy -= num * (num2 / maxSpeed) * Time.deltaTime;
         if (energy < 0f)
         {
          energy = 0f;
         }
         if (energy == 0f)
         {
          {
              exploded = true;
              started = false;
              int i = 0;
              Component[] componentsInChildren = this.GetComponentsInChildren(typeof(MeshRenderer));
              int length = componentsInChildren.Length;
              while (i < length)
              {
                 ((MeshRenderer)componentsInChildren*).enabled = false;*

i++;
}
int j = 0;
Component[] componentsInChildren2 = this.GetComponentsInChildren(typeof(ParticleSystemRenderer));
int length2 = componentsInChildren2.Length;
while (j < length2)
{
((ParticleSystemRenderer)componentsInChildren2[j]).particleSystem.Stop();
j++;
}
UnityEngine.Object.Instantiate(this.PrefabExplosion, this.transform.position, this.transform.localRotation);
}
}
}
}
void getEnergyLevel()
{
return energy;
}
}