Ejemplo n.º 1
0
    private void LateUpdate()
    {
        if (!pView.IsMine)
        {
            return;
        }

        if (!dead)
        {
            if (!gc.getQuestionMode())
            {
                if (Input.GetMouseButton(0))
                {
                    if (pbc.canShoot())
                    {
                        shotsFired++;
                        //if you want the effect instantiated at a point
                        if (pbc.getBlasterType() == 1)
                        {
                            cam.gameObject.GetComponent <SmoothMouseLook>().shoot1(pbc.getName() + "effect", pbc.getDamage());
                            pbc.incrementAmmo();
                            pbc.shooting();
                            ac.SetBool("shooting", true);
                        }
                        //if you want a trail to be shot
                        else if (pbc.getBlasterType() == 2 || pbc.getBlasterType() == 3)
                        {
                            cam.gameObject.GetComponent <SmoothMouseLook>().shoot2(pbc.getName() + "effect", pbc.getDamage(),
                                                                                   (transform.forward * 2 + transform.up * 3.8f + transform.right * -2.5f + transform.position));//pbc.getGunTipPosition());
                            pbc.incrementAmmo();
                            pbc.shooting();
                            ac.SetBool("shooting", true);
                        }
                        else if (pbc.getBlasterType() == 4)
                        {
                            cam.gameObject.GetComponent <SmoothMouseLook>().shoot3(pbc.getEffect().name, pbc.getGunTipPosition());
                            pbc.incrementAmmo();
                            pbc.shooting();
                            ac.SetBool("shooting", true);
                        }
                    }
                    else
                    {
                        //if you're not shooting
                        if (!pbc.isShooting())
                        {
                            ac.SetBool("shooting", false);
                        }
                        //Make empty clip sound
                    }
                }
                else
                {
                    if (!pbc.isShooting())
                    {
                        ac.SetBool("shooting", false);
                    }
                }
            }
        }
        if (gc.getQuestionMode() && !controller.isGrounded)
        {
            moveDirection.x  = 0f;
            moveDirection.z  = 0f;
            moveDirection.y -= gravity * Time.deltaTime;
        }
        if (!gameOver)
        {
            if (!(dead && controller.isGrounded))
            {
                moveDirection = Quaternion.AngleAxis(-30, Vector3.up) * moveDirection;
                controller.Move(moveDirection * Time.deltaTime);
            }
        }
    }