// Update is called once per frame
    void Update()
    {
        if (currentTransform != null)
        {
            currentTransform   = followTransform;
            transform.position = followTransform.position;
            //transform.position = Vector3.Lerp(transform.position, followTransform.position + new Vector3(0, 2.0f, 0), smooth);
        }
        else
        {
            HandleMovementInput();
        }

        if (TutorialController.DoIfTutorial(TutorialController.Tutorial_State.Focus) && Input.GetKeyDown(KeyCode.F))
        {
            if (GameController.Instance.isInTutorial)
            {
                TutorialController.Instance.FocusDone();
            }
            currentTransform = followTransform;
        }

        if (TutorialController.DoIfTutorial(TutorialController.Tutorial_State.Camera) && (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow) ||
                                                                                          Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow) ||
                                                                                          Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow) ||
                                                                                          Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
            )
        {
            currentTransform = null;
        }

        HandleZoomInput();
        HandleRotationInput();
    }
    void HandleMovementInput()
    {
        if (TutorialController.DoIfTutorial(TutorialController.Tutorial_State.Camera) && (
                Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)))
        {
            if (GameController.Instance.isInTutorial)
            {
                TutorialController.Instance.CameraMovementDone(KeyCode.W);
            }
            newPosition += (transform.forward * movementSpeed);
        }
        if (TutorialController.DoIfTutorial(TutorialController.Tutorial_State.Camera) && (
                Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)))
        {
            if (GameController.Instance.isInTutorial)
            {
                TutorialController.Instance.CameraMovementDone(KeyCode.S);
            }
            newPosition += (transform.forward * -movementSpeed);
        }
        if (TutorialController.DoIfTutorial(TutorialController.Tutorial_State.Camera) && (
                Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)))
        {
            if (GameController.Instance.isInTutorial)
            {
                TutorialController.Instance.CameraMovementDone(KeyCode.D);
            }
            newPosition += (transform.right * movementSpeed);
        }
        if (TutorialController.DoIfTutorial(TutorialController.Tutorial_State.Camera) && (
                Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)))
        {
            if (GameController.Instance.isInTutorial)
            {
                TutorialController.Instance.CameraMovementDone(KeyCode.A);
            }
            newPosition += (transform.right * -movementSpeed);
        }


        newPosition = new Vector3(
            Mathf.Clamp(newPosition.x, MIN_X, MAX_X),
            Mathf.Clamp(newPosition.y, MIN_Y, MAX_Y),
            Mathf.Clamp(newPosition.z, MIN_Z, MAX_Z));

        /*if (Input.GetKey(KeyCode.R)) {
         *  newZoom += zoomAmount;
         * }
         * if (Input.GetKey(KeyCode.F)) {
         *  newZoom -= zoomAmount;
         * }*/

        transform.position = Vector3.Lerp(transform.position, newPosition, Time.deltaTime * movementTime);
    }
Ejemplo n.º 3
0
 void Update()
 {
     if (TutorialController.DoIfTutorial(TutorialController.Tutorial_State.Heal) && (!GameController.Instance.isInTutorial || TutorialController.Instance.isWaitingforG) && Input.GetKeyDown(KeyCode.G) && !GameController.isFinished)
     {
         if (GameController.Instance.isInTutorial)
         {
             TutorialController.Instance.HealingDone();
         }
         ConsumeHealthPotion();
     }
 }
    void Update()
    {
        if (!GameController.isPaused && !GameController.isFinished)
        {
            if (TutorialController.DoIfTutorial(TutorialController.Tutorial_State.Movement) && Input.GetMouseButtonDown(0))
            {
                Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    if (GameController.Instance.isInTutorial)
                    {
                        TutorialController.Instance.MovementDone();
                    }

                    motor.MoveToPoint(hit.point);
                    isEnemyTarget = false;
                    RemoveFocus();
                    target = null;
                }
            }
            if (TutorialController.DoIfTutorial(TutorialController.Tutorial_State.Attack) && Input.GetMouseButtonDown(1))
            {
                Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit))
                {
                    EnemyController enemy = hit.collider.GetComponent <EnemyController>();
                    if (enemy != null)
                    {
                        SetFocus(enemy);
                        isEnemyTarget = true;
                        target        = enemy.transform;
                    }
                }
            }

            if (isEnemyTarget && focus != null && focus.IsAlive() && agent.remainingDistance <= agent.stoppingDistance)
            {
                AttackTarget();
            }
        }
        else if (GameController.isFinished)
        {
            agent.isStopped = true;
        }
    }
    void HandleZoomInput()
    {
        if (TutorialController.DoIfTutorial(TutorialController.Tutorial_State.Zoom))
        {
            if (Input.mouseScrollDelta.y != 0)
            {
                if (GameController.Instance.isInTutorial)
                {
                    TutorialController.Instance.ZoomDone();
                }
                newZoom += Input.mouseScrollDelta.y * zoomAmount;

                newZoom = new Vector3(
                    newZoom.x,
                    Mathf.Clamp(newZoom.y, MIN_CAM_Y, MAX_CAM_Y),
                    Mathf.Clamp(newZoom.z, MIN_CAM_Z, MAX_CAM_Z));


                cameraTransform.localPosition = Vector3.Lerp(cameraTransform.localPosition, newZoom, Time.deltaTime * movementTime);
            }
        }
    }
Ejemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            if (TutorialController.DoIfTutorial(TutorialController.Tutorial_State.OpenShop) && !isShopOpen && !GameController.isPaused && !GameController.isFinished)
            {
                OpenShopWindow();
                if (GameController.Instance.isInTutorial)
                {
                    TutorialController.Instance.OpenShopDone();
                }
            }
            else if (TutorialController.DoIfTutorial(TutorialController.Tutorial_State.CloseShop) && isShopOpen)
            {
                CloseShopWindow();
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape) && isShopOpen)
        {
            CloseShopWindow();
        }
    }
    void HandleRotationInput()
    {
        if (TutorialController.DoIfTutorial(TutorialController.Tutorial_State.Rotation))
        {
            if (Input.GetKey(KeyCode.Q))
            {
                if (GameController.Instance.isInTutorial)
                {
                    TutorialController.Instance.RotationDone(KeyCode.Q);
                }
                newRotation *= Quaternion.Euler(Vector3.up * -rotationAmount);
            }
            if (Input.GetKey(KeyCode.E))
            {
                if (GameController.Instance.isInTutorial)
                {
                    TutorialController.Instance.RotationDone(KeyCode.E);
                }
                newRotation *= Quaternion.Euler(Vector3.up * rotationAmount);
            }

            transform.rotation = Quaternion.Lerp(transform.rotation, newRotation, Time.deltaTime * movementTime);
        }
    }