Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.LoadLevel("Main menu");
            if (PlayerPrefs.GetString("MusicBackground") != "no")
            {
                GameObject.Find("BackgroundMusic").GetComponent <AudioSource>().Play();
            }
            else
            {
                GameObject.Find("BackgroundMusic").GetComponent <AudioSource>().Stop();
            }
        }
        RandomSpawn    randomSpawn    = RandomSpawnScript.GetComponent <RandomSpawn>();
        MainScriptBall mainScriptBall = MainBall.GetComponent <MainScriptBall>();

        if (mainScriptBall.GameOver)
        {
            clicktostartgame.text = "Click anywhere to restart game";
            clicktostartgame.transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y - 7, 1);
            Startgame = false;
            mainScriptBall.GameOver = false;
            PlayAudio(deadClip);
        }

        if (Input.GetKeyUp(KeyCode.Mouse0) && !Startgame)
        {
            Camera.main.orthographicSize      = 6f;
            Camera.main.transform.position    = new Vector3(0, 0, -10);
            HealtsObject.transform.position   = new Vector3(0, 5, 0);
            HealtsObject.transform.localScale = new Vector2(0.14f, 0.12f);
            MainBall.transform.position       = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, 0);
            MainBall.SetActive(true);
            mainScriptBall.Healts = 100f;
            mainScriptBall.Score  = 0;
            mainScriptBall.hightScoreText.text = "";
            mainScriptBall.SpawnParticalEffect(mainScriptBall.destroyEffectBlue);
            mainScriptBall.rg.velocity = new Vector2(0, 0);
            clicktostartgame.text      = "";
            Startgame                      = true;
            mainScriptBall.Click           = false;
            mainScriptBall.rg.gravityScale = 1.3f;
            PlayAudio(startClip);
            randomSpawn.RandomSpawnObject();
        }
        if (startgame)
        {
            if (Camera.main.orthographicSize < 8f)
            {
                Camera.main.orthographicSize += 0.1f;
                if (Camera.main.orthographicSize >= 8f)
                {
                    Camera.main.orthographicSize = 8f;
                }
            }
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        MainScriptBall mainScriptBall = MainBall.GetComponent <MainScriptBall>();

        StartGame startGame = StartGameManeger.GetComponent <StartGame>();

        if (mainScriptBall.Click && startGame.Startgame)
        {
            if (Input.GetKey(KeyCode.Mouse0))
            {
                lr.enabled = true;
                StartPos   = MainBall.transform.position;
                lr.SetPosition(0, StartPos);
                lr.useWorldSpace  = true;
                lr.numCapVertices = 10;
                EndPos            = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                lr.SetPosition(1, EndPos);
            }
            if (Input.GetKeyUp(KeyCode.Mouse0))
            {
                lr.enabled = false;
            }
        }
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        Camera.main.transform.position = new Vector3(player.transform.position.x, player.transform.position.y, -10);

        StartGame      startGame      = StartGameManeger.GetComponent <StartGame>();
        MainScriptBall mainScriptBall = player.GetComponent <MainScriptBall>();

        if (Input.GetKey(KeyCode.Mouse0))
        {
            Camera.main.GetComponent <AudioSource>().volume = 0.7f;
        }
        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            Camera.main.GetComponent <AudioSource>().volume = 1f;
        }
        if (mainScriptBall.Healts <= 0)
        {
            mainScriptBall.HightScoreShake();
        }
        if (startGame.Startgame)
        {
            {
                Camera.main.orthographicSize += 0.01f;
            }
            if (Camera.main.transform.position.y > 10f && !Input.GetKey(KeyCode.Mouse0) && Camera.main.orthographicSize < 13f)
            {
                Camera.main.orthographicSize   += 0.04f;
                HealtsObj.transform.localScale += new Vector3(0.0006f, 0.0006f);
                HealtsObj.transform.position    = new Vector3(HealtsObj.transform.position.x, HealtsObj.transform.position.y + 0.025f);
                if (Camera.main.orthographicSize >= 13f)
                {
                    Camera.main.orthographicSize = 13f;
                }
                if (HealtsObj.transform.position.y > Camera.main.transform.position.y + 8.5f)
                {
                    HealtsObj.transform.position = new Vector3(HealtsObj.transform.position.x, Camera.main.transform.position.y + 8.5f);
                }
                if (HealtsObj.transform.localScale.x >= 0.275f && HealtsObj.transform.localScale.y >= 0.235f)
                {
                    HealtsObj.transform.localScale = new Vector3(0.28f, 0.24f);
                }
            }


            if (Camera.main.transform.position.y < 10f && Camera.main.orthographicSize >= 8.4f && !Input.GetKey(KeyCode.Mouse0))
            {
                Camera.main.orthographicSize   -= 0.05f;
                HealtsObj.transform.localScale -= new Vector3(0.0013f, 0.0013f);
                HealtsObj.transform.position    = new Vector3(HealtsObj.transform.position.x, HealtsObj.transform.position.y - 0.04f);
                if (Camera.main.orthographicSize <= 8.4f)
                {
                    Camera.main.orthographicSize = 8.4f;
                }
                if (HealtsObj.transform.position.y < Camera.main.transform.position.y + 5.5f)
                {
                    HealtsObj.transform.position = new Vector3(HealtsObj.transform.position.x, Camera.main.transform.position.y + 5.5f);
                }
                if (HealtsObj.transform.localScale.x <= 0.17f && HealtsObj.transform.localScale.y <= 0.15f)
                {
                    HealtsObj.transform.localScale = new Vector3(0.17f, 0.15f);
                }
            }
        }
    }