Esempio n. 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);
        }
Esempio n. 2
0
        void OnCollisionEnter(Collision colInfo)
        {
            // destroy cylinder if it was same color, if not just bounce off
            Material cylinderMat = colInfo.transform.GetComponent <Renderer>().sharedMaterial;
            Material ballMat     = transform.GetComponent <Renderer>().sharedMaterial;

            if (cylinderMat == ballMat)
            {
                // get all same coloured cylinders
                List <Collider> chainOfCylinders = new List <Collider>();
                chainOfCylinders.AddRange(FindChainOfSameColour(colInfo.transform, colInfo.transform.GetComponent <Renderer>().sharedMaterial, LevelManager.instance.proximityDistance));

                // destroy the chain of cylinders, add explision force, and show partile effects
                foreach (Collider item in chainOfCylinders)
                {
                    // apply force t surrounding cylinders
                    SimulateExplosion(item.transform, LevelManager.instance.explosionForce, LevelManager.instance.explosionRadius);

                    // particle effect
                    GameObject partEff = Instantiate(LevelManager.instance.popCylinderEffect, item.transform.position, LevelManager.instance.popCylinderEffect.transform.rotation);
                    partEff.transform.GetComponent <ParticleSystemRenderer>().material = item.GetComponent <Renderer>().material;

                    // keep track of level progress
                    if (item.transform.parent != null)
                    {
                        LevelManager.instance.UpdateLevelProgress();
                    }

                    // destroy cylinder
                    Destroy(item.gameObject);
                }
                // tell LeveManager to unlock new floors if neccessary
                if (LevelManager.instance.chooseTowerType == LevelManager.TowerType.Tetris)
                {
                    if (UIScreens.instance.comboGoober.sharedMaterial == transform.GetComponent <Renderer>().sharedMaterial)
                    {
                        TetrisMode.UpdateFloor(chainOfCylinders);
                    }
                }
                else
                {
                    LevelManager.instance.UpdateFloors();
                }



                // finaly destroy this ball so it doesnt destroy more cylinders
                Destroy(gameObject);
            }
            else
            {
                // if cylinder was not same color make the ball bounce off somewhere else harmlessly
                rgbody.useGravity  = true;
                rgbody.isKinematic = false;
                Vector3 bounceDirection = (transform.position - colInfo.transform.position).normalized;
                transform.GetComponent <Rigidbody>().AddForce(bounceDirection * LevelManager.instance.bounceForce, ForceMode.Impulse);
                gameObject.layer = LayerMask.NameToLayer("Default");
            }
        }
Esempio n. 3
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);
        }