Пример #1
0
 public void StartWork(StationTop moveTo)
 {
     isWorking   = true;
     workStation = moveTo;
     this.transform.DOMove(moveTo.workTransform.position, 0.5f).SetEase(Ease.InOutSine);
     this.transform.DORotate(moveTo.workTransform.rotation.eulerAngles, 0.5f).SetEase(Ease.InOutSine);
     // Switch to working animation
 }
Пример #2
0
    void OnCollisionExit(Collision collision)
    {
        // Remove station being interacted with and box being interacted with
        StationTop collStation = collision.gameObject.GetComponent <StationTop>();

        if (collStation != null && collStation == canInteractStation)
        {
            Debug.Log("Setting Cannot Interact " + canInteractStation);
            canInteractStation = null;
        }
    }
Пример #3
0
    void OnCollisionEnter(Collision collision)
    {
        // Set the station that can be interacted with and the box that can be interacted with

        StationTop collStationTop = collision.gameObject.GetComponent <StationTop>();

        if (collStationTop != null)
        {
            Debug.Log("Setting Can Interact " + canInteractStation);
            canInteractStation = collStationTop;
        }
    }
Пример #4
0
    void OnCollisionStay(Collision collision)
    {
        // Set the station that can be interacted with and the box that can be interacted with

        StationTop collStationTop = collision.gameObject.GetComponent <StationTop>();

        if (collStationTop != null && canInteractStation != null)
        {
            if (collStationTop == canInteractStation)
            {
                // No need to check if station is the same
                return;
            }

            float collStationDistance = Vector3.Distance(collStationTop.transform.position, transform.position);
            float currStationDistance = Vector3.Distance(canInteractStation.transform.position, transform.position);
            if (collStationDistance < currStationDistance)
            {
                canInteractStation = collStationTop;
            }
        }
    }
Пример #5
0
 // Start is called before the first frame update
 void Start()
 {
     thisStation = GetComponent <StationTop>();
 }
Пример #6
0
 // Start is called before the first frame update
 void Start()
 {
     thisStation = GetComponent <StationTop>();
     gManager    = FindObjectOfType <GameManager>();
 }
Пример #7
0
    //Game Code
    // Update is called once per frame
    void Update()
    {
        // TODO: Sendsignal over to Station Tops for interaction

        // HAVE MINIGAME CONTROLS HERE
        // If Carrying a box
        if (isInteracting1 || isInteracting2)
        {
            if (carryingBox)
            {
                if (canInteractStation != null && isInteracting1)
                {
                    carryingBox.isCarried = false;
                    carryingBox.isPlaced  = true;
                    Debug.Log("Interacting with station " + canInteractStation.name);
                    canInteractStation.Interact(this, carryingBox);
                    canInteractStation = null;
                }

                if (canInteractStation != null && isInteracting2)
                {
                    carryingBox.isCarried = false;
                    carryingBox.isPlaced  = true;
                    Debug.Log("Interacting with station " + canInteractStation.name);
                    canInteractStation.Interact(this, carryingBox);
                    canInteractStation = null;
                }
            }
            else
            {
                Debug.Log(canInteractStation != null);
                // If not carrying a box
                if (canInteractStation != null)
                {
                    if (canInteractStation.progress >= 1f)
                    {
                        Debug.Log("Interacting with station without box (Completed) " + canInteractStation.name);
                        canInteractStation.Interact(this, null);
                        canInteractStation = null;
                    }
                    else if (canInteractStation.isWorking == false)
                    {
                        Debug.Log("Interacting with station without box (non working) " + canInteractStation.name);
                        canInteractStation.Interact(this, null);
                        canInteractStation = null;
                    }
                }
            }
        }
        // Check Joystick Control
        if (isWorking)
        {
            if (isSprinting)
            {
                // Cancel Work, change anim
                isWorking = false;
                workStation.Pause();
                workStation = null;
            }
        }

        if (animator)
        {
            animator.SetBool("Moving", joystickMoving);
            animator.SetBool("Working", isWorking);
        }
        //animator.SetBool("hasBox", carryingBox != null);
        if (joystickMoving && !isWorking)
        {
            // handle movement
            Vector2 directionToMove = joystickPosition * (movingSpeed * (isSprinting ? 1.5f : 1f));

            // Set movement limits
            if ((transform.position.z < -3.5f && directionToMove.y < 0) || (transform.position.z > 50f && directionToMove.y > 0))
            {
                directionToMove.y = 0f;
            }
            if ((transform.position.x < -29f && directionToMove.x < 0) || (transform.position.x > 29f && directionToMove.x > 0))
            {
                directionToMove.x = 0f;
            }

            // TODO:: Should be rigidbody physics?
            gameObject.transform.Translate(new Vector3(directionToMove.x, 0, directionToMove.y));

            Vector3    dir = new Vector3(directionToMove.x, 0, directionToMove.y);
            Quaternion rot = Quaternion.LookRotation(dir);
            // slerp to the desired rotation over time
            Debug.Log("ROTATING");
            modelReference.transform.localRotation = Quaternion.Slerp(modelReference.transform.localRotation, rot, rotationSpeed * Time.deltaTime);
        }
    }