Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
        }

        MouseMove();

        if (gameObject.layer == 13)
        {
            Body.isKinematic = true;


            CheckIntercalbe();
            if (isInterecable)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    Click_1 = true;
                }
            }



            if (Click_1)
            {
                Direct(DirectRotation());
                Board.Direct();
                Board_1.Direct();
                rotate.Direct();
                Vector2 new_pos   = PosMousePosition;
                Vector2 new_pos_1 = PosMousePosition;


                if (Vector2.Distance(new_pos, pos) < max && Vector2.Distance(new_pos, pos) > 0)
                {
                    float dis = Vector2.Distance(new_pos, pos);

                    Vector2 scale1 = new Vector2(Scale.x, (Scale.y + dis) * 0.5f);
                    Vector2 scale2 = new Vector2(Scale_1.x, (Scale_1.y + dis) * 0.5f);
                    Board.SetScale(scale1);
                    Board_1.SetScale(scale2);
                    transform.position = new_pos;
                }

                else
                {
                    new_pos_1 = pos - (2 * DirectRotation_1().normalized *max * 0.5f);

                    transform.position = new_pos_1;
                    float   dis    = Vector2.Distance(new_pos_1, pos);
                    Vector2 scale1 = new Vector2(Scale.x, (Scale.y + dis) * 0.5f);
                    Vector2 scale2 = new Vector2(Scale_1.x, (Scale_1.y + dis) * 0.5f);
                    Board.SetScale(scale1);
                    Board_1.SetScale(scale2);
                }
            }
            if (Input.GetMouseButtonUp(0) && Click_1)
            {
                //   Debug.Log("Mosue_Up");
                Click_2 = true;
                Click_1 = false;
            }
            if (Click_2 && !Click_1)
            {
                Board.ResetScale();
                Board_1.ResetScale();
                Shoot(DirectAndForce());
                transform.position = pos;
                //   gameObject.layer = 14;
                StartCoroutine(RestTrigger());

                Click_2 = false;
            }
        }
        else
        {
            //  MoveFollowPlayer.instance.moveCamera = true;

            time += 10;

            //    transform.rotation = Quaternion.AngleAxis(time, Vector3.forward);
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        transform.GetComponent <SpriteRenderer>().sprite = GameController.instance.SpriteBall();
        // Time.timeScale = 1.4f;
        if (!GameController.instance.GameOver || !GameController.instance.GamePause)
        {
            DirectRotation();
            SpawnPractice();


            if (GameController.instance.leftBottomReal.y <= transform.position.y)
            {
                if (gameObject.layer == 13)
                {
                    Body.isKinematic = true;
                    MoveFollowPlayer.instance.moveCamera = false;
                    MouseMove();
                    CheckIntercalbe();
                    //   if (isInterecable)
                    //    {
                    if (Input.GetMouseButtonDown(0))
                    {
                        Click_1 = true;
                    }

                    //     }



                    if (Click_1)
                    {
                        if (done)
                        {
                            transform.localPosition = Vector3.zero;
                            done = false;
                        }

                        Direct(DirectRotation());
                        Board.Direct();
                        rotate.Direct();
                        Board_1.Direct();
                        Vector2 new_pos   = PosMousePosition;
                        Vector2 new_pos_1 = PosMousePosition;

                        /*
                         * if (Vector2.Distance(new_pos, pos) < max && Vector2.Distance(new_pos, pos) > 0)
                         * {
                         *     float dis = Vector2.Distance(new_pos, pos);
                         *
                         *     Vector2 scale1 = new Vector2(Scale.x, (Scale.y + dis) * 0.5f);
                         *     Board.SetScale(scale1);
                         *     Board_1.SetScale(scale1);
                         *     transform.position = new_pos;
                         * }
                         * else if (Vector2.Distance(new_pos, pos) > max)
                         * {
                         *     new_pos_1 = pos - (2 * DirectRotation_1().normalized * max * 0.5f);
                         *
                         *     transform.position = new_pos_1;
                         *     float dis = Vector2.Distance(new_pos_1, pos);
                         *     Vector2 scale1 = new Vector2(Scale.x, (Scale.y + dis) * 0.5f);
                         *     Board.SetScale(scale1);
                         *     Board_1.SetScale(scale1);
                         *
                         * }
                         */
                        if (Vector2.Distance(new_pos, pos) < max)
                        {
                            float dis = Vector2.Distance(new_pos, pos);

                            Vector2 scale1 = new Vector2(Scale.x, (Scale.y + dis * 0.8f));
                            //    Vector2 scale2 = new Vector2(Scale_1.x, (Scale_1.y +dis));
                            Board.SetScale(scale1);
                            //     Board_1.SetScale(scale2);
                            transform.position = new_pos;
                            FullForce          = false;
                        }
                        else
                        {
                            FullForce = true;
                            new_pos_1 = pos - (DirectRotation_1().normalized *max);

                            transform.position = new_pos_1;
                            float   dis    = Vector2.Distance(new_pos_1, pos);
                            Vector2 scale1 = new Vector2(Scale.x, (Scale.y + dis * 0.8f));
                            //      Vector2 scale2 = new Vector2(Scale_1.x, (Scale_1.y +dis));
                            Board.SetScale(scale1);
                            //      Board_1.SetScale(scale2);
                            //      Debug.Log(scale1 + " " + scale2);
//
                        }

                        SimulateTrajectory(transform.position, DirectAndForce());
                    }
                    else
                    {
                        enableTrajectory(false);
                    }
                    if (Input.GetMouseButtonUp(0) && Click_1)
                    {
                        //   Debug.Log("Mosue_Up");
                        Click_2 = true;
                        Click_1 = false;
                        enableTrajectory(false);
                    }
                    if (Click_2 && !Click_1)
                    {
                        Board.ResetScale();
                        Board_1.ResetScale();

                        Shoot(DirectAndForce());
                        transform.position = pos;



                        Click_2       = false;
                        VectorReflect = DirectAndForce();
                    }
                }
                else
                {
                    MoveFollowPlayer.instance.moveCamera = true;

                    time += 10;

                    // transform.rotation = Quaternion.AngleAxis(time, Vector3.forward);
                }
                // Debug.Log(Body.velocity);
            }
        }
        else
        {
            GameObject.Find("ScreenGameplay").GetComponent <ScreenGamePlay>().GameOverWindow();
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        //Time.timeScale = 1.4f;
        if (!GameController.instance.GameOver || !GameController.instance.GamePause)
        {
            DirectRotation();
            width  = GetComponent <SpriteRenderer>().size.x;
            height = GetComponent <SpriteRenderer>().size.y;
            max    = width;
            SpawnPractice();


            if (GameController.instance.leftBottomReal.y <= transform.position.y)
            {
                if (gameObject.layer == 13)
                {
                    Body.isKinematic = true;
                    MoveFollowPlayer.instance.moveCamera = false;
                    MouseMove();
                    CheckIntercalbe();
                    if (isInterecable)
                    {
                        if (Input.GetMouseButtonDown(0))
                        {
                            Click_1 = true;
                        }
                    }



                    if (Click_1)
                    {
                        Direct(DirectRotation());
                        Board.Direct();
                        rotate.Direct();
                        Board_1.Direct();
                        Vector2 new_pos   = PosMousePosition;
                        Vector2 new_pos_1 = PosMousePosition;

                        /*
                         *              if (Vector2.Distance(new_pos, pos) < max && Vector2.Distance(new_pos, pos) > 0)
                         *              {
                         *                  float dis = Vector2.Distance(new_pos, pos);
                         *
                         *                  Vector2 scale1 = new Vector2(Scale.x, (Scale.y + dis) * 0.5f);
                         *                  Board.SetScale(scale1);
                         *                  Board_1.SetScale(scale1);
                         *                  transform.position = new_pos;
                         *              }
                         *              else if (Vector2.Distance(new_pos, pos) > max)
                         *              {
                         *                  new_pos_1 = pos - (2 * DirectRotation_1().normalized * max * 0.5f);
                         *
                         *                  transform.position = new_pos_1;
                         *                  float dis = Vector2.Distance(new_pos_1, pos);
                         *                  Vector2 scale1 = new Vector2(Scale.x, (Scale.y + dis) * 0.5f);
                         *                  Board.SetScale(scale1);
                         *                  Board_1.SetScale(scale1);
                         *
                         *              }
                         */
                        if (Vector2.Distance(new_pos, pos) < max)
                        {
                            float dis = Vector2.Distance(pos, new_pos);

                            Vector2 scale1 = new Vector2(Scale.x, (Scale.y + dis) * 0.5f);
                            Vector2 scale2 = new Vector2(Scale_1.x, (Scale_1.y + dis) * 0.5f);
                            Board.SetScale(scale1);
                            Board_1.SetScale(scale2);
                            transform.position = new_pos;
                        }
                        else
                        {
                            new_pos_1 = pos - (DirectRotation_1().normalized *(max));

                            transform.position = new_pos_1;
                            float   dis    = Vector2.Distance(pos, new_pos_1);
                            Vector2 scale1 = new Vector2(Scale.x, (Scale.y + dis) * 0.5f);
                            Vector2 scale2 = new Vector2(Scale_1.x, (Scale_1.y + dis) * 0.5f);
                            Board.SetScale(scale1);
                            Board_1.SetScale(scale2);
                            //   Debug.Log(scale1 + " " + scale2);
                        }
                    }
                    else
                    {
                    }
                    if (Input.GetMouseButtonUp(0) && Click_1)
                    {
                        //   Debug.Log("Mosue_Up");
                        Click_2 = true;
                        Click_1 = false;
                    }
                    if (Click_2 && !Click_1)
                    {
                        Board.ResetScale();
                        Board_1.ResetScale();

                        Shoot(DirectAndForce());
                        transform.position = pos;


                        StartCoroutine(RestTrigger());

                        Click_2       = false;
                        VectorReflect = DirectAndForce();
                    }
                }
                else
                {
                    MoveFollowPlayer.instance.moveCamera = true;

                    time += 10;

                    // transform.rotation = Quaternion.AngleAxis(time, Vector3.forward);
                }
                // Debug.Log(Body.velocity);
            }
        }
        if (gameObject.layer == 16)
        {
            RaycastHit2D ray;
            ray = Physics2D.CircleCast(transform.position, 1, new Vector2(1, 1));


            if (ray.collider != null)
            {
                if (ray.collider.gameObject.layer == 17)
                {
                    SpawnEffect.instance.Set_System(Paractice_Type.PUM, ray.point, "", null);
                }
            }
        }
    }