示例#1
0
    public void GenerateLevel()
    {
        //Sets the gap scaler
        gapScaler += (0.1f * difficulty);

        //Generate level seed
        float levelSeed = GenerateLevelSeed(StaticVariables.LevelNumber());

        Transform safeZone1, safeZone2;

        //Start platform
        safeZone1 = GenerateSafeZone(new Vector2(-5.0f, -3.0f), SafeZoneScript.TYPE.START);

        //safeZone2 = GenerateSafeZone (new Vector2 (30.0f, -3.0f), SafeZoneScript.TYPE.CHECKPOINT);

        safeZone2 = GenerateSafeZone(new Vector2(gridWidth, -3.0f), SafeZoneScript.TYPE.END);
        GeneratePlatforms(levelSeed, safeZone1.position.x + 1.5f, safeZone2.position.x - 1.5f);

        //End
        GenerateSafeZone(new Vector2(gridWidth, -3.0f), SafeZoneScript.TYPE.END);
    }
示例#2
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Player")
     {
         if (zoneType == TYPE.END)
         {
             //Takes the player back to the level select screen
             SceneManager.LoadScene(0);
             StaticVariables.levelCompleted [StaticVariables.LevelNumber()] = true;
         }
         else
         {
             //If the new spawn is further on than the last
             if (transform.position.x > StaticVariables.spawnX)
             {
                 //Sets the new spawn position
                 StaticVariables.spawnX = transform.position.x;
             }
         }
     }
 }
示例#3
0
        private void FixedUpdate()
        {
            m_Grounded = false;

            // The player is grounded if a circlecast to the groundcheck position hits anything designated as ground
            // This can be done using layers instead but Sample Assets will not overwrite your project settings.
            Collider2D[] colliders = Physics2D.OverlapCircleAll(m_GroundCheck.position, k_GroundedRadius, m_WhatIsGround);
            for (int i = 0; i < colliders.Length; i++)
            {
                if (colliders[i].gameObject != gameObject)
                {
                    m_Grounded = true;
                }
            }
            m_Anim.SetBool("Ground", m_Grounded);

            // Set the vertical animation
            m_Anim.SetFloat("vSpeed", m_Rigidbody2D.velocity.y);

            if (transform.position.y < -5.0f)
            {
                StaticVariables.LoadLevel(StaticVariables.LevelNumber());
            }
        }