Exemplo n.º 1
0
    void FixedUpdate()
    {
        if (UseTouchControls)
        {
            float moveHorizontal = CFInput.GetAxis("Horizontal");
            float moveVertical   = CFInput.GetAxis("Vertical");
            MoveShip(moveHorizontal, moveVertical);
        }

        if (!UseTouchControls)
        {
            float moveHorizontal = (Input.acceleration.x * 2);
            float moveVertical   = (Input.acceleration.y * 2);
            MoveShip(moveHorizontal - deviceHorizontal, moveVertical - deviceVertical);
        }

//		!!! Make sure to disable Keyboard control in the UI when building for mobile!!
        if (Testing)
        {
            float moveHorizontal = Input.GetAxis("Horizontal");
            float moveVertical   = Input.GetAxis("Vertical");
            MoveShip(moveHorizontal, moveVertical);
        }

        rigidbody.position = new Vector3(

            Mathf.Clamp(rigidbody.position.x, boundary.xMin, boundary.xMax),
            0.0f,
            Mathf.Clamp(rigidbody.position.z, boundary.zMin, boundary.zMax)

            );

        rigidbody.rotation = Quaternion.Euler(0.0f, 0.0f, rigidbody.velocity.x * -tilt);
    }
 // Token: 0x06000DB2 RID: 3506 RVA: 0x00057AC8 File Offset: 0x00055EC8
 private void Update()
 {
     this.target.transform.Rotate(new Vector3(0f, CFInput.GetAxis("Mouse X"), 0f) * (this.XSpeed * 100f) * Time.deltaTime);
     if (this.enableYAxis)
     {
         base.transform.Rotate(new Vector3(CFInput.GetAxis("Mouse Y"), 0f, 0f) * (this.YSpeed * 100f) * Time.deltaTime);
     }
 }
    // Token: 0x060007E2 RID: 2018 RVA: 0x00034600 File Offset: 0x00032A00
    public static float GetAxisPx(string axisName, float refResolution = 1280f, float maxDragInches = 1f)
    {
        if (CFInput.ControllerActive() && TouchController.IsSupported())
        {
            float actualDPI = CFInput.ctrl.GetActualDPI();
            float axis      = CFInput.GetAxis(axisName);
            return(axis / (actualDPI * maxDragInches) * refResolution);
        }
        int width = Screen.currentResolution.width;

        return(CFInput.GetAxis(axisName) * ((width != 0) ? (refResolution / (float)width) : 1f));
    }
    // Token: 0x06000C31 RID: 3121 RVA: 0x0004D2BC File Offset: 0x0004B6BC
    private void LateUpdate()
    {
        if (!this.target)
        {
            return;
        }
        if (!this.targetBody)
        {
            this.targetBody = this.target;
        }
        if (Time.timeScale == 0f)
        {
            return;
        }
        this.x        += CFInput.GetAxis("Mouse X") * this.xSpeed * 0.02f;
        this.y        -= CFInput.GetAxis("Mouse Y") * this.ySpeed * 0.02f;
        this.distance -= CFInput.GetAxis("Mouse ScrollWheel") * Time.deltaTime * this.zoomRate * Mathf.Abs(this.distance);
        this.distance  = Mathf.Clamp(this.distance, this.minDistance, this.maxDistance);
        this.y         = ARPGcameraC.ClampAngle(this.y, this.yMinLimit, this.yMaxLimit);
        Quaternion rotation = Quaternion.Euler(0f, this.x, 0f);

        base.transform.rotation = rotation;
        this.aim = Quaternion.Euler(0f - this.aimAngle, this.x, 0f);
        if (CFInput.GetButton("Fire1") || CFInput.GetButton("Fire2") || CFInput.GetAxis("Horizontal") != 0f || CFInput.GetAxis("Vertical") != 0f || this.lockOn)
        {
            this.targetBody.transform.rotation = Quaternion.Euler(0f, this.x, 0f);
        }
        Vector3 position = this.target.position - (rotation * Vector3.forward * this.distance + new Vector3(this.offsetX, -this.targetHeight, this.offsetZ));

        base.transform.position = position;
        Vector3 vector = this.target.transform.position - new Vector3(0f, -this.targetHeight, 0f);

        if (Physics.Linecast(vector, base.transform.position, out this.hit) && this.hit.transform.tag == "Wall")
        {
            float d = Vector3.Distance(vector, this.hit.point) - 0.28f;
            position = this.target.position - (rotation * Vector3.forward * d + new Vector3(0f, -this.targetHeight, 0f));
            base.transform.position = position;
        }
    }
Exemplo n.º 5
0
 // Token: 0x06000DB6 RID: 3510 RVA: 0x00057BB0 File Offset: 0x00055FB0
 private void Update()
 {
     if (this.target)
     {
         this.target.transform.Rotate(new Vector3(0f, CFInput.GetAxis("Mouse X"), 0f) * (this.angularSpeed * 10f) * Time.deltaTime);
         if (this.lockOn)
         {
             base.transform.localEulerAngles = this.euler;
             this.RotUpDown = -CFInput.GetAxis("Mouse Y") * (this.angularSpeed * 10f) * Time.deltaTime;
             this.euler.y   = this.euler.y + this.RotLeftRight;
             this.euler.x   = this.euler.x + this.RotUpDown;
             if (this.euler.x >= this.maxY)
             {
                 this.euler.x = this.maxY;
             }
             if (this.euler.x <= this.minY)
             {
                 this.euler.x = this.minY;
             }
         }
     }
 }
Exemplo n.º 6
0
    // Update is called once per frame.
    void Update()
    {
        // Check if the player's hitbox collides with a ladder.
        Vector2 pos    = transform.position;
        Vector2 pointA = new Vector2(pos.x + boxCollider.offset.x - (boxCollider.size.x / 2), pos.y + boxCollider.offset.y - (boxCollider.size.y / 2));
        Vector2 pointB = new Vector2(pos.x + boxCollider.offset.x + (boxCollider.size.x / 2), pos.y + boxCollider.offset.y + (boxCollider.size.y / 2));

        hitLadder = Physics2D.OverlapArea(pointA, pointB, ladderLayer);

        // If the player isn't currently on a ladder, there is a ladder collission and the player isn't falling, dashing, crouching, sliding or stuck on a wall...
        if (!player.onLadder && hitLadder && !player.falling && !player.dashing && !player.crouching && !player.sliding && !player.stuckToWall)
        {
            // ... cache the vertical CFInput.
            float v = CFInput.GetAxis("Vertical");

            // If the player isn't on a ladder and the vertical movement is either moving up or down...
            if (!player.onLadder && (v > 0.5 || v < -0.5))
            {
                // ... make sure the player is stuck to the ladder.
                Stick();
            }
        }

        // If there isn't a collission with a ladder and the player is considered on a ladder...
        if (!hitLadder && player.onLadder)
        {
            // ... make the player unstuck from the ladder.
            Unstick();
        }

        // If the player is on a ladder, there is a ladder object and the player is allowed to jump...
        if (player.onLadder && ladder && ladder.allowJump && CFInput.GetButtonDown("Jump"))
        {
            // ... unstick the player from the ladder and perform the jump.
            Unstick();
            player.Jump();
        }
    }
    // Fixed update is called in sync with physics
    private void FixedUpdate()
    {
        //				if (!m_Character.JetPackStatus) {
        float h = CFInput.GetAxis("Horizontal");
        float v = CFInput.GetAxis("Vertical");

        PlayerPrefs.SetFloat(mushroomdirection, h);
        v = 0.0f;

        //			m_Move = h * Vector3.right + v * Vector3.up;

        //0 TRUE 1 FALSE
        int backrestrict = PlayerPrefs.GetInt("BACKRESTRICT");

        //			Debug.Log ("backkkkkkkkkkk"+backrestrict);

        if (backrestrict == 1)
        {
            //				Debug.Log("h valueee" +h);
            if (h < 0.0f)
            {
                h = 0.0f;

                //m_Move = new Vector3(0,0,0);
                m_Character.Move(m_Move, false, false);
                m_Character.playerVelocityZero();
                return;
            }
        }

        if (this.ctrl != null)
        {
            int uiDisable = PlayerPrefs.GetInt("UI_DESABLE");

            if (uiDisable == 0)
            {
                Time.timeScale = 1;
                walkStick.Enable(true);
            }
            else if (uiDisable == 2)
            {
                PlayerPrefs.SetInt("walkStickStatus", 0);
                walkStick.Disable(true);
            }
            else
            {
                walkStick.Disable(true);
                PlayerPrefs.SetInt("walkStickStatus", 0);
                Time.timeScale = 0;
            }

            if (walkStick.JustPressed())
            {
                PlayerPrefs.SetInt("walkStickStatus", 1);
                //					walkStick.Disable(true);
                //					walkStick.Enable(true);
                // Debug.Log("SDHAKAR JustPressed ");
            }
            else if (walkStick.GetKey(KeyCode.UpArrow) && walkStick.GetKey(KeyCode.LeftArrow))
            {
                //					Debug.Log("left Upper");
                //					if(m_Character.isMovingOnRope)
                //						return;
                //					if(m_Character.isMovingOnLog)
                //						return;
                PlayerPrefs.SetInt("walkStickStatus", 1);
                if (m_Character.swimStatus)
                {
                    m_Character.swimUpMovingAnim();
                }
                else if (m_Character.swimUpStatus)
                {
                    m_Character.swimUpClimbingLeftAnim();
                }
                if (m_Character.JetPackStatus)
                {
                    return;
                }
                m_Jump = true;
                m_Character.jumpDirectionValue = -10.0f;
                moveTrasfer(h, v);
                PlayerPrefs.SetInt("PathRemovalLEFT", 1);
                return;
            }
            else if (walkStick.GetKey(KeyCode.UpArrow) && walkStick.GetKey(KeyCode.RightArrow))
            {
                //					Debug.Log("right Upper");
                //					if(m_Character.isMovingOnRope)
                //						return;
                //					if(m_Character.isMovingOnLog)
                //						return;
                PlayerPrefs.SetInt("walkStickStatus", 1);
                if (m_Character.swimStatus)
                {
                    m_Character.swimUpMovingAnim();
                }
                else if (m_Character.swimUpStatus)
                {
                    m_Character.swimUpClimbingRightAnim();
                }
                if (m_Character.JetPackStatus)
                {
                    return;
                }
                m_Jump = true;
                // m_Character.jumpDirection();
                m_Character.jumpDirectionValue = 10.0f;
                moveTrasfer(h, v);
                return;
            }
            else if (walkStick.GetKey(KeyCode.DownArrow) && walkStick.GetKey(KeyCode.LeftArrow))
            {
                return;
            }
            else if (walkStick.GetKey(KeyCode.DownArrow) && walkStick.GetKey(KeyCode.RightArrow))
            {
                return;
            }
            else if (walkStick.GetKey(KeyCode.UpArrow))
            {
                //					if(m_Character.isMovingOnRope)
                //						return;
                //					if(m_Character.isMovingOnLog)
                //						return;
                //					Debug.Log(" Upper");
                PlayerPrefs.SetInt("walkStickStatus", 1);
                if (m_Character.swimStatus)
                {
                    m_Character.swimUpMovingAnim();
                }
                if (m_Character.swimUpStatus)
                {
                    m_Character.swimUpClimbingRightAnim();
                }
                if (m_Character.JetPackStatus)
                {
                    m_Character.jetPackUpMoving();
                }
                else
                {
                    m_Jump = true;
                    m_Character.jumpDirectionValue = 0.0f;
                    moveTrasfer(h, v);
                }
            }
            else if (walkStick.GetKey(KeyCode.DownArrow))
            {
                //					if(m_Character.isMovingOnRope)
                //						return;
                //					if(m_Character.isMovingOnLog)
                //						return;
                PlayerPrefs.SetInt("walkStickStatus", 1);
                if (PlayerPrefs.GetInt("JetPackStatus") != 1)
                {
                    if (m_Character.swimStatus)
                    {
                        return;
                    }
                    if (m_Character.JetPackStatus)
                    {
                        m_Character.jetPackDownMoving();
                    }
                    else
                    {
                        if (!SlidingStatus && !m_Character.isSwimStarted && !m_Character.clibStartTag)
                        {
                            //								SlidingStatus = true;
                            //								m_Character.slidingAnimation ();
                            //								Invoke ("slidingCompleted", 1.0f);
                        }
                    }
                }
            }
            else if (walkStick.GetKey(KeyCode.RightArrow))
            {
                PlayerPrefs.SetInt("walkStickStatus", 1);
                PlayerPrefs.SetInt("walkStickStatus2", 0);
                //					if(m_Character.isMovingOnLog)
                //						m_Character.movingOnLogStatus = true;
                //					if(m_Character.isMovingOnRope)
                //						m_Character.movingOnRopeStatus = true;
                if (m_Character.swimStatus)
                {
                    m_Character.swimRightMovingAnim();
                }
                if (m_Character.JetPackStatus)
                {
                    return;
                }

                PlayerPrefs.SetInt(ShieldRotateStatus, 1);
                PlayerPrefs.SetInt("PathRemovalLEFT", 0);

                m_Character.jumpDirectionValue = 0.0f;
                moveTrasfer(h, v);
                return;
            }
            else if (walkStick.GetKey(KeyCode.LeftArrow))
            {
                PlayerPrefs.SetInt("walkStickStatus", 1);
                PlayerPrefs.SetInt("walkStickStatus2", 1);
                if (m_Character.swimStatus)
                {
                    m_Character.swimLeftMovingAnim();
                }
                if (m_Character.JetPackStatus)
                {
                    return;
                }
                PlayerPrefs.SetInt(ShieldRotateStatus, 1);
                PlayerPrefs.SetInt("PathRemovalLEFT", 1);

                m_Character.jumpDirectionValue = 0.0f;
                moveTrasfer(h, v);
                return;
            }
            else if (walkStick.JustReleased())
            {
                PlayerPrefs.SetInt("walkStickStatus", 0);
                //					m_Character.movingOnRopeStatus = false;
                //					m_Character.movingOnLogStatus = false;
            }
            else
            {
                //				m_Character.movingOnRopeStatus = false;
                //				m_Character.movingOnLogStatus = false;
            }
        }

        if (m_Character.JetPackStatus)
        {
            h = 0;
        }
        if (h == 0)
        {
            PlayerPrefs.SetInt(ShieldRotateStatus, 0);
        }
        moveTrasfer(h, v);
    }
Exemplo n.º 8
0
    // This function is called every fixed framerate frame.
    void FixedUpdate()
    {
        // Cache the vertical and horizontal CFInput.
        float v = CFInput.GetAxis("Vertical");
        float h = CFInput.GetAxis("Horizontal");

        // If the player is on a ladder and the Ladder class is set...
        if (player.onLadder && ladder)
        {
            // Create the variables used to check if the player is almost falling off the ladder.
            bool    stillOnLadder = true;
            Vector2 pos           = transform.position;
            Vector2 pointA        = new Vector2(pos.x + boxCollider.offset.x - (boxCollider.size.x / 2), pos.y + boxCollider.offset.y - (boxCollider.size.y / 2));
            Vector2 pointB        = new Vector2(pos.x + boxCollider.offset.x + (boxCollider.size.x / 2), pos.y + boxCollider.offset.y + (boxCollider.size.y / 2));

            // If the player is moving down and movement down is allowed...
            if (v < 0 && ladder.allowDown)
            {
                // ... check if the player is almost falling off the ladder if the player isn't allowed to fall off.
                if (!ladder.fallOffBottom)
                {
                    stillOnLadder = Physics2D.OverlapArea(pointA, new Vector2(pointB.x, pointB.y - 0.1f), ladderLayer);
                }

                // If the player isn't allowed to fall off and is almost falling off the ladder...
                if (!ladder.fallOffBottom && !stillOnLadder)
                {
                    // ... make sure there is no Y movement.
                    player.SetYVelocity(0);
                    // Or else...
                }
                else
                {
                    // ... set the player's Y velocity based on the climbing and default speed.
                    player.SetYVelocity(v * (climingSpeedDown + (ladder.defaultSpeedY <= 0 ? ladder.defaultSpeedY : -ladder.defaultSpeedY)));
                }
                // Or else if the player is moving up and movement down is allowed...
            }
            else if (v > 0 && ladder.allowUp)
            {
                // ... check if the player is almost falling off the ladder if the player isn't allowed to fall off.
                if (!ladder.fallOffTop)
                {
                    stillOnLadder = Physics2D.OverlapArea(new Vector2(pointA.x, pointA.y + 0.1f), pointB, ladderLayer);
                }

                // If the player isn't allowed to fall off and is almost falling off the ladder...
                if (!ladder.fallOffTop && !stillOnLadder)
                {
                    // ... make sure there is no Y movement.
                    player.SetYVelocity(0);
                    // Or else...
                }
                else
                {
                    // ... set the player's Y velocity based on the climbing and default speed.
                    player.SetYVelocity(v * (climingSpeedUp + ladder.defaultSpeedY));
                }
                // Or else ...
            }
            else
            {
                // ... set the player's speed to the ladder's default speed.
                player.SetYVelocity(ladder.defaultSpeedY);
            }

            // If the player is grounded and is moving left or right...
            if (player.grounded && (h < 0 || h > 0))
            {
                // ... unstick the player from the ladder.
                Unstick();
                // Or else if the player is snapped to the middle...
            }
            else if (ladder.snapToMiddle)
            {
                // ... if the player is snapped to the middle and allowed to fall off the ladder and moving left or right...
                if (snappedToMiddle && (v == 0) && ((ladder.fallOffLeft && h < 0) || (ladder.fallOffRight && h > 0)))
                {
                    // ... unstick the player from the ladder.
                    Unstick();
                    // Or else...
                }
                else
                {
                    // ... if the player is currently in the middle of the ladder...
                    if (transform.position.x > (hitLadder.transform.position.x - 0.05f) && transform.position.x < (hitLadder.transform.position.x + 0.05f))
                    {
                        // Make sure the X velocity is set to 0.
                        player.SetXVelocity(0);
                        // Make sure the player is snapped to the middle.
                        snappedToMiddle = true;
                        // Or else...
                    }
                    else
                    {
                        // ... calculate the velocity needed to move to the center of the ladder.
                        Vector2 gotoCenter = (new Vector3(hitLadder.transform.position.x, transform.position.y, 0) - transform.position).normalized * snapSpeed;
                        // Set the X velocity to this velocity.
                        player.SetXVelocity(gotoCenter.x);
                        // Make sure the player isnt't snapped to the middle.
                        snappedToMiddle = false;
                    }
                }
                // Or else...
            }
            else
            {
                // ... if the player is moving to the left and is allowed to move to the left...
                if (h < 0 && ladder.allowLeft)
                {
                    // ... check if the player is almost falling off the ladder if the player isn't allowed to fall off.
                    if (!ladder.fallOffLeft)
                    {
                        //
                        stillOnLadder = Physics2D.OverlapArea(pointA, new Vector2(pointB.x - 0.1f, pointB.y), ladderLayer);
                    }

                    // If the player isn't allowed to fall off and is almost falling off the ladder...
                    if (!ladder.fallOffLeft && !stillOnLadder)
                    {
                        // ... make sure the X velocity is set to 0.
                        player.SetXVelocity(0);
                        // Or else...
                    }
                    else
                    {
                        // ... set the player's X velocity based on the climbing and default speed.
                        player.SetXVelocity(h * (climingSpeedLeft + (ladder.defaultSpeedX <= 0 ? ladder.defaultSpeedX : -ladder.defaultSpeedX)));
                    }
                    // Or else if the player is moving to the right and is allowed to move to the right...
                }
                else if (h > 0 && ladder.allowRight)
                {
                    // ... check if the player is almost falling off the ladder if the player isn't allowed to fall off.
                    if (!ladder.fallOffRight)
                    {
                        stillOnLadder = Physics2D.OverlapArea(new Vector2(pointA.x + 0.1f, pointA.y), pointB, ladderLayer);
                    }

                    // If the player isn't allowed to fall off and is almost falling off the ladder...
                    if (!ladder.fallOffRight && !stillOnLadder)
                    {
                        // ... make sure the X velocity is set to 0.
                        player.SetXVelocity(0);
                        // Or else...
                    }
                    else
                    {
                        // ... set the player's X velocity based on the climbing and default speed.
                        player.SetXVelocity(h * (climingSpeedRight + ladder.defaultSpeedX));
                    }
                    // Or else...
                }
                else
                {
                    // ... set the player's X velocity to the ladder's X default speed.
                    player.SetXVelocity(ladder.defaultSpeedX);
                }
            }
        }
    }
Exemplo n.º 9
0
    void Update()
    {
        animator.SetBool("grounded", grounded);
        animator.SetBool("walking", walking);
        animator.SetBool("crouching", crouching);
        animator.SetBool("sliding", sliding);
        animator.SetBool("dashing", dashing);
        animator.SetBool("falling", falling);
        animator.SetBool("wall", stuckToWall);
        animator.SetBool("onLadder", onLadder);
        animator.SetBool("jumpingThrough", jumpingThrough);

        if (timer > 0f)
        {
            timer -= Time.deltaTime;
        }

        if (timer < 0f)
        {
            timer = 0f;
        }

        if (timer == 0f)
        {
            WSVibrator.Cancel();
        }

        if (orient == null)
        {
            orient = GameObject.Find("KingOrient");
        }

        if (goodSpawn == null)
        {
            goodSpawn = GameObject.Find("EndSpawnBack");
        }

        if (attackTimer > 0f)
        {
            attackTimer -= Time.deltaTime;
        }

        if (attackTimer == 0f && timedFire)
        {
            timedFire = false;
            fire      = false;
        }

        if (nextFire > 0f)
        {
            nextFire -= Time.deltaTime;
        }

        if (attackTimer < 0f)
        {
            attackTimer = 0f;
        }

        if (staffTimer < 0f)
        {
            staffTimer = 0f;
        }

        if (staffTimer > 0f)
        {
            staffTimer -= Time.smoothDeltaTime;
        }

        if (staffTimer == 0)
        {
            staffClicks = 0;
        }

        if (nextFire < 0f)
        {
            nextFire = 0f;
        }

        Vector2 pos = transform.position;

        if (facingRight)
        {
            frontCheckTop.transform.position = new Vector2(pos.x + boxCollider.offset.x + (boxCollider.size.x / 2), pos.y + boxCollider.offset.y + (boxCollider.size.y / 2));
            frontCheckBot.transform.position = new Vector2(pos.x + boxCollider.offset.x + (boxCollider.size.x / 2) + 0.1f, pos.y + boxCollider.offset.y - (boxCollider.size.y / 2) - (circleCollider.radius / 2));
        }

        else
        {
            frontCheckTop.transform.position = new Vector2(pos.x + boxCollider.offset.x - (boxCollider.size.x / 2), pos.y + boxCollider.offset.y + (boxCollider.size.y / 2));
            frontCheckBot.transform.position = new Vector2(pos.x + boxCollider.offset.x - (boxCollider.size.x / 2) - 0.1f, pos.y + boxCollider.offset.y - (boxCollider.size.y / 2) - (circleCollider.radius / 2));
        }

        if (!stop)
        {
            hor = CFInput.GetAxis("Horizontal");
            animator.SetFloat("horizontal", Mathf.Abs(hor));
        }

        animator.SetFloat("xSpeed", Mathf.Abs(GetComponent <Rigidbody2D>().velocity.x));
        animator.SetFloat("ySpeed", GetComponent <Rigidbody2D>().velocity.y);

        if (!OnPlatform())
        {
            groundCollider = Physics2D.OverlapCircle(groundCheck.position, groundRadius, groundLayer);
        }

        if (keepVelocityOnGround && groundedXVelocity > 0)
        {
            if (groundedTimer > 0)
            {
                groundedTimer -= Time.deltaTime;
            }

            else
            {
                groundedXVelocity = 0;
            }
        }

        if (groundCollider && !jumpingThrough)
        {
            if (keepVelocityOnGround && !grounded)
            {
                groundedXVelocity = GetComponent <Rigidbody2D>().velocity.x;
                groundedTimer     = groundedVelocityTime;
            }
            grounded = true;
            jumping  = false;
            if (rotateOnSlope && !OnPlatform())
            {
                transform.rotation = groundCollider.transform.localRotation;
            }
            if (falling)
            {
                animator.SetTrigger("stateComplete");
            }
            falling = false;
        }

        else
        {
            transform.rotation = normalRotation;
            grounded           = false;
        }

        if ((hor > 0 && !facingRight) || (hor < 0 && facingRight) || flipAgain)
        {
            Flip();
        }

        if (Staff)
        {
            if (pickup.staffAmmo > 0f && staffClicks == 1 && !staffFired)
            {
                if (staffTimer < 0.3f)
                {
                    Vib100();
                    isAttacking = true;
                    fire        = true;
                    animator.SetBool("StaffFire", true);
                    GetComponent <AudioSource>().PlayOneShot(staffShot, 1.0f);
                    GameObject      newBullet = Instantiate(staffBullet);
                    StaffController bullCon   = newBullet.GetComponent <StaffController>();
                    bullCon.playerObject = gameObject;
                    bullCon.StaffShoot();
                    newBullet.transform.position = staffBulletSpawn.position;
                    pickup.staffAmmo--;
                    staffFired = true;
                }
            }
        }

        if (CFInput.GetButtonDown("Fire1"))
        {
            Fire();
        }

        if (CFInput.GetButton("Fire1") && Machinegun)
        {
            machinegunBulletSpawn = GameObject.Find("MachineGunSpawnPoint").transform;
            if (!onLadder && !stuckToWall)
            {
                if (nextFire == 0f && pickup.machinegunAmmo > 0f)
                {
                    Vib50();
                    isAttacking = true;
                    nextFire    = machinegunFireRate;
                    animator.SetBool("MachineGunFire", true);
                    GetComponent <AudioSource>().PlayOneShot(machinegunShot, 1.0f);
                    GameObject           newBullet = Instantiate(machinegunBullet);
                    GameObject           newKick   = Instantiate(machinegunKick);
                    MachineGunController bullCon   = newBullet.GetComponent <MachineGunController>();
                    ParticleFlip         kickCon   = newKick.GetComponent <ParticleFlip>();
                    bullCon.playerObject = gameObject;
                    kickCon.playerObject = gameObject;
                    bullCon.MachineGunShoot();
                    kickCon.MachineGunShoot();
                    newBullet.transform.position = machinegunBulletSpawn.position;
                    newKick.transform.position   = machinegunBulletSpawn.position;
                    pickup.machinegunAmmo--;
                }

                else if (pickup.machinegunAmmo == 0f)
                {
                    isAttacking = false;
                    animator.SetBool("MachineGunFire", false);
                    GetComponent <AudioSource>().PlayOneShot(outOfAmmo);
                }
            }
        }

        if (CFInput.GetButtonUp("Fire1") && Machinegun)
        {
            isAttacking = false;
            animator.SetBool("MachineGunFire", false);
        }
    }
Exemplo n.º 10
0
    // Token: 0x060003E6 RID: 998 RVA: 0x00018788 File Offset: 0x00016B88
    private void Update()
    {
        this.stick = (UnityEngine.Object.FindObjectOfType(typeof(EasyJoystick)) as EasyJoystick);
        if (CFInput.GetButton("Eat") && this.eats && this.questM.Eatbar())
        {
            if (base.GetComponent <AttackTriggerC>().useMecanim)
            {
                this.mainModel.GetComponent <Animator>().CrossFade(this.EatingAnim, 0.5f);
            }
            else
            {
                this.mainModel.GetComponent <Animation>()[this.EatingAnim].layer = 25;
                this.mainModel.GetComponent <Animation>().CrossFade(this.EatingAnim);
            }
        }
        if (this.moveSleep && this.maleSleepPos && this.femaleSleepPos)
        {
            this.mate.transform.position = Vector3.MoveTowards(this.mate.transform.position, this.femaleSleepPos.position, 0.1f);
            base.transform.position      = Vector3.MoveTowards(base.transform.position, this.maleSleepPos.position, 0.1f);
        }
        if (this.rotating)
        {
            this._lookRotation      = Quaternion.LookRotation(this._direction);
            base.transform.rotation = Quaternion.Slerp(base.transform.rotation, this._lookRotation, Time.deltaTime * this.RotationSpeed);
        }
        StatusC component = base.GetComponent <StatusC>();

        if (component.freeze)
        {
            this.motor.inputMoveDirection = new Vector3(0f, 0f, 0f);
            return;
        }
        if (Time.timeScale == 0f)
        {
            return;
        }
        if (this.dodging)
        {
            Vector3 a = base.transform.TransformDirection(this.dir);
            this.controller.Move(a * 8f * Time.deltaTime);
            return;
        }
        if (this.recover && !this.sprint && !this.dodging)
        {
            if (this.recoverStamina >= this.staminaRecover)
            {
                this.StaminaRecovery();
            }
            else
            {
                this.recoverStamina += Time.deltaTime;
            }
        }
        if (this.dodgeRollSetting.canDodgeRoll)
        {
            if (CFInput.GetButtonDown("Vertical") && CFInput.GetAxis("Vertical") > 0f && (this.controller.collisionFlags & CollisionFlags.Below) != CollisionFlags.None && CFInput.GetAxis("Horizontal") == 0f)
            {
                if (CFInput.GetButtonDown("Vertical") && Time.time - this.lastTime < 0.4f && CFInput.GetButtonDown("Vertical") && Time.time - this.lastTime > 0.1f && CFInput.GetAxis("Vertical") > 0.03f)
                {
                    this.lastTime = Time.time;
                    this.dir      = Vector3.forward;
                    base.StartCoroutine(this.DodgeRoll(this.dodgeRollSetting.dodgeForward));
                }
                else
                {
                    this.lastTime = Time.time;
                }
            }
            if (CFInput.GetButtonDown("Vertical") && CFInput.GetAxis("Vertical") < 0f && (this.controller.collisionFlags & CollisionFlags.Below) != CollisionFlags.None && CFInput.GetAxis("Horizontal") == 0f)
            {
                if (CFInput.GetButtonDown("Vertical") && Time.time - this.lastTime < 0.4f && CFInput.GetButtonDown("Vertical") && Time.time - this.lastTime > 0.1f && CFInput.GetAxis("Vertical") < -0.03f)
                {
                    this.lastTime = Time.time;
                    this.dir      = Vector3.back;
                    base.StartCoroutine(this.DodgeRoll(this.dodgeRollSetting.dodgeBack));
                }
                else
                {
                    this.lastTime = Time.time;
                }
            }
            if (CFInput.GetButtonDown("Horizontal") && CFInput.GetAxis("Horizontal") < 0f && (this.controller.collisionFlags & CollisionFlags.Below) != CollisionFlags.None && !CFInput.GetButton("Vertical"))
            {
                if (CFInput.GetButtonDown("Horizontal") && Time.time - this.lastTime < 0.3f && CFInput.GetButtonDown("Horizontal") && Time.time - this.lastTime > 0.15f && CFInput.GetAxis("Horizontal") < -0.03f)
                {
                    this.lastTime = Time.time;
                    this.dir      = Vector3.left;
                    base.StartCoroutine(this.DodgeRoll(this.dodgeRollSetting.dodgeLeft));
                }
                else
                {
                    this.lastTime = Time.time;
                }
            }
            if (CFInput.GetButtonDown("Horizontal") && CFInput.GetAxis("Horizontal") > 0f && (this.controller.collisionFlags & CollisionFlags.Below) != CollisionFlags.None && !CFInput.GetButton("Vertical"))
            {
                if (CFInput.GetButtonDown("Horizontal") && Time.time - this.lastTime < 0.3f && CFInput.GetButtonDown("Horizontal") && Time.time - this.lastTime > 0.15f && CFInput.GetAxis("Horizontal") > 0.03f)
                {
                    this.lastTime = Time.time;
                    this.dir      = Vector3.right;
                    base.StartCoroutine(this.DodgeRoll(this.dodgeRollSetting.dodgeRight));
                }
                else
                {
                    this.lastTime = Time.time;
                }
            }
        }
        if ((this.sprint && Input.GetAxis("Vertical") < 0.02f) || (this.sprint && this.stamina <= 0f) || (this.sprint && Input.GetButtonDown("Fire1")) || (this.sprint && Input.GetKeyUp(KeyCode.LeftShift)))
        {
            this.sprint  = false;
            this.recover = true;
            this.motor.movement.maxForwardSpeed  = this.walkSpeed;
            this.motor.movement.maxSidewaysSpeed = this.walkSpeed;
            this.recoverStamina = 0f;
        }
        Vector3 vector = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical"));

        if (vector != Vector3.zero)
        {
            float num = vector.magnitude;
            vector /= num;
            num     = Mathf.Min(1f, num);
            num    *= num;
            vector *= num;
        }
        this.motor.inputMoveDirection = base.transform.rotation * vector;
        if (CFInput.GetButton("Jump") && !this.alwJump)
        {
            base.GetComponent <PlayerMecanimAnimationC>().PlayAnim("jump");
            base.GetComponent <PlayerMecanimAnimationC>().PlayAnim("Jump_place_All_short");
            base.StartCoroutine(this.jumping());
        }
        this.motor.inputJump = CFInput.GetButton("Jump");
        if (this.sprint)
        {
            this.motor.movement.maxForwardSpeed  = this.sprintSpeed;
            this.motor.movement.maxSidewaysSpeed = this.sprintSpeed;
            return;
        }
        if (CFInput.GetButton("Sprint") && Input.GetAxis("Vertical") > 0f && (this.controller.collisionFlags & CollisionFlags.Below) != CollisionFlags.None && this.canSprint && this.stamina > 0f)
        {
            this.sprint = true;
            base.StartCoroutine(this.Dasher());
        }
        if (CFInput.GetButton("Sprint"))
        {
        }
    }