Example #1
0
 void Update()
 {
     if (tracking && !GameManager.GetPaused() && StartZoom.GetBegin())
     {
         Vector3 currentDirection = Direction().normalized;
         Orientation.Move(gameObject, direction * GameObject.FindWithTag("Player").GetComponent <PadMove>().speed *v *Time.deltaTime);
         direction = (1 - s) * direction + s * currentDirection;
     }
 }
Example #2
0
 void FixedUpdate()
 {
     // pas faire bouger avant le début
     if (StartZoom.GetBegin())
     {
         player.GetComponent <Rigidbody2D>().AddForce(-formerForce);  // on enlève la force d'avant pour l'actualiser :
         OM3         = player.GetComponent <Transform>().position - gameObject.GetComponent <Transform>().position;
         OM          = new Vector2(OM3.x, OM3.y);
         norme       = Mathf.Sqrt(Mathf.Pow(OM.x, 2) + Mathf.Pow(OM.y, 2));
         formerForce = -player.GetComponent <Rigidbody2D>().mass *m *OM / Mathf.Pow(norme, 3);
         player.GetComponent <Rigidbody2D>().AddForce(formerForce);
     }
 }
Example #3
0
 void Update()
 {
     if (Time.time - StartZoom.Gett0() > m * Dt && !GameManager.GetPaused() && StartZoom.GetBegin())
     {
         Destroy(Clouds[m % n]);
         Clouds[m % n] = CreateCloud(GameObject.FindWithTag("Player").GetComponent <Transform>().position, 1, 1);
         Clouds[m % n].GetComponent <Transform>().SetParent(GameObject.FindWithTag("LevelObjects").GetComponent <Transform>());
         for (int i = 1; i < n; i++)
         {
             ChangeCloud(ref Clouds[(m + i) % n]);
         }
         m += 1;
     }
 }
Example #4
0
 void LateUpdate()
 {
     // si on a commencé à bouger, on fait le scrolling
     if (StartZoom.GetBegin())
     {
         initialPos  = newPos;
         newPos      = player.GetComponent <Transform>().position;
         translation = newPos - initialPos;
         Camera.main.GetComponent <RectTransform>().Translate(translation);
         pad.GetComponent <Transform>().Translate(translation);
         foreach (GameObject star in backgroundStars)
         {
             star.GetComponent <Transform>().Translate(-star.GetComponent <Transform>().position.z *translation / 150);
         }
     }
 }
Example #5
0
    // Update is called once per frame
    void Update()
    {
//        if (Input.touchCount > 0) pour quand Touch
        {
            if (StartZoom.GetBegin() && !caught && !GameManager.GetPaused()) // tout en position réelle (pas écran) et que x et y
            {
                center = new Vector2(PadCenter.transform.position.x, PadCenter.transform.position.y);
                if (Application.platform == RuntimePlatform.Android)
                {
                    if (Input.GetTouch(0).position == null)
                    {
                        PadPosition = PadCenter.GetComponent <Transform>().position;
                    }
                    PadPosition = cam.ScreenToWorldPoint(Input.GetTouch(0).position);
                }
                else
                {
                    PadPosition = cam.ScreenToWorldPoint(Input.mousePosition);
                }
                direction = PadPosition - center;
                if (distance(PadPosition, center) > 0.85f * distance(PadBorder.transform.position, center))
                {
                    direction  /= distance(direction, new Vector3(0, 0, 0));                          // divise par la norme
                    direction  *= distance(PadBorder.transform.position, center);                     // on donne la direction max
                    PadPosition = center + 0.85f * (new Vector2(direction.x, direction.y));           // on place le pad à 0.85 du centre
                }
                Vector3 directionNormee = direction / distance(PadBorder.transform.position, center); // norme entre 0 et  1
                Orientation.Move(this.gameObject, directionNormee * speed * Time.deltaTime);
                if (direction != new Vector3(0, 0, 0))
                {
                    float angle = Vector3.Angle(new Vector3(0, 1, 0), direction) * ((direction.x < 0) ? 1f : -1f) - GetComponent <Transform>().eulerAngles.z;   // l'angle manquant (la ref est Oy)
                    gameObject.GetComponent <Transform>().Rotate(new Vector3(0, 0, angle));
                }
                Pad.transform.position = PadPosition;
            }
        }
    }