コード例 #1
0
    IEnumerator MoveByStep(int step)
    {
        car_Animator.SetFloat("Speed", MoveAnimationSpeed);
        float      timer;
        Vector3    startPos;
        Vector3    endPos;
        Quaternion startRot;
        Quaternion endRot;

        for (int i = 0; i < step; i++)
        {
            timer = 0;
            if (currentStep > bricks_Pos.Length - 1)
            {
                currentStep = 0;
            }
            int nextStep = currentStep + 1;
            if (nextStep > bricks_Pos.Length - 1)
            {
                nextStep = 0;
            }
            startPos = bricks_Pos[currentStep];
            startRot = car_step_rotation[currentStep];
            endPos   = bricks_Pos[nextStep];
            endRot   = car_step_rotation[nextStep];
            while (timer < OneStepNeedStep)
            {
                yield return(null);

                timer += Time.deltaTime / Time.timeScale;
                float progress = timer / OneStepNeedStep;
                car_Trans.position = Vector3.Lerp(startPos, endPos, progress);
                car_Trans.rotation = Quaternion.Lerp(startRot, endRot, progress);
            }
            car_Trans.position = endPos;
            car_Trans.rotation = endRot;
            currentStep        = nextStep;
        }
        if (!save.player.hasShowMGGuid && save.player.totalWasteEnergy >= 3)
        {
            needShowMGGuid            = true;
            save.player.hasShowMGGuid = true;
        }
        if (currentStep == 0)
        {
            GetExtraBonus();
            RandomReward();
            currentStep = 0;
            ChangeSceneBg();
            if (!save.player.hasRateUs && save.player.showExchange)
            {
                needRateUs            = true;
                save.player.hasRateUs = true;
            }
        }
        yield return(new WaitForSeconds(0.3f * Time.timeScale));

        //获得奖励
        int rewardType = brick_reward[currentStep];

        if (brick_rewardGo_Dic.ContainsKey(currentStep))
        {
            brick_rewardGo_Dic[currentStep].SetActive(false);
            brick_reward_get[currentStep] = true;
        }
        switch (rewardType)
        {
        case 0:
            if (canGetExtraBonus && currentStep != 0)
            {
                GetExtraBonus();
                canGetExtraBonus = false;
            }
            else
            {
                canRollDice = true;
            }
            break;

        case 1:
            panelManager.ShowPanel(PanelType.Jackpot, 0.3f);
            break;

        case 2:
            GetSpecialPropsRandom(false);
            panelManager.ShowPanel(PanelType.Reward, 0.3f);
            break;

        case 3:
            GetSpecialPropsRandom(true);
            panelManager.ShowPanel(PanelType.Reward, 0.3f);
            break;

        default:
            if (needShowMGGuid)
            {
                needShowMGGuid = false;
                MG_Manager.ShowMGGuid();
            }
            break;
        }
        car_Animator.SetFloat("Speed", IdleAnimationSpeed);
    }