// Update is called once per frame
    void FixedUpdate()
    {
        move = new Vector3(0, 0, 0);
        if (moveState == MoveState.toBuilding)
        {
            //going to building
            move = warehouseRequester.transform.position - this.transform.position;
            if (move.magnitude < satisfactionRadius)
            {
                //deposit resources
                moveState = MoveState.atBuilding;
            }
            else
            {
                this.transform.position += move.normalized * speed;
            }
        }
        else if (moveState == MoveState.atBuilding)
        {
            counter++;
            if (counter >= gatheringTime)
            {
                counter   = 0;
                moveState = MoveState.toWarehouse;
                resources = warehouseRequester.GatherResources();
            }
        }
        else if (moveState == MoveState.toWarehouse)
        {
            move = warehouseManager.transform.position - this.transform.position;
            if (move.magnitude < warehouseRequestRadius)
            {
                targetPort = warehouseManager.RequestPort().transform.position;
                moveState  = MoveState.requestingPort;
            }
            else
            {
                this.transform.position += move.normalized * speed;
            }
        }
        else if (moveState == MoveState.requestingPort)
        {
            counter++;
            if (counter > requestWait)
            {
                moveState = MoveState.enteringPort;
                counter   = 0;
            }
        }
        else if (moveState == MoveState.enteringPort)
        {
            move = targetPort - this.transform.position;
            if (move.magnitude < satisfactionRadius)
            {
                warehouseManager.DepositResources(resources);
                Destroy(this.gameObject);
            }
            else
            {
                this.transform.position += move.normalized * speed;
            }
        }

        //handle sprite representation
        if (move.x == 0 && move.y == 0)
        {
            srenderer.sprite = regular[(int)moveState % 2];
        }
        else if (move.x > 0 && move.x > Mathf.Abs(move.y))
        {
            srenderer.sprite = right[(int)moveState % 2];
        }
        else if (move.x < 0 && -move.x > Mathf.Abs(move.y))
        {
            srenderer.sprite = left[(int)moveState % 2];
        }
        else if (move.y > 0 && move.y > Mathf.Abs(move.x))
        {
            srenderer.sprite = up[(int)moveState % 2];
        }
        else if (move.y < 0 && move.y > Mathf.Abs(move.x))
        {
            srenderer.sprite = down[(int)moveState % 2];
        }
    }