예제 #1
0
    // Update is called once per frame
    void Update()
    {
        var x = (GlobalControl.GetHorizontal(playerNum) * 0.05f * mvSpeed);
        var y = (GlobalControl.GetVertical(playerNum) * 0.05f * mvSpeed);

        if (transform.position.x + x > bounds.max.x)
        {
            Debug.Log("Clamping " + transform.position.x + " into " + bounds.max.x);
            x = Mathf.Clamp(x, int.MinValue, 0);
        }
        else if (transform.position.x + x < bounds.min.x)
        {
            x = Mathf.Clamp(x, 0, int.MaxValue);
        }


        /*if (transform.position.y + y > bounds.max.y) {
         *      Debug.Log ("Clamping y!");
         *      y = Mathf.Clamp (y, 0, int.MaxValue);
         * }
         * else if(transform.position.y + y < bounds.min.x)
         *      y = Mathf.Clamp (y, int.MinValue,0);*/

        if (canMove)
        {
            transform.position += new Vector3(x, y, 0);
            Debug.Log("Moving by " + x + " " + y);
        }
    }
예제 #2
0
    void Update()
    {
        if (!hasControl || isDead)
        {
            return;
        }

        float horizontal = GlobalControl.GetHorizontal(playerNum);
        float vertical   = GlobalControl.GetVertical(playerNum);

        rigid2d.velocity = new Vector2(horizontal, vertical).normalized *speed;

        float horizontalAim = GlobalControl.GetHorizontalAim(playerNum);
        float verticalAim   = GlobalControl.GetVerticalAim(playerNum);


        if (horizontalAim != 0f || verticalAim != 0f)
        {
            transform.up = new Vector3(horizontalAim + 0.01f, verticalAim, 0);
        }

        if (GlobalControl.GetButtonDownRT(playerNum))
        {
            ThrowBoomerang();
        }
    }
    // Update is called once per frame
    void Update()
    {
        float inputX = GlobalControl.GetHorizontal(num);
        float inputY = GlobalControl.GetVertical(num);
        float stepX  = inputX * Time.deltaTime * speed;
        float stepY  = inputY * Time.deltaTime * speed;

        if (transform.position.x > -6.25f && inputX < 0f || transform.position.x < 9 && inputX > 0f)
        {
            transform.position = new Vector3(transform.position.x + stepX, transform.position.y + stepY, transform.position.z);
        }
    }
    // Update is called once per frame
    void Update()
    {
        //Horizontal movment for the character
        float inputX = GlobalControl.GetHorizontal(num);

        theRigidBody.velocity = new Vector2(inputX * speed, theRigidBody.velocity.y);



        //makes a character jump if they press A
        //want to make a double jump, you can only jup is you have a jump left.
        bool jump = GlobalControl.GetButtonDownA(num);


        if (jump && theRigidBody.transform.position.y < (-3.10) || jump && onFridge)
        {
            theRigidBody.velocity = new Vector2(theRigidBody.velocity.x, jumpPower);
        }
        if (onFridge)
        {
            animator.SetBool("isJumping", false);
        }
        if (transform.position.y < (-3.10) || onFridge)
        {
            animator.SetBool("isJumping", false);
        }
        else
        {
            animator.SetBool("isJumping", true);
        }
        animator.SetFloat("speed", Mathf.Abs(theRigidBody.velocity.x));

        if (theRigidBody.velocity.x < 0)
        {
            sR.flipX = true;
        }
        else
        {
            sR.flipX = false;
        }
        if (theRigidBody.transform.position.x > -7f || theRigidBody.transform.position.y > 0)
        {
            onFridge = false;
        }
    }
    // Update is called once per frame
    void Update()
    {
        var x = GlobalControl.GetHorizontal(BossPNum) * 0.05f * speed;

        if (transform.position.x + x > bounds.max.x)
        {
            Debug.Log("Clamping " + transform.position.x + " into " + bounds.max.x);
            x = Mathf.Clamp(x, int.MinValue, 0);
        }
        else if (transform.position.x + x < bounds.min.x)
        {
            x = Mathf.Clamp(x, 0, int.MaxValue);
        }
        transform.position += new Vector3(x, 0, 0);

        if (players.TrueForAll(isDisabled))
        {
            ChangeScene("End_Screen");
            Debug.Log("Game Over");
        }
        frameCt++;
        if (currentObstacle != null)
        {
            currentObstacle.transform.position = transform.position;
            //Debug.Log ("Updating " + Input.GetButton ("X_P1"));
            if (GlobalControl.GetButtonA(BossPNum) || Input.GetKeyDown(KeyCode.Space))
            {
                Debug.Log("Pressed");
                currentObstacle.GetComponent <Obstacle>().setActive(conveyor);
                currentObstacle = null;
                frameCt         = 0;
            }
        }
        else
        {
            if (frameCt > frameDelay)
            {
                currentObstacle = Instantiate(obPreFabs[Random.Range(0, obPreFabs.Length)]).GetComponent <Obstacle>();
                currentObstacle.GetComponent <AffectedByConveyor>().conveyor = conveyor;
                currentObstacle.transform.position = transform.position;
                frameCt = 0;
            }
        }
    }