Exemplo n.º 1
0
    //Start
    void Start()
    {
        //Data from option
        speedmod = DataManager.Instance.speedmodSelected*speedmodRate;
        DataManager.Instance.LoadScoreJudge(DataManager.Instance.scoreJudgeSelected);
        DataManager.Instance.LoadHitJudge(DataManager.Instance.hitJudgeSelected);
        DataManager.Instance.LoadLifeJudge(DataManager.Instance.lifeJudgeSelected);
        isFullComboRace = DataManager.Instance.raceSelected == 9;
        isFullExComboRace = DataManager.Instance.raceSelected == 10;
        targetScoreInverse = DataManager.Instance.giveTargetScoreOfRace(DataManager.Instance.raceSelected);
        typeOfDeath = DataManager.Instance.deathSelected;
        KeyCodeDown = DataManager.Instance.KeyCodeDown;
        KeyCodeUp = DataManager.Instance.KeyCodeUp;
        KeyCodeLeft = DataManager.Instance.KeyCodeLeft;
        KeyCodeRight = DataManager.Instance.KeyCodeRight;
        SecondaryKeyCodeDown = DataManager.Instance.SecondaryKeyCodeDown;
        SecondaryKeyCodeUp = DataManager.Instance.SecondaryKeyCodeUp;
        SecondaryKeyCodeLeft = DataManager.Instance.SecondaryKeyCodeLeft;
        SecondaryKeyCodeRight = DataManager.Instance.SecondaryKeyCodeRight;
        speedmodSelected = DataManager.Instance.speedmodSelected;
        speedmodstring = DataManager.Instance.speedmodSelected.ToString("0.00");
        speedmodok = true;
        var rand = (int)(UnityEngine.Random.value*DataManager.Instance.skyboxList.Count);
        if(rand == DataManager.Instance.skyboxList.Count){
            rand--;
        }

        //Arrows
        for(int i=0;i<4;i++){
            if(i != DataManager.Instance.skinSelected){
                var go = GameObject.Find("ArrowSkin" + i);
                Destroy(go);
                var go2 = GameObject.Find("ArrowModelSkin" + i);
                Destroy(go2);
            }
        }
        arrow = typeArrow.ElementAt(DataManager.Instance.skinSelected);
        var modelskin = GameObject.Find("ArrowModelSkin" + DataManager.Instance.skinSelected);
        modelskin.SetActiveRecursively(false);
        arrowLeft = (GameObject) Instantiate(modelskin, new Vector3(0f, 0f, 2f), modelskin.transform.rotation);
        if(DataManager.Instance.skinSelected == 3){
            arrowLeft.transform.FindChild("RotationCenter").Rotate(0f, 0f, 90f);
        }else if(DataManager.Instance.skinSelected != 0){
            arrowLeft.transform.Rotate(0f, 0f, 90f);
            arrowLeft.transform.FindChild("ParticulePrec").Rotate(0f, 0f, -90f);
            arrowLeft.transform.FindChild("ParticulePrec").localPosition = new Vector3(-1f, 0f, 0f);
        }

        arrowLeft.transform.parent = MainCamera.gameObject.transform;
        arrowRight = (GameObject) Instantiate(modelskin, new Vector3(6f, 0f, 2f), modelskin.transform.rotation);
        if(DataManager.Instance.skinSelected == 3){
            arrowRight.transform.FindChild("RotationCenter").Rotate(0f, 0f, -90f);
        }else if(DataManager.Instance.skinSelected == 1){
            arrowRight.transform.Rotate(0f, 0f, -90f);
            arrowRight.transform.FindChild("ParticulePrec").Rotate(0f, 0f, 90f);
            arrowRight.transform.FindChild("ParticulePrec").localPosition = new Vector3(1f, 0f, 0f);
        }
        arrowRight.transform.parent = MainCamera.gameObject.transform;
        arrowDown = (GameObject) Instantiate(modelskin, new Vector3(2f, 0f, 2f), modelskin.transform.rotation);
        if(DataManager.Instance.skinSelected == 3){
            arrowDown.transform.FindChild("RotationCenter").Rotate(0f, 0f, 180f);
        }else if(DataManager.Instance.skinSelected == 1){
            arrowDown.transform.Rotate(0f, 0f, 180f);
            arrowDown.transform.FindChild("ParticulePrec").Rotate(0f, 0f, -180f);
            arrowDown.transform.FindChild("ParticulePrec").localPosition = new Vector3(0f, 1f, 0f);
        }
        arrowDown.transform.parent = MainCamera.gameObject.transform;
        arrowUp = (GameObject) Instantiate(modelskin, new Vector3(4f, 0f, 2f), modelskin.transform.rotation);
        arrowUp.transform.parent = MainCamera.gameObject.transform;

        arrowTarget = new Transform[4];
        arrowTarget[0] = arrowLeft.transform;
        arrowTarget[1] = arrowDown.transform;
        arrowTarget[2] = arrowUp.transform;
        arrowTarget[3] = arrowRight.transform;
        scaleBase = arrowTarget[0].localScale.x;
        matArrowModel = matSkinModel[DataManager.Instance.skinSelected];

        RenderSettings.skybox = DataManager.Instance.skyboxList.ElementAt(rand);
        DataManager.Instance.skyboxIndexSelected = rand;
        displayValue = DataManager.Instance.displaySelected;

        firstArrow = -10f;
        lastArrow = -10f;
        thesong = DataManager.Instance.songSelected;
        songLoaded = thesong.GetAudioClip();
        audio.loop = false;
        createTheChart(thesong);
        Application.targetFrameRate = -1;
        QualitySettings.vSyncCount = 0;
        nextSwitchBPM = 1;
        nextSwitchStop = 0;
        actualBPM = thesong.bpms.First().Value;
        actualstop = (double)0;
        changeBPM = 0;

        _count = 0L;

        timebpm = (double)0;
        timechart = 0f;//-(float)thesong.offset;
        timetotalchart = (double)0;

        arrowFrozen = new Dictionary<Arrow, float>();

        precRight = new Dictionary<string, ParticleSystem>();
        precLeft = new Dictionary<string, ParticleSystem>();
        precUp = new Dictionary<string, ParticleSystem>();
        precDown = new Dictionary<string, ParticleSystem>();
        clearcombo = new Dictionary<string, ParticleSystem>();

        //Prepare the scene
        foreach(var el in Enum.GetValues(typeof(PrecParticle))){
            precLeft.Add( el.ToString(), (ParticleSystem) arrowLeft.transform.FindChild("ParticulePrec").gameObject.transform.FindChild(el.ToString()).particleSystem );
            precDown.Add( el.ToString(), (ParticleSystem) arrowDown.transform.FindChild("ParticulePrec").gameObject.transform.FindChild(el.ToString()).particleSystem );
            precRight.Add( el.ToString(), (ParticleSystem) arrowRight.transform.FindChild("ParticulePrec").gameObject.transform.FindChild(el.ToString()).particleSystem );
            precUp.Add( el.ToString(), (ParticleSystem) arrowUp.transform.FindChild("ParticulePrec").gameObject.transform.FindChild(el.ToString()).particleSystem );
        }
        for(int i=0; i< particleComboCam.transform.GetChildCount(); i++){
            clearcombo.Add(particleComboCam.transform.GetChild(i).name, particleComboCam.transform.GetChild(i).particleSystem);
        }

        precAverage = new List<double>();
        timeCombo = new Dictionary<double, int>();
        lifeGraph = new Dictionary<double, double>();

        TMainCamera = MainCamera.transform;
        MoveCameraBefore();

        //Textures
        TextureBase = new Dictionary<string, Texture2D>();
        TextureBase.Add("FANTASTIC", (Texture2D) Resources.Load("Fantastic"));
        TextureBase.Add("EXCELLENT", (Texture2D) Resources.Load("Excellent"));
        TextureBase.Add("GREAT", (Texture2D) Resources.Load("Great"));
        TextureBase.Add("DECENT", (Texture2D) Resources.Load("Decent"));
        TextureBase.Add("WAYOFF", (Texture2D) Resources.Load("Wayoff"));
        TextureBase.Add("MISS", (Texture2D) Resources.Load("Miss"));
        for(int i=0; i<10; i++){
            TextureBase.Add("S" + i, (Texture2D) Resources.Load("Numbers/S" + i));
            TextureBase.Add("C" + i, (Texture2D) Resources.Load("Numbers/C" + i));
        }

        TextureBase.Add("PERCENT", (Texture2D) Resources.Load("Numbers/Percent"));
        TextureBase.Add("DOT", (Texture2D) Resources.Load("Numbers/Dot"));
        TextureBase.Add("COMBODISPLAY", (Texture2D) Resources.Load("DisplayCombo"));
        TextureBase.Add("BLACK", (Texture2D) Resources.Load("black"));
        TextureBase.Add("FAIL", (Texture2D) Resources.Load("Fail"));
        TextureBase.Add("CLEAR", (Texture2D) Resources.Load("Clear"));
        TextureBase.Add("FC", (Texture2D) Resources.Load("FC"));
        TextureBase.Add("FEC", (Texture2D) Resources.Load("FEC"));
        TextureBase.Add("FFC", (Texture2D) Resources.Load("FFC"));
        TextureBase.Add("PERFECT", (Texture2D) Resources.Load("Perfect"));

        //stuff
        scoreToDisplay = Precision.NONE;
        timeDisplayScore = Mathf.Infinity;
        sensFantastic = true;
        alpha = 1f;
        scenechartfaded = false;

        //init score and lifebase
        scoreBase = new Dictionary<string, float>();
        scoreCount = new Dictionary<string, int>();
        lifeBase = new Dictionary<string, float>();
        fantasticValue = 100f/(thesong.numberOfStepsWithoutJumps + thesong.numberOfJumps + thesong.numberOfFreezes + thesong.numberOfRolls);
        foreach(Precision el in Enum.GetValues(typeof(Precision))){
            if(el != Precision.NONE){
                scoreBase.Add(el.ToString(), fantasticValue*DataManager.Instance.ScoreWeightValues[el.ToString()]);
                lifeBase.Add(el.ToString(), DataManager.Instance.LifeWeightValues[el.ToString()]);

            }
        }

        foreach(ScoreCount el2 in Enum.GetValues(typeof(ScoreCount))){
            if(el2 != ScoreCount.NONE){
                scoreCount.Add(el2.ToString(), 0);
            }
        }

        life = 50f;
        lifeGraph.Add(0, life);
        score = 0f;
        scoreInverse = 100f;
        firstEx = -1;
        firstGreat = -1;
        firstMisteak = -1;

        theLifeBar = lifeBar.GetComponent<LifeBar>();

        //var bps = thesong.getBPS(actualBPM);
        //changeBPM -= (float)(bps*thesong.offset)*speedmod;
        firstUpdate = true;
        oneSecond = 0f;
        startTheSong = (float)thesong.offset + DataManager.Instance.globalOffsetSeconds;

        //bump
        nextBump = 0;

        //combo
        ct = ComboType.FULLFANTASTIC;
        matProgressBar = progressBarEmpty.renderer.material;
        matProgressBarFull = progressBar.renderer.material;
        colorCombo = 1f;
        comboMisses = 0;
        alphaCombo = 0.5f;
        //GUI
        /*wd = posPercent.width*128;
        hg = posPercent.height*1024;
        hgt = posPercent.height*254;*/
        //ecart = 92f;

        displaying = scoreDecoupe();
        thetab = comboDecoupe();

        //Fail and clear
        fail = false;
        clear = false;
        fullCombo = false;
        fullExCombo = false;
        fullFantCombo = false;
        perfect = false;
        dead = false;
        zwip = 0;
        appearFailok = false;
        disappearFailok = false;
        zoomfail = 0f;
        failalpha = 0f;
        passalpha = 0f;
        cacheFailed = true;
        timeGiveUp = 0f;

        //Transformation display
        if(displayValue[4]){ //No judge
            limitDisplayScore = -1f;
        }

        if(displayValue[5]){ //No background
            RenderSettings.skybox = null;
            Background.GetComponent<MoveBackground>().enabled = false;
            Background.SetActiveRecursively(false);

        }

        if(displayValue[6]){ //No target
            arrowLeft.renderer.enabled = false;
            arrowDown.renderer.enabled = false;
            arrowUp.renderer.enabled = false;
            arrowRight.renderer.enabled = false;
        }

        //No score : inside the code

        //No UI
        if(displayValue[8]){
            for(int i=0;i<lifeBar.transform.childCount; i++){
                lifeBar.transform.GetChild(i).renderer.enabled = false;
            }
            progressBar.renderer.enabled = false;
            progressBarEmpty.renderer.enabled = false;
            slow.renderer.enabled = false;
            fast.renderer.enabled = false;
        }
    }