Esempio n. 1
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        gameObject.SetActive(false);
        ObjectController.CreateArrowHit(transform.position, transform.rotation, coll.gameObject.transform);
        Killable killable = coll.gameObject.GetComponent <Killable>();

        SoundController.PlayArrowHit();
        ObjectController.CreateSmallSmoke(transform.position + transform.right * 0.5f);
        Camera.main.GetComponent <FollowCamera>().Shake();
        if (killable != null)
        {
            killable.Damage(5);
        }
        Destroy(gameObject);
    }
Esempio n. 2
0
 private void Jump()
 {
     body.AddForce(new Vector2(0, jumpForce));
     if (form == Form.BIRD)
     {
         if (body.velocity.y > maxYVelocity)
         {
             body.velocity = new Vector2(body.velocity.x, maxYVelocity);
         }
         bird_flap.gameObject.SetActive(false);
         bird_flap.gameObject.SetActive(true);
         SoundController.PlayJumpBird();
     }
     else
     {
         SoundController.PlayJumpPerson();
         ObjectController.CreateSmallSmoke(transform.position - new Vector3(0, collider.radius));
     }
     grounded = false;
 }
Esempio n. 3
0
    void FixedUpdate()
    {
        if (dead)
        {
            return;
        }

        if ((Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D)) && form == Form.PERSON && grounded)
        {
            if (footstepTimer == 0)
            {
                SoundController.PlayFootstep();
                ObjectController.CreateSmallSmoke(transform.position - new Vector3(0, collider.radius));
                footstepTimer += Time.fixedDeltaTime;
            }
            else
            {
                footstepTimer += Time.fixedDeltaTime;
                if (footstepTimer > footstepFrequency)
                {
                    footstepTimer = 0;
                }
            }
        }
        else
        {
            footstepTimer = 0;
        }

        if (Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D))
        {
            if (form == Form.PERSON || !grounded)
            {
                body.AddForce(new Vector2(-moveForce, 0));
                if (!moving)
                {
                    moving = true;
                    UpdatePlayerDisplay();
                }
            }
        }
        else if (Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.A))
        {
            if (form == Form.PERSON || !grounded)
            {
                body.AddForce(new Vector2(moveForce, 0));
                if (!moving)
                {
                    moving = true;
                    UpdatePlayerDisplay();
                }
            }
        }
        else
        {
            if (moving)
            {
                moving = false;
                UpdatePlayerDisplay();
            }
        }

        //apply horizontal damping
        if (form == Form.PERSON)
        {
            body.velocity = new Vector2(body.velocity.x * horizontalDamping, body.velocity.y);
        }
        if (body.velocity.y < -15)
        {
            body.velocity = new Vector2(body.velocity.x, -15);
        }
    }