public void StartCar()
 {
     // I usually alter the center of mass to make the car more stable. I'ts less likely to flip this way.
     //rigidbody.centerOfMass += Vector3(0, -1, .25);
     GetComponent<Rigidbody>().centerOfMass = new Vector3(GetComponent<Rigidbody>().centerOfMass.x, GetComponent<Rigidbody>().centerOfMass.y -1, GetComponent<Rigidbody>().centerOfMass.z + 0.25f);
     muzzleyOn = false;
     rotacaoAuto = 28;
     carState = BUMPERCAR.NORMAL;
     powerUpTimeInitial = 16;
     multiplicadorDeVelocidade = 1;
     carenagemMat = carenagem.GetComponent<Renderer>().material;
     borrachaMat = borrachao.GetComponent<Renderer>().material;
     volanteMat = volante.GetComponent<Renderer>().material;
     AtivarHudPowerUp(false);
     if (steerside != STEERSIDE.IA)
     {
         steerside = STEERSIDE.FRENTE;
     }
 }
    void AtivarHudPowerUp(bool b, Texture t, BUMPERCAR state)
    {
        AtivarHudPowerUp(false);

        carState = state;
        powerUpTime = powerUpTimeInitial;

        if (puHud != null)
        {
            puHud.gameObject.SetActive(b);
            puHud.texture = t;
        }
        if (puTime != null)
            puTime.gameObject.SetActive(b);

        switch (carState) {
            case BUMPERCAR.NORMAL:
            multiplicadorDeVelocidade = 1;
        break;
            case BUMPERCAR.COLETOR:
        break;
            case BUMPERCAR.ESCUDO:
        break;
            case BUMPERCAR.INVISIVEL:
            SetInvisible();
        break;
            case BUMPERCAR.LENTO:
            multiplicadorDeVelocidade = 0.1f;
        break;
            case BUMPERCAR.TURBO:
            multiplicadorDeVelocidade = 2;
        break;
        }
    }
    void AtivarHudPowerUp(bool b)
    {
        if (puHud != null)
            puHud.gameObject.SetActive(b);
        if (puTime != null)
            puTime.gameObject.SetActive(b);

        powerUpTime = powerUpTimeInitial;
        carState = BUMPERCAR.NORMAL;
        SetVisible();
        multiplicadorDeVelocidade = 1;
    }
Exemplo n.º 4
0
    void Update()
    {
        switch (state)
        {
            case BUMPERCAR.NORMAL:
            //print("normal");
        break;
            case BUMPERCAR.ESCUDO:
            time += Time.deltaTime;

            if (time >= timeToBackNormal)
            {
                state = BUMPERCAR.NORMAL;
                time = 0;
            }
            //print("escudo");
        break;
            case BUMPERCAR.INVISIVEL:
            time += Time.deltaTime;

            if (time >= timeToBackNormal)
            {
                SetVisible();
                state = BUMPERCAR.NORMAL;
                time = 0;
            }
            //print("invisivel");
        break;
            case BUMPERCAR.LENTO:
            time += Time.deltaTime;

            if (time >= timeToBackNormal)
            {
                SetVelocity(false);
                state = BUMPERCAR.NORMAL;
                time = 0;
            }
            //print("lento");
        break;
            case BUMPERCAR.TURBO:
            time += Time.deltaTime;

            if (time >= timeToBackNormal)
            {
                SetVelocity(false);
                state = BUMPERCAR.NORMAL;
                time = 0;
            }
            //("turbo");
        break;
        }

        float velz = Input.GetAxis("Vertical") * velocity;
        float velx = Input.GetAxis("Horizontal") * velocityRotation;

        rigidbody.AddRelativeForce(0, 0, velz);
        //rigidbody.AddRelativeTorque(0, velx, 0);
        transform.Rotate(0,velx,0);

        //		if (Input.GetKey(KeyCode.A))
        //		{
        //			transform.Rotate(0,-velocityRotation * Time.deltaTime,0);
        //		}
        //
        //		if (Input.GetKey(KeyCode.D))
        //		{
        //			transform.Rotate(0,velocityRotation * Time.deltaTime,0);
        //		}
    }
Exemplo n.º 5
0
 void Start()
 {
     rigidbody.centerOfMass = new Vector3(0, 0, 0.5f);
     life = 100;
     coins = 100;
     velocityRotation = 5f;
     velocity = 600f;
     initialVelocity = velocity;
     state = BUMPERCAR.NORMAL;
     borrachaMat = borrachao.renderer.material;
     carenagemMat = carenagem.renderer.material;
     volanteMat = volante.renderer.material;
     timeToBackNormal = 7;
 }
Exemplo n.º 6
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "PowerUp")
        {
            switch (other.gameObject.GetComponent<PowerUp>().state)
            {
            case PowerUp.POWERUP.ESCUDO:
                this.state = BUMPERCAR.ESCUDO;
                SetVisible();
                SetVelocity(false);
                break;
            case PowerUp.POWERUP.INVISIVEL:
                this.state = BUMPERCAR.INVISIVEL;
                SetInvisible();
                SetVelocity(false);
                break;
            case PowerUp.POWERUP.LENTO:
                this.state = BUMPERCAR.LENTO;
                SetVisible();
                SetVelocity(true);
                break;
            case PowerUp.POWERUP.TURBO:
                this.state = BUMPERCAR.TURBO;
                SetVisible();
                SetVelocity(false);
                SetTurbo();
                break;
            }

            time = 0;
            Destroy(other.gameObject);
        }
    }