using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

public class WrapAround : MonoBehavclops
{
    GameBounds bounds;

    protected void Start()
    {
        bounds = GameBounds.Instance;
    }

    protected void Update()
    {
        Vector3 pos = transform.position;
        if(pos.x < bounds.leftEdge)
        {
            transform.position = new Vector3(bounds.rightEdge, transform.position.y, transform.position.z);
        }
        if (pos.x > bounds.rightEdge)
        {
            transform.position = new Vector3(bounds.leftEdge, transform.position.y, transform.position.z);
        }
        if (pos.y > bounds.topEdge)
        {
            transform.position = new Vector3(transform.position.x, bounds.bottomEdge, transform.position.z);
        }
        if (pos.y < bounds.bottomEdge)
        {
            transform.position = new Vector3(transform.position.x, bounds.topEdge, transform.position.z);
        }
    }
}
