Shoot() private method

private Shoot ( ) : void
return void
Exemplo n.º 1
0
    void Update()
    {
        if (!pause.IsPaused)
        {
            // Movement
            playerMovement.Move(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));

            // Rotation
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                playerMovement.LookAt(hit.point);

                Debug.DrawRay(ray.origin, ray.direction * 100);
            }

            // Shooting
            if (Input.GetMouseButton(0))
            {
                playerShoot.Shoot();
            }

            // Reloading
            if (Input.GetKeyDown(KeyCode.R))
            {
                playerShoot.isReloading = true;
            }
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        if (!isLocalPlayer || m_pHealth.m_isDead)
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            m_pShoot.Shoot();
        }

        Vector3 inputDirection = GetInput();

        //rotate chassis
        if (inputDirection.sqrMagnitude > 0.25f)
        {
            m_pMotor.RotateChassis(inputDirection);
        }

        //rotate turret
        //see pic on phone concerning this calculation/subtraction.
        Vector3 turretDir = Utility.GetWorldPointFromScreenPoint(Input.mousePosition, m_pMotor.m_turret.position.y) - m_pMotor.m_turret.position;

        m_pMotor.RotateTurrent(turretDir);
    }
Exemplo n.º 3
0
 public void OnPointerUp(PointerEventData eventData)
 {
     force = pointDownTimer * timesPower;
     playerShooter.Shoot(pointDownTimer * timesPower);
     Reset();
     Debug.Log("up pressed");
 }
 public void Shoot()
 {
     //通常ショット
     if (shoot_Time < _shoot.shoot_Interval)
     {
         shoot_Time += Time.deltaTime;
         if (input.GetKeyDown(Key.Shoot))
         {
             is_Buffered_Input = true;
         }
     }
     else
     {
         if (input.GetKeyDown(Key.Shoot) || is_Buffered_Input)
         {
             _shoot.Shoot();
             shoot_Time        = 0;
             is_Buffered_Input = false;
         }
     }
     //チャージショット
     if (collection_Manager.Is_Collected("Yuka"))
     {
         if (input.GetKey(Key.Shoot))
         {
             _shoot.Charge();
         }
         if (input.GetKeyUp(Key.Shoot))
         {
             _shoot.Charge_Shoot();
         }
     }
 }
Exemplo n.º 5
0
 private void ShootBulletInput()
 {
     if (Input.GetMouseButtonDown(0))
     {
         playerShoot.Shoot();
     }
 }
Exemplo n.º 6
0
    void PcControls()
    {
        if (_movement.CanMove)
        {
            if (Input.GetButton(InputAxes.PC_MOVEHORIZONTAL))
            {
                _x = Input.GetAxis(InputAxes.PC_MOVEHORIZONTAL);
                _movement.Move(new Vector2(_x, 0));
                _movement.IsMoving = true;
            }
            else
            {
                _movement.Move(new Vector2(0, 0));
                _movement.IsMoving = false;
            }

            if (Input.GetButtonDown(InputAxes.PC_JUMP))
            {
                _movement.Jump();
            }
        }

        if (Input.GetButton(InputAxes.PC_ATTACK))
        {
            _shoot.Shoot();
        }
    }
Exemplo n.º 7
0
    void FixedUpdate()
    {
        if (playerMovement == null)
        {
            playerMovement = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement>();
        }
        if (playerShooting == null)
        {
            playerShooting = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerShoot>();
        }
        if (playerStats == null)
        {
            playerStats = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerStats>();
        }

        if (Time.timeScale == 0)
        {
            return;
        }

        if (Input.GetMouseButton(0))
        {
            if (time + (1 / playerStats.FireRate) < Time.time)
            {
                playerShooting.Shoot();
                time = Time.time;
            }
        }
        playerMovement.Move(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
    }
Exemplo n.º 8
0
 private void Update()
 {
     if (!_dead)
     {
         Movement();
         _weapon.Shoot();
     }
 }
Exemplo n.º 9
0
    public void Shoot()
    {
        Vector2 dir = (Vector2)player.position + spriteOffset - (Vector2)transform.position;

        dir = -dir.normalized;


        transform.localRotation = Quaternion.Euler(0, 0, -Dash.AngleBetween(Vector2.up, dir));
        ps.Shoot(dir);
    }
    // Update is called once per frame
    void Update()
    {
        bGrounded = Physics2D.Linecast(trans.position, transGroundCheck.position, groundMask);
        if (bGrounded && Input.GetButtonDown("Jump"))
        {
            bJump = true;
        }

        if (Input.GetButtonDown("Fire1"))
        {
            playerShoot.Shoot(facingRight);
        }
    }
Exemplo n.º 11
0
    private void Update()
    {
        if (GameState.InGame && !GameState.InCountdown && !PauseManager.IsPaused)
        {
            playerMovement.Move(GetPlayerAxis(), Input.GetKey(forward), Input.GetKey(backward));
            playerEngine.UpdateEngineSound(Input.GetKey(KeyCode.W));

            if (Input.GetKey(shoot))
            {
                playerShoot.Shoot();
            }
        }
    }
Exemplo n.º 12
0
    //Commands have to be queued and executed because we want to
    //store the command we are trying to execute, until player is done
    //rotating. If during rotation another command is issued, we can simply
    //replace the command and the previous command never occurs.
    void ExecuteCommand(PlayerCommand command)
    {
        switch (command)
        {
        case PlayerCommand.STOP:
            Stop();
            queuedCommand = PlayerCommand.NOTHING;
            return;

        case PlayerCommand.MOVE:
            if (!isRotating)
            {
                Move();
                queuedCommand = PlayerCommand.NOTHING;
            }
            return;

        case PlayerCommand.SHOOT:
            if (!isRotating)
            {
                playerShoot.Shoot();
                queuedCommand = PlayerCommand.NOTHING;
            }
            return;

        case PlayerCommand.DISJOINT:
            if (!isRotating)
            {
                //additional check in case collision detected between
                //disjoint and click.
                if (!playerStatus.IsRooted)
                {
                    playerDisjoint.StartDisjoint();
                }
                queuedCommand = PlayerCommand.NOTHING;
            }
            return;

        case PlayerCommand.BLAST:
            if (!isRotating)
            {
                playerBlast.StartBlast();
                queuedCommand = PlayerCommand.NOTHING;
            }
            return;

        default:
            return;
        }
    }
Exemplo n.º 13
0
    private async void Update()
    {
        currentRotation.x -= Input.GetAxisRaw("Mouse Y") * Sensitivity;
        currentRotation.y += Input.GetAxisRaw("Mouse X") * Sensitivity;


        if (CanJump && Input.GetButtonUp("Jump"))
        {
            rb.velocity = new Vector3(0, 20, 0);
        }

        if (Input.GetButtonUp("Fire1"))
        {
            playerShoot.Shoot(2.0f);
        }
    }
Exemplo n.º 14
0
    void Update()
    {
        Vector2 direction = new Vector2(playerInput.Vertical * speed, playerInput.Horizontal * speed);

        PlayerMovement.Move(direction);

        mouseInput.x = Mathf.Lerp(mouseInput.x, playerInput.MouseInput.x, 1f / MouseControl.Damping.x);
        mouseInput.y = Mathf.Lerp(mouseInput.y, playerInput.MouseInput.y, 1f / MouseControl.Damping.y);

        transform.Rotate(Vector3.up * mouseInput.x * MouseControl.Sensitivity.x);

        Crosshair.LookHeight(mouseInput.y * MouseControl.Sensitivity.y);

        PlayerShoot.Shoot(GameManager.Instance.InputController.Fire1);

        PlayerHealth.CheckDamage();
    }
Exemplo n.º 15
0
    void Update()
    {
        if (!m_photon.isMine && m_hasData)
        {
            m_lerpTime += Time.deltaTime * 9;
            this.transform.position           = Vector3.Lerp(m_lastPosition, m_targetPosition, m_lerpTime);
            this.transform.rotation           = Quaternion.Lerp(m_lastRotation, m_targetRotation, m_lerpTime);
            this.m_turret.transform.rotation  = Quaternion.Lerp(m_lastTurretRotation, m_targetTurretRotation, m_lerpTime);
            this.m_weapons.transform.rotation = Quaternion.Lerp(m_lastWeaponRotation, m_targetWeaponRotation, m_lerpTime);

            PlayerShoot playerShoot = this.GetComponent <PlayerShoot>();

            if (this.AddBulletHit)
            {
                playerShoot.AddBulletHit(this.BulletHitLocation);
                this.AddBulletHit = false;
            }

            if (this.HasShot)
            {
                playerShoot.Shoot(SideShot);
                HasShot = false;
            }

            if (this.HasHit)
            {
                var allPlayers = GameObject.FindGameObjectsWithTag("Player");
                foreach (var player in allPlayers)
                {
                    var photon = player.GetComponent <PhotonView>();
                    if (photon != null && photon.owner != null)
                    {
                        if (photon.owner.ID == this.HitPlayer)
                        {
                            playerShoot.Hit(player.transform);
                            this.HasHit = false;

                            m_photon.owner.SetScore(m_photon.owner.GetScore() + 1);
                            break;
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 16
0
    void Update()
    {
        if (isMobile == true)
        {
            transform.Rotate(new Vector2(-rotationJoystick.Vertical, rotationJoystick.Horizontal), rotSpeed * Time.deltaTime);
        }
        else
        {
            float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivity;
            rotationY += Input.GetAxis("Mouse Y") * sensitivity;
            rotationY  = Mathf.Clamp(rotationY, minY, maxY);
            transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
        }

        if (Input.GetKey(KeyCode.Mouse0))
        {
            playerShoot.Shoot();
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }
        if (Input.GetMouseButtonDown(0))
        {
            m_pShoot.Shoot();
        }
        Vector3 inputDir = GetInput();

        if (inputDir.sqrMagnitude > 0.25f)
        {
            m_pMotor.RotateChasis(inputDir);
        }
        Vector3 turretDir = Utility.GetWorldPointFromScreenPoint(Input.mousePosition, m_pMotor.m_turret.position.y) - m_pMotor.m_turret.position;

        m_pMotor.RotateTurret(turretDir);
    }
Exemplo n.º 18
0
    void Update()
    {
        //stuff to move around
        float Xmove = Input.GetAxis("Horizontal");
        float Zmove = Input.GetAxis("Vertical");

        Vector3 moveHorizontal = transform.right * Xmove;
        Vector3 moveVertical   = transform.forward * Zmove;

        Vector3 velocity = (moveHorizontal + moveVertical) * speed;

        motor.Move(velocity);

        timer -= Time.deltaTime;
        if (timer <= 0 && Input.GetKey(KeyCode.LeftShift))
        {
            gun.Shoot();
            timer = gun.shootInterval;
        }
    }
Exemplo n.º 19
0
    private void Update()
    {
        if (!isLocalPlayer || pHealth.IsDead)
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            pShoot.Shoot();
        }

        Vector3 inputDirection = GetInput();

        if (inputDirection.sqrMagnitude > 0.25f)
        {
            pMotor.RotateChassis(inputDirection);
        }
        Vector3 turretDir = Utility.GetWorldPointFromScreenPoint(Input.mousePosition, pMotor.transform.position.y) - pMotor.transform.position;

        pMotor.RotateTurret(turretDir);
    }
Exemplo n.º 20
0
    // Update is called once per frame
    void Update()
    {
        speed = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        myEngine.move(speed, -1);

        if (Input.GetKey(KeyCode.Space))
        {
            isShooting = true;
            myShoot.Shoot();
        }
        else
        {
            isShooting = false;
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            myShoot.UpdateTir();
        }

        myShoot.lastShoot++;
        myBase.Energy(isShooting);
    }
 //ショット
 public void Shoot()
 {
     //通常ショット
     if (shoot_Time < SHOOT_INTERVAL)
     {
         shoot_Time += Time.deltaTime;
     }
     else
     {
         if (input.GetKeyDown(Key.Shoot))
         {
             _shoot.Shoot();
         }
     }
     //チャージショット
     if (input.GetKey(Key.Shoot))
     {
         _shoot.Charge();
     }
     if (input.GetKeyUp(Key.Shoot))
     {
         _shoot.Charge_Shoot();
     }
 }
Exemplo n.º 22
0
    // Update is called once per frame
    void Update()
    {
        print(_canShoot);

        if (Input.GetKey("up") && (Input.GetKey("right")))
        {
            transform.right = topRightTarget.position - transform.position;
        }
        else if (Input.GetKey("right"))
        {
            transform.right = rightTarget.position - transform.position;
        }

        else if (Input.GetKey("up") && ShootDirection == true)
        {
            transform.right = topTarget.position - transform.position;
            ShootDirection  = true;
        }

        if (Input.GetKey("left") && (Input.GetKey("up")))
        {
            ShootDirection  = false;
            transform.right = topLeftTarget.position - transform.position;
        }

        else if (Input.GetKey("left"))
        {
            transform.right = leftTarget.position - transform.position;
        }

        else if (Input.GetKey("down") && ShootDirection == true)
        {
            transform.right = downTarget.position - transform.position;
            ShootDirection  = true;
            _canShoot       = false;
        }
        else
        {
            _canShoot = true;
        }

        if (Input.GetKey("down") && (Input.GetKey("left")))
        {
            ShootDirection  = false;
            transform.right = downLeftTarget.position - transform.position;
        }

        else if (Input.GetKey("down") && (Input.GetKey("right")))
        {
            transform.right = downRightTarget.position - transform.position;
        }

        if (Input.GetKey(KeyCode.X) && _canShoot)
        {
            _playershoot.Shoot();
        }


        if (Input.GetKeyUp("left"))
        {
            ShootDirection = true;
        }
    }
Exemplo n.º 23
0
    void Update()
    {
        if (!Input.GetKey(modify))
        {
            //Movement
            if (Input.GetKey(moveUp) || Input.GetKey(moveDown))
            {
                //tilt vertical
                movement.MoveVertical();
            }
            if (Input.GetKey(moveLeft) || Input.GetKey(moveRight))
            {
                //tilt horizontal
                movement.MoveHorizontal();
            }

            if (Input.GetKeyDown(fire))
            {
                shoot.Shoot();
            }

            if (Input.GetKeyDown(throddleUp))
            {
                // speed up
            }


            if (Input.GetKeyDown(throddleDown))
            {
                // slow down
            }

            if (Input.GetKeyDown(testFunction))
            {
                StartCoroutine(camFollow.CamShake(1f / 2, 1f / 3));
                //camFollow.CamShake(10f, 1000f);
            }
        }
        else
        // MODIFIED
        {
            if (Input.GetKeyDown(throddleUp))
            {
                // full throddle
            }
            if (Input.GetKeyDown(throddleDown))
            {
                // zero throddle
            }

            if (Input.GetKeyDown(menu))
            {
                // Beam Recharge
            }
            if (Input.GetKeyDown(shields))
            {
                // Threat Display
            }


            if (Input.GetKeyDown(beamWeapon))
            {
                // Hyperspace
            }

            //Redirect Laser
            if (Input.GetKeyDown(moveUp))
            {
                //move laser right
            }
            if (Input.GetKeyDown(moveDown))
            {
                //move laser down
            }
            if (Input.GetKeyDown(moveLeft))
            {
                //move laser left
            }
            if (Input.GetKeyDown(moveRight))
            {
                //move laser right
            }
        }
    }
Exemplo n.º 24
0
    // Update is called once per frame
    void Update()
    {
        if (!enablePlayer)
        {
            return;
        }
        //获取鼠标移动
        float hMouse = Input.GetAxis("Mouse X");
        float vMouse = Input.GetAxis("Mouse Y");

        //玩家和坦克的第三人称视角
        if (isOnTank)
        {
            playerTankController.CameraRotate(hMouse);
            playerTankController.TankTurretRotate();
        }
        else
        {
            playerController.CameraRotate(hMouse, vMouse);
        }

        waitingTime += Time.deltaTime;
        if (Input.GetButtonDown("Fire1"))
        {
            if (isOnTank)
            {
                Debug.Log("Fire1");
                playerTankFiring.TankFire(ref waitingTime);
            }
            else
            {
                playerShoot.Shoot();
                playerAnimation.Shoot();
            }
        }

        //if(Input.GetKeyDown(KeyCode.T) && !isOtherPlayerOnTank && !isOnTank)
        //{
        //    playerController.PlayerGetOnTank();
        //    isOnTank = true;
        //}
        //else if(Input.GetKeyDown(KeyCode.F))
        //{
        //    playerTankController.PlayerGetOffTank();
        //    isOnTank = false;
        //}

        if (Input.GetKeyDown(KeyCode.T))
        {
            if (isOnTank)
            {
                playerTankController.PlayerGetOffTank();
                isOnTank = false;
            }
            else
            {
                if (!isOtherPlayerOnTank)
                {
                    playerController.PlayerGetOnTank();
                    isOnTank = true;
                    //isOtherPlayerOnTank = true;
                }
            }
        }

        if (Input.GetButtonDown("Jump") && !isJump)
        {
            //Debug.Log("Jump");
            isJump = true;
        }

        //锁定鼠标
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;
    }
Exemplo n.º 25
0
    void Update()
    {
        //Movement
        if (charC.isGrounded)
        {
            moveDir = transform.TransformDirection(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")) * speed);
            if (Input.GetKey(KeyCode.LeftShift))
            {
                moveDir = transform.TransformDirection(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")) * shiftSpeed);
            }

            if (Input.GetButton("Jump"))
            {
                moveDir.y = jumpSpeed;
            }
        }
        moveDir.y -= gravity * Time.deltaTime;
        charC.Move(moveDir * Time.deltaTime);

        //Health
        hpSlider.value = Mathf.Clamp01(curHP / maxHP);

        //Mouse Look
        if (canLook)
        {
            if (axis == RotationalAxis.MouseXandY)
            {
                float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivity;
                rotationY += Input.GetAxis("Mouse Y") * sensitivity;
                rotationY  = Mathf.Clamp(rotationY, minY, maxY);
                transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
            }
            else if (axis == RotationalAxis.MouseX)
            {
                transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivity, 0);
            }
            else
            {
                rotationY += Input.GetAxis("Mouse Y") * sensitivity;
                rotationY  = Mathf.Clamp(rotationY, minY, maxY);
                transform.localEulerAngles = new Vector3(-rotationY, 0, 0);
            }
        }

        //Shoot
        if (lastResort)
        {
            gun2.SetActive(true);
            if (Input.GetButton("Fire1"))
            {
                pShoot.LastResort();
            }
        }
        else
        {
            gun2.SetActive(false);
            if (Input.GetButton("Fire1"))
            {
                pShoot.Shoot();
            }
        }

        //Interact
        if (voteTotal == 1)
        {
            totalItem.text = voteTotal.ToString() + " vote!";
        }
        else
        {
            totalItem.text = voteTotal.ToString() + " votes!";
        }

        if (voteTotal == 4)
        {
            holdingItem.text      = "Oh no the Liberals are mad! Defend the trams!";
            lastResort            = true;
            spawn[0].activateBoss = true;
            spawn[1].spawnRate    = 2;
            spawn[2].activateBoss = true;
            spawn[3].spawnRate    = 2;
            spawn[4].activateBoss = true;
            Interact();
            if (voteTotal == 1)
            {
                totalItem.text = voteTotal.ToString() + " fragments!";
            }
            else
            {
                totalItem.text = voteTotal.ToString() + " fragments!";
            }
        }
        else if (voteTotal >= 7)
        {
            winState.SetActive(true);
            menus.WinGame();
        }
        else
        {
            Interact();
        }

        //Pause
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            menus.OpenPauseMenu();
        }
    }
Exemplo n.º 26
0
 void CmdFire()
 {
     ps.Shoot();
 }