コード例 #1
0
    //This is used for Endless mode level ending
    private IEnumerator LevelChangeState(float PlayerSpeedLimit, float PlayerSpeed)
    {
        if (!isStarted)
        {
            yield return(new WaitUntil(() => blocks[0] != null));

            isStarted = true;
            isGameOn  = true;
            uIScript.startGame();
            Time.timeScale = 1f;
        }
        else
        {
            yield return(new WaitForSeconds(.3f));
        }
        playerLock = true;

        ObjectPooler.SharedInstance.CreateObjects("BrokenBlock", GameObject.FindWithTag("ALLPLATFORM").transform, blockNumber);
        BlockChanger();
        HollowSetter(blocks[0].gameObject.transform.position.z - 2f);
        gunScript.passedBlock = 0;

        //Debug.Log("Top hızlanmaya baslıyor. Top hızı :" + Player.instance.speed.z);
        float speedRate = 5f;
        float waitTime  = .01f;

        while (!PlayerAccelerator.PlayerFastEnough(Player.instance.speed.z, PlayerSpeedLimit))
        {
            Player.instance.speed.z += speedRate;
            yield return(new WaitForSeconds(waitTime));
        }

        yield return(new WaitUntil(() => Player.instance.transform.position.z >= GameObject.FindWithTag("LevelHollows").transform.GetChild(GameObject.FindWithTag("LevelHollows").transform.childCount - 12).transform.position.z));

        while (!PlayerAccelerator.PlayerNormalSpeed(Player.instance.speed.z, PlayerSpeed))
        {
            if (PlayerSpeed + 70f >= Player.instance.speed.z && !gunScript.isShooting)
            {
                gunScript.blockNumb       = 0;
                gunScript.totBulletSended = 0;
                gunScript.StartGun();
                waitTime = .03f;
            }
            Player.instance.speed.z -= speedRate;
            yield return(new WaitForSeconds(waitTime));
        }
        Player.instance.bulletProofSpeed = PlayerAccelerator.GetPlayerNormalSpeed(Player.instance.initialSpeed) + (Player.instance.modeSpeedIncrease) + ((Player.instance.strikeConstant - 1) * 2f);
        int m = Player.instance.mode;

        Player.instance.speed.z = (m == (int)Player.Mode.normal) ? PlayerAccelerator.GetPlayerNormalSpeed(Player.instance.initialSpeed) : Player.instance.bulletProofSpeed;
        //Player.instance.RayCalculator(0);

        yield return(new WaitUntil(() => Player.instance.gameObject.transform.position.z >= blocks[0].gameObject.transform.position.z - 35f));

        playerLock = false;
        yield return(new WaitUntil(() => Player.instance.gameObject.transform.position.z >= blocks[0].gameObject.transform.position.z - 15f)); //Player.instance.gameObject.transform.position.z >= blocks[0].gameObject.transform.position.z - 10f);

        isLevel = true;
        GameObject.FindWithTag("LevelHollows").transform.position = new Vector3(0f, 0f, LastPosOfArray + 80f);
        CoinsScript.IncreaseAndActivateCoins(GameObject.FindWithTag("Coins"));
        AddLevelHollow(2);
        //createNewLevel = false;
        StopCoroutine(LevelChangeState(PlayerSpeedLimit, PlayerSpeed));
    }
コード例 #2
0
    public void Update()
    {
        if (GameConst.instance.isGameOn)
        {
            if (mode == (int)Mode.normal)
            {
                this.transform.Rotate(new Vector3(speed.z * 8, 0, 0) * Time.deltaTime, Space.Self);
            }
            else
            {
                this.transform.Rotate(new Vector3(speed.z * 11, 0, 0) * Time.deltaTime, Space.Self);
            }

            //_____________________________For making blocks change COLOR_________________________________________//
            if (Physics.Raycast(transform.position, rayVector, out hit, 20f, blockLayerMask.value))
            {
                if (hit.collider.gameObject.layer == blockLayerIndex && hit.normal == hit.collider.gameObject.transform.up && !canCollide && state == (int)State.forward)
                {
                    canCollide = true;
                    GameConst.instance.lastHit = hit.collider.gameObject;
                    //orgBlockColor = hit.collider.GetComponent<Renderer>().material.GetColor("_Color");
                    Color color = Color.Lerp(GameConst.instance.lastHit.GetComponentInParent <BlockColorChanger>().GetColor(), HittableBlockColor, .4f);
                    hit.collider.GetComponent <Renderer>().material.SetColor("_Color", color);
                }
            }
            else if (GameConst.instance.lastHit != null && canCollide)
            {
                canCollide = false;
                GameConst.instance.lastHit.GetComponent <Renderer>().material.SetColor("_Color", GameConst.instance.lastHit.GetComponentInParent <BlockColorChanger>().GetColor());
            }

            // Energy Düsürme ve 0 sa bölüm sonlandırma ________________

            if (energyTot <= GameConst.instance.energyTime / 3f && GameConst.instance.isLevel && strike <= 0)
            {
                energyTot -= Time.deltaTime * energyDecreaseRate;
            }

            if ((energyTot <= 0 && !GameConst.instance.isEnergyFinished))
            {
                GameConst.instance.isEnergyFinished = true;
                StartCoroutine(Player.instance.EnergyFinish());
            }


            // ____________________BulletProof Hız ayarlama _______________________________________

            if (mode == (int)Mode.bulletProof && !PlayerAccelerator.PlayerFastEnough(speed.z, bulletProofSpeed) && !GameConst.instance.playerLock)
            {
                speed.z += .5f;
                if (PlayerAccelerator.PlayerFastEnough(speed.z, bulletProofSpeed) && strikeConstant == 1)
                {
                    RayCalculator(modeSpeedIncrease);
                }
            }
            else if (mode == (int)Mode.normal && !PlayerAccelerator.PlayerNormalSpeed(speed.z, normalSpeed) && !GameConst.instance.playerLock)
            {
                speed.z -= .5f;
                if (PlayerAccelerator.PlayerNormalSpeed(speed.z, normalSpeed))
                {
                    RayCalculator(modeSpeedIncrease);
                }
            }

            //____________________________ Passed Block Calculation && Calculation of if not collided end bulletmode ______________________//

            if (lastPassedBlock <= GameConst.instance.blockNumber - 1 && GameConst.instance.blocks[lastPassedBlock + 1].transform.position.z + 15f <= this.transform.position.z && GameConst.instance.isLevel)
            {
                lastPassedBlock += 1;
                //Debug.Log(lastPassedBlock);
                if (!GameConst.instance.blocks[lastPassedBlock].gameObject.GetComponent <BlockScript>().didCollided)
                {
                    if (strike > 0)
                    {
                        energyTot = GameConst.instance.energyTime / 3f;
                        strike    = 0;
                    }

                    if (mode == (int)Mode.bulletProof)
                    {
                        changeToNormal();
                    }
                }
            }

            //______________________________ END OF LEVEL ______________________________//

            if (transform.position.z >= GameConst.instance.LastPosOfArray + 20f && GameConst.instance.isLevel) //&& GameConst.instance.destroyedBlockNumber >= GameConst.instance.BlockDestroyLimit)
            {
                Debug.Log("Bölüm Geçildi !!!!!!!!!!!!!!!!!!!!");
                GameConst.instance.isLevel = false;
                GameConst.instance.LevelChanger(speed.z + 180f);
                lastPassedBlock = -1;
            }

            //___________________ END OF KAFA ATMA MODU  3 mermi yedin go_______________________//

            if (mode == (int)Mode.bulletProof && bulletHits >= 3)
            {
                changeToNormal();
            }
        }
    }
コード例 #3
0
    //This is used for level based level endings
    private IEnumerator LevelEndedState(float PlayerSpeedLimit)
    {
        yield return(new WaitForSeconds(.3f));

        ///////////////////////////////////////////////////renklerrrr////////////////////////////////////////////////////////////////

        /*float randFlt = Random.Range (0.01f, 1f);
         *
         * DataScript.levelModeBlockColor = HueChanger.hueChanger (DataScript.levelModeBlockColor, randFlt);//Random.Range (0f,1f));
         * DataScript.levelModeHexogenColor = HueChanger.hueChanger (DataScript.levelModeHexogenColor, randFlt);//Random.Range (0f,1f));*/
        ///////////////////////////////////////////////////renklerrrr//////////////////////////////////////////////////////////////
        ///
        /// Safe swicth for when player dies after stepping last block dont increment level and break corountine
        if (isGameOn != true)
        {
            yield break;
        }

        playerLock                         = true;
        onIdle                             = true;
        DataScript.pointHolder             = points;
        DataScript.isSessionEnded          = false;
        DataScript.isPassedAtLeastOneLevel = true;
        DataScript.ThemeIndex              = (Level - 1) % DataScript.Themes.Count;
        PlayerPrefs.SetInt("PlayerLevel", Level);
        FB.LogAppEvent(AppEventName.AchievedLevel, (float)Level - 1);
        if (PlayerPrefs.GetInt("MaxLevel") < Level)
        {
            PlayerPrefs.SetInt("MaxLevel", Level);
        }
        GameObject coins         = GameObject.FindWithTag("Coins");
        GameObject levelHexogans = GameObject.FindWithTag("LevelHollows");

        float speedRate = 10f;
        float waitTime  = .01f;

        while (!PlayerAccelerator.PlayerFastEnough(Player.instance.speed.z, PlayerSpeedLimit))
        {
            Player.instance.speed.z += speedRate;
            yield return(new WaitForSeconds(waitTime));
        }

        bool  changed = false;
        float tilt    = 0;
        Color ex      = levelHexogans.transform.GetChild(0).transform.GetChild(0).GetComponent <Renderer>().material.color;

        while (onIdle)
        {
            if (Player.instance.transform.position.z >= coins.transform.GetChild(coins.transform.childCount - 1).transform.position.z + 50f && !changed)
            {
                changed = true;
                uIScript.NextLevel();
            }
            if (tilt < 1)
            {
                tilt = Mathf.MoveTowards(tilt, 1f, 0.01f);
                foreach (Renderer r in levelHexogans.GetComponentsInChildren <Renderer>())
                {
                    r.material.color = Color.Lerp(ex, DataScript.Themes[DataScript.ThemeIndex].HexagonColor, tilt);
                }
                Edges.ForEach(delegate(GameObject g)
                {
                    foreach (Renderer r in g.GetComponentsInChildren <Renderer>())
                    {
                        r.material.color = Color.Lerp(ex, DataScript.Themes[DataScript.ThemeIndex].HexagonColor, tilt);
                    }
                });
            }

            LevelHollowGetDistance.SetHollow(levelHexogans.transform.GetChild(0).gameObject, LevelHollowGetDistance.GetDistance(levelHexogans.transform) + 10f);
            levelHexogans.transform.GetChild(0).SetAsLastSibling();
            yield return(new WaitUntil(() => Player.instance.transform.position.z >= GameObject.FindWithTag("LevelHollows").transform.GetChild(GameObject.FindWithTag("LevelHollows").transform.childCount - 25).transform.position.z));
        }
    }