private IEnumerator MoveRight() { while (coroutineManager.IsTrackedCoroutineRunning()) { yield return(waitForEndOfFrame); } Vector3 dest = GetMap.WorldToGrid(transform.position + Map.East); //print("MoveLeft : position before : " + transform.position + " dest : " + dest); if (!GetMap.Contains(dest)) { SpawnParticle(transform.position + (Map.East * GetMap.ScaleFactor.x)); } yield return(coroutineManager.StartTrackedCoroutine(MoveOverSeconds(transform.position + (Map.East * GetMap.ScaleFactor.x), speed))); if (!GetMap.Contains(dest)) { transform.position = new Vector3(GetMap.GridToWorld(Map.West * (GetMap.dimension.x)).x + transform.position.x, transform.position.y, transform.position.z); } }
private IEnumerator MoveDown() { while (coroutineManager.IsTrackedCoroutineRunning()) { yield return(waitForEndOfFrame); } // print("MoveDOwn : position before : " + transform.position); Vector3 dest = GetMap.WorldToGrid(transform.position + Map.South); if (!GetMap.Contains(dest)) { SpawnParticle(transform.position + (Map.South * GetMap.ScaleFactor.z)); } yield return(coroutineManager.StartTrackedCoroutine(MoveOverSeconds(transform.position + (Map.South * GetMap.ScaleFactor.z), speed))); if (!GetMap.Contains(dest)) { transform.position = new Vector3(transform.position.x, transform.position.y, GetMap.GridToWorld(Map.North * (GetMap.dimension.y - 1)).z); } }