void Setup() { var mm = GameObject.Find("Map").GetComponent <MapManager> (); screen = BlitEngine.Instance.screen; var width = mm.width * mm.segmentWidth; var height = mm.height * mm.segmentHeight; if (width <= screen.unitWidth) { minX = maxX = Utils.RoundToNearestPixel((width / 2) + 0.5f); } else { minX = Utils.RoundToNearestPixel(screen.unitWidth / 2); maxX = Utils.RoundToNearestPixel(width - (screen.unitWidth / 2) - 1); } minY = Utils.RoundToNearestPixel((screen.unitHeight / 2)); maxY = Utils.RoundToNearestPixel(height - (screen.unitHeight / 2)); // Move to initial position var target = Utils.RoundToNearestPixel(new Vector3() { x = Mathf.Max(Mathf.Min(player.transform.position.x, maxX), minX), y = Mathf.Max(Mathf.Min(player.transform.position.y, maxY), minY), z = Camera.main.transform.position.z }); transform.position = target; }
private void ScreenSetup() { ScreenSetup _screen = gameObject.GetComponent <ScreenSetup> (); _screen.Setup(); screenWidthFloat = _screen.ScreenWidth; }
public BackgroundSection(Sprite backgroundSprite, ScreenSetup screen, Depth depth, Vector2 startPos = default) { this.depth = depth; this.screen = screen; fstQuad.Position = startPos; sndQuad.Position = startPos; CreateBackground(backgroundSprite.Texture, backgroundSprite.Region); }