public void SetPlayerAndBlocksPosition()
    {
        if (currentBlocks != null && currentTemple != null && player != null)
        {
            player.SetPosition(currentTemple.ComputePlayerPosition(timelinePercentage));
            currentBlocks.SetPosition(currentBlocks.ComputeBlocksPosition(timelinePercentage));
        }

        if (timelinePercentage > 0.99f && onReachEnd != null)
        {
            onReachEnd();
        }

        if (currentBlocks == null)
        {
            currentBlocks = FindObjectOfType <BlocksRoot>();
        }

        if (currentTemple == null)
        {
            currentTemple = FindObjectOfType <TempleRoot>();
        }

        if (player == null)
        {
            player = FindObjectOfType <Player>();
        }
    }
Exemple #2
0
    void Update()
    {
        if (currentBlocksRoot == null)
        {
            currentBlocksRoot = FindObjectOfType <BlocksRoot>();
        }

        if (!placed)
        {
            if (temple == null)
            {
                temple = FindObjectOfType <TempleRoot>();
            }

            if (temple != null)
            {
                this.transform.position = temple.endPosition.position + tableOffsetFromFinalPosition;
                placed = true;
            }
        }

        // DEBUG
        if (push)
        {
            PushButton(pushnb);
            push = false;
            if (Application.isEditor)
            {
                if (HasRightCombination())
                {
                    Debug.Log("YOU WIN");
                }
                if (HasMadeTooManyMistakes())
                {
                    Debug.Log("YOU LOOSE");
                }
            }
        }

        if (restart)
        {
            restart = false;
            OnRestartLevel();
        }
    }