コード例 #1
0
ファイル: Movement.cs プロジェクト: ukjolie2/gitCloud
    // Update is called once per frame
    void Update()
    {
        if (_body.isGrounded)
        {
            if (Input.GetKey(KeyCode.F))
            {
                _animator.setAnimation("Dancing");
            }
            else
            {
                _animator.setAnimation("Idle");
            }
        }
        else if (_body.velocity.y > 1)
        {
            _animator.setAnimation("JumpingUp");
        }
        else if (_body.velocity.y < 1)
        {
            _animator.setAnimation("JumpingDown");
        }

        if (Input.GetAxis("Horizontal") < 0)
        {
            _animator.setFacing("Left");
            _body.velocity.x = -walkSpeed;
        }
        else if (Input.GetAxis("Horizontal") > 0)
        {
            _animator.setFacing("Right");
            _body.velocity.x = walkSpeed;
        }
        else
        {
            _body.velocity.x = 0;
        }

        if (Input.GetAxis("Jump") > 0 && _body.isGrounded)
        {
            _body.velocity.y = Mathf.Sqrt(2f * jumpHeight * -gravity);
        }
        _body.velocity.x *= 0.85f;
        _body.velocity.y += gravity * Time.deltaTime;
        _body.move(_body.velocity * Time.deltaTime);
    }
コード例 #2
0
ファイル: PlayerController.cs プロジェクト: Eagle13559/Legacy
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.I))
        {
            brain.SetNextAvailableIncense();
            _timer.ChangeTimerBarSprite(brain.IncenseSprites[(int)brain.currIncense]);
        }

        if (Input.GetKeyDown(KeyCode.B) && debugMode)
        {
            infiniteBombs = !infiniteBombs;
        }

        if (_isInvincible)
        {
            _invincibleTimer += Time.deltaTime;
            if (_invincibleTimer > _invincibleTime)
            {
                _invincibleTimer = 0;
                _isInvincible    = false;
                _invincibilitySprite.SetActive(false);
            }
        }

        // Check to see if player has eliminated all key enemies.
        if (!shopping && _gameManager.GetNumOfKeyEnemiesAlive() <= 0)
        {
            if (_currentState != playerState.WINNING)
            {
                _animator.setAnimation(_victoryAnimation);
            }
            _currentState = playerState.WINNING;
            // Wait until the player is on the ground, all controls are blocked
            if (_controller.isGrounded)
            {
                if (_winTimer < _winTime)
                {
                    _winTimer += Time.deltaTime;
                }
                if (_winTimer >= _winTime)
                {
                    _gameManager.LevelFinished();
                    //_animator.setAnimation("ShibaFreezeFrame");
                }
                //_gameManager.LevelFinished();
            }
        }
        if (_currentState == playerState.DEAD)
        {
            _animator.setAnimation(_deadAnimation);
            if (_deathTimer < _deathTime)
            {
                _deathTimer += Time.deltaTime;
            }
            if (_deathTimer >= _deathTime)
            {
                _gameManager.GameOver();
            }
        }
        else
        {
            // The order of importance of player actions is as follows:
            //  1. Dashing (will interupt all other actions and override them)
            //  2. Attacking (can attack anytime other than when dashing)
            //  3. Jumping/Falling
            //  4. Walking
            //  Falling is checked first, then dashing, then attacking, then other
            Vector3 velocity = _controller.velocity;
            velocity.x = 0;
            // Keeps track of the amount of items the player has at this frame
            int BombTotal  = brain.playerItemCounts[TheBrain.ItemTypes.Bomb];
            int invicTotal = brain.playerItemCounts[TheBrain.ItemTypes.Invincible];

            if (!_canPlaceBomb)
            {
                _bombCooldownTimer += Time.deltaTime;
                if (_bombCooldownTimer >= _bombCooldownWaitTime)
                {
                    _canPlaceBomb = true;
                }
            }

            //private float _damageTimer = 0.2f;
            //private float _damageTime = 0f;
            // If the player is currently taking damage...
            if (_currentState == playerState.TAKINGDAMAGE)
            {
                if (!_isInvincible)
                {
                    _animator.setAnimation(_damageAnimation);
                }
                _damageTime            += Time.deltaTime;
                _playerCollider.enabled = false;
                if (_damageTime >= _damageTimer)
                {
                    _currentState           = playerState.FREE;
                    _damageTime             = 0;
                    _playerCollider.enabled = true;
                    _animator.setAnimation("ShibaIdle");
                }
                else
                {
                    velocity.y = 0;
                    velocity  -= _damageFallbackDirection * 500 * Time.deltaTime;
                    // Fall!
                    //velocity.y += gravity * Time.deltaTime;
                }
            }
            // If the player has left the ground...
            else if (!_controller.isGrounded)
            {
                _wasLanded = false;
                // ...or is falling.
                // Checking the y is important- if a player is on the rising
                //  arc of their jump they shouldn't be falling. Also if the player
                //  is aerial attacking do not switch the animation
                if (_prevY > gameObject.transform.position.y && !(_currentState == playerState.AIRATTACKING))
                {
                    _animator.setAnimation(_fallAnimation);
                }
            }
            // ...and just landed.
            if (!_wasLanded && _controller.isGrounded && _currentState != playerState.TAKINGDAMAGE)
            {
                _wasLanded    = true;
                _currentState = playerState.LANDING;
            }
            // If the player can't dash, incrememnt their cooldown timer.
            if (!_canDash)
            {
                // If they've done their time, allow the ability again
                if (dashCooldownTime + dashTime < _dashTimer)
                {
                    _canDash   = true;
                    _dashTimer = 0;
                }
                else
                {
                    _dashTimer += Time.deltaTime;
                }
            }
            // Dashing overrides all other movements (except for the player taking damage)
            if (((Input.GetKeyDown("k") && _canDash) || (_currentState == playerState.DASHING)) && _currentState != playerState.TAKINGDAMAGE && _currentState != playerState.WINNING)
            {
                // Player doesn't fall
                velocity.y = 0;
                _animator.setAnimation(_dashAnimation);
                // If the player has just begun dashing,
                //  allow them to attack.
                if (_currentState != playerState.DASHING)
                {
                    _currentState = playerState.DASHING;
                    _attackColliderController.setEnabled(true);
                    _source.PlayOneShot(_playerDash, _playerDashVolume);
                }
                // Move in the direction they are facing
                if (_isFacingRight)
                {
                    velocity.x = dashSpeed;
                }
                else
                {
                    velocity.x = dashSpeed * -1;
                }
                // Increment the timer for how long they can dash for.
                _dashTimer += Time.deltaTime;
                // Check to see if they are finished dashing.
                if (_dashTimer > dashTime)
                {
                    _currentState = playerState.FREE;
                    _canDash      = false;
                    _animator.setAnimation(_idleAnimation);
                }
            }

            // Only perform other checks if not dashing or attacking
            else if (_currentState != playerState.TAKINGDAMAGE)
            {
                if (_currentState == playerState.ATTACKING || _currentState == playerState.AIRATTACKING)
                {
                    // attackAnimationTimer is how long they are in an attack state
                    _attackTimer += Time.deltaTime;
                    // Check to see if they are finished
                    if (_attackTimer > attackAnimationTimer)
                    {
                        _currentState = playerState.FREE;
                        _attackTimer  = 0;
                    }
                    if (_currentState == playerState.ATTACKING)
                    {
                        return;
                    }
                }
                // If walking left
                if (Input.GetAxis("Horizontal") < 0 && _currentState != playerState.WINNING)
                {
                    velocity.x = walkSpeed * -1;
                    _animator.setFacing("Left");
                    if (_controller.isGrounded)
                    {
                        _animator.setAnimation(_walkAnimation);
                    }
                    _isFacingRight = false;
                }
                // If walking right
                else if (Input.GetAxis("Horizontal") > 0 && _currentState != playerState.WINNING)
                {
                    velocity.x = walkSpeed;
                    _animator.setFacing("Right");
                    if (_controller.isGrounded)
                    {
                        _animator.setAnimation(_walkAnimation);
                    }
                    _isFacingRight = true;
                }
                else
                {
                    // If the player is on the ground, they either just landed
                    //  or are in an idle state
                    if (_controller.isGrounded)
                    {
                        // Idling
                        if (_currentState != playerState.LANDING)
                        {
                            _animator.setAnimation(_idleAnimation);
                        }
                        // Landing
                        else
                        {
                            _animator.setAnimation(_landAnimation);
                            _landingTimer += Time.deltaTime;
                            if (_landingTimer > _landTime)
                            {
                                _landingTimer = 0;
                                _currentState = playerState.FREE;
                            }
                        }
                    }
                }
                // If the player tries to jump, only allow it if they are grounded.
                if (Input.GetAxis("Jump") > 0 && _controller.isGrounded && _currentState != playerState.WINNING)
                {
                    if (_controller.isGrounded)
                    {
                        _source.PlayOneShot(_playerJump, _playerJumpVolume);
                    }
                    velocity.y = Mathf.Sqrt(2f * jumpHeight * -gravity);
                    _animator.setAnimation(_jumpAnimation);
                }
                // The player has initiated an attack...
                if (Input.GetKeyDown("j") && _currentState != playerState.WINNING)
                {
                    Vector2 forceVect = _isFacingRight ? new Vector2(projectileSpeed, 0) : new Vector2(-1 * projectileSpeed, 0);
                    _source.PlayOneShot(_playerAttack, _playerAttackVolume);
                    // ...perform a ground attack.
                    if (_controller.isGrounded)
                    {
                        _animator.setAnimation(_attackAnimation);
                        _projectile.ShootProjectile(forceVect, _isFacingRight);
                        _currentState = playerState.ATTACKING;
                    }
                    // ...perform an aerial attack
                    else
                    {
                        _animator.setAnimation(_attackAirAnimation);
                        _projectile.ShootProjectile(forceVect, _isFacingRight);
                        _currentState = playerState.AIRATTACKING;
                    }
                    _attackColliderController.setEnabled(true);
                }
                if (Input.GetKeyDown("l") && _bombsPlaced < 2 && (BombTotal > 0 || infiniteBombs) && _currentState != playerState.WINNING)
                {
                    if (_canPlaceBomb)
                    {
                        _canPlaceBomb = false;
                        GameObject bomb = Instantiate(_Bomb, transform.position, Quaternion.identity) as GameObject;
                        _bombsPlaced++;
                        bomb.GetComponent <Rigidbody2D>().velocity = transform.TransformDirection(transform.forward);//.AddForce(transform.forward * _bombThrust);
                        if (!infiniteBombs)
                        {
                            brain.playerItemCounts[TheBrain.ItemTypes.Bomb] = CalcNewItemCount(BombTotal);
                        }

                        //Debug.Log("Removed Bomb Ability : " + brain.playerItemCounts[TheBrain.ItemTypes.Bomb]);
                    }
                }
                if (Input.GetKeyDown(";") && _currentState != playerState.WINNING && invicTotal > 0)
                {
                    if (!_isInvincible)
                    {
                        _isInvincible = true;
                        _invincibilitySprite.SetActive(true);

                        brain.playerItemCounts[TheBrain.ItemTypes.Invincible] = CalcNewItemCount(invicTotal);
                    }
                }
                // Fall!
                velocity.y += gravity * Time.deltaTime;
            }
            // Save the y, so on the next frame we can check if the player is falling.
            _prevY = gameObject.transform.position.y;
            // Perform the move.
            _controller.move(velocity * Time.deltaTime);
        }
    }
コード例 #3
0
    private Vector3 PlayerInput()
    {
        Vector3 velocity = _controller.velocity;

        velocity.x = 0;

        #region moving platform parenting
        if (_controller.isGrounded && _controller.ground != null && (_controller.ground.tag.Equals("MovingPlatform") || _controller.ground.tag.Equals("Wind")))
        {
            this.transform.parent = _controller.ground.transform;
            if (_controller.ground.tag.Equals("Wind"))
            {
                _animator.setAnimation("Deploy");
                floatin = true;
                wind    = true;
            }
        }
        else
        {
            if (this.transform.parent != null)
            {
                this.transform.parent = null;
            }
        }
        #endregion

        #region running left/right
        // Left arrow key
        if (Input.GetAxis("Horizontal") < 0 && !shieldin && !swinging)
        {
            velocity.x = -walkSpeed;
            if (_controller.isGrounded && !floatin)
            {
                _animator.setAnimation("Walk");
                _animator.setFacing("Left");
            }
        }

        // Right arrow key
        else if (Input.GetAxis("Horizontal") > 0 && !shieldin && !swinging)
        {
            velocity.x = walkSpeed;
            if (_controller.isGrounded && !floatin)
            {
                _animator.setAnimation("Walk");
                _animator.setFacing("Right");
            }
        }
        #endregion

        #region idle
        //Idle
        else
        {
            if (_controller.isGrounded && currHealth != 0 && !shieldin && !swinging && !floatin)
            {
                _animator.setAnimation("Idle");
            }
        }
        #endregion

        #region Jump/Float
        // Space bar - Jump
        if (Input.GetKeyDown(KeyCode.Space) && !shieldin && _controller.isGrounded && !swinging && !floatin)
        {
            _animator.setAnimation("Jump");
            velocity.y = Mathf.Sqrt(2f * jumpHeight * -gravity);
        }
        else if ((Input.GetKeyDown(KeyCode.Space) && !_controller.isGrounded) || floatin)
        {
            _animator.setAnimation("Deploy");
            velocity.y = -2;
            floatin    = true;
        }
        if (_controller.isGrounded || Input.GetKeyUp(KeyCode.Space))
        {
            if (!_controller.isGrounded)
            {
                _animator.setAnimation("Fall");
                wind = false;
            }
            else
            {
                //_animator.setAnimation("Land");
            }
            if (!wind)
            {
                floatin = false;
                gravity = -35;
            }
        }

        if (!_controller.isGrounded)
        {
            wind = false;
        }
        #endregion

        #region shield
        //Shield up and down
        //if (Input.GetAxis("Fire1") > 0) {
        //	shieldin = true;
        //} else
        //	shieldin = false;

        if (Input.GetKey(KeyCode.X) && !swinging)
        {
            _animator.setAnimation("Preblock");
            shieldin = true;
            shield.SetActive(true);
        }
        else if (Input.GetKeyUp(KeyCode.X) && shieldin)
        {
            _animator.setAnimation("Unblock");
            shieldin = false;
            shield.SetActive(false);
        }
        else
        {
            shieldin = false;
            shield.SetActive(false);
        }
        #endregion

        #region sword swing
        // swing dat sword bb
        if (Input.GetKey(KeyCode.C) && !shieldin)
        {
            _animator.setAnimation("Slash");
            swinging = true;
            sword.SetActive(true);
            //Transform pos = sword.GetComponent<Transform>();
            //swordStartPos = pos.localPosition;
            //Vector3 axis = new Vector3(pos.localPosition.x, pos.localPosition.y - pos.localPosition.sqrMagnitude, 0);
            //pos.RotateAround(axis, axis, 20 * Time.deltaTime);
        }
        else
        {
            swinging = false;
            sword.SetActive(false);
        }
        #endregion

        // Change velocity.
        velocity.y += gravity * Time.deltaTime;
        return(velocity);
    }
コード例 #4
0
    private void StandardMovement()
    {
        Vector3 velocity = Controller.velocity;

        velocity.x = 0;

        if (Input.GetAxis("Horizontal") < 0)
        {
            velocity.x = walkSpeed * -1;

            if (Controller.isGrounded)
            {
                Animator.setAnimation("WalkAnimation");

                if ((weapon.transform.eulerAngles.z < 90 && weapon.transform.eulerAngles.z >= 0) || (weapon.transform.eulerAngles.z <= 360 && weapon.transform.eulerAngles.z > 270))
                {
                    Animator.setFacing("Right");
                    weapon.localScale = new Vector3(1, 1, weapon.localScale.z);
                    weapon.position   = new Vector3(this.gameObject.transform.position.x + 0.04f, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
                else
                {
                    Animator.setFacing("Left");
                    weapon.localScale = new Vector3(-1, -1, weapon.localScale.z);
                    weapon.position   = new Vector3(this.gameObject.transform.position.x - 0.04f, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
            }
        }
        else if (Input.GetAxis("Horizontal") > 0)
        {
            velocity.x = walkSpeed;

            if (Controller.isGrounded)
            {
                Animator.setAnimation("WalkAnimation");

                if ((weapon.transform.eulerAngles.z < 90 && weapon.transform.eulerAngles.z >= 0) || (weapon.transform.eulerAngles.z <= 360 && weapon.transform.eulerAngles.z > 270))
                {
                    Animator.setFacing("Right");
                    weapon.localScale = new Vector3(1, 1, weapon.localScale.z);
                    weapon.position   = new Vector3(this.gameObject.transform.position.x + 0.04f, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
                else
                {
                    Animator.setFacing("Left");
                    weapon.localScale = new Vector3(-1, -1, weapon.localScale.z);
                    weapon.position   = new Vector3(this.gameObject.transform.position.x - 0.04f, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
            }
        }
        else
        {
            Animator.setAnimation("NewIdle");

            if ((weapon.transform.eulerAngles.z < 90 && weapon.transform.eulerAngles.z >= 0) || (weapon.transform.eulerAngles.z <= 360 && weapon.transform.eulerAngles.z > 270))
            {
                Animator.setFacing("Right");
                weapon.localScale = new Vector3(1, 1, weapon.localScale.z);
                weapon.position   = new Vector3(this.gameObject.transform.position.x - 0.045f, this.gameObject.transform.position.y + 0.028f, this.gameObject.transform.position.z);
            }
            else
            {
                Animator.setFacing("Left");
                weapon.localScale = new Vector3(-1, -1, weapon.localScale.z);
                weapon.position   = new Vector3(this.gameObject.transform.position.x + 0.045f, this.gameObject.transform.position.y + 0.028f, this.gameObject.transform.position.z);
            }
        }

        if (Input.GetKeyDown("space") && Controller.isGrounded)
        {
            velocity.y = Mathf.Sqrt(5f * jumpHeight * -gravity);
            Animator.setAnimation("NewIdle");

            if ((weapon.transform.eulerAngles.z < 90 && weapon.transform.eulerAngles.z >= 0) || (weapon.transform.eulerAngles.z <= 360 && weapon.transform.eulerAngles.z > 270))
            {
                Animator.setFacing("Right");
                weapon.localScale = new Vector3(1, 1, weapon.localScale.z);
                weapon.position   = new Vector3(this.gameObject.transform.position.x - 0.045f, this.gameObject.transform.position.y + 0.028f, this.gameObject.transform.position.z);
            }
            else
            {
                Animator.setFacing("Left");
                weapon.localScale = new Vector3(-1, -1, weapon.localScale.z);
                weapon.position   = new Vector3(this.gameObject.transform.position.x + 0.045f, this.gameObject.transform.position.y + 0.028f, this.gameObject.transform.position.z);
            }
        }

        if (hookLatched)
        {
            HookMovement();
        }
        else
        {
            velocity.y += gravity * Time.deltaTime;
        }

        Controller.move(velocity * Time.deltaTime);
    }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        if (_dying)
        {
            _source.Stop();
            _source.PlayOneShot(_kappaDeath, _kappaDeathVolume);
            _deathTimer += Time.deltaTime;
            if (_deathTimer >= _deathTime)
            {
                Destroy(gameObject);
            }
            return;
        }

        Vector3 velocity = _controller.velocity;

        velocity.x = 0;

        // If the enemy has reached the end of the patrol point
        if (((!waiting) && (!chasePlayer) && (((this.transform.position.x > endingPatrolPoint.x) && outgoing) || ((this.transform.position.x < startingPatrolPoint.x) && !outgoing))) ||
            ((!waiting) && chasePlayer && (((this.transform.position.x > maxChasePoint.x) && outgoing) || ((this.transform.position.x < minChasePoint.x) && !outgoing))))
        {
            waiting = true;
            _source.Stop();
        }

        if (timer > turnTime)
        {
            outgoing = !outgoing;
            waiting  = false;
            _source.Play();
            timer = 0;
        }
        // This code fires when the character is about to begin moving
        else if (timer > rovingPauseTime)
        {
            _animator.setAnimation(anim_turn);
            timer += Time.deltaTime;
        }
        // This is when the enemy has reached the end of the patrol
        else if (waiting)
        {
            _animator.setAnimation(anim_idle);
            timer += Time.deltaTime;
        }
        // Handle all variations of movement
        if (!waiting)
        {
            _animator.setAnimation(anim_walk);
            if (outgoing)
            {
                _animator.setFacing("Right");
                if (!chasePlayer)
                {
                    velocity.x = walkSpeed;
                }
                else
                {
                    //_animator.setAnimation(anim_run);
                    velocity.x = runSpeed;
                }
            }
            else
            {
                _animator.setFacing("Left");
                if (!chasePlayer)
                {
                    //_animator.setAnimation(anim_walk);
                    velocity.x = walkSpeed * -1;
                }
                else
                {
                    //_animator.setAnimation(anim_run);
                    velocity.x = runSpeed * -1;
                }
            }
        }

        if (!_controller.isGrounded)
        {
            velocity.y += gravity * Time.deltaTime;
        }
        _controller.move(velocity * Time.deltaTime);
    }
コード例 #6
0
    // Update is called once per frame
    void Update()
    {
        if (!dead)
        {
            if (hitAnim > 0)
            {
                colorChange.color = new Color(150, 0, 0);
                hitAnim          -= Time.deltaTime;
            }
            else
            {
                colorChange.color = baseColor;
            }
            Debug.Log("AirPushVelocity = " + AirPushVelocity);
            if (airCooldown > 0 && weapon == null)
            {
                airCooldown -= Time.deltaTime;
            }
            if (airCooldown <= 0 && weapon == null && !(weapons.Count > 0))
            {
                var shot = Instantiate(defaultShot) as Transform;
                shot.position = transform.position;
                PlayerWeaponScript shotScript = shot.gameObject.GetComponent <PlayerWeaponScript>();
                weapon            = shotScript;
                shotScript.caster = this;
                shotScript.MoveToCaster();
            }
            if (fireCooldown > 0)
            {
                fireCooldown -= Time.deltaTime;
            }

            if (burning)
            {
                burnDown -= Time.deltaTime;
                if (burnDown <= 0f)
                {
                    health.ManualDamage(health.hp, "fire");
                }
            }

            Vector3 velocity = _controller.velocity;
            if (_controller.isGrounded && _controller.ground != null && _controller.ground.tag == "MovingPlatform")
            {
                this.transform.parent = _controller.ground.transform;
            }
            else
            {
                if (this.transform.parent != null)
                {
                    this.transform.parent = null;
                }
            }

            // Gravity: pull player down
            if (!Bounce)
            {
                velocity.y += gravity * Time.deltaTime;
            }

            // Player is bouncing
            else if (Bounce)
            {
                if (velocity.y > 0)
                {
                    velocity.y *= 2.25f;
                }
                else if (velocity.y < 9 && velocity.y > -9)
                {
                    velocity.y = 20;
                }
                else
                {
                    velocity.y += -velocity.y * 2.25f;
                }
                if (velocity.y > maxHeight)
                {
                    velocity.y = maxHeight;
                }
                Bounce = false;
            }

            if (!frozen)
            {
                // Player is moving horizontally
                //if (MultiInput.GetAxis("Horizontal", "", name) < 0 || MultiInput.GetAxis("LeftJoystickX", "", name) < 0)
                if (MultiInput.GetAxis("LeftJoystickX", "", name) < 0)
                {
                    if (slide)
                    {
                        if (velocity.x > 0)
                        {
                            velocity.x += -walkSpeed * 0.002f;
                        }
                        else
                        {
                            velocity.x += -walkSpeed * 0.11f;
                        }
                    }
                    else if (RunLeft | RunRight)
                    {
                        RunArrows = true;
                    }
                    else if (!_controller.isGrounded)
                    {
                        velocity.x = -airSpeed;
                    }
                    else
                    {
                        velocity.x = -walkSpeed;
                    }
                    if (!_controller.isGrounded)
                    {
                        _animator.setAnimation(character + " Jump");
                    }
                    else
                    {
                        _animator.setAnimation(character + " Walk");
                    }
                    _animator.setFacing("Left");
                    faceRight = false;
                }
                //else if (MultiInput.GetAxis("Horizontal", "", name) > 0 || MultiInput.GetAxis("LeftJoystickX", "", name) > 0)
                else if (MultiInput.GetAxis("LeftJoystickX", "", name) > 0)
                {
                    if (slide)
                    {
                        if (velocity.x < 0)
                        {
                            velocity.x += walkSpeed * 0.002f;
                        }
                        else
                        {
                            velocity.x += walkSpeed * 0.11f;
                        }
                    }
                    else if (RunLeft | RunRight)
                    {
                        RunArrows = true;
                    }
                    else if (!_controller.isGrounded)
                    {
                        velocity.x = airSpeed;
                    }
                    else
                    {
                        velocity.x = walkSpeed;
                    }
                    if (!_controller.isGrounded)
                    {
                        _animator.setAnimation(character + " Jump");
                    }
                    else
                    {
                        _animator.setAnimation(character + " Walk");
                    }
                    _animator.setFacing("Right");
                    faceRight = true;
                }
                else if (!_controller.isGrounded)
                {
                    _animator.setAnimation(character + " Jump");
                }

                else
                {
                    _animator.setAnimation(character + " Idle");
                    if (slide)
                    {
                        velocity.x += velocity.x * 0.05f;
                    }
                    else if (RunArrows)
                    {
                        velocity.x += velocity.x * 3;
                    }
                    else if (pushed)
                    {
                        velocity.x += velocity.x * 1.2f;
                    }
                    else if (_controller.isGrounded)
                    {
                        velocity.x = 0;
                    }
                }
            }
            else if (frozen)
            {
                freezeWarmup -= Time.deltaTime;
                if (freezeWarmup <= 0)
                {
                    frozen     = false;
                    jumpHeight = 2;
                }
            }


            if (RunLeft || RunRight)
            {
                RunArrows = true;
            }

            if (RunArrows)
            {
                if (RunRight)
                {
                    velocity.x += RunArrowStrength;
                    velocity.y += 10;
                }
                else if (RunLeft)
                {
                    velocity.x -= RunArrowStrength;
                    velocity.y += 10;
                }
                AirControl = false;
            }

            if (pushed)
            {
                if (!faceRight)
                {
                    Debug.Log("AirPushVelocity = " + AirPushVelocity);
                    velocity.x += AirPushVelocity;
                    velocity.y += 3;
                }
                else if (faceRight)
                {
                    Debug.Log("AirPushVelocity = " + AirPushVelocity);
                    velocity.x -= AirPushVelocity;
                    velocity.y += 3;
                }
                pushed  = false;
                hitAnim = hitAnimTime;
            }

            //if ((MultiInput.GetAxis("Vertical", "", name) < 0 || MultiInput.GetAxis("LeftJoystickY", "", name) > 0) && !_controller.isGrounded)
            if (MultiInput.GetButton("LeftBumper", "", name) && !_controller.isGrounded)
            {
                velocity.y += gravity * Time.deltaTime * 3;
            }
            velocity.x *= 0.85f;

            if (!_controller.isGrounded && !doubleJumped)
            {
                doubleJump = true;
            }

            if (_controller.isGrounded)
            {
                doubleJumped = false;
                doubleJump   = false;
            }

            // Double jump
            //if (!doubleJumped && doubleJump && (MultiInput.GetButtonDown("Jump", "", name) || MultiInput.GetButtonDown("A", "", name)
            //    || MultiInput.GetButtonDown("LeftBumper", "", name)))
            if (!doubleJumped && doubleJump && (MultiInput.GetButtonDown("A", "", name) ||
                                                MultiInput.GetButtonDown("LeftBumper", "", name)))
            {
                velocity.y   = 0;
                velocity.y   = Mathf.Sqrt(2f * jumpHeight * -gravity);
                doubleJump   = false;
                doubleJumped = true;
                Transform      djParticle = transform.GetChild(1);
                ParticleSystem dj         = djParticle.GetComponent <ParticleSystem>();
                dj.Play();
            }

            // First jump
            //else if ((MultiInput.GetButtonDown("Jump", "", name) || MultiInput.GetButtonDown("A", "", name)
            //    || MultiInput.GetButtonDown("LeftBumper", "", name)) && _controller.isGrounded)
            else if ((MultiInput.GetButtonDown("A", "", name) ||
                      MultiInput.GetButtonDown("LeftBumper", "", name)) && _controller.isGrounded)
            {
                audioPlayer.PlayOneShot(sounds.Jump);
                velocity.y   = Mathf.Sqrt(2f * jumpHeight * -gravity);
                doubleJump   = true;
                doubleJumped = false;
            }
            pushed     = false;
            colorTimer = true;


            _controller.move(velocity * Time.deltaTime);
            RunArrows = false;

            if (_controller.isGrounded)
            {
                AirControl = true;
            }


            //float inputX = MultiInput.GetAxis("Horizontal", "", name);
            float inputX = MultiInput.GetAxis("LeftJoystickX", "", name);
            //float inputY = MultiInput.GetAxis("Vertical", "", name);
            float inputY = MultiInput.GetAxis("LeftJoystickY", "", name);

            float aimX = MultiInput.GetAxis("RightJoystickX", "", name);
            float aimY = MultiInput.GetAxis("RightJoystickY", "", name);

            //bool shoot = Input.GetButtonDown("Shoot_P1");
            //bool shoot = MultiInput.GetButtonDown("Shoot", "", name);
            bool shoot = MultiInput.GetButton("RightBumper", "", name);
            //bool grab = MultiInput.GetButtonDown("Grab","",name);

            float grab = MultiInput.GetAxis("X", "", name);

            if (shoot && fireCooldown <= 0)
            {
                fireCooldown = fireRate;
                if (weapon != null && weapon.hasShot)
                {
                    if (weapon.rock)
                    {
                        weapon.gameObject.GetComponent <Rigidbody2D>().gravityScale = 6;
                    }
                    if (weapon.shotType.Equals("air") && airCooldown <= 0)
                    {
                        airCooldown = airFireRate;
                        if (aimX != 0 || aimY != 0)
                        {
                            float x = aimX * 10;
                            float y = aimY * 10;
                            float z = -(Mathf.Atan2(y, x) * 57.2958f);
                            if (aimX < 0)
                            {
                                weapon.gameObject.transform.Rotate(180, 0, -z, Space.Self);
                            }
                            else
                            {
                                weapon.gameObject.transform.Rotate(0, 0, z, Space.Self);
                            }
                            weapon.Attack(aimX, aimY);
                        }
                        else
                        {
                            if (faceRight)
                            {
                                weapon.Attack(1, 0);
                            }
                            else
                            {
                                weapon.gameObject.transform.Rotate(180, 0, 180, Space.Self);
                                weapon.Attack(-1, 0);
                            }
                        }
                        weapon = null;
                    }
                    else
                    {
                        if (aimX != 0 || aimY != 0)
                        {
                            float x = aimX * 10;
                            float y = aimY * 10;
                            float z = -(Mathf.Atan2(y, x) * 57.2958f);
                            weapon.Attack(aimX, aimY);
                            Debug.Log("this is happening");
                        }
                        else
                        {
                            if (faceRight)
                            {
                                weapon.Attack(1, 0);
                            }
                            else
                            {
                                weapon.Attack(-1, 0);
                            }
                        }
                        // Post weapon firing
                        if (weapons.Count > 0)
                        {
                            weapon = (PlayerWeaponScript)weapons.Pop();
                        }
                        else
                        {
                            weapon = null;
                        }
                    }
                }
                airCooldown += 0.75f;
            }
            if (grab > 0)
            {
                if (nearRock)
                {
                    if (weapon != null && weapon.shotType.Equals("air"))
                    {
                        Destroy(weapon.gameObject);
                    }
                    while (weapons.Count > 0)
                    {
                        weapon = (PlayerWeaponScript)weapons.Pop();
                        Destroy(weapon.gameObject);
                    }
                    weapon = rock.gameObject.GetComponentInParent <PlayerWeaponScript>();
                    //weapon.rockScript.player = this;
                    weapon.caster = this;
                    weapon.gameObject.GetComponent <Rigidbody2D>().gravityScale = 0;
                }

                else if (inFountain)
                {
                    if (weapon != null && weapon.shotType.Equals("air") && weapons.Count == 0)
                    {
                        Destroy(weapon.gameObject);
                        fountain.CreateShot(this);
                    }
                    else if (weapon == null)
                    {
                        fountain.CreateShot(this);
                        if (weapon.shotType.Equals("water"))
                        {
                            burning = false;

                            Transform      burnParticles       = transform.GetChild(0);
                            ParticleSystem nbaJamOnFireEdition = burnParticles.GetComponent <ParticleSystem>();
                            nbaJamOnFireEdition.Stop();
                        }
                    }
                }
            }
        }
        else
        {
            if (plasmaDeath)
            {
                transform.Rotate(new Vector3(0, 0, 10));
                transform.localScale = new Vector3(transform.localScale.x * 0.95f, transform.localScale.y * 0.95f, 0f);
            }
        }
    }