示例#1
0
    // Update is called once per frame
    void Update()
    {
        // Play purchase animation
        if (playerPurchasing)
        {
            RemoveAllFromCart();
            _animator.setAnimation(_purchase);
            purchaseAnimation = true;
            playerPurchasing  = false;
        }
        // Play idle animation
        else if (!purchaseAnimation || timer > purchaseAnimuLimit)
        {
            _animator.setAnimation(_idle);
            purchaseAnimation = false;
            playerPurchasing  = false;
            timer             = 0;
        }
        // increase timer for switch.
        else
        {
            timer += Time.deltaTime;
        }

        player.ShowTimer();

        BombCount.text          = cart.GetNumOfSpecificItem(TheBrain.ItemTypes.Bomb).ToString();
        InvincibilityCount.text = cart.GetNumOfSpecificItem(TheBrain.ItemTypes.Invincible).ToString();

        BombPricing.text          = (10 * cart.GetNumOfSpecificItem(TheBrain.ItemTypes.Bomb)).ToString();
        InvincibilityPricing.text = (10 * cart.GetNumOfSpecificItem(TheBrain.ItemTypes.Invincible)).ToString();

        TotalCount.text   = cart.GetTotalSizeOfCart().ToString();
        TotalPricing.text = player.BankAccount.TotalWithdrawalAmount.ToString();
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        Vector2 velocity = player.velocity;

        if (Input.GetAxis("Horizontal") < 0)
        {
            velocity.x = -walkSpeed;
            if (!Input.GetButton("Vertical"))
            {
                animate.setAnimation("WalkLeft");
            }
        }
        else if (Input.GetAxis("Horizontal") > 0)
        {
            velocity.x = walkSpeed;
            if (!Input.GetButton("Vertical"))
            {
                animate.setAnimation("WalkRight");
            }
        }
        if (Input.GetAxis("Vertical") > 0)
        {
            velocity.y = walkSpeed;
            animate.setAnimation("WalkUp");
        }
        else if (Input.GetAxis("Vertical") < 0)
        {
            velocity.y = -walkSpeed;
            animate.setAnimation("WalkDown");
        }
        velocity.x *= 0.85f;
        velocity.y *= 0.85f;
        player.Move(velocity * Time.deltaTime);
    }
示例#3
0
    void Start()
    {
        rockScript = gameObject.GetComponent <RockScript>();
        animator   = gameObject.GetComponent <AnimationController2D>();
        rb2d       = GetComponent <Rigidbody2D>();
        sizeX      = transform.localScale.x;
        hasShot    = false;
        switch (shotType)
        {
        case "air":
            animator.setAnimation("mostlyBlank");
            break;

        case "water":
            animator.setAnimation("waterIdle");
            break;

        case "fire":
            animator.setAnimation("fireIdle");
            break;

        case "plasma":
            animator.setAnimation("plasmaIdle");
            break;
        }
    }
示例#4
0
    // Update is called once per frame
    void FixedUpdate()
    {
        Vector2 velocity = player.velocity;

        if (Input.GetAxis("Horizontal") < 0)
        {
            velocity.x = -walkSpeed;
            if (!Input.GetButton("Vertical"))
            {
                animate.setAnimation("WalkLeft");
                direction = 1;
            }
        }
        else if (Input.GetAxis("Horizontal") > 0)
        {
            velocity.x = walkSpeed;
            if (!Input.GetButton("Vertical"))
            {
                animate.setAnimation("WalkRight");
                direction = 3;
            }
        }
        if (Input.GetAxis("Vertical") > 0)
        {
            velocity.y = walkSpeed;
            animate.setAnimation("WalkUp");
            direction = 2;
        }
        else if (Input.GetAxis("Vertical") < 0)
        {
            velocity.y = -walkSpeed;
            animate.setAnimation("WalkDown");
            direction = 0;
        }
        velocity.x *= 0.6f;
        velocity.y *= 0.6f;
        if (velocity.x < 2 && velocity.y < 2 && velocity.x > -2 && velocity.y > -2)
        {
            switch (direction)
            {
            case 0:
                animate.setAnimation("IdleDown");
                break;

            case 1:
                animate.setAnimation("IdleLeft");
                break;

            case 2:
                animate.setAnimation("IdleUp");
                break;

            case 3:
                animate.setAnimation("IdleRight");
                break;
            }
        }
        player.velocity = velocity;
    }
示例#5
0
 // Update is called once per frame
 void Update()
 {
     _boomTimer += Time.deltaTime;
     if (_boomTimer >= _bombTime)
     {
         _animator.setAnimation("BombExplode");
         if (_blastingZone.radius < _explosionRadius)
         {
             _blastingZone.radius += 0.05f;
         }
         else if (!_finishedExploding)
         {
             GetComponent <CircleCollider2D>().enabled = false;
             _finishedExploding = true;
         }
         if (_boomTimer >= _animationTimer)
         {
             Destroy(parent);
             Destroy(gameObject);
             _player._bombsPlaced--;
         }
         if (explosionTriggered == false)
         {
             // Why do this? If the bomb is falling while it explodes,
             //  we don't want it to keep falling. This will have it freeze
             //  wherever it exploded.
             Rigidbody2D      parentPhysics  = parent.GetComponent <Rigidbody2D>();
             CircleCollider2D parentCollider = parent.GetComponent <CircleCollider2D>();
             parentCollider.enabled = false;
             parentPhysics.bodyType = RigidbodyType2D.Static;
             explosionTriggered     = true;
             _source.PlayOneShot(_bombExplode, _bombExplodeVolume);
         }
     }
 }
    void OnTriggerEnter2D(Collider2D collider)
    {
        InventoryScript       playerInventory = collider.gameObject.GetComponent <InventoryScript> ();
        AnimationController2D animator        = door.GetComponent <AnimationController2D> ();

        if (playerInventory != null && door != null)
        {
            foreach (string keycard in playerInventory.inventory)
            {
                if (keycard.Equals(KeyToOpen))
                {
                    rend.color = Green;
                    if (animator != null)
                    {
                        animator.setAnimation("door open");
                    }
                    if (DoorOpen != null)
                    {
                        if (!played)
                        {
                            DoorOpen.Play();
                            played = true;
                        }
                    }
                    door.layer = LayerMask.NameToLayer("Default");
                }
            }
        }
    }
示例#7
0
 public void CreateShot(PlayerController player)
 {
     if (cooldown <= 0)
     {
         cooldown = cooldownRate;
         if (fountainType.Equals("plasma"))
         {
             var shot = Instantiate(shotPrefab) as Transform;
             shot.position = transform.position;
             PlayerWeaponScript shotScript = shot.gameObject.GetComponent <PlayerWeaponScript>();
             player.weapon     = shotScript;
             shotScript.caster = player;
             shotScript.MoveToCaster();
         }
         if (fountainType.Equals("fire"))
         {
             var shot1 = Instantiate(shotPrefab) as Transform;
             var shot2 = Instantiate(shotPrefab) as Transform;
             var shot3 = Instantiate(shotPrefab) as Transform;
             shot1.position = shot2.position = shot3.position = transform.position;
             PlayerWeaponScript shotScript1 = shot1.gameObject.GetComponent <PlayerWeaponScript>();
             PlayerWeaponScript shotScript2 = shot2.gameObject.GetComponent <PlayerWeaponScript>();
             PlayerWeaponScript shotScript3 = shot3.gameObject.GetComponent <PlayerWeaponScript>();
             player.weapon = shotScript1;
             player.weapons.Push(shotScript2);
             player.weapons.Push(shotScript3);
             shotScript1.caster = shotScript2.caster = shotScript3.caster = player;
             //shotScript1.caster = player;
             //shotScript2.caster = player;
             //shotScript3.caster = player;
             shotScript1.MoveToCaster();
             shotScript2.MoveToCaster();
             shotScript3.MoveToCaster();
         }
         else if (fountainType.Equals("water"))
         {
             var shot = Instantiate(shotPrefab) as Transform;
             shot.position = transform.position;
             PlayerWeaponScript shotScript = shot.gameObject.GetComponent <PlayerWeaponScript>();
             player.weapon     = shotScript;
             shotScript.caster = player;
             shotScript.MoveToCaster();
             if (player.burning)
             {
                 player.burning = false;
                 Transform      burnParticles       = player.transform.GetChild(0);
                 ParticleSystem nbaJamOnFireEdition = burnParticles.GetComponent <ParticleSystem>();
                 nbaJamOnFireEdition.Stop();
                 Destroy(shotScript.gameObject);
             }
         }
         Transform      particles = transform.GetChild(0);
         ParticleSystem p         = particles.GetComponent <ParticleSystem>();
         p.Stop();
         AnimationController2D anim = GetComponent <AnimationController2D>();
         anim.setAnimation(fountainType + "Despawn");
     }
 }
示例#8
0
    // 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);
    }
示例#9
0
    // runs every frame
    void Update()
    {
        if (_isDying)
        {
            _deathTimer += Time.deltaTime;
            if (_deathTimer > _deathTime)
            {
                _levelManager.RemoveKeyEnemy();

                Instantiate(_crowHead, transform.position, Quaternion.identity);
                moneySpawn.DropMoney(this.transform.position);

                Destroy(this.gameObject);
            }
        }
        else if (isIdle && _invisibleTime < _timer - Time.deltaTime)
        {
            _timer = 0;
            _animator.setAnimation(_idleAnimation);
            isIdle         = false;
            gameObject.tag = "Crow";
            //_collider.enabled = true;
            _source.Play();
        }
        else if (!isIdle && _idleTime < _timer - Time.deltaTime)
        {
            _timer = 0;
            _animator.setAnimation(_invinsibleAnimation);
            isIdle         = true;
            gameObject.tag = "Enemy";
            _source.Stop();
            _source.PlayOneShot(_crowInvincible, _crowInvincibleVolume);
            //_collider.enabled = false;
        }

        _timer += Time.deltaTime;
    }
示例#10
0
 void Update()
 {
     if (player != null && (ZeroGArea != null && canSwitch))
     {
         if (Input.GetButtonDown("Button Press"))
         {
             if (ZeroGArea.layer == 0)
             {
                 ZeroGArea.layer = LayerMask.NameToLayer("Trigger");
                 anim.setAnimation("Zero G off to on");
             }
             else if (ZeroGArea.layer == 10)
             {
                 anim.setAnimation("zero g on to off");
                 ZeroGArea.layer = LayerMask.NameToLayer("Default");
             }
         }
     }
     else if (hookshot != null && (ZeroGArea != null && canSwitch))
     {
         if (hookshot.transform.parent == null || hookshot.transform.parent == this.gameObject)
         {
             if (ZeroGArea.layer == 0)
             {
                 anim.setAnimation("Zero G off to on");
                 ZeroGArea.layer = LayerMask.NameToLayer("Trigger");
                 canSwitch       = false;
             }
             else if (ZeroGArea.layer == 10)
             {
                 anim.setAnimation("zero g on to off");
                 ZeroGArea.layer = LayerMask.NameToLayer("Default");
                 canSwitch       = false;
             }
         }
     }
 }
示例#11
0
 void Update()
 {
     if (cooldown > 0)
     {
         cooldown -= Time.deltaTime;
         if (cooldown <= 0)
         {
             Transform      particles = transform.GetChild(0);
             ParticleSystem p         = particles.GetComponent <ParticleSystem>();
             p.Play();
             AnimationController2D anim = GetComponent <AnimationController2D>();
             anim.setAnimation(fountainType + "Norm");
         }
     }
 }
    void Start()
    {
        shield      = GameObject.FindGameObjectWithTag("Shield");
        sword       = GameObject.FindGameObjectWithTag("Sword");
        coll        = GameObject.FindGameObjectWithTag("Player").GetComponent <BoxCollider2D> ();
        enemy       = GameObject.FindGameObjectWithTag("Enemy").GetComponent <BoxCollider2D> ();
        _controller = gameObject.GetComponent <CharacterController2D>();
        _animator   = gameObject.GetComponent <AnimationController2D>();

        gameCamera.GetComponent <CameraFollow2D> ().startCameraFollow(this.gameObject);
        winPanel.SetActive(false);
        gameOverPanel.SetActive(false);
        pausePanel.SetActive(false);
        currHealth = health;
        _animator.setAnimation("Fall");
    }
示例#13
0
    // 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);
        }
    }
    void Update()
    {
        if (playerControl)
        {
            Vector3 velocity = PlayerInput();
            _controller.move(velocity * Time.deltaTime);
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            pause = !pause;
            if (pause)
            {
                Time.timeScale = 0;
                pausePanel.SetActive(true);
                playerControl = false;
                _animator.setAnimation("Idle");
            }
            else
            {
                Time.timeScale = 1;
                pausePanel.SetActive(false);
                playerControl = true;
            }
        }
    }
示例#15
0
    private void StandardMovement()
    {
        Vector3 velocity = Controller.velocity;

        velocity.x = 0;

        if ((weapon.transform.eulerAngles.z < 90 && weapon.transform.eulerAngles.z >= 0) || (weapon.transform.eulerAngles.z <= 360 && weapon.transform.eulerAngles.z > 270))
        {
            directionAiming = "Right";
        }
        else
        {
            directionAiming = "Left";
        }

        if (directionAiming == "Right")
        {
            weapon.localScale           = new Vector3(1, 1, weapon.localScale.z);
            weaponRenderer.sortingOrder = -1;
        }
        else
        {
            weapon.localScale           = new Vector3(1, -1, weapon.localScale.z);
            weaponRenderer.sortingOrder = 1;
        }

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

            if (Controller.isGrounded)
            {
                if (directionAiming == "Left")
                {
                    Animator.setAnimation("Walk_Left");
                    weapon.position = new Vector3(this.gameObject.transform.position.x - 0.02f, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
                else
                {
                    Animator.setAnimation("Walk_Right_Reverse");
                    weapon.position = new Vector3(this.gameObject.transform.position.x + 0.04f, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
            }
            else
            {
                if (directionAiming == "Left")
                {
                    Animator.setAnimation("Jump_Left");
                    weapon.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
                else
                {
                    Animator.setAnimation("Jump_Right");
                    weapon.position = new Vector3(this.gameObject.transform.position.x + 0.04f, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
            }
        }
        //Moving Right
        else if (Input.GetAxis("Horizontal") > 0)
        {
            velocity.x = walkSpeed;

            if (Controller.isGrounded)
            {
                if (directionAiming == "Left")
                {
                    Animator.setAnimation("Walk_Left_Reverse");
                    weapon.position = new Vector3(this.gameObject.transform.position.x - 0.02f, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
                else
                {
                    Animator.setAnimation("Walk_Right");
                    weapon.position = new Vector3(this.gameObject.transform.position.x + 0.04f, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
            }
            else
            {
                if (directionAiming == "Left")
                {
                    Animator.setAnimation("Jump_Left");
                    weapon.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
                else
                {
                    Animator.setAnimation("Jump_Right");
                    weapon.position = new Vector3(this.gameObject.transform.position.x + 0.04f, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
            }
        }
        //Standing Still
        else
        {
            if (Controller.isGrounded)
            {
                if (directionAiming == "Left")
                {
                    Animator.setAnimation("Idle Left");
                    weapon.position = new Vector3(this.gameObject.transform.position.x + 0.03f, this.gameObject.transform.position.y - 0.02f, this.gameObject.transform.position.z);
                }
                else
                {
                    Animator.setAnimation("NewIdle");
                    weapon.position = new Vector3(this.gameObject.transform.position.x - 0.045f, this.gameObject.transform.position.y + 0.028f, this.gameObject.transform.position.z);
                }
            }
            else
            {
                if (directionAiming == "Left")
                {
                    Animator.setAnimation("Jump_Left");
                    weapon.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
                else
                {
                    Animator.setAnimation("Jump_Right");
                    weapon.position = new Vector3(this.gameObject.transform.position.x + 0.04f, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
                }
            }
        }

        if (Input.GetKeyDown("space") && Controller.isGrounded)
        {
            velocity.y = Jump(velocity);
        }

        if (Input.GetAxis("Vertical") < 0 && hookLatched)
        {
            velocity.y = walkSpeed * -0.5f;
        }

        if (Input.GetAxis("Vertical") > 0 && hookLatched)
        {
            velocity.y = walkSpeed * 0.5f;
        }

        if (hookLatched)
        {
            HookMovement();
            Controller.move(velocity * Time.deltaTime * hookMoveResist);
        }
        else
        {
            velocity.y += gravity * Time.deltaTime;
            Controller.move(velocity * Time.deltaTime);
        }
    }
示例#16
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);
            }
        }
    }
示例#17
0
    void Update()
    {
        if (!rock)
        {
            // Regular weapons
            if (caster != null)
            {
                // Weapon is following player
                if (!fire)
                {
                    if (caster.faceRight)
                    {
                        direction.x = 1;
                    }
                    else
                    {
                        direction.x = -1;
                    }
                    float   inputX = MultiInput.GetAxis("RightJoystickX", "", caster.name);
                    float   inputY = MultiInput.GetAxis("RightJoystickY", "", caster.name);
                    float   z      = -(Mathf.Atan2(inputY, inputX) * 57.2958f);
                    Vector2 mag    = new Vector2(inputX, inputY);
                    if (mag.magnitude < 0.15f)
                    {
                        inputX = 0;
                        inputY = 0;
                    }

                    float X = caster.transform.position.x - this.transform.position.x + inputX;
                    float Y = caster.transform.position.y - this.transform.position.y - inputY;
                    float Z = (Mathf.Atan2(Y, X) * 57.2958f);

                    if ((X > 0.1 || X < -0.1) || (Y > 0.1 || Y < -0.1))
                    {
                        aim = true;
                        if (shotType.Equals("water"))
                        {
                            if (mag.magnitude >= 0.5)
                            {
                                gameObject.transform.rotation = Quaternion.Euler(0, 0, z);
                            }
                            else
                            {
                                gameObject.transform.rotation = Quaternion.Euler(0, 0, Z);
                            }
                        }
                        atCaster = false;
                        Vector3 movement = new Vector3((speed.x / 2) * X, (speed.y / 2) * Y, 0);
                        movement *= Time.deltaTime;
                        transform.Translate(movement, Space.World);
                    }

                    else
                    {
                        aim      = false;
                        hasShot  = true;
                        atCaster = true;
                        if (!caster.faceRight)
                        {
                            //transform.rotation = Quaternion.Euler(180, 0, 180);
                        }
                    }
                }
            }

            if (connected)
            {
                if (shotType.Equals("fire"))
                {
                    animator.setAnimation("Fireball Explosion");
                    speed.x = -speed.x;
                    speed.y = -speed.y;
                    if (transform.localScale.x < (3 * sizeX))
                    {
                        transform.localScale = new Vector3(transform.localScale.x * 1.05f, transform.localScale.y * 1.05f, 1);
                    }
                    else
                    {
                        Destroy(gameObject);
                    }
                }
                else if (shotType.Equals("plasma"))
                {
                    animator.setAnimation("Plasma Spin");
                    if (transform.localScale.x < (4 * sizeX))
                    {
                        transform.localScale = new Vector3(transform.localScale.x * 1.05f, transform.localScale.y * 1.05f, 1);
                    }
                }
                else if (shotType.Equals("air"))
                {
                    Destroy(gameObject);
                }
                else if (shotType.Equals("water"))
                {
                    animator.setAnimation("waterFreeze");
                    if (destroyCountdown >= 0)
                    {
                        destroyCountdown -= Time.deltaTime;
                    }
                    else
                    {
                        Destroy(gameObject);
                    }
                }
            }
            //else
            //{
            //    Destroy(gameObject);
            //}
        }

        // Rock
        if (rock)
        {
            if (caster != null)
            {
                //rb2d.isKinematic = true;
                if (!fire)
                {
                }

                // Shot connected
                if (connected)
                {
                    fire      = false;
                    connected = false;
                    hasShot   = false;
                    speed.x   = 20;
                    caster    = null;
                }
            }
            else
            {
                rb2d.isKinematic = false;
            }
        }
    }
示例#18
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);
    }
示例#19
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);
    }