Пример #1
0
    public void checkHeight()
    {
        //yPosition <= currentFrameMaxHeight <= currentScore <= currentGameMaxHeight <= PlayerData.maxHeight.
        if (endMenuManager.isGameEnded == true)
        {
            return;
        }
        const int  lowValue = -9999;
        int        currentFrameMaxHeight = lowValue;
        GameObject maxHeightGameObject   = null;
        int        i = 0;

        //Getting the highest height and it's game object.
        for (; i < placedObjects.Count; i++)
        {
            if (checkValues(i) == true)
            {
                int yPosition = (int)(placedObjectsTransforms[i].position.y);
                if (yPosition > currentFrameMaxHeight)
                {
                    currentFrameMaxHeight = yPosition;
                    maxHeightGameObject   = placedObjects[i];
                }
            }
        }
        //We check if it stays like that for maxFrameChecking frames.
        if (currentFrameMaxHeight != lowValue)
        {
            frameCount++;
            if (frameCount == 1)
            {
                previousFrameGameObject = maxHeightGameObject;
                return;
            }
            else if ((frameCount == maxFrameChecking) && (previousFrameGameObject == maxHeightGameObject))
            {
                currentScore = currentFrameMaxHeight;
                if (currentScore > currentGameMaxHeight)
                {
                    currentGameMaxHeight = currentScore;
                }
                if (currentScore > LoadedPlayerData.playerData.maxHeight)
                {
                    LoadedPlayerData.playerData.maxHeight = currentScore;
                }
                if (currentFrameMaxHeight >= _objectiveScript.objectiveScore)
                {
                    _objectiveScript.clientRPCGenerateObjective(false);
                    if (isServer == true)
                    {
                        _objectScript.giveMoreItems();
                    }
                }
                frameCount = 0;
            }
            else if (previousFrameGameObject != maxHeightGameObject)
            {
                frameCount = 0;
            }
        }
        return;
    }