Пример #1
0
        List <GameObject> GenerateLevel(TowerType type)
        {
            List <GameObject> list;

            switch (type)
            {
            case TowerType.Circle:
                list = NormalMode.InstantiateCircleTower(centerOfTower, pieceCount, floorCount, cylinderPrefab, radius, rotateFloors);
                break;

            case TowerType.Triangle:
                list = NormalMode.TriangleTower(centerOfTower, pieceCount, floorCount, cylinderPrefab, radius, rotateFloors);
                break;

            case TowerType.HourGlass:
                list = NormalMode.HourGlassTower(centerOfTower, pieceCount, floorCount, cylinderPrefab, radius, rotateFloors);
                break;

            case TowerType.Tetris:
                list = TetrisMode.TetrisTower(centerOfTower, pieceCount, floorCount, cylinderPrefab, discPrefab, radius, rotateFloors);
                break;

            default:
                list = NormalMode.InstantiateCircleTower(centerOfTower, pieceCount, floorCount, cylinderPrefab, radius, rotateFloors);
                break;
            }
            return(list);
        }
Пример #2
0
        // rewrite this so it goes hrough al the floors and checks if they are empty
        public void UpdateFloors()
        {
            for (int i = allFloors.Count - 1; i > lockedFloors.Count - 1; i--)
            {
                // if all cylinders of the topmost floor have fallen or been destroyed unlock a new floor to maintain an 8 floor minimum
                if (allFloors[i].transform.childCount <= 0)
                {
                    if (lockedFloors.Count > 0)
                    {
                        allFloors.RemoveAt(allFloors.Count - 1);

                        // unlock a new floor
                        NormalMode.UnlockFloors(lockedFloors, 1);

                        // tell camera to follow unlocked floors
                        if (mainCam.routine != null)
                        {
                            StopCoroutine(mainCam.routine);
                        }
                        mainCam.routine = StartCoroutine(mainCam.SlideToPosition(lockedFloors[lockedFloors.Count - 1].transform.position, cameraSlideDownSpeed));

                        // remove the unlocked floor from the locked floors list
                        lockedFloors.RemoveAt(lockedFloors.Count - 1);
                    }
                }
            }
        }
Пример #3
0
        IEnumerator NewLevelSequence()
        {
            // at the same time rotate the camera
            Vector3 targetPos = allFloors[Mathf.Clamp(allFloors.Count - 8, 0, allFloors.Count)].transform.position;

            StartCoroutine(mainCam.RotateObject(targetPos, Vector3.up, cameraRotationAtStart, moveCameraUpInterval));
            // move camera slowly upward to top of tower
            if (chooseTowerType == TowerType.Tetris)
            {
                yield return(StartCoroutine(mainCam.SlideToPosition(tetrisDisks[tetrisDisks.Count - 1].transform.position, moveCameraUpInterval)));
            }
            else
            {
                yield return(StartCoroutine(mainCam.SlideToPosition(targetPos, moveCameraUpInterval)));

                // lock all fooors except top 8
                yield return(StartCoroutine(NormalMode.LockFloors(allFloors, lockedFloors, 8, delayBetweenFloors, lockedCylinderColor)));
            }
            // enable camera movement and shooting
            mainCam.GetComponent <CameraMovement>().canRotate = true;
            mainCam.GetComponent <ShootBall>().canShoot       = true;
            // spawn a ball
            mainCam.GetComponent <ShootBall>().SpawnNewBall();
            // adjust the collider sthat detects wehn cylinders fall off the tower
            fallOffDetectorOutside.GetComponent <CapsuleCollider>().radius = radius;
            fallOffDetectorOutside.SetActive(true);
            fallOffDetectorInside.GetComponent <CapsuleCollider>().radius = radius / 2;
            fallOffDetectorInside.SetActive(true);

            UIScreens.instance.ballCounter.gameObject.SetActive(true);



            yield return(null);
        }
Пример #4
0
        // Start is called before the first frame update
        void Start()
        {
            if (thisObjectIsSpawnPoint)
            {
                centerOfTower = this.transform.position;
            }
            mainCam      = Camera.main.GetComponent <CameraMovement>();
            allFloors    = new List <GameObject>();
            lockedFloors = new List <GameObject>();
            fallOffDetectorOutside.SetActive(false);
            fallOffDetectorInside.SetActive(false);

            UIScreens.instance.currentLevel.text        = SceneManager.GetActiveScene().buildIndex.ToString();
            UIScreens.instance.nextLevel.text           = (SceneManager.GetActiveScene().buildIndex + 1).ToString();
            UIScreens.instance.levelProgress.fillAmount = 0f;
            UIScreens.instance.ballCounter.gameObject.SetActive(false);

            // generate level
            allFloors.AddRange(GenerateLevel(chooseTowerType));
            initialCylinderCount = allFloors.Count * allFloors[0].transform.childCount;
            if (chooseTowerType != TowerType.Tetris)
            {
                // assign random colors to all cylinders and remember those colors
                NormalMode.AssignRandomColors(allFloors, cylinderColors);
                // lock them in place
                for (int i = 0; i < allFloors.Count - 8; i++)
                {
                    foreach (Transform cylinder in allFloors[i].transform)
                    {
                        cylinder.GetComponent <Rigidbody>().isKinematic = true;
                    }
                }
            }
            else
            {
                TetrisMode.AssignRandomColors(allFloors, cylinderColors, tetrisDisks);
                UIScreens.instance.comboCounter.text = obstacleThreshold.ToString();
            }

            UIScreens.instance.ShowScreen("start", true);
        }