/** * Raise and show the pillar. */ public void Show() { if (!hidden) { return; //No point in showing a pillar that is already being shown. } StartCoroutine(OverTime.Translate(transform, new Vector3(0, hiddenYDifference * -1, 0), duration, AfterAnimation)); }
/** * Lower and hide the pillar. */ public void Hide() { if (hidden) { return; //No point in hiding a pillar that is already hidden. } StartCoroutine(OverTime.Translate(transform, new Vector3(0, hiddenYDifference, 0), duration, AfterAnimation)); }
private void OnTriggerEnter(Collider other) { if (triggered) { return; } Debug.Log("Raise"); StartCoroutine(OverTime.Translate(waterTransform, new Vector3(0, heightChange, 0), duration, AfterRise)); triggered = true; }
public IEnumerator PressAndLock(Action onCompletion) { if (!locked) { GetComponent <AudioSource> ().Play(); locked = true; StartCoroutine(OverTime.Translate(transform, pressDistance, pressSpeed, null)); yield return(new WaitForSeconds(pressSpeed)); } if (onCompletion != null) { onCompletion(); } }
public IEnumerator UnlockAndRelease(Action onCompletion) { if (locked) { GetComponent <AudioSource> ().Play(); StartCoroutine(OverTime.Translate(transform, pressDistance * -1, pressSpeed, null)); yield return(new WaitForSeconds(pressSpeed)); locked = false; } if (onCompletion != null) { onCompletion(); } }
/** * Move the pillar by the appropriate offset value based on the given direction over the given time, if it can be moved. * Also returns whether it can be moved. */ public bool Move(MoveDirection direction, float duration, Action onMoveFinish) { Vector3 startPostion = transform.localPosition; Vector3 distance; //TBD //Determine the distance to move based on the direction. if (direction == MoveDirection.Up && positionNumbers.y <= 0) { distance = new Vector3(0, offset.y, 0); positionNumbers.y += 1; } else if (direction == MoveDirection.Down && positionNumbers.y >= 0) { distance = new Vector3(0, -1 * offset.y, 0); positionNumbers.y -= 1; } else if (direction == MoveDirection.Left && positionNumbers.x >= 0) { distance = new Vector3(-1 * offset.x, 0, 0); positionNumbers.x -= 1; } else if (direction == MoveDirection.Right && positionNumbers.x <= 0) { distance = new Vector3(offset.x, 0, 0); positionNumbers.x += 1; } else { return(false); } Debug.Log(distance); //Animate translation. GetComponent <AudioSource>().Play(); StartCoroutine(OverTime.Translate(transform, distance, duration, onMoveFinish)); return(true); }