Beispiel #1
0
    private void Update()
    {
        if (timer == null)
        {
            return;
        }

        if (choosen != null && !isLevelEnd)
        {
            if (!choosen.IsOver())
            {
                return;
            }
            if (endLevelState == LEVEL_STATE.WIN)
            {
                ChangeCubeColor(new Color(0, 255, 0, 0.5f));
            }
            if (endLevelState == LEVEL_STATE.LOSE)
            {
                float shapeScale = choosen.transform.localScale.x;
                float cubeScale  = gameSceneCreator.GetLevelCube().transform.localScale.x;
                if (shapeScale > cubeScale)
                {
                    GameObject cube = gameSceneCreator.GetLevelCube();
                    broken = Instantiate(gameSceneCreator.brokenCubePrefab);
                    broken.transform.position   = cube.transform.position;
                    broken.transform.localScale = cube.transform.localScale;
                    Destroy(cube);
                }
                if (shapeScale < cubeScale)
                {
                    ChangeCubeColor(new Color(255, 0, 0, 0.5f));
                }
            }

            Debug.Log("Is over: " + choosen.IsOver());
            isLevelEnd = true;
            PlayEndLevelSound(endLevelState);
            if (endLevelState == LEVEL_STATE.WIN)
            {
                IncreaseCurrentLevelStage();
            }
            else
            {
                currentLevel = 0;
            }
            UI.ActiveteEndLevelUI(SetupEndLevelText(endLevelState), SetupEndLevelTextColor(endLevelState));
            StartNextLevel();
            choosen = null;
        }
        else
        {
            if (!timeout)
            {
                if (timer.GetCurrentTime() <= 0 && !isLevelEnd)
                {
                    timeout = true;
                    EndLevel(LEVEL_STATE.LOSE, null);
                    currentLevel = 0;
                    UI.ActiveteEndLevelUI(SetupEndLevelText(endLevelState), SetupEndLevelTextColor(endLevelState));
                    StartNextLevel();
                    choosen = null;
                }
            }
        }
    }