public override void Update(GameTime gameTime) { base.Update(gameTime); //Check if position is out of bounds, if so correct. MovingCamera camera = GameWorld.Find("camera") as MovingCamera; if (camera != null) { limitBB = camera.CameraLimit; if (Position.X < limitBB.Left) { position.X = limitBB.Left; } else if (Position.X + center.X * 2 > limitBB.Right) { position.X = limitBB.Right - center.X * 2; } if (Position.Y > limitBB.Bottom) { position.Y = limitBB.Bottom; } else if (Position.Y < limitBB.Top) { position.Y = limitBB.Top; } } }
/// <summary> /// Moves the camera to a new position. /// </summary> private IEnumerator MoveCamera(Vector3 newPosition) { GameObject cameraObject = AppCentral.APP.GetCameraObject(); if (cameraObject != null) { if (MovingCamera != null) { MovingCamera.Invoke(); } Vector3 startPosition = cameraObject.transform.position; newPosition.y = startPosition.y; float progress = 0.0f; while (progress <= 1.0f) { progress = progress + Time.deltaTime; cameraObject.transform.position = Vector3.Lerp(startPosition, newPosition, progress); yield return(null); } if (DestinationReached != null) { DestinationReached.Invoke(); } } }
/** * Returns this entity's position relative to the camera screen, rather than the Y position in board * @param camera * @return */ public Point getPositionRelativeTo(MovingCamera camera) { return(new Point( camera.getRelativeX((int)this.x), camera.getRelativeY((int)this.y) )); }
protected override void Initialize() { int distance = int.Parse(ConfigurationSettings.AppSettings["g.camera.initialDistance"]); camera = new MovingCamera { Position = new Vector3(0, distance, distance), Target = new Vector3(0, 0, 0), UpVector = -Vector3.UnitZ, InitialPosition = new Vector3(0, distance, distance), InitialTarget = new Vector3(0, 0, 0) }; camera.Update(); egm = Content.Load <Texture2D>("index"); LoadEGMs(); thr_update = new Thread(new ThreadStart(UpdateThread)); thr_update.Start(); quad_piso = new Quad(Vector3.Zero, Vector3.Backward, Vector3.Up, 1, 1); quad_test = new Quad(Vector3.Zero, Vector3.Backward, Vector3.Up, 1, 1); base.Initialize(); }
// Use this for initialization void Start() { InputEventQueue = Queue.Synchronized(new Queue()); server = new Server(AcceptingPort, CommunicationPort, InputEventQueue); players = new List <QuickPlayer>(); server.Start(); mc = GetComponent <MovingCamera>(); InitializeMenu(); }
private void Start() { OE = FindObjectOfType <OpeningEffect>(); TextAsset json = Resources.Load("00Json/TutorialPrologue", typeof(TextAsset)) as TextAsset; PS = JsonUtility.FromJson <PrologueScript>(json.text); mc = FindObjectOfType <MovingCamera>(); StartCoroutine(TitleEffect(2)); }
void Start() { StartCoroutine(Oleadas()); movimiento = GetComponent <MovingCamera>(); puntos = 0; textoPausa.enabled = false; textoR.enabled = false; textoGO.enabled = false; salir.gameObject.SetActive(false); gameOver = false; nave = GetComponentInChildren <ShipController>(); }
// Use this for initialization void Start() { // Get all of the sitting spots in the foreach (Transform child in transform) { if (child.gameObject.tag == "SittingSpot") { sittingSpots.Add(child); } // Randomize the sitting spots order for (int i = 0; i < sittingSpots.Count; i++) { Transform temp = sittingSpots[i]; int randomeIndex = Random.Range(i, sittingSpots.Count); sittingSpots[i] = sittingSpots[randomeIndex]; sittingSpots[randomeIndex] = temp; } } // Set up the other objects in the scene if (buttonPromptText.activeSelf == true) { buttonPromptText.SetActive(false); } movingCameraScript = Camera.main.GetComponent <MovingCamera>(); // Get a referecne to the pause menu so that it can be disabled when players try to laod a level if (InteractiveMenu.instance != null) { interactiveMenuSingleton = InteractiveMenu.instance; } controllerManagerInstance = NewControllerManager.instance; // Create the Audio Events fModLevelCompleteEvent = FMODUnity.RuntimeManager.CreateInstance(confirmLevelSound); fModLevelInteractionEvent = FMODUnity.RuntimeManager.CreateInstance(levelInteractionSound); foreach (Transform child in Camera.main.transform) { if (child.name == "Music") { musicEmitter = child.GetComponent <FMODUnity.StudioEventEmitter>(); } } }
/// <summary> /// updates positions based on the save /// </summary> public IEnumerator UpdateBasedOnSave() { player1 = null; player2 = null; while (player1 == null && player2 == null) { FindPlayers(); //in case you've switched scenes and lost reference yield return(null); } //print(save.player1Position); player1.position = save.player1Position; player2.position = save.player2Position; //print(player1.position); //auto update the camera pos so that you dont see it zoot over MovingCamera camRef = Camera.main.transform.root.GetComponentInChildren <MovingCamera>(); while (!camRef) { camRef = Camera.main.transform.root.GetComponentInChildren <MovingCamera>(); yield return(null); } camRef.transform.position = new Vector3(camRef.AveragePosition().x, camRef.AveragePosition().y, camRef.transform.position.z); if (VerifyCigs()) { audioRef.PlayDelayed(1); myChild = GameObject.Find("cigParticles"); myChild.transform.position = Camera.main.transform.position + Vector3.up * 20f; myChild.transform.parent = Camera.main.transform; myChild.transform.GetChild(0).gameObject.SetActive(true); } }
public void MoveToGuide() { movingCamera = MoveToGuide; Camera.main.transform.position = Vector3.Lerp(Camera.main.transform.position, tutorialCanvas.transform.position - new Vector3(0, 0, 10), 1f * Time.deltaTime); }
public void MoveToOption() { movingCamera = MoveToOption; Camera.main.transform.position = Vector3.Lerp(Camera.main.transform.position, optionMenu.transform.position - new Vector3(0, 0, 10), 1f * Time.deltaTime); }
void Awake() { instance = this; }
void Start() { main = this; wantedPosition = new Vector3(player.position.x, player.position.y, -10f); }
/** * Returns this entity's Y position relative to the camera screen, rather than the Y position in board * @param camera * @return the ordinate of this entity relative to the camera area */ public int getYRelativeTo(MovingCamera camera) { return(camera.getRelativeY((int)this.y)); }
/** * Returns this entity's X position relative to the camera screen, rather than the X position in board * @param camera * @return the ordinate of this entity relative to the camera area */ public int getXRelativeTo(MovingCamera camera) { return(camera.getRelativeX((int)this.x)); }