コード例 #1
0
 private void SwingRelease()
 {
     moveVector = new Vector3(rewiredPlayer.GetAxis2DRaw("Horizontal", "Vertical").x, rewiredPlayer.GetAxis2DRaw("Horizontal", "Vertical").y, 0);
     Debug.Log(type);
     if (type == SwingType.Forehand)
     {
         leftRacket.transform.Rotate(Vector3.forward * RacketRotateSpeed * Time.deltaTime);
         if (rewiredPlayer.GetButtonUp("LeftWindup"))
         {
             //left swing
             swinging = true;
             state    = PlayerState.Swinging;
         }
     }
     else if (type == SwingType.Backhand)
     {
         rightRacket.transform.Rotate(-Vector3.forward * RacketRotateSpeed * Time.deltaTime);
         if (rewiredPlayer.GetButtonUp("RightWindup"))
         {
             //left swing
             swinging = true;
             state    = PlayerState.Swinging;
         }
     }
 }
コード例 #2
0
    public virtual void UpdateInputSnapshot()
    {
        snapshot.xAxis = player.GetAxisRaw("Move Horizontal");
        snapshot.yAxis = player.GetAxisRaw("Move Vertical");

        snapshot.xAxisThrow = player.GetAxisRaw("Throw Stick Horizontal");
        snapshot.yAxisThrow = player.GetAxisRaw("Throw Stick Vertical");

        //snapshot.xAxis = ConstrainAxisTo16Angles (snapshot.xAxis);
        //snapshot.yAxis = ConstrainAxisTo16Angles (snapshot.yAxis);

        //snapshot.xAxis *= 2f;
        //snapshot.xAxis = ConstrainAxisTo16Angles (snapshot.xAxis);
        //snapshot.xAxis /= 2f;

        //snapshot.yAxis *= 2f;
        //snapshot.yAxis = ConstrainAxisTo16Angles (snapshot.yAxis);
        //snapshot.yAxis /= 2f;

        if (player.GetButtonDown("Jump"))
        {
            JumpButtonDown();
        }

        if (player.GetButtonUp("Jump"))
        {
            JumpButtonUp();
        }

        if (player.GetButtonDown("Throw"))
        {
            ThrowButtonDown();
        }

        if (player.GetButtonUp("Throw"))
        {
            ThrowButtonUp();
        }

        if (player.GetButtonDown("Start"))
        {
            StartButtonDown();
        }

        if (player.GetButtonUp("Start"))
        {
            StartButtonUp();
        }

//		if (Input.GetButtonDown (selectButton)) {
//			snapshot.selectButton.down = true;
//			snapshot.selectButton.pressed = true;
//		}
//
//		if (Input.GetButtonUp (selectButton)) {
//			snapshot.selectButton.up = true;
//			snapshot.selectButton.pressed = false;
//		}
    }
コード例 #3
0
 // Update is called once per frame
 void Update()
 {
     if (_player.GetButtonUp("pause"))
     {
         pause.Invoke();
     }
     if (_player.GetButtonUp("gui_accept"))
     {
         accept.Invoke();
     }
     if (_player.GetButtonUp("gui_back"))
     {
         back.Invoke();
     }
 }
コード例 #4
0
    private void DoInput()
    {
        if (inputBlocked)
        {
            return;
        }

        if (rePlayer.GetAxis("LStick Horizontal") != 0)
        {
            float newY = Mathf.Sin(Time.time * 10) / 10;
            playerObject.transform.localPosition = new Vector3(playerObject.transform.localPosition.x, newY, playerObject.transform.localPosition.z);
            float newX = Mathf.Sin(Time.time * 10) / 400;
            handObject.transform.localPosition = new Vector3(newX, handObject.transform.localPosition.y, handObject.transform.localPosition.z);
        }

        // Activate all actions if they exist
        foreach (KeyValuePair <string, PlayerUsable> action in actionMap)
        {
            if (rePlayer.GetButton(action.Key))
            {
                action.Value.Use();
            }
            else if (rePlayer.GetButtonUp(action.Key))
            {
                action.Value.UnUse();
            }
            else if (rePlayer.GetButtonDown(action.Key))
            {
                action.Value.UseOnce();
            }
        }
    }
コード例 #5
0
ファイル: Player.cs プロジェクト: matejnavara/PirateJam2018
    void Attack()
    {

        if (player.GetButton("Fire1"))
        {
            isAttacking = true;
            weapon.SetColliderActive(true);
            weapon.SwingSound();
            if (player.GetAxis("MoveHorizontal") >= 0)
            {
                weapon.transform.Rotate(0, 0, -20f);
            }
            else
            {
                weapon.transform.Rotate(0, 0, 20f);
            }
                
        }

        if (player.GetButtonUp("Fire1"))
        {
            isAttacking = false;
            weapon.SetColliderActive(false);
            weapon.transform.localRotation = Quaternion.Lerp(weapon.transform.rotation, Quaternion.identity, 1f);
        }

        if (player.GetButton("Fire2"))
        {
            Special();
        }
        
    }
コード例 #6
0
        private void HandleInput()
        {
            _horizontal += _player.GetAxis(InputActions.Horizontal);
            _vertical   += _player.GetAxis(InputActions.Vertical);

            _isSwitchLeftPressed  = _isSwitchLeftPressed || _player.GetButtonDown(InputActions.SwitchLeft);
            _isSwitchLeftReleased = _isSwitchLeftReleased || _player.GetButtonUp(InputActions.SwitchLeft);
            _isSwitchLeftHeld     = _isSwitchLeftHeld || _player.GetButton(InputActions.SwitchLeft);

            _isSwitchRightPressed  = _isSwitchRightPressed || _player.GetButtonDown(InputActions.SwitchRight);
            _isSwitchRightReleased = _isSwitchRightReleased || _player.GetButtonUp(InputActions.SwitchRight);
            _isSwitchRightHeld     = _isSwitchRightHeld || _player.GetButton(InputActions.SwitchRight);

            _isShootPressed  = _isShootPressed || _player.GetButtonDown(InputActions.Shoot);
            _isShootReleased = _isShootReleased || _player.GetButtonUp(InputActions.Shoot);
            _isShootHeld     = _isShootHeld || _player.GetButton(InputActions.Shoot);
        }
コード例 #7
0
 public bool GetButtonUp(int _PlayerID, string _Button)
 {
     if (_PlayerID == 1)
     {
         return(Player1RW.GetButtonUp(_Button));
     }
     else if (_PlayerID == 2)
     {
         return(Player2RW.GetButtonUp(_Button));
     }
     return(false);
 }
コード例 #8
0
    //Check for Block
    private void BlockCheck()
    {
        if (rewiredPlayer.GetButtonDown("Block"))
        {
            //switch to Block
            SendInput(InputState.Block, 0f);
        }

        if (rewiredPlayer.GetButtonUp("Block"))
        {
            //stop blocking, switch to Idle
            SendInput(InputState.EndBlock, 0f);
        }
    }
コード例 #9
0
ファイル: GameInput.cs プロジェクト: akur-8/UltraCyber
    public static bool GetButtonUp(uint index, Button button)
    {
#if USE_REWIRED
        RE.Player player = RE.ReInput.players.GetPlayer((int)index);
        return(player.GetButtonUp(ButtonToRewiredAction(button)));
#else // USE_REWIRED
        if (Input.GetKeyUp(ButtonToKeyCode(index, button)))
        {
            return(true);
        }

        Xbox360Button?btn360 = ButtonTo360(button);
        return(btn360 == null ? false : GetXboxButtonUp((uint)index, btn360.Value));
#endif // USE_REWIRED
    }
コード例 #10
0
    void Update()
    {
        // Grab peg
        if (isHoldingPeg && player.GetButtonUp(grab))
        {
            isHoldingPeg = false;
            Destroy(this.gameObject.GetComponent <HingeJoint2D>());
        }
        else if (!isHoldingPeg && player.GetButtonDown(grab))
        {
            StartPegSeek(FindCloestPeg());
        }
        else if (!isHoldingPeg && player.GetButtonUp(grab))
        {
            StopPegSeek();
        }

        // Pull peg
        if (isHoldingPeg)
        {
            if (player.GetButtonDown(pull))
            {
                pullPegCo = StartCoroutine(PullPeg());
            }
            if (player.GetButtonUp(pull))
            {
                StopCoroutine(pullPegCo);
            }
        }

        if (seekPeg)
        {
            Vector3 dir = (pegTarget - transform.position).normalized;
            GetComponent <Rigidbody2D>().AddForce(dir * seekMult * handSpeed);
        }
    }
コード例 #11
0
        private void Update()
        {
            if (m_input != null)
            {
                Vector3 moveInput = GetMoveInput();
                SetMoveDirection(moveInput);

                if (m_input.GetButtonDown(Action.Jump))
                {
                    TryJump();
                }
                else if (m_input.GetButtonUp(Action.Jump))
                {
                    StopJumping();
                }

                if (m_input.GetButtonDown(Action.Pause))
                {
                    GameMode.Instance.TogglePause();
                }
            }

            UpdateAnimator();
        }
コード例 #12
0
ファイル: Player.cs プロジェクト: nialltl/Muddledash
    void HandleMovement()
    {
        if (!ReInput.isReady) return;

        player_controller = ReInput.players.GetPlayer(rewiredPlayerID);
        if (player_controller == null) return;

        justKicked = false;

        float axis = player_controller.GetAxis(RewiredConsts.Action.Run);
        moveX = (axis == 0) ? 0 : (int)Mathf.Sign(axis);

        if (moveX != 0) FestivalTimeOutManager.Reset();

        if (!canControl || !canMoveHorizontal || Dashing) moveX = 0;

        // Slippy surface audio
        if (Slipping) {
            float velFactor = Mathf.Min(maxVelX, rbody.velocity.x) / maxVelX;
            velFactor *= velFactor;
            float slipVol = AudioManager.sfxVol * velFactor * 0.6f;

            if (_audio.continualSourceIsPlaying && !_audio.continualSourceIsTweening) {
                _audio.continualSource.volume = slipVol;
            }
            if (surface != Surface.None && !_audio.continualSourceIsPlaying) {
                _audio.EnableContinual(slipVol);
            }
        }
        if ((surface == Surface.None || !Slipping) && _audio.continualSourceIsPlaying) {
            _audio.DisableContinual();
        }

        if (canControl) {
            bool can_jump_this_frame =  (ledgeBody && !ledgeHead && surface == Surface.None);

            // Jump logic
            bool jumpCondition = player_controller.GetButton(RewiredConsts.Action.Jump);
            if (jumpCondition) {
                // keep racking up time
                jumpTime += Time.deltaTime;
            }

            if (ledgeCondition && surface == Surface.None && jumpCondition) {
                ledgeGrabTime = maxLedgeGrabTime;
            }
            if (ledgePushAccumulator > 0) ledgePushAccumulator -= Time.deltaTime;

            bool jumpTimeCondition = (player_controller.GetButtonDown(RewiredConsts.Action.Jump) || jumpTime > maxJumpTime);
            bool surfaceCondition = (surface != Surface.None || ledgeGrabTime > 0);

            bool end_of_ledge_grab = !can_jump_this_frame && can_jump_prev_frame;
            if (jumpCondition && ((jumpTimeCondition && surfaceCondition) || end_of_ledge_grab)) {
                // Regular jump
                jc_0 = true;

                // Quickfeet achievement
                if (surface == Surface.Player && squishHitbox.last_touched_player != null && squishHitbox.last_touched_player.Dashing) {
                    achievementMgr.GetQuickFeet();
                }

                // allow shunt in direction of ledge
                if (ledgeGrabTime > 0) ledgePushAccumulator = maxLedgePushTime;

                jumpTime = 0;

                Squish(SquishType.JUMP);
            }

            can_jump_prev_frame = can_jump_this_frame;

            // Hopping up ledges autoassist
            if (ledgePushAccumulator > 0) {
                ledgePushAccumulator -= Time.deltaTime;
                jc_1 = true;
            }

            // Slowing down to allow variable jump height
            jumpCondition = player_controller.GetButtonUp(RewiredConsts.Action.Jump);
            if (jumpCondition && rbody.velocity.y > 0 && !Boosting) {
                jc_2 = true;

                // reset jump time
                jumpTime = 0;
            }

            // Slamming
            bool slamCondition = player_controller.GetButtonDown(RewiredConsts.Action.Kick);
            if (slamCondition && canSlam) {
                slamming = true;
                if (surface == Surface.None) {
                    slammingInAir = true;
                }

                // Kicking when on ground
                if (surface == Surface.Ground) {
                    Kick();
                } else {
                    // Add slam speed to whatever downward motion we already have
                    jc_3 = true;
                }

                // Allow multiple player slams, but disable constant slamming in the air
                if (surface != Surface.Player) canSlam = false;

                // Audiovisual update
                if (surface == Surface.None) Squish(SquishType.SLAM);
                //_audio.PlayClipOnce("slam", AudioManager.sfxVol * 0.5f, Random.Range(2.8f, 3f));
            }

            // Dashing
            bool dashCondition = player_controller.GetButtonDown(RewiredConsts.Action.Dash);
            if (dashCoroutine == null && !tired && !Dashing && dashCondition && canMoveHorizontal) {
                dashCoroutine = StartCoroutine("InitDash");
            }

            // Switch direction of sprite with movement
            if (!Transitioning) {
                UpdateOrientation(moveX);
            }
        }
    }
コード例 #13
0
    void Update()
    {
        if (dead)
        {
            anim.SetTrigger("Death");
        }
        else if (canDoActions)
        {
            hAxis = playerInput.GetAxis("Move Horizontal");
            vAxis = playerInput.GetAxis("Move Vertical");
            anim.SetFloat("vSpeed", playerRigidbody2D.velocity.y);
            if (Mathf.Abs(hAxis) <= 0.1)
            {
                anim.SetFloat("Speed", hAxis);
            }
            //anim.SetBool(ANIM_GROUND, grounded);
            // If the input is moving the player right and the player is facing left...
            if ((hAxis > 0 && !facingRight) || (hAxis < 0 && facingRight))
            {
                Flip();
            }

            if (anim.GetBool(ANIM_ATTACK))
            {
                anim.SetBool(ANIM_ATTACK, false);
            }
            if (anim.GetBool(ANIM_AIR_ATTACK))
            {
                anim.SetBool(ANIM_AIR_ATTACK, false);
            }

            checkAbilityToUseWeapon();

            CheckAbilityToJump();

            CheckDash();

            //checking wall jump duration
            if (wallJumping)
            {
                timeSinceWallJump += Time.deltaTime;
                if (grounded || timeSinceWallJump >= wallJumpDuration)
                {
                    wallJumping = false;
                }
            }

            // Fall faster while holding down
            if (!grounded && !wallSliding && vAxis < -0.5f)
            {
                //playerRigidbody2D.gravityScale = 2f;
                ////Debug.Log("setting gravity in fall");
                if (playerInput.GetButton("Sword"))
                {
                    anim.SetBool(ANIM_DOWN_ATTACK, true);
                }
            }
            else
            {
                playerRigidbody2D.gravityScale = 1f;
                ////Debug.Log("setting gravity back from fall");
                anim.SetBool(ANIM_DOWN_ATTACK, false);
            }

            CheckLedgeGrab(hAxis);
            if (!grabbingLedge)
            {
                CheckWallSlide(hAxis);
            }

            //duck
            if (grounded && vAxis < -0.5f && Mathf.Abs(hAxis) < .3f)
            {
                anim.SetBool(ANIM_DUCKING, true);
            }
            else
            {
                anim.SetBool(ANIM_DUCKING, false);
            }

            //looking up
            if (grounded && vAxis > 0.5f && Mathf.Abs(hAxis) < .3f)
            {
                anim.SetBool(ANIM_LOOKING_UP, true);
            }
            else
            {
                anim.SetBool(ANIM_LOOKING_UP, false);
            }

            //blocking
            if (grounded && playerInput.GetButtonDown("Block") && ableToBlock)
            {
                timeSinceBlock = 0f;
                ableToBlock    = false;
                anim.SetBool(ANIM_BLOCKING, true);
            }

            /* checking inputs */
            if (!playerInput.GetButton("Shuriken") && !playerInput.GetButton("Grenade"))
            {
                anim.SetBool(ANIM_PREPARING_THROW, false);
                directionalTarget.SetActive(false);
            }

            if (playerInput.GetButtonDown("Grenade"))
            {
                timeSinceGrenadePrep = 0f;
                grenadeTimeToExplode = grenadePrefab.GetComponent <GrenadeController>().secondsToExplosion;
            }

            if (playerInput.GetButton("Shuriken") || playerInput.GetButton("Grenade"))
            {
                if (playerInput.GetButton("Grenade"))
                {
                    timeSinceGrenadePrep += Time.deltaTime;
                    //if (timeSinceGrenadePrep >= grenadeTimeToExplode)
                    //{
                    //    throwGrenade(targetDirection);
                    //    targetDirection = Vector2.zero;
                    //    directionalTarget.SetActive(false);
                    //}
                }

                anim.SetBool(ANIM_PREPARING_THROW, true);
                if (targetDirection == Vector2.zero)
                {
                    targetDirection = new Vector2(facingRight ? 1 : -1, .5f);
                }

                if (grounded)
                {//stop sliding when targeting
                    playerRigidbody2D.velocity = Vector2.zero;
                }

                if (Mathf.Abs(hAxis) + Mathf.Abs(vAxis) > 1.0f)
                {
                    targetDirection = new Vector2(hAxis, .5f + (vAxis / 2f));//setting y to a 0 to 1 range instead of -1 to 1
                }
                setDirectionalTarget(targetDirection, Mathf.Atan2(vAxis, Mathf.Abs(hAxis)) * Mathf.Rad2Deg);
            }

            if (playerInput.GetButtonUp("Shuriken"))
            {
                if (shurikenCount > 0)
                {
                    throwShuriken(targetDirection);
                }
                targetDirection = Vector2.zero;
            }
            else if (playerInput.GetButtonUp("Grenade"))
            {
                if (grenadeCount > 0)// && timeSinceGrenadePrep < grenadeTimeToExplode)
                {
                    throwGrenade(targetDirection);
                }
                targetDirection = Vector2.zero;
            }

            if (!blockingActionInEffect())
            {
                if (playerInput.GetButtonDown("Sword") && ableToAttack)// || (
                //playerId != 0 && ableToAttack && Time.realtimeSinceStartup % 3 < 1
                //))
                {
                    ableToAttack    = false;
                    timeSinceAttack = 0f;
                    if (grounded)
                    {
                        if (Mathf.Abs(hAxis) > .3f)
                        {
                            anim.SetTrigger("Attack");
                            playerRigidbody2D.AddForce(new Vector2(facingRight ? attackThrustSpeed : -attackThrustSpeed, 0), ForceMode2D.Impulse);
                            //dashing = true;
                            //ableToDash = false;
                            //timeSinceDash = 0f;
                            //dashToward = transform.position + (new Vector3((facingRight)?1f:-1f, 0f) * 10f);
                        }
                        else
                        {
                            anim.SetBool(ANIM_ATTACK, true);
                        }
                    }
                    else
                    {
                        anim.SetBool(ANIM_AIR_ATTACK, true);
                    }
                }
                else if (playerInput.GetButtonDown("Dash") && ableToDash && !touchingRightWall)
                {
                    dashing = true;
                    playerRigidbody2D.isKinematic = true;
                    setSpriteOpacity(.6f);
                    gameObject.layer = LayerMask.NameToLayer("Dodging Character");
                    incrementStat(Statistics.DODGES);

                    ableToDash    = false;
                    timeSinceDash = 0f;
                    //preDashVelocity = rigidbody2D.velocity;
                    float yDashForce = 0;
                    if (Mathf.Abs(vAxis) > .4f)
                    {
                        yDashForce = (vAxis > .1f) ? 1f : -1f;
                    }

                    float xDashForce = 0;
                    if (Mathf.Abs(hAxis) > .4f || yDashForce == 0)
                    {
                        xDashForce = (facingRight) ? 1f : -1f;
                    }

                    //if (grounded && Mathf.Abs(xDashForce) > Mathf.Abs(yDashForce))
                    //{
                    //    anim.SetBool(ANIM_ROLLING, true);
                    //}
                    if (Mathf.Abs(xDashForce) > Mathf.Abs(yDashForce))
                    {
                        anim.SetBool(ANIM_DASHING, true);
                        if (facingRight)
                        {
                            dashRightEffect.Play();
                        }
                        else
                        {
                            dashLeftEffect.Play();
                        }
                    }
                    else
                    {
                        anim.SetBool(ANIM_DASH_UPWARD, true);
                        if (yDashForce > 0)
                        {
                            dashUpEffect.Play();
                        }
                    }

                    Vector3 dashForce = new Vector2(xDashForce, yDashForce);
                    dashToward = transform.position + (dashForce * 10f);
                    //playerRigidbody2D.AddForce (dashForce, ForceMode2D.Impulse);
                }
                else if (Mathf.Abs(hAxis) > 0.3 && !wallJumping && !wallSliding && !dashing)
                {                   //checking if we are going to allow side to side force or velocity changes
                    if (grounded || //walking or running
                        (!grounded && (hAxis < 0 && playerRigidbody2D.velocity.x > 0 || hAxis > 0 && playerRigidbody2D.velocity.x < 0)))
                    {               //Changing velocity when moving along the ground or when in the air and changing direction
                        playerRigidbody2D.velocity = new Vector2(hAxis * maxSpeed, playerRigidbody2D.velocity.y);
                    }
                    else
                    { //adding force when in the air and moving in the same direction
                        playerRigidbody2D.velocity = new Vector2(hAxis * airMoveForce, playerRigidbody2D.velocity.y);
                    }
                    anim.SetFloat("Speed", Mathf.Abs(hAxis));
                }

                if (playerInput.GetButtonDown("Jump"))
                {
                    tryToJump();
                }
            }
        }
    }
コード例 #14
0
ファイル: Player.cs プロジェクト: Smcmax/RealityBleed
    void LateUpdate()
    {
        bool       leftClick           = true;
        bool       fire                = false;
        GameObject hover               = Game.m_rewiredEventSystem.GetGameObjectUnderPointer(m_playerId);
        bool       mouseOverGameObject = hover || UIItem.HeldItem;

        if (HideUIOnEvent.ObjectsHidden.Contains(hover))
        {
            mouseOverGameObject = UIItem.HeldItem;
        }
        if (UIItem.HeldItem && this == UIItem.Holder)
        {
            UIItem.HeldItem.MoveItem(m_mouse.GetPosition());
        }
        if (MenuHandler.Instance.m_openedMenus.Count > 0 || m_interactingWithNPC ||
            Time.time - m_lastNPCInteract <= 0.5f)
        {
            if (m_interactingWithNPC)
            {
                m_lastNPCInteract = Time.time;
            }
            return;
        }

        if (m_rewiredPlayer.GetButtonDown("SpawnNPC"))
        {
            Game.m_npcGenerator.GenerateRandom(1);
        }
        if (m_rewiredPlayer.GetButtonDown("SpawnEnemy"))
        {
            Game.m_enemyGenerator.Generate("TestEnemy");
        }

        if (m_rewiredPlayer.GetButton("Primary Fire"))
        {
            fire = true;
        }
        else if (m_rewiredPlayer.GetButton("Secondary Fire"))
        {
            fire = true; leftClick = false;
        }

        if (mouseOverGameObject)          // make sure we can't fire when we hover outside of ui elements when dragging items
        {
            m_wasHoldingLeftClick  = m_rewiredPlayer.GetButton("Primary Fire");
            m_wasHoldingRightClick = m_rewiredPlayer.GetButton("Secondary Fire");
        }
        else if (m_wasHoldingLeftClick || m_wasHoldingRightClick)
        {
            fire = false;
        }

        if (m_rewiredPlayer.GetButtonUp("Primary Fire"))
        {
            m_wasHoldingLeftClick = false;
        }
        if (m_rewiredPlayer.GetButtonUp("Secondary Fire"))
        {
            m_wasHoldingRightClick = false;
        }

        if (fire && !mouseOverGameObject)
        {
            Weapon weapon = m_equipment.GetWeaponHandlingClick(leftClick);
            string toFire = m_equipment.GetShotPatternHandlingClick(leftClick);

            if (weapon == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(toFire))
            {
                return;
            }

            weapon.Use(this, new string[] { weapon.m_leftClickPattern == toFire ? "true" : "false", "true" });            // using weapon in case it has specific code to execute
        }

        for (int i = 1; i <= 6; i++)
        {
            if (m_rewiredPlayer.GetButtonDown("Hotkey " + i))
            {
                AbilityWrapper wrapper = m_abilities.Find(a => a.HotkeySlot == i);

                if (wrapper != null)
                {
                    UseAbility(wrapper.AbilityName);
                }
            }
        }
    }
コード例 #15
0
ファイル: Player.cs プロジェクト: Magneseus/moonshine
    void Update()
    {
        UpdateInputs();

        // Movement
        Vector3 movement = new Vector3(input_horizontal, 0.0f, input_vertical);

        movement *= moveSpeed * Time.deltaTime;
        controller.Move(movement);

        // Setting anim params
        m_Animator.SetFloat("Speed", Math.Abs(movement.x) + Math.Abs(movement.z));

        // Looking direction
        Vector3 lookDir = new Vector3(input_look_horizontal, 0.0f, input_look_vertical);

        lookDir += controller.transform.position;
        controller.transform.LookAt(lookDir);

        // Apply gravity if falling
        if (!controller.isGrounded)
        {
            controller.Move(new Vector3(0.0f, -0.5f, 0.0f));
        }

        if (rewiredPlayer.GetButton("Interact"))
        {
            if (interactables.Count > 0)
            {
                // Find the closest interactable and interact with it
                float        minDist = float.MaxValue;
                float        dist;
                Interactable closestInteractable = null;

                foreach (Interactable interactable in interactables)
                {
                    if (interactable.gameObject == heldObject)
                    {
                        continue;
                    }

                    dist = Vector3.Distance(this.transform.position, interactable.transform.position);
                    if (dist < minDist)
                    {
                        minDist             = dist;
                        closestInteractable = interactable;
                    }
                }
                if (closestInteractable != null)
                {
                    closestInteractable.OnInteractStart(this);
                }
                //anim["Pickup"].AddMixingTransform(joint, true);
            }
        }
        else if (rewiredPlayer.GetButtonUp("Interact"))
        {
            // Dropping items
            RemoveAllInteractables();
        }

        if (rewiredPlayer.GetButtonUp("Drop"))
        {
            DropHeldObject();
        }
    }
コード例 #16
0
    void Update()
    {
        if (!pauseMenu.isPaused)
        {
            directionalInput = new Vector2(rewiredPlayer.GetAxisRaw("Move Horizontal"), rewiredPlayer.GetAxisRaw("Move Vertical"));
            if (directionalInput.x > 0.05f)
            {
                directionalInput.x = 1;
            }
            else if (directionalInput.x < -0.05f)
            {
                directionalInput.x = -1;
            }
            else
            {
                directionalInput.x = 0;
            }

            //if (directionalInput.x != 0 || directionalInput.y != 0)
            //{
            //    EventManager.Instance.PostNotification(EVENT_TYPE.MOVE, this, directionalInput);
            //}
            movementController.SetDirectionalInput(directionalInput);

            if (rewiredPlayer.GetButtonDown("Jump"))
            {
                //Checking for these collision parameters here because we don't want to keep send the jump command in the air, as it resets preJump
                if (controller.collisions.below || controller.collisions.wallSliding)
                {
                    MessageKit.post(EventTypes.JUMP_INPUT_DOWN);
                }
            }

            if (rewiredPlayer.GetButtonUp("Jump"))
            {
                MessageKit.post(EventTypes.JUMP_INPUT_UP);
            }

            if (rewiredPlayer.GetButtonDown("Attack"))
            {
                if (teleportAttack != null &&
                    !animatorController.animationStates.isAttacking &&
                    !animatorController.animationStates.isWallSliding &&
                    !animatorController.animationStates.isHurt)
                {
                    if (!standardAttack.cooldown.active)
                    {
                        if (controller.collisions.below)
                        {
                            standardAttack.cooldown.StartCooldown();
                            MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.GroundedAttack1Animation, PlayerAnimationParameters.GroundedAttack1Parameter);
                        }
                        else
                        {
                            standardAttack.cooldown.StartCooldown();
                            MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.AirAttack1Animation, PlayerAnimationParameters.AirAttack1Parameter);
                        }
                    }
                    else
                    {
                        MessageKit <string> .post(EventTypes.UI_ELEMENT_SHAKE_1P, "Energy_Portrait");
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.R))
            {
                if (controller.collisions.below)
                {
                    MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.GroundedAttack2Animation, PlayerAnimationParameters.GroundedAttack2Parameter);
                }
                else
                {
                    MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.AirAttack2Animation, PlayerAnimationParameters.AirAttack2Parameter);
                }
            }

            if (Input.GetKeyDown(KeyCode.T))
            {
                if (controller.collisions.below)
                {
                    MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.GroundedAttack3Animation, PlayerAnimationParameters.GroundedAttack3Parameter);
                }
                else
                {
                    MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.AirAttack3Animation, PlayerAnimationParameters.AirAttack3Parameter);
                }
            }

            if (rewiredPlayer.GetButtonDown("Teleport Attack"))
            {
                if (teleportAttack != null &&
                    !animatorController.animationStates.isAttacking &&
                    !animatorController.animationStates.isWallSliding &&
                    !animatorController.animationStates.isHurt)
                {
                    if (!teleportAttack.cooldown.active)
                    {
                        teleportAttack.faceDirectionSnapshot = (animatorController.facingRight) ? 1 : -1;
                        if (controller.collisions.below)
                        {
                            teleportAttack.cooldown.StartCooldown();
                            MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.GroundedTeleportAttackAnimation, PlayerAnimationParameters.GroundedTeleportAttackParameter);
                        }
                        else
                        {
                            teleportAttack.cooldown.StartCooldown();
                            MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.AirTeleportAttackAnimation, PlayerAnimationParameters.AirTeleportAttackParameter);
                        }
                    }
                    else
                    {
                        MessageKit <string> .post(EventTypes.UI_ELEMENT_SHAKE_1P, "Teleport_Icon");
                    }
                }
            }
        }

        if (rewiredPlayer.GetButtonDown("Pause") || rewiredPlayer.GetButtonDown("UIPause"))
        {
            MessageKit.post(EventTypes.UI_PAUSE_MENU);
        }

        //if (Input.GetKeyDown(KeyCode.R))
        //{
        //    attackParameters[0] = "Player_Attack_Heavy";
        //    attackParameters[1] = "IsHeavyAttack";
        //    MessageKit<string[]>.post(EventTypes.ATTACK_INPUT_DOWN_1P, attackParameters);
        //}
    }
コード例 #17
0
 public bool GetButtonUp(string name)
 {
     return(Enabled ? playerInput.GetButtonUp(name) : false);
 }
コード例 #18
0
        public void GetRuns()
        {
            if (GameOptions.GetDancepadMode())
            {
                if ((rwPlayer.GetButtonDown("RunL") || rwPlayer.GetButtonDown("RunR")) && _currentFunds >= costOfMove && pc.IsGrounded())
                {
                    SetCurrentFunds(_currentFunds - costOfMove);
                    Vector2 f = dp_moveForce * Mathf.Clamp((moveForceDegenerationFactor - (CurrentVelocity / pc.CurrentMaxSpeed)), 0.0f, moveForceDegenerationFactor);
                    pc.Propel(f);
                }

                if ((!rwPlayer.GetButton("RunL") && !rwPlayer.GetButton("RunR")) && hadFootDownLastFrame)
                {
                    pc.Jump();
                }

                if (rwPlayer.GetButton("RunL") || rwPlayer.GetButton("RunR"))
                {
                    hadFootDownLastFrame = true;
                }
                else
                {
                    hadFootDownLastFrame = false;
                }

                if (rwPlayer.GetButtonDown("Slide") && hadFootDownLastFrame)
                {
                    sliding = true;
                    animator.SetBool("sliding", sliding);
                }
                else if (rwPlayer.GetButtonUp("Slide"))
                {
                    sliding = false;
                    animator.SetBool("sliding", sliding);
                }
            }
            else
            {
                if ((rwPlayer.GetButtonDown("RunL") || rwPlayer.GetButtonDown("RunR")) && _currentFunds >= costOfMove && pc.IsGrounded())
                {
                    SetCurrentFunds(_currentFunds - costOfMove);
                    Vector2 f = dp_moveForce * Mathf.Clamp((moveForceDegenerationFactor - (CurrentVelocity / pc.CurrentMaxSpeed)), 0.0f, moveForceDegenerationFactor);
                    pc.Propel(f);
                }
                if (rwPlayer.GetButtonDown("Jump"))
                {
                    pc.Jump();
                }

                if (rwPlayer.GetButtonDown("Slide"))
                {
                    sliding = true;
                    animator.SetBool("sliding", sliding);
                }
                else if (rwPlayer.GetButtonUp("Slide"))
                {
                    sliding = false;
                    animator.SetBool("sliding", sliding);
                }
            }
        }