Exemple #1
0
    /**
     * Brings the outer pillars to the middle of the group over the given time.
     */
    public IEnumerator BringPillarsToCentre(float duration, float stopAtPercentage)
    {
        foreach (GroupRotatingPillar pillar in outerPillarsCorrectPosition.Keys)
        {
            pillar.enabled = false;

            pillar.movementSoundSource.Play();
            StartCoroutine(OverTime.Move(pillar.transform, pillar.transform.localPosition, outerPillarsCorrectPosition[pillar], duration, stopAtPercentage, null));
        }

        yield return(new WaitForSeconds(duration));
    }
Exemple #2
0
    /**
     * Position the pillars at the distance aroud the centre over the given time.
     */
    public IEnumerator SeparatePillars(float duration, float endRadius)
    {
        foreach (GroupRotatingPillar pillar in outerPillarsCorrectPosition.Keys)
        {
            pillar.movementSoundSource.Play();
            StartCoroutine(OverTime.Move(pillar.transform, pillar.transform.localPosition, GetChildPosition(pillar, endRadius), duration, null));
        }

        yield return(new WaitForSeconds(duration));

        foreach (RotatingPillar pillar in outerPillarsCorrectPosition.Keys)
        {
            pillar.enabled = true;
        }
    }
Exemple #3
0
    /**
     * Has the piece move along the given path, and fire an event when it gets there.
     */
    public IEnumerator MoveAlongPath(MovementPath path)
    {
        beingAnimated = true;

        //Iterate over the points, animating movement to each.
        foreach (Vector3 point in path)
        {
            yield return(OverTime.Move(transform, transform.position, point, Vector3.Distance(transform.position, point) / movementSpeed, null));
        }

        beingAnimated = false;


        //  Notify the node at the end of the path that it has been reached.
        if (path.reverseEnumeration)
        {
            path.Start.NotifyReached();
        }
        else
        {
            path.End.NotifyReached();
        }
    }
    private IEnumerator CheckSolution()
    {
        int correctGroups = 0;

        //Check the groups and then animate them going into the centre.
        foreach (PillarGroup group in groupsCorrectPositions.Keys)
        {
            if (group.OuterPillarsAtCorrectRotation())
            {
                Debug.Log("Correct Outer");

                //If the outer pillars are correctly rotated, bring them all the way to the centre and add 1 to the correct entried.
                correctGroups++;
                StartCoroutine(group.BringPillarsToCentre(duration, 1));
            }
            else
            {
                StartCoroutine(group.BringPillarsToCentre(duration, incorrectStopAtRatio));
            }
        }

        yield return(new WaitForSeconds(duration));

        if (correctGroups >= groupsCorrectPositions.Count)
        {
            //The groups have been assembled correctly based on the middle pillar, now check whole group arrangment.
            foreach (PillarGroup group in groupsCorrectPositions.Keys)
            {
                if (group.CentrePillarAtCorrectRotation())
                {
                    Debug.Log("Correct Inner");

                    correctGroups--;

                    group.PlayMovementSounds();
                    StartCoroutine(OverTime.Move(group.transform, group.transform.localPosition, groupsCorrectPositions [group], duration, 1, null));
                }
                else
                {
                    group.PlayMovementSounds();
                    StartCoroutine(OverTime.Move(group.transform, group.transform.localPosition, groupsCorrectPositions [group], duration, incorrectStopAtRatio, null));
                }
            }

            yield return(new WaitForSeconds(duration));

            if (correctGroups <= 0)
            {
                outcome.Activate();
            }
            else
            {
                foreach (PillarGroup group in groupsCorrectPositions.Keys)
                {
                    group.PlayMovementSounds();
                    StartCoroutine(OverTime.Move(group.transform, group.transform.localPosition, GetChildPosition(group, groupsDistanceFromCentre), duration, null));
                }

                yield return(new WaitForSeconds(duration));

                foreach (PillarGroup group in groupsCorrectPositions.Keys)
                {
                    group.PlayMovementSounds();
                    StartCoroutine(group.SeparatePillars(duration, outerPillarsDistanceFromCentre));
                }
            }
        }
        else
        {
            //There is a group assembled incorrectly, don't proceed to next stage.
            foreach (PillarGroup group in groupsCorrectPositions.Keys)
            {
                StartCoroutine(group.SeparatePillars(duration, outerPillarsDistanceFromCentre));
            }
        }
    }