Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        Application.targetFrameRate = 60;
        loaded = false;
        offBeatObjects = new GameObject[2];
        offBeatObjects[0] = Instantiate(offbeat);
        offBeatObjects[1] = Instantiate(offbeat);
        offBeatObjects[0].SetActive(false);
        offBeatObjects[1].SetActive(false);

        offBeatCounter = 0;

        nextPermittedBeat = 0;
        GlobalData.GOButtonsReady = false;

        touches = new Vector3[2];
        screenHeight = Camera.main.orthographicSize * 2.0f;
        screenWidth = Camera.main.aspect * screenHeight;

        effect = Camera.main.GetComponent<effects>();
        cameraMiss = Camera.main.GetComponent<MissFrame>();
        cameraShake = Camera.main.GetComponent<Shake>();

        latestTouch = 0;
        lastTouchPosition = new Vector2(100, 100);
        fxParticles = new GameObject[2];
        fxParticles[0] = Instantiate(FXParticles);
        fxParticles[1] = Instantiate(FXParticles);
        fxParticlesControl = new CustomParticles[2];
        fxParticlesControl[0] = fxParticles[0].GetComponent<CustomParticles>();
        fxParticlesControl[1] = fxParticles[1].GetComponent<CustomParticles>();

        UpdateColors();

        fxPointer = 0;
        wrongClicks = 0;
        beat = GlobalData.beat;

        wiggleSpace = GlobalData.wiggleSpace;

        time = 0;
        god = GameObject.Find("God").GetComponent<GodDeath>();
        /* PAUSE READY
        pause = GameObject.Find("Pause").GetComponent<Pause>();
        */
        bool missed = false;
        uint oneInXMissing = 3;
        float distanceCoef = (700.0f / 500.0f);
        float expectedBunnyLifetime = GetJumpTimeFromLinearTime((350.0f / (250.0f)) * distanceCoef, beat) / (0.48f / beat);

        realDuration = 0;
        if (audio.clip)
            realDuration = audio.clip.length;
        if (percentage)
        {
            percentageS = percentage.GetComponent<Percentage>();
            percentageS.realDuration = Mathf.Floor((realDuration - expectedBunnyLifetime) / beat) * beat + expectedBunnyLifetime;
        }

        if (GOPercentage)
        {
            GOPercentageS = GOPercentage.GetComponent<Percentage>();
            GOPercentageS.realDuration = Mathf.Floor((realDuration - expectedBunnyLifetime) / beat) * beat + expectedBunnyLifetime;
        }

        float[] angles = new float[5] { Mathf.PI / 2.0f, 4.6f, 2.65f, 5.6f, 1.4f };
        if (beat == 0.375f)
        {
            oneInXMissing = 5;
        }
        effectObject = GameObject.Find("Offbeat");

        GameObject bunnObject = GameObject.Find("Bunnies");
        if (bunnObject)
        {
            bunz = bunnObject.GetComponent<Bunnies>();
        }
        GameObject screen = GameObject.Find("Screen");
        int latestColor = 0;
        Color[] colorsRhino = new Color[3]{
            new Color(0,1.0f,91.0f / 255.0f),
            new Color(0,1.0f,187.0f / 255.0f),
            new Color(144.0f / 255.0f,0,1),
        };

        Color[] colorsBear = new Color[3]{
            new Color(1,0,0),
            new Color(1,212.0f / 255.0f,0),
            new Color(1,0,110.0f / 255.0f),
        };

        Color[] colorsBull = new Color[3]{
            new Color(1.0f,0,238 / 255.0f),
            new Color(0,206 / 255.0f,229 / 255.0f),
            new Color(144 / 255.0f,0,1),
        };

        Color[] colors = null;
        switch (GlobalData.selectedGod)
        {
            case GlobalData.Gods.RHINO:
                colors = colorsRhino;
                break;
            case GlobalData.Gods.BEAR:
                colors = colorsBear;
                break;
            case GlobalData.Gods.BULL:
                colors = colorsBull;
                break;
        }

        for (int i = 0; i < maxCount; i++)
        {
            float endTime = 0;
            if (missing && (Random.Range(0, oneInXMissing)) == 0 && !missed && i > 2 && endTime < 50.0f)
            {
                missed = true;
            } else if (missed)
            {
                missed = false;
            }
            if (!missed)
            {
                GameObject bunny = null;
                if (bunz)
                {
                    bunny = bunz.bunnies[i];
                    bunny.SetActive(true);
                }
                else
                {
                    bunny = Instantiate(bunnyPrefab);
                    bunny.GetComponent<BunnyJump>().Startingu();
                    bunny.SetActive(true);
                }
                bunny.transform.parent = null;
                BunnyJump bunnyJumpS = bunny.GetComponent<BunnyJump>();
                bunnyJumpS.parentTransform = screen.transform;
                bunnyJumpS.startTime = i * beat;
                endTime = i * beat + expectedBunnyLifetime;
                bunnyJumpS.expectedBunnyLifetime = expectedBunnyLifetime;
                bunnyJumpS.beat = beat;
                bunnyJumpS.god = god;
                int randomColor = Random.Range(0, 3);
                while (randomColor == latestColor)
                {
                    randomColor = Random.Range(0, 3);
                }
                latestColor = randomColor;
                bunnyJumpS.color = colors[randomColor];
                bunnyJumpS.wiggleSpace = wiggleSpace;
                if (!randomSpawn)
                {
                    bunnyJumpS.angle = angles[i];
                }
                float scale = Random.Range(0.8f, 1.4f);
                bunny.GetComponent<Transform>().localScale = new Vector3(scale, scale, 1);
                bunnyJumpS.Init();
                bunnyCount++;
                bunnies.Add(bunnyJumpS);
            }
            if (endTime + beat > realDuration)
            {
                break;
            }
        }

        freq = 1.0f / audio.clip.frequency;

        startTime = AudioSettings.dspTime;

        minOffset = 0.0f;
        maxOffset = 0.0f;
    }
    // Use this for initialization
    void Start()
    {
        effectObject = GameObject.Find("Offbeat");

        fxParticles = new GameObject[2];
        fxParticles[0] = Instantiate(FXParticles);
        fxParticles[1] = Instantiate(FXParticles);
        fxParticlesControl = new CustomParticles[2];
        fxParticlesControl[0] = fxParticles[0].GetComponent<CustomParticles>();
        fxParticlesControl[1] = fxParticles[1].GetComponent<CustomParticles>();

        touches = new Vector3[2];
        deadBunnies =0;
        fxPointer = 0;
        latestTouch = 0;
        time = 0;
        god = GameObject.Find("God").GetComponent<GodDeath>();
        pause = GameObject.Find("Pause").GetComponent<Pause>();
        uint bunnyCount = 0;
        float distanceCoef = (700.0f / 500.0f);
        beat = 0.66666f;
        float expectedBunnyLifetime = GetJumpTimeFromLinearTime((350.0f / (250.0f)) * distanceCoef, beat);

        int latestColor = 0;
        Color []colors = new Color[3]{
            new Color(0,1.0f,59 / 255.0f),
            new Color(0,255 / 255.0f,187 / 255.0f),
            new Color(97 / 255.0f,0,255 / 255.0f),
        };

        float realDuration = 0;
        float []angles = new float[5]{Mathf.PI / 2.0f, 4.6f, 2.65f, 5.6f, 1.4f};
        for (int i = 0; i < 5; i++)
        {
            float endTime = i * beat + expectedBunnyLifetime;
            GameObject bunny = (GameObject) Instantiate(bunnyPrefab);
            BunnyJump bunnyJumpS = bunny.GetComponent<BunnyJump>();
            bunnyJumpS.startTime = 2 * i * 0.66666f + 1.0f * 0.666666f + (i == 0 ? 0 : 2.0f * 0.66666f);;
            bunnyJumpS.expectedBunnyLifetime = expectedBunnyLifetime;
            bunnyJumpS.beat = beat;
            bunnyJumpS.god = god;
            bunnyJumpS.angle = angles[i];
            bunnyJumpS.wiggleSpace = 0.1f;
            bunnyJumpS.velocityMod = false;
            int randomColor = Random.Range(0,3);
            while(randomColor == latestColor || randomColor == GlobalData.godIndex)
            {
                randomColor = Random.Range(0,3);
            }
            latestColor = randomColor;
            bunnyJumpS.color = colors[randomColor];
            bunnyJumpS.Startingu();
            bunnyJumpS.Init();

            bunnyCount++;
            bunnies.Add(bunnyJumpS);
        }

        cameraMiss = Camera.main.GetComponent<MissFrame>();
        cameraShake = Camera.main.GetComponent<Shake>();
    }