コード例 #1
0
 /**
  * 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));
 }
コード例 #2
0
 /**
  * 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));
 }
コード例 #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (triggered)
        {
            return;
        }

        Debug.Log("Raise");

        StartCoroutine(OverTime.Translate(waterTransform, new Vector3(0, heightChange, 0), duration, AfterRise));
        triggered = true;
    }
コード例 #4
0
    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();
        }
    }
コード例 #5
0
    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();
        }
    }
コード例 #6
0
    /**
     * 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);
    }