Example #1
0
 void OnCollisionEnter2D(Collision2D other)
 {
     Debug.Log("COlide");
     if (other.gameObject.tag == "Player")
     {
         RewindCore rewindCore = other.gameObject.GetComponent <RewindCore>();
         if (rewindCore.getRewinding())
         {
             return;
         }
         else
         {
             rewindCore.startRewind();
         }
         Destroy(this.gameObject);
     }
 }
Example #2
0
    void shoot()
    {
        RaycastHit2D ray;

        ray = Physics2D.Linecast(this.transform.position, player.transform.position);
        if (ray.collider != null)
        {
            RewindCore rewindCore = ray.collider.gameObject.GetComponent <RewindCore>();
            if (rewindCore.getRewinding())
            {
                return;
            }
            else
            {
                rewindCore.startRewind();
            }
        }
    }
Example #3
0
 private void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.tag == "Player")
     {
         RewindCore rewindCore = other.gameObject.GetComponent <RewindCore>();
         if (rewindCore.getRewinding())
         {
             return;
         }
         else
         {
             rewindCore.startRewind();
         }
     }
     else if (other.gameObject.tag == "Enemy")
     {
         return;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
    void Update()
    {
        float x = Input.GetAxisRaw("Horizontal");
        float y = Input.GetAxisRaw("Vertical");

        if (GetComponent <RewindCore>().getRewinding())
        {
            x = 0;
            y = 0;
        }



        gCheck1 = Physics2D.Raycast(transform.position, Vector3.down, DistanceToTheGround + 0.01f, ground);
        Vector3 VDisSide = new Vector3(DistanceToSide - 0.05f, 0, 0);

        gCheck2 = Physics2D.Raycast(transform.position + VDisSide, Vector3.down, DistanceToTheGround + 0.01f, ground);
        gCheck3 = Physics2D.Raycast(transform.position - VDisSide, Vector3.down, DistanceToTheGround + 0.01f, ground);
        Debug.DrawRay(transform.position - VDisSide, Vector3.down, Color.red);
        Debug.DrawRay(transform.position + VDisSide, Vector3.down, Color.blue);
        Debug.DrawRay(transform.position, Vector3.down);
        isGrounded = gCheck1 || gCheck2 || gCheck3;
        a.SetFloat("Direction", x);
        if (x == 0)
        {
            a.SetBool("Running", false);
        }
        else
        {
            if (x < 0)
            {
                sr.flipX = true;
            }
            else if (x > 0)
            {
                sr.flipX = false;
            }
            a.SetBool("Running", true);
        }
        if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
        {
            isJumping = true;
        }
        if (y < 0)
        {
            if (!isDucking)
            {
                duck();
            }
        }
        else
        {
            if (isDucking)
            {
                unDuck();
            }
        }

        if (rc.stopedRewinding)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                jump();
                rc.stopedRewinding = false;
            }
        }

        transform.Translate(Vector2.right * x * speed * Time.deltaTime);

        if (rc.getRewinding())
        {
            text.text = "rewinding";
        }
        else
        {
            text.text = "";
        }
    }