Ejemplo n.º 1
0
    //-----------------------------------------------------------------------------------
    // Method:      TriggerReload
    // Description: Triggers a reload for weaponToReload. Decided to encapsulate reload
    //              code here because sometimes is useful to call from pickup.cs script
    //              For example the player has 0 bullets in the handgun and picks up a handgun
    //              a reload animation will automatically play
    //-----------------------------------------------------------------------------------
    public void TriggerReload(WeaponSet weaponToReload)
    {
        if (!CanFire)
        {
            return;
        }
        switch (weaponToReload)
        {
        case WeaponSet.None:
            break;

        case WeaponSet.Handgun:
            _handgun.Reload();
            _fpsAnimator.SetTrigger(TagsHashIDs.Reload);
            _handgun.ReloadAudio.pitch = Random.Range(0.95f, 1.05f);
            _handgun.ReloadAudio.Play();
            break;

        case WeaponSet.Shotgun:
            _shotgun.Reload();
            _fpsAnimator.SetTrigger(TagsHashIDs.Reload);
            _shotgun.ReloadAudio.pitch = Random.Range(0.95f, 1.05f);
            _shotgun.ReloadAudio.Play();
            break;

        case WeaponSet.PlasmaRifle:
            _plasmaRifle.Reload();
            _fpsAnimator.SetTrigger(TagsHashIDs.Reload);
            _plasmaRifle.ReloadAudio.pitch = Random.Range(0.95f, 1.05f);
            _plasmaRifle.ReloadAudio.Play();
            break;

        case WeaponSet.RailGun:
            break;

        default:
            break;
        }
    }
Ejemplo n.º 2
0
    private void Update()
    {
        Ray ray = GetComponentInChildren <Camera>().ScreenPointToRay(Input.mousePosition);

        Debug.DrawRay(ray.origin, ray.direction * 100, Color.yellow);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            //


            if (lastHealth != Health)
            {
                Debug.Log($"I've lost some Health {lastHealth - Health}, Health:{Health}");
                lastHealth = Health;
            }
        }

        if (Input.GetButtonDown("Fire1"))
        {
            activeWeapon.PrimaryFire();
        }

        if (Input.GetButtonDown("Fire2"))
        {
            activeWeapon.SecondaryFire();
        }

        if (Input.GetButtonDown("Use") && target.GetComponent <Interactable>().isInteractable)
        {
            //target.GetComponent<Interactable>();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            activeWeapon.Reload();
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        movingSpeed = (SpeedUPActive) ? 25f : 14f;
        vel         = new Vector3(0, 0, 0);
        //   rg.gravityScale = 1;
        isGrounded        = ((Mathf.Abs(rg.velocity.y) < 0.001f));
        ImmunityFrames   -= Time.deltaTime;
        jumplock         -= Time.deltaTime;
        cd               -= Time.deltaTime;
        SpeedUPDuration  -= Time.deltaTime;
        DamageUPDuration -= Time.deltaTime;
        PeterCD          -= Time.deltaTime;
        if (walkStopTime >= 0f)
        {
            walkStopTime -= Time.deltaTime;
        }
        if (jumplock < 0)
        {
            jumplock = 0f;
        }

        if (DamageUPDuration < 0)
        {
            DamageUPDuration = 0;
            DamageUPActive   = false;
        }
        if (SpeedUPDuration < 0)
        {
            SpeedUPDuration = 0;
            SpeedUPActive   = false;
        }
        if (PeterCD <= 0)
        {
            PeterCD = 0;
            if (false == DamageUPActive)
            {
                PeterSchreibHierDeinenRanzRein();
            }
        }

        if (ImmunityFrames < 0)
        {
            ImmunityFrames       = 0;
            immunityFramesActive = false;
        }
        //float horizontalSpeed;
        float horizontalInpit = Input.GetAxis("Horizontal"); // ad , lr sidestep
        float heightInput     = Input.GetAxis("Jump");       //spaaaaaaace
        float walkInput       = Input.GetAxis("Vertical");   //ws, vh Vorrrrrrw�rrrts!
        float firePress       = Input.GetAxis("Fire1");      //bumm!
        float mouseXPress     = Input.GetAxis("Mouse X");    //drehen
        float mouseYPress     = Input.GetAxis("Mouse Y");    //Kopf nicken

        if (horizontalInpit != 0)
        {
            var looking_dir = (int)Input.GetAxisRaw("Horizontal");
            vel = new Vector3(vel.x + looking_dir, vel.y, vel.z);
        }
        if (walkInput != 0)
        {
            var walkingforward = (int)Input.GetAxisRaw("Vertical");
            vel = new Vector3(vel.x, vel.y, vel.z + walkingforward);
        }
        if (firePress != 0)
        {
            Shoot();
        }
        else
        {
            shootReleased = true;
        }
        if (cd <= 0)
        {
            cd = 0;
            if (!isloaded)
            {
                shotty.Reload(DamageUPActive);
                isloaded      = true;
                shootReleased = false;
            }
        }
        if (jumplock == 0 && isGrounded)
        {
            rg.AddForce(new Vector2(0, (JumpForce * heightInput * rg.mass)));
        }

        vel = vel.normalized * movingSpeed;

        //MouseX:

        player.transform.Rotate(Vector3.up, mouseXPress * sensitivity, Space.Self);
        vel = Quaternion.Euler(0, player.transform.rotation.eulerAngles.y, 0) * vel;
        vel = new Vector3(vel.x, rg.velocity.y, vel.z);


        head.transform.Rotate(Vector3.left, mouseYPress * sensitivity, Space.Self);



        if (head.transform.localRotation.eulerAngles.x < 285 && head.transform.localRotation.eulerAngles.x > 110)
        {
            head.transform.localRotation = Quaternion.Euler(-75, 0, 0);
        }
        if (head.transform.localRotation.eulerAngles.x > 75 && head.transform.localRotation.eulerAngles.x < 80)
        {
            head.transform.localRotation = Quaternion.Euler(75, 0, 0);
        }

        if (aircontrol)
        {
            rg.velocity = vel;
        }

        if (Mathf.Abs(rg.velocity.x) > 0.2f || Mathf.Abs(rg.velocity.z) > 0.2f)
        {
            anim.SetBool("Walk", true);
        }
        else
        {
            if (walk && anim.GetBool("Walk"))
            {
                walkStopTime = 0.3f;
            }
            if (walkStopTime <= 0)
            {
                anim.SetBool("Walk", false);
            }
            walk = false;
        }
    }
Ejemplo n.º 4
0
Archivo: Rockjaw.cs Proyecto: wuw94/pon
 public override void Reload()
 {
     StartCoroutine(primary.Reload());
 }