Ejemplo n.º 1
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.gameObject.layer == gameObject.layer && collision.gameObject.tag == "Player")
     {
         BackGroundFloor.finishDash();
     }
 }
Ejemplo n.º 2
0
 private void OnCollisionStay2D(Collision2D collision)
 {
     if (collision.gameObject.layer == gameObject.layer && collision.gameObject.tag == "Player")
     {
         if (gameObject.tag == "enemy" && Human.Attacking)
         {
             int Ran = (int)Random.Range(0.0f, 8.0f);
             if (Ran < 2)
             {
                 GameObject obj = Instantiate(redObj, gameObject.transform.position, Quaternion.identity);
                 obj.name = "Red";
                 obj.AddComponent <WallCollision>();
             }
             else if (Ran < 4)
             {
                 GameObject obj = Instantiate(monsterObj, gameObject.transform.position, Quaternion.identity);
                 obj.name = "Monster";
                 obj.AddComponent <WallCollision>();
             }
             Destroy(gameObject);
             BackGroundFloor.finishDash();
             GlobalData.isStop = false;
         }
     }
 }
Ejemplo n.º 3
0
    void useItem()
    {
        if (Input.GetKeyDown(KeyCode.K))
        {
            if (canChange)
            {
                _changeSprite.changeSprites();
                this.canChange = false;
                canRedBull.GetComponent <Image>().enabled = false;
            }
        }

        if (!GlobalData.isStop)
        {
            if (Input.GetKey(KeyCode.L))
            {
                if (stamina > 0)
                {
                    stamina -= Time.deltaTime * 2;
                    BackGroundFloor.isDash();
                    staminaSlider.value = stamina;
                    if (stamina <= 0)
                    {
                        return;
                    }
                }
            }
            else if (Input.GetKeyUp(KeyCode.L))
            {
                BackGroundFloor.finishDash();
            }
        }
    }
Ejemplo n.º 4
0
 private void OnCollisionExit2D(Collision2D collision)
 {
     if (collision.gameObject.layer == gameObject.layer && collision.gameObject.tag == "Player")
     {
         BackGroundFloor.finishDash();
         GlobalData.isStop = false;
     }
 }
Ejemplo n.º 5
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.layer == gameObject.layer && collision.gameObject.tag == "Player")
     {
         if (gameObject.tag == "enemy" && Human.Attacking)
         {
             int Ran = (int)Random.Range(0.0f, 8.0f);
             if (Ran < 2)
             {
                 GameObject obj = Instantiate(redObj, gameObject.transform.position, Quaternion.identity);
                 obj.name = "Red";
                 obj.AddComponent <WallCollision>();
             }
             else if (Ran < 4)
             {
                 GameObject obj = Instantiate(monsterObj, gameObject.transform.position, Quaternion.identity);
                 obj.name = "Monster";
                 obj.AddComponent <WallCollision>();
             }
             Destroy(gameObject);
         }
         else
         {
             if (gameObject.tag == "enemy")
             {
                 audiosource.PlayOneShot(SE[2]);
             }
             if (gameObject.tag == "cat")
             {
                 audiosource.PlayOneShot(SE[1]);
             }
             if (gameObject.tag == "car")
             {
                 audiosource.PlayOneShot(SE[0]);
             }
             BackGroundFloor.onStop();
             GlobalData.isStop = true;
         }
     }
 }
Ejemplo n.º 6
0
    void Moving()
    {
        gameObject.transform.rotation = this.quaternion;
        //if (!Jumping) transform.position = new Vector3(transform.position.x, GlobalData.yPosition[-layer + 12], 0.0f);
        Transform myTransform = this.transform;
        Vector3   pos         = myTransform.position;

        this.deltaTimes += Time.deltaTime;


        if (this.deltaTimes >= 1.0)
        {
            this.deltaTimes -= 1.0f;
        }

        if (this.deltaTimes >= 0.75)
        {
            gameObject.GetComponent <SpriteRenderer>().sprite = Right;
        }
        else if (this.deltaTimes >= 0.5)
        {
            gameObject.GetComponent <SpriteRenderer>().sprite = Normal;
        }
        else if (this.deltaTimes >= 0.25)
        {
            gameObject.GetComponent <SpriteRenderer>().sprite = Left;
        }
        else
        {
            gameObject.GetComponent <SpriteRenderer>().sprite = Normal;
        }

        if (!UpDown)
        {
            if (Input.GetKey(KeyCode.W) && layer < 12)
            {
                //gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0.0f, 7.5f), ForceMode2D.Impulse);
                BackGroundFloor.finishDash();
                Jumping = true;
                pos.y   = GlobalData.yPosition[-layer + 11] + 0.5f;
                myTransform.position = pos;//*/
                gameObject.layer    += 1;
                UpDown            = true;
                GlobalData.isStop = false;
            }
            if (Input.GetKey(KeyCode.S) && layer > 8)
            {
                /*pos.y -= 1f;
                 * pos.y = (int)pos.y;
                 * myTransform.position = pos;//*/
                BackGroundFloor.finishDash();
                gameObject.layer -= 1;
                Jumping           = true;
                UpDown            = true;
                GlobalData.isStop = false;
            }
        }
        else if (!Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.S))
        {
            UpDown = false;
        }

        if (Input.GetKey(KeyCode.A) && pos.x > -8)
        {
            pos.x -= moveSpeed * Time.deltaTime;
            myTransform.position = pos;
        }
        if (Input.GetKey(KeyCode.D) && pos.x < 8)
        {
            pos.x += moveSpeed * Time.deltaTime;
            myTransform.position = pos;
        }
    }