Example #1
0
    private void sendData()
    {
        AndroidJavaClass  unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject activity    = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");

        activity.Call("setHighScore", ScrollingScript.getHeight(), PlayerCollisionScript.getKills());
        activity.Call("setPowerups", convertPowerups());
        activity.Call("addCoins", (PlayerCollisionScript.getKills() * 10) + ScrollingScript.getHeight());

        ParseObject scoreObject = new ParseObject("Highscore");

        scoreObject["UserName"]  = name;
        scoreObject["UserScore"] = ScrollingScript.getHeight();
        scoreObject.SaveAsync();
    }
Example #2
0
    void OnGUI()
    {
        GUIStyle textStyle = new GUIStyle("label");

        textStyle.alignment = TextAnchor.MiddleCenter;
        textStyle.fontSize  = 80;
        textStyle.fontStyle = FontStyle.Bold;
        // Make a background box

        GUIStyle buttonStyle = new GUIStyle("button");

        buttonStyle.fontSize = 50;

        GUI.Box(new Rect(10, 10, Screen.width - 20, Screen.height - 20), "");

        GUI.Label(new Rect(Screen.width / 2 - 400, 50, 800, 150), "Summary", textStyle);

        GUIStyle centeredTextStyle = new GUIStyle("label");

        centeredTextStyle.alignment = TextAnchor.MiddleCenter;
        centeredTextStyle.fontSize  = 50;
        centeredTextStyle.fontStyle = FontStyle.Bold;

        GUI.Label(new Rect(Screen.width / 2 - 400, 150, 800, 150), "Height: " + ScrollingScript.getHeight(), centeredTextStyle);
        GUI.Label(new Rect(Screen.width / 2 - 400, 250, 800, 150), "Kills: " + PlayerCollisionScript.getKills(), centeredTextStyle);


        if (!FB.IsLoggedIn)
        {
            //GUI.Label((new Rect(179 , 11, 287, 160)), "Login to Facebook");
            if (GUI.Button(new Rect(Screen.width / 2 - 300, 400, 600, 130), "Login to Facebook", buttonStyle))
            {
                //FB.Login("email,publish_actions", LoginCallback);
            }
        }

        // Make the second button.
        else if (GUI.Button(new Rect(Screen.width / 2 - 200, 400, 400, 130), "Share", buttonStyle))
        {
            if (FB.IsLoggedIn)
            {
                /*FB.Feed(
                 *      linkCaption: "I just reached " + PlayerScript.distance + "! Can you beat it?",
                 *      picture: "http://www.friendsmash.com/images/logo_large.jpg",
                 *      linkName: "Checkout my Jumpy greatness!",
                 *      link: "http://apps.facebook.com/" + FB.AppId + "/?challenge_brag=" + (FB.IsLoggedIn ? FB.UserId : "guest")
                 *      );*/
            }
        }

        // Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
        if (GUI.Button(new Rect(Screen.width / 2 - 200, 550, 400, 130), "Restart", buttonStyle))
        {
            PlayerScript.distance = 0;
            Time.timeScale        = 1;

            Application.LoadLevel(0);
        }



        if (GUI.Button(new Rect(Screen.width / 2 - 200, 700, 400, 130), "Main Menu", buttonStyle))
        {
            Application.Quit();
        }
    }
Example #3
0
    void OnGUI()
    {
        if (hide)
        {
            Color c = TopFrame.renderer.material.color;
            c.a = 0;

            TopFrame.renderer.material.color = c;
        }
        else
        {
            Color c = TopFrame.renderer.material.color;
            c.a = 0.58f;

            TopFrame.renderer.material.color = c;
            GUI.contentColor = Color.white;
            GUIStyle style = new GUIStyle();
            style.fontSize         = 75;
            style.fontStyle        = FontStyle.Bold;
            style.normal.textColor = Color.white;
            GUI.Label(new Rect(39, 20, 300, 280), "Height: " + ScrollingScript.getHeight(), style);

            GUIStyle newStyle = new GUIStyle();
            newStyle.fontSize         = 30;
            newStyle.fontStyle        = FontStyle.Bold;
            newStyle.normal.textColor = Color.white;

            // Make a background box
            //GUI.Box(new Rect(10,10,100,90), "Loader Menu");

            // Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
            if (GUI.Button(new Rect(Screen.width - 110, 10, 100, 100), texture))
            {
                if (play)
                {
                    timeScale      = Time.timeScale;
                    Time.timeScale = 0;
                    play           = false;
                    texture        = playTexture;
                }
                else
                {
                    Time.timeScale = timeScale;
                    play           = true;
                    texture        = pauseTexture;
                }
            }

            List <Powerup> powerups = player.GetComponent <PlayerScript>().getPowerups();

            if (powerups[1].getQuantity() == 0)
            {
                GUI.color = Color.grey;
            }
            else
            {
                GUI.color = Color.white;
            }

            if (!btnTexture && showGUI)
            {
                if (GUI.Button(new Rect(Screen.width / 2 - 300, Screen.height - 150, 150, 150), "Click") && powerups[1].getQuantity() > 0)
                {
                    timeLeft = 10.0f;
                    showGUI  = false;
                    player.GetComponent <PlayerScript>().Supershooter();
                    powerups[1].use();
                }
            }
            else if (showGUI)
            {
                if (GUI.Button(new Rect(Screen.width / 2 - 300, Screen.height - 150, 150, 150), btnTexture) && powerups[1].getQuantity() > 0)
                {
                    timeLeft = 10.0f;
                    showGUI  = false;
                    player.GetComponent <PlayerScript>().Supershooter();
                    GameObject  shootSound = GameObject.Find("Sounds").transform.Find("Pow1").gameObject;
                    AudioSource ac         = shootSound.GetComponent <AudioSource>();
                    ac.audio.Play();
                    powerups[1].use();
                }
            }

            if (powerups[0].getQuantity() == 0)
            {
                GUI.color = Color.grey;
            }
            else
            {
                GUI.color = Color.white;
            }

            if (!btnTexture2 && showGUI)
            {
                if (GUI.Button(new Rect(Screen.width / 2 - 150, Screen.height - 150, 150, 150), "Click") && powerups[0].getQuantity() > 0)
                {
                    timeLeft = 10.0f;
                    showGUI  = false;
                    player.GetComponent <PlayerScript>().Slowdown(0.6f);
                    powerups[0].use();
                }
            }
            else if (showGUI)
            {
                if (GUI.Button(new Rect(Screen.width / 2 - 150, Screen.height - 150, 150, 150), btnTexture2) && powerups[0].getQuantity() > 0)
                {
                    timeLeft = 10.0f;
                    showGUI  = false;
                    player.GetComponent <PlayerScript>().Slowdown(0.6f);
                    GameObject  shootSound = GameObject.Find("Sounds").transform.Find("Pow2").gameObject;
                    AudioSource ac         = shootSound.GetComponent <AudioSource>();
                    ac.audio.Play();
                    powerups[0].use();
                }
            }

            if (powerups[2].getQuantity() == 0)
            {
                GUI.color = Color.grey;
            }
            else
            {
                GUI.color = Color.white;
            }

            if (!btnTexture3 && showGUI)
            {
                if (GUI.Button(new Rect(Screen.width / 2, Screen.height - 150, 150, 150), "Click") && powerups[2].getQuantity() > 0)
                {
                    timeLeft = 30.0f;
                    showGUI  = false;
                    gameGenerator.noenemies();
                    powerups[2].use();
                }
            }
            else if (showGUI)
            {
                if (GUI.Button(new Rect(Screen.width / 2, Screen.height - 150, 150, 150), btnTexture3) && powerups[2].getQuantity() > 0)
                {
                    timeLeft = 30.0f;
                    showGUI  = false;
                    gameGenerator.noenemies();
                    GameObject  shootSound = GameObject.Find("Sounds").transform.Find("Pow3").gameObject;
                    AudioSource ac         = shootSound.GetComponent <AudioSource>();
                    ac.audio.Play();
                    powerups[2].use();
                }
            }

            if (powerups[3].getQuantity() == 0)
            {
                GUI.color = Color.grey;
            }
            else
            {
                GUI.color = Color.white;
            }

            if (!btnTexture4 && showGUI)
            {
                if (GUI.Button(new Rect(Screen.width / 2 + 150, Screen.height - 150, 150, 150), "Click") && powerups[3].getQuantity() > 0)
                {
                    timeLeft = 15.0f;
                    showGUI  = false;
                    player.GetComponent <PlayerScript>().Indestructible();
                    powerups[3].use();
                }
            }
            else if (showGUI)
            {
                if (GUI.Button(new Rect(Screen.width / 2 + 150, Screen.height - 150, 150, 150), btnTexture4) && powerups[3].getQuantity() > 0)
                {
                    timeLeft = 15.0f;
                    showGUI  = false;
                    player.GetComponent <PlayerScript>().Indestructible();
                    GameObject  shootSound = GameObject.Find("Sounds").transform.Find("Pow1").gameObject;
                    AudioSource ac         = shootSound.GetComponent <AudioSource>();
                    ac.audio.Play();
                    powerups[3].use();
                }
            }
        }
    }
Example #4
0
    public void spawnObjects()
    {
        float curPoint = size.y;

        if (ScrollingScript.getHeight() >= newHeight)
        {
            if (inbetween && !ScrollingScript.isTransition)
            {
                nextPlatform = null;

                while (nextPlatform == null)
                {
                    if (cur == platforms.Capacity * 2)
                    {
                        cur = 0;
                    }

                    nextPlatform = platforms[(cur + 1) / 2];
                }

                if (started)
                {
                    background.GetComponent <ScrollingScript>().Transition((GameObject)Instantiate(backgrounds[cur]), (GameObject)Instantiate(backgrounds[cur + 1]));
                    lBackground.GetComponent <ScrollingScript>().Transition((GameObject)Instantiate(leftBackgrounds[cur]), (GameObject)Instantiate(leftBackgrounds[cur + 1]));
                    rBackground.GetComponent <ScrollingScript>().Transition((GameObject)Instantiate(rightBackgrounds[cur]), (GameObject)Instantiate(rightBackgrounds[cur + 1]));

                    cur++;
                    cur++;
                }

                combine = true;

                inbetween = !inbetween;
            }
            else if (!inbetween && !ScrollingScript.isTransition)
            {
                combine   = false;
                newHeight = ScrollingScript.getHeight() + 100;

                curPlatform = nextPlatform;
                enemyProb  *= 1.3f;

                PlayerScript.speed *= 1.1f;
                if (area < 8 && increase)
                {
                    area *= 1.2f;

                    if (area > 8)
                    {
                        area    /= 1.2f;
                        increase = false;
                    }
                    lowerArea += 0.1f;
                }

                inbetween = !inbetween;

                if (!increase)
                {
                    enemyProb *= 1.3f;
                }
            }
        }

        GameObject platform = curPlatform;

        while (true)
        {
            curPoint += Random.Range(lowerArea, area) + platform.renderer.bounds.size.y;

            if (curPoint > size.y * 2)
            {
                break;
            }

            if (combine)
            {
                int n = Random.Range(0, 2);

                if (n == 0)
                {
                    platform = curPlatform;
                }
                else
                {
                    platform = nextPlatform;
                }
            }

            maxObj = (GameObject)Instantiate(platform, new Vector3(Random.Range(-size.x + platform.renderer.bounds.size.x / 2, size.x - platform.renderer.bounds.size.x / 2), curPoint), Quaternion.identity);

            if (Random.Range(0f, 1f) < enemyProb && hasEnemies)
            {
                GameObject enemy      = enemies[Random.Range(0, enemies.Count)];
                Transform  enemyChild = enemy.transform.GetChild(0);
                GameObject e          = (GameObject)Instantiate(enemy, new Vector3(maxObj.transform.position.x, maxObj.transform.position.y + enemyChild.renderer.bounds.size.y / 2, enemy.transform.position.z), Quaternion.identity);
                e.transform.parent = enemyHolder.transform;
            }
        }
    }