Exemplo n.º 1
0
    public void SetState()
    {
        car_component.transform.Reset();

        d_State = Drive_State.Wait;
        m_State = Moving_State.Parking;
    }
Exemplo n.º 2
0
    private void MoveCar()
    {
        switch (d_State)
        {
        case Drive_State.Wait:
            return;

        case Drive_State.Acceleration:
        case Drive_State.Deceleration:
            break;

        case Drive_State.Out_of_control:
            //여기서는 그냥 뺑뺑이로 밖으로 튀어나가는 연출 보여줄거고
            //카메라는 고정시킨다.
            //그리고 차가 카메라 밖으로 나가면 레이스 끝내는걸로
            if (!isGamePlaying)
            {
                return;
            }
            m_State = Moving_State.OutOfControl;
            RaceEnd(FinishType.OutOfControl);
            break;

        default:
            Debug.LogError("Wrong State");
            break;
        }
        CalcCurrentSpeed();

        switch (m_State)
        {
        case Moving_State.OnCurve:

            if (_Drive_State == Drive_State.Acceleration)
            {
                currentHP -= curveDamage;
            }
            else if (_Drive_State == Drive_State.Deceleration)
            {
                currentHP += current_Car.Brake * 0.01f;
                if (currentHP >= current_Car.MaxHP)
                {
                    currentHP = current_Car.MaxHP;
                    time      = 0;
                }
            }

            if (currentHP <= 0)
            {
                _Drive_State = Drive_State.Out_of_control;
                Debug.LogError("Die");
            }
            break;

        case Moving_State.OnStraight:

            //코너링 능력치 대비 회복량 조정해야한다
            //현재 틱당 1%
            DesignConstStorage.DoItList();
            currentHP += current_Car.Cornering * 0.01f;
            if (currentHP >= current_Car.MaxHP)
            {
                currentHP = current_Car.MaxHP;
                time      = 0;
            }
            break;
        }

        if (M_State != Moving_State.OutOfControl)
        {
            int _checkfactor = (int)(current_Car.Cornering / CurrentSpeed) + 1;
            _checkfactor = 3;
            float divideSpeed = CurrentSpeed / (_checkfactor + 1);

            //Debug.LogError(string.Format("f{0} c{1} s{2} ds{3}", _checkfactor, current_Car.Cornering, CurrentSpeed, divideSpeed));

            //이부분 대대적으로 바꿔야 할수도 있다. 191009 기준
            //왜냐하면 지나간 정보로 판단하고 있어서 정보 전달이 늦을수도 있거든
            //이전 정보가 아니라 미래정보 계산하는 방식으로 변경해야 할수도 있다.
            //아닌가? 중간중간 처리하면 안해도 될거 같기도 하다.
            Quaternion preQuat = gameObject.transform.rotation;

            for (int i = 0; i < _checkfactor; i++)
            {
                SetDestination();
                Car_Rotation();
                MoveTo(divideSpeed);
            }

            if (isLastSection)
            {
                //마지막 섹션이면 속도 0 되었을때 결과 팝업
                if (CurrentSpeed <= 0.0f && m_State != Moving_State.Parking)
                {
                    RaceEnd(FinishType.Finish);
                }
            }
            else
            {
                //마지막 섹션이 아니니까 브레이크 띄면 다시 주행
            }

            curveAngle = Quaternion.Angle(preQuat, gameObject.transform.rotation);

            isTurnRight = (preQuat.eulerAngles - gameObject.transform.eulerAngles).z >= 0;
        }

        CheckMovingState();
    }
Exemplo n.º 3
0
    public void CarInit(PlayingCarModifier cStat)
    {
        current_Car = cStat;

        isBooster = false;

        float sizeFactor = 1;

        switch (current_Car.ModedCarStat.Information.Size)
        {
        case Car_Information.CarSize.Big:
            sizeFactor = 1.1f;
            break;

        case Car_Information.CarSize.Normal:
            sizeFactor = 1.0f;
            break;

        case Car_Information.CarSize.Compact:
            sizeFactor = 0.9f;
            break;

        case Car_Information.CarSize.Small:
            sizeFactor = 0.8f;
            break;
        }

        this.gameObject.transform.localScale = baseObjectSize * sizeFactor;


        trackPostions = Game_Manager.Instance.track_manager.Section_vecs;

        CurrentSpeed = 0;
        curveAngle   = 0;
        curveDamage  = 0;

        car_component.sprite = Resources.Load <Sprite>(string.Format(path, current_Car.ModedCarStat.CarName));

        isGamePlaying = true;

        spots = new List <GameObject>();

        currentHP = current_Car.MaxHP;

        sectionIndex = 0;
        this.gameObject.transform.position = currentSection[0];

        destinationIndex = 0;

        d_State = Drive_State.Wait;
        m_State = Moving_State.Parking;
        //Load_Status();
        //Debug.LogError(string.Format("{0} {1} {2} {3}", current_Car.TopSpeed, current_Car.Acceleration, current_Car.Brake, current_Car.Cornering));

        SetDestination();
        Car_Rotation();

        Red   = 70;
        Green = 200;
        brake_Btn_Image.sprite = start_Image;
        Balance_Text.text      = MyLocalization.Exchange("balance");
        Start_Btn.SetActive(true);
        Brake_Image.SetActive(false);
    }