예제 #1
0
    public void FireWeapon()
    {
        if (ammoType != null)
        {
            firedAmmoInstances = new GameObject[buckShot];

            for (int i = 0; i < buckShot; i++)
            {
                Vector3 firePosition  = GetRandomLaunchPoint();
                Vector3 fireDirection = transform.forward;

                firedAmmoInstances[i] = ammoType.FireAmmo(null, new Ray(firePosition, fireDirection), shootMask, damageMultiplier);
            }
        }
    }
예제 #2
0
        void Update()
        {
            UpdateRagdollGrabberPosition();

            CheckCameraTarget();
            UpdateSloMo();

            /* shoot from the clicked position */
            if (Input.GetMouseButtonDown(0))
            {
                if (currentAmmoType != null)
                {
                    currentAmmoType.FireAmmo(this, cam.ScreenPointToRay(Input.mousePosition), shootMask, 1);
                }
            }
            if (Input.GetMouseButtonDown(1))
            {
                StartCoroutine(CheckForRagdollGrab(cam.ScreenPointToRay(Input.mousePosition)));
            }

            /* launch the ball from the camera */
            if (Input.GetKeyDown(KeyCode.B))
            {
                GameObject.FindObjectOfType <DemoSceneController>().SwitchActiveScene();
            }
            /* drop teh ball on the controlled character */
            if (Input.GetKeyDown(KeyCode.E))
            {
                ToggleAmmoType();
            }

            if (controlledCharacter)
            {
                /* manually ragdoll the controlled character */
                if (Input.GetKeyDown(KeyCode.R))
                {
                    ragdollController.GoRagdoll("manual");
                }

                /* moved the controlled character */
                if (!controlledCharacter.disableExternalMovement)
                {
                    //do turning
                    controlledCharacter.transform.Rotate(0f, Input.GetAxis("Horizontal") * turnSpeed * Time.deltaTime, 0f);
                    //set speed
                    controlledCharacter.SetMovementSpeed(Input.GetAxis("Vertical") * (Input.GetKey(KeyCode.LeftShift) ? 2 : 1));
                }

                //disable char control
                if (Input.GetKeyDown(KeyCode.P))
                {
                    AttachToCharacter(null);
                }
            }
            else
            {
                /* look for character to control */
                if (Input.GetKeyDown(KeyCode.P))
                {
                    StartCoroutine(CheckForCharacter(cam.ScreenPointToRay(Input.mousePosition)));
                }
            }
        }