public IEnumerator SmoothMove(Vector3 endPoint)
    {
        isMoving = true;
        float smoothMoveTime      = 0f;
        float smoothMoveDuration  = 2f;
        int   changeRotationSpeed = 5;

        Vector3 vectorToTarget = endPoint - transform.position;
        float   angle          = (Mathf.Atan2(vectorToTarget.y, vectorToTarget.x) * Mathf.Rad2Deg) - 90;

        while (smoothMoveTime < smoothMoveDuration)
        {
            if (isPlayerPaused == true)
            {
                yield break;
            }
            //Change position
            Vector3 newPosition = Vector3.Lerp(transform.position, endPoint, Time.deltaTime * smoothMoveDuration);
            gameObject.transform.position = newPosition;
            smoothMoveTime += Time.deltaTime;

            //Change rotation
            Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward);
            transform.rotation = Quaternion.Slerp(transform.rotation, q, Time.deltaTime * changeRotationSpeed);
            lineDrawer.DrawLines();

            yield return(null);
        }

        transform.position = endPoint;
        Transform destination = WaypointController.waypointsQueue.Dequeue();

        Destroy(destination.gameObject);
        isMoving = false;
    }
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

            if (hit && hit.transform.tag != "UI")
            {
                SetWaypoint(hit.point);
                lineDrawer.DrawLines();
            }
        }
    }
Ejemplo n.º 3
0
    public void UpdateAll()
    {
        GameObject[] pieces = GameObject.FindGameObjectsWithTag("GamePiece");

        foreach (GameObject piece in pieces)
        {
            bool currentlySelected = selected.Contains(piece);

            piece.GetComponent <GamePiece>().UpdateState(selectedActionType, currentlySelected, sumAttack);
        }


        lineDrawer.DrawLines(selected);
    }
Ejemplo n.º 4
0
 public void UpdateGridState(int boxX, int boxY, Letter newLetter)
 {
     GridLetters[boxX, boxY] = newLetter;
     ld.DrawLines();
 }