Esempio n. 1
0
 public void CarTurnOverAdjust(bool flag)
 {
     isCanTurn = false;
     carstatus = CarStatusType.LineRun;
     //todo:将轮胎调整为正常
     for (int i = 0; i < WHEEL_COUNT; i++)
     {
         Wheel[i].DORotate(this.transform.eulerAngles, 0.1f);
     }
 }
Esempio n. 2
0
 public void Freeze()
 {
     if (carStatus == CarStatusType.Freeze)
     {
         return;
     }
     this.originVelocity  = this.rigi.velocity;
     this.rigi.velocity   = Vector2.zero;
     this.carStatus       = CarStatusType.Freeze;
     this.freezeTimeCount = 0;
 }
Esempio n. 3
0
 public bool Dash()
 {
     if (!this.IsDashReady())
     {
         return(false);
     }
     this.carStatus     = CarStatusType.Accelerate;
     this.rigi.velocity = CarConstant.AccScale * this.rigi.velocity;
     this.accelerateTimeLeft--;
     dashCoolDownTimeCounter = 0;
     return(true);
 }
Esempio n. 4
0
 // Use this for initialization
 void Start()
 {
     this.accelerateCountdown = CarConstant.AccNoOfFrames;
     this.accelerateTimeLeft  = CarConstant.BaseAccTimes;
     this.rigi.velocity       = Vector2.zero;
     this.ifInit             = false;
     carStatus               = CarStatusType.Normal;
     landType                = LandType.Road;
     ifDash                  = false;
     dashCoolDownTimeCounter = CarConstant.DashCoolDownTime;
     move = 0;
     this.freezeTimeCount = 0;
 }
Esempio n. 5
0
 void Start()
 {
     carstatus        = CarStatusType.LineRun;
     isCanTurn        = false;
     DriftCar         = false;
     CanDrift         = false;
     DriftIndex       = 0;
     IsAccelerate     = false;
     IsAccelerateOver = false;
     Forward          = Vector3.zero;
     Wheel[(int)Wheel_Type.car_FL] = this.transform.FindChild("CarWheel/car_FL");
     Wheel[(int)Wheel_Type.car_FR] = this.transform.FindChild("CarWheel/car_FR");
     r = GetComponent <References>();
     if (r != null)
     {
         MainCamera = r.Object[0].transform;
     }
     carMaxSpeed        = DataManager.Instance.PlayerCarMaxSpeed;
     carAccSpeed        = DataManager.Instance.PlayerCarAcceSpeed;
     maxSteerAngle      = GameData.maxSteerAngle;
     maxSpeedSteerAngle = GameData.maxSpeedSteerAngle;
     maxmotorTorque     = DataManager.Instance.PlayerCarMaxMotorTorque;
 }
Esempio n. 6
0
 public void SetCarStatus(CarStatusType t)
 {
     this.carStatus = t;
 }
Esempio n. 7
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (this.carStatus == CarStatusType.Win || this.carStatus == CarStatusType.Die)
        {
            this.rigi.velocity = Vector2.zero;
            return;
        }
        if (GameController.instance.GetGameStatus() != GameController.GameStatus.start)
        {
            return;
        }
        if (!ifInit)
        {
            Init();
            ifInit = true;
        }


        if (this.carStatus == CarStatusType.Freeze && this.freezeTimeCount > 30)
        {
            this.freezeTimeCount = 0;
            this.carStatus       = CarStatusType.Normal;
            this.rigi.velocity   = this.originVelocity;
            return;
        }
        else if (this.carStatus == CarStatusType.Freeze)
        {
            this.freezeTimeCount++;
            return;
        }

        //float move = Input.GetAxis("Horizontal");
        ////ifDash = Input.GetKeyDown("q") || ifDash;
        if (Input.GetKeyDown("q"))
        {
            this.Dash();
        }
        if (Input.GetAxis("Horizontal") == 1)
        {
            this.TurnRight();
        }
        else if (Input.GetAxis("Horizontal") == -1)
        {
            this.TurnLeft();
        }
//        if (Input.touchCount > 0 && Input.GetTouch(0).position.x <= Screen.width * 0.3)
//        {
//            move = -1;
//        }
//        else if (Input.touchCount > 0 && Input.GetTouch(0).position.x >= Screen.width * 0.7)
//        {
//            move = 1;
//        }
        //else if (Input.touchCount > 0 && Input.GetTouch(0).position.x > Screen.width * 0.35 && Input.GetTouch(0).position.x < Screen.width * 0.65)
        //{
        //    ifDash = true;
        //}

        if (move != 0)
        {
            float x     = this.rigi.velocity.x;
            float y     = this.rigi.velocity.y;
            float angle = move * CarConstant.TurningAngle;
            this.rigi.velocity = new Vector2(x * Mathf.Cos(angle) + y * Mathf.Sin(angle), (-1) * x * Mathf.Sin(angle) + y * Mathf.Cos(angle));
            transform.Rotate(0, 0, (-1) * angle * 180 / Mathf.PI);
            move = 0;
        }

        dashCoolDownTimeCounter += Time.deltaTime;
//        if (ifDash && this.carStatus == CarStatusType.Normal && this.accelerateTimeLeft > 0)
//        {
//            this.carStatus = CarStatusType.Accelerate;
//            this.rigi.velocity = CarConstant.AccScale * this.rigi.velocity;
//            this.accelerateTimeLeft--;
//            ifDash = false;
//            dashCoolDownTimeCounter = 0;
//        }
        if (this.carStatus == CarStatusType.Accelerate && this.accelerateCountdown > 0)
        {
            this.accelerateCountdown--;
        }
        else if (this.carStatus == CarStatusType.Accelerate)
        {
            this.carStatus           = CarStatusType.Normal;
            this.rigi.velocity       = this.rigi.velocity / CarConstant.AccScale;
            this.accelerateCountdown = CarConstant.AccNoOfFrames;
        }
    }
Esempio n. 8
0
 public void CarTurnAdjust(bool flag)//长按转向
 {
     isCanTurn = true;
     carstatus = (CarStatusType)(flag ? 1 : 2);
 }