예제 #1
0
파일: Destroy.cs 프로젝트: Glenn415/MEGATAP
    private void Update()
    {
        if (bottomPlayer.GetFloor() > floor || (bottomPlayer.GetFloor() == floor && bottomPlayer.GetState() > face))
        {
            Component[] components      = GetComponents <Component>();
            Component[] childComponents = GetComponentsInChildren <Component>();

            foreach (Component c in components)
            {
                //Desetroy ALL components besides meshrenderers and transforms so it stays the same visually
                if (c.GetType() != typeof(Transform) && c.GetType() != typeof(SkinnedMeshRenderer) && c.GetType() != typeof(MeshRenderer) && c != this)
                {
                    Destroy(c);
                }
            }

            foreach (Component c in childComponents)
            {
                if (c.name == "Base" || c.name == "PlaceImage")
                {
                    Destroy(c.gameObject);
                }

                if (c.GetType() == typeof(TrapOverlap))
                {
                    Destroy(c);
                }
            }

            Destroy(this);
        }
    }
예제 #2
0
    private void Start()
    {
        once  = false;
        count = 0;
        cam   = GameObject.Find("Player 1").GetComponent <CameraOneRotator>();

        switch (cam.GetState())
        {
        case 1:
            transform.eulerAngles = new Vector3(0, 0, 0);
            direction             = new Vector3(-1.0f, 0.0f, 0.0f);
            break;

        case 2:
            transform.eulerAngles = new Vector3(0, 270, 0);
            direction             = new Vector3(0.0f, 0.0f, -1.0f);
            break;

        case 3:
            transform.eulerAngles = new Vector3(0, 180, 0);
            direction             = new Vector3(1.0f, 0.0f, 0.0f);
            break;

        case 4:
            transform.eulerAngles = new Vector3(0, 90, 0);
            direction             = new Vector3(0.0f, 0.0f, 1.0f);
            break;
        }
    }
예제 #3
0
    void Update()
    {
        state = cam.GetState();

        if (isGrounded)
        {
            movementMultiplier = 1;
        }
        else if (!isGrounded)
        {
            movementMultiplier = inAirSpeed;
        }

        switch (state)
        {
        case 1:
            this.transform.Translate(Input.GetAxis("Horizontal") * moveSpeed * movementMultiplier, 0, 0);
            break;

        case 2:
            this.transform.Translate(0, 0, Input.GetAxis("Horizontal") * moveSpeed * movementMultiplier);
            break;

        case 3:
            this.transform.Translate(-Input.GetAxis("Horizontal") * moveSpeed * movementMultiplier, 0, 0);
            break;

        case 4:
            this.transform.Translate(0, 0, -Input.GetAxis("Horizontal") * moveSpeed * movementMultiplier);
            break;
        }

        //jump
        if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
        {
            isGrounded = false;
            rb.AddForce(jump * jumpForce, ForceMode.Impulse);
        }

        //crouch
        if (Input.GetKeyDown(KeyCode.S) && isGrounded)
        {
            Debug.Log("S is pressed");
            moveSpeed = 0;
        }
        if (Input.GetKeyUp(KeyCode.S) && isGrounded)
        {
            Debug.Log("S is released");
            moveSpeed = 0.2f;
        }


        //fall faster
        if (rb.velocity.y < 0)
        {
            rb.velocity += Vector3.up * Physics.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
        }
        else if (rb.velocity.y > 0 && !Input.GetButton("Jump"))
        {
            rb.velocity += Vector3.up * Physics.gravity.y * (lowerJumpMultiplier - 1) * Time.deltaTime;
        }
    }
예제 #4
0
    private void Update()
    {
        camOneState = cam.GetState();
        grounded    = GetComponentInChildren <PlayerGrounded>().IsGrounded();
        if (move == true)
        {
            inputAxis = checkControllers.GetInputAxis();

            //jumping
            if (Input.GetButtonDown("Jump_Joy_1") && grounded && crouching == false)
            {
                jumping = true;
            }

            if (Input.GetButtonDown("Jump_Joy_1") && grounded && crouching == true && cantStandUp == false)
            {
                jumping = true;
            }

            //crouch
            if (Input.GetButton("Crouch_Joy_1") && grounded)
            {
                crouching = true;
            }
            if (Input.GetButtonUp("Crouch_Joy_1") || (!Input.GetButton("Crouch_Joy_1") && cantStandUp == false))
            {
                if (cantStandUp == true)
                {
                    crouching = true;
                    if (slowed == false)
                    {
                        speed = moveSpeed / 2;
                    }
                }
                if (cantStandUp == false)
                {
                    crouching = false;
                    if (slowed == false)
                    {
                        speed = moveSpeed;
                    }
                }
            }
            // Animation parameters update
            animator.SetBool("Jumping", jumping);
            if (jumping)
            {
                animator.SetBool("Running", false);
            }
            //animator.SetBool("Running", move);
            animator.SetBool("Stunned", false);
            stun.enabled = false;
        }

        switch (camOneState)
        {
        case 1:
            movementVector = new Vector3(inputAxis * speed, rb.velocity.y, 0);
            if (inputAxis > 0)
            {
                transform.eulerAngles = new Vector3(0, 90, 0);
                animator.SetFloat("Velocity", speed);
                if (grounded)
                {
                    animator.SetBool("Running", true);
                }
            }
            else if (inputAxis < 0)
            {
                transform.eulerAngles = new Vector3(0, 270, 0);
                animator.SetFloat("Velocity", -speed);

                if (grounded)
                {
                    animator.SetBool("Running", true);
                }
            }
            else
            {
                animator.SetFloat("Velocity", 0);

                if (grounded)
                {
                    animator.SetBool("Running", false);
                }
            }
            rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
            break;

        case 2:
            movementVector = new Vector3(0, rb.velocity.y, inputAxis * speed);
            if (inputAxis > 0)
            {
                transform.eulerAngles = new Vector3(0, 0, 0);
                animator.SetFloat("Velocity", speed);
                if (grounded)
                {
                    animator.SetBool("Running", true);
                }
            }
            else if (inputAxis < 0)
            {
                transform.eulerAngles = new Vector3(0, 180, 0);
                animator.SetFloat("Velocity", -speed);
                if (grounded)
                {
                    animator.SetBool("Running", true);
                }
            }
            else
            {
                animator.SetFloat("Velocity", 0);
                if (grounded)
                {
                    animator.SetBool("Running", false);
                }
            }
            rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionX;
            break;

        case 3:
            movementVector = new Vector3(-inputAxis * speed, rb.velocity.y, 0);
            if (inputAxis > 0)
            {
                transform.eulerAngles = new Vector3(0, 270, 0);
                animator.SetFloat("Velocity", -speed);
                if (grounded)
                {
                    animator.SetBool("Running", true);
                }
            }
            else if (inputAxis < 0)
            {
                transform.eulerAngles = new Vector3(0, 90, 0);
                animator.SetFloat("Velocity", speed);
                if (grounded)
                {
                    animator.SetBool("Running", true);
                }
            }
            else
            {
                animator.SetFloat("Velocity", -rb.velocity.x);
                if (grounded)
                {
                    animator.SetBool("Running", false);
                }
            }
            rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
            break;

        case 4:
            movementVector = new Vector3(0, rb.velocity.y, -inputAxis * speed);
            if (inputAxis > 0)
            {
                transform.eulerAngles = new Vector3(0, 180, 0);
                animator.SetFloat("Velocity", -speed);
                if (grounded)
                {
                    animator.SetBool("Running", true);
                }
            }
            else if (inputAxis < 0)
            {
                transform.eulerAngles = new Vector3(0, 0, 0);
                animator.SetFloat("Velocity", speed);
                if (grounded)
                {
                    animator.SetBool("Running", true);
                }
            }
            else
            {
                animator.SetFloat("Velocity", 0);
                if (grounded)
                {
                    animator.SetBool("Running", false);
                }
            }
            rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionX;
            break;
        }

        if (crouching == true)
        {
            if (slowed == false)
            {
                speed = moveSpeed / 2;
            }
            col.height = 2.25f;
            col.center = new Vector3(0, 1.1f, 0);
        }

        if (crouching == false || grounded == false)
        {
            col.height = 4.5f;
            col.center = new Vector3(0, 2.2f, 0);
        }

        cantStandUp = gameObject.GetComponentInChildren <Colliding>().GetCollision();

        Move();
    }