예제 #1
0
    // Update is called once per frame
    void Update()
    {
        upgradeCounterText.text = upgradeCounter.ToString();

        if (!gameIsStart && Input.GetKeyUp(KeyCode.Return))
        {
            if (storeTxture.enabled)
            {
                storeTxture.enabled        = false;
                instructionTexture.enabled = true;
            }
            else if (instructionTexture.enabled)
            {
                instructionTexture.enabled = false;
                gameIsStart = true;
            }
            return;
        }
        //if (!ControlInPlanet) ////////@later
        //    return;
        if (gotTheUpgrade)
        {
            gotUpgradeTexture.enabled = true;
        }


        if (CanControlPlanet) /////@ here may put the getkey in the top if condition (according to the releasebutton condition)
        {
            if (Input.GetKey("r") && topCube.canRotate)
            {
                WantRotate   = true;
                rotatingTier = enumRotatingTier.top;
            }
            else if (Input.GetKey("e") && bottomCube.canRotate)
            {
                WantRotate   = true;
                rotatingTier = enumRotatingTier.bottom;
            }
        }
        else if (WantRotate)
        {
            if (!CanRotate)
            {
                if (cameraMoveDirection == enumCameraMoveDirection.noMove)
                {
                    /// add a bool to indicate the direction of camera movement
                    if (manager.cameraControl.moveToWideAnglePosition())
                    {
                        CanRotate = true;
                    }
                }

                else if (cameraMoveDirection == enumCameraMoveDirection.moveBack)        ///$ infact the condition of moveToWideAngle is not used
                {
                    if (manager.cameraControl.moveBackToPlayModePositionFromWideAngle()) /////////////////@ next time start from here
                    {
                        WantRotate = false;
                    }
                }
            }
            else
            {
                if (rotatingTier == enumRotatingTier.top)
                {
                    if (topCube.rotateTier())
                    {
                        CanRotate = false;
                        ////@ add the character can move later
                    }
                }
                else if (rotatingTier == enumRotatingTier.bottom)
                {
                    if (bottomCube.rotateTier())
                    {
                        CanRotate = false;
                    }
                }
            }
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        upgradeCounterText.text = upgradeCounter.ToString();

        if (!gameIsStart && Input.GetKeyUp(KeyCode.Return))
        {
            if (storeTxture.enabled)
            {
                storeTxture.enabled        = false;
                instructionTexture.enabled = true;
            }
            else if (instructionTexture.enabled)
            {
                instructionTexture.enabled = false;
                gameIsStart = true;
            }
            return;
        }
        //if (!ControlInPlanet) ////////@later
        //    return;
        if (gotTheUpgrade)
        {
            gotUpgradeTexture.enabled = true;
        }

        if (CanControlCharacter)
        {
            if (characterController.isGrounded || characterCanMoveUp)
            {
                print("is Grounded");
                //if ((characterController.collisionFlags & CollisionFlags.Sides) != 0)
                //    print("Touching sides!");
                //else
                {
                    if (Input.GetKey("d"))
                    {
                        moveDirection = Vector3.right * 0.5f;
                    }
                    else if (Input.GetKey("a"))
                    {
                        moveDirection = Vector3.left * 0.5f;
                    }
                    else
                    {
                        moveDirection = Vector3.zero;
                    }
                    if (Input.GetKey("w"))
                    {
                        if (characterCanMoveUp) // when there is a ladder
                        {
                            moveDirection = Vector3.up * 0.2f;
                        }
                        else
                        {
                            moveDirection.y += 80f * Time.deltaTime;
                        }
                    }
                    else if (Input.GetKey("s") && characterCanMoveUp)
                    {
                        moveDirection = Vector3.down * 0.2f;
                    }
                }
            }
            else
            {
                if ((characterController.collisionFlags & CollisionFlags.Above) != 0)
                {
                    moveDirection = Vector3.zero;
                }
                if (!characterCanMoveUp)
                {
                    moveDirection.y -= 10f * Time.deltaTime;
                }
                print("is not Grounded");
            }

            characterController.Move(moveDirection * 0.3f);
            manager.cameraControl.updateCamera(character.transform.position);
            //print (controller.on)

            //character.transform.Translate(Vector3.right * Time.deltaTime, Space.World);
        }
        if (CanControlPlanet) /////@ here may put the getkey in the top if condition (according to the releasebutton condition)
        {
            if (Input.GetKey("r") && topCube.canRotate)
            {
                WantRotate   = true;
                rotatingTier = enumRotatingTier.top;
            }
            else if (Input.GetKey("e") && bottomCube.canRotate)
            {
                WantRotate   = true;
                rotatingTier = enumRotatingTier.bottom;
            }
        }
        else if (WantRotate)
        {
            if (!CanRotate)
            {
                if (cameraMoveDirection == enumCameraMoveDirection.noMove)
                {
                    /// add a bool to indicate the direction of camera movement
                    if (manager.cameraControl.moveToWideAnglePosition())
                    {
                        CanRotate = true;
                    }
                }

                else if (cameraMoveDirection == enumCameraMoveDirection.moveBack)        ///$ infact the condition of moveToWideAngle is not used
                {
                    if (manager.cameraControl.moveBackToPlayModePositionFromWideAngle()) /////////////////@ next time start from here
                    {
                        WantRotate = false;
                    }
                }
            }
            else
            {
                if (rotatingTier == enumRotatingTier.top)
                {
                    if (topCube.rotateTier())
                    {
                        CanRotate = false;
                        ////@ add the character can move later
                    }
                }
                else if (rotatingTier == enumRotatingTier.bottom)
                {
                    if (bottomCube.rotateTier())
                    {
                        CanRotate = false;
                    }
                }
            }
        }
    }