Example #1
0
 void OnGUI()
 {
     if (Time.timeScale == 0f)
     {
         if (GUI.Button(new Rect(0, 50, 50, 50), "Level1"))
         {
             Application.LoadLevel(Application.loadedLevel);
             NbackGenerator.setLevel(1);
         }
         else if (GUI.Button(new Rect(0, 100, 50, 50), "Level2"))
         {
             Application.LoadLevel(Application.loadedLevel);
             NbackGenerator.setLevel(2);
         }
         else if (GUI.Button(new Rect(0, 150, 50, 50), "Level3"))
         {
             Application.LoadLevel(Application.loadedLevel);
             NbackGenerator.setLevel(3);
         }
         else if (GUI.Button(new Rect(0, 200, 50, 50), "Level4"))
         {
             Application.LoadLevel(Application.loadedLevel);
             NbackGenerator.setLevel(4);
         }
         else if (GUI.Button(new Rect(0, 250, 50, 50), "Level5"))
         {
             Application.LoadLevel(Application.loadedLevel);
             NbackGenerator.setLevel(5);
         }
     }
 }
Example #2
0
    // Use this for initialization
    void Start()
    {
        gameMngr = FindObjectOfType(typeof(PopzGameManager)) as PopzGameManager;

        // Set up references to object generators and grid
        grid           = GameObject.FindGameObjectWithTag("Grid").GetComponent <Grid> ();
        platformGen    = GameObject.FindGameObjectWithTag("PlatformGen").GetComponent <PlatformGenerator> ();
        collectibleGen = GameObject.FindGameObjectWithTag("CollectibleGen").GetComponent <CollectibleGenerator> ();
        groundGen      = GameObject.FindGameObjectWithTag("GroundGen").GetComponent <GroundGenerator> ();
        nbackGen       = FindObjectOfType(typeof(NbackGenerator)) as NbackGenerator;
        player         = GameObject.FindGameObjectWithTag("Player").GetComponent <Player> ();

        // Position generator and box collider
        Vector3 bottomLeft = Camera.main.ScreenToWorldPoint(new Vector3(0f, 0f, 0f));
        Vector3 topRight   = Camera.main.ScreenToWorldPoint(new Vector3(Camera.main.pixelWidth, Camera.main.pixelHeight, 0f));

        bottomLeft.y = Camera.main.GetComponent <FixedHeight> ().height - (topRight.y - bottomLeft.y) / 2f;
        BoxCollider2D boxCol    = gameObject.GetComponent <BoxCollider2D> ();
        float         boxHeight = topRight.y - bottomLeft.y;
        float         boxWidth  = 1f;

        boxCol.size        = new Vector2(boxWidth, boxHeight);
        boxCol.offset      = new Vector2(-boxWidth, boxHeight / 2f);
        transform.position = new Vector3(bottomLeft.x, bottomLeft.y, 0f);

        BoxCollider2D chunkBoxCol    = terrainChunk.GetComponent <BoxCollider2D> ();
        float         chunkBoxWidth  = 2f * ((float)grid.numCellsX) * grid.cellSizeX;
        float         chunkBoxHeight = topRight.y - bottomLeft.y;

        chunkBoxCol.size      = new Vector2(chunkBoxWidth, chunkBoxHeight);
        chunkBoxCol.offset    = new Vector2(chunkBoxWidth / 2f, chunkBoxHeight / 2f);
        chunkBoxCol.isTrigger = true;

        genPlants    = false;
        genPlatforms = false;

        //Debug.Log (transform.position);
        GenerateTerrain(transform.position);
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (this.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("PlayerBoostFall"))
        {
            justJumped = false;
        }

        if (jumpEnabled && canJump && Input.GetKeyDown("space"))
        {
            if (onGround)
            {
                StartCoroutine("InitJumpDelay", jumpDelayNum);
            }
            else
            {
                this.GetComponent <Animator>().SetInteger("PlayerState", 2);
                Jump();
            }
        }
        if (canRun)
        {
            transform.Translate(new Vector3(runningSpeed * Time.deltaTime, 0f, 0f));
        }

        UpdateTouch();
        NbackPlatformsInput();
        this.GetComponent <Animator>().SetBool("PlayerInAir", !onGround);

        LivesText.GetComponent <Text>().text = "Lives: " + numLives.ToString();

        if (numLives <= 0)
        {
            int n = NbackGenerator.currentLevel;
            Application.LoadLevel(Application.loadedLevel);
            NbackGenerator.setLevel(n);
        }
    }
Example #4
0
    // Use this for initialization
    void Start()
    {
        gameMngr = FindObjectOfType (typeof(PopzGameManager)) as PopzGameManager;

        // Set up references to object generators and grid
        grid = GameObject.FindGameObjectWithTag ("Grid").GetComponent<Grid> ();
        platformGen = GameObject.FindGameObjectWithTag ("PlatformGen").GetComponent<PlatformGenerator> ();
        collectibleGen = GameObject.FindGameObjectWithTag ("CollectibleGen").GetComponent<CollectibleGenerator> ();
        groundGen = GameObject.FindGameObjectWithTag ("GroundGen").GetComponent<GroundGenerator> ();
        nbackGen = FindObjectOfType (typeof(NbackGenerator)) as NbackGenerator;
        player = GameObject.FindGameObjectWithTag ("Player").GetComponent<Player> ();

        // Position generator and box collider
        Vector3 bottomLeft = Camera.main.ScreenToWorldPoint (new Vector3 (0f, 0f, 0f));
        Vector3 topRight = Camera.main.ScreenToWorldPoint (new Vector3 (Camera.main.pixelWidth, Camera.main.pixelHeight, 0f));
        bottomLeft.y = Camera.main.GetComponent<FixedHeight> ().height - (topRight.y - bottomLeft.y)/2f;
        BoxCollider2D boxCol = gameObject.GetComponent<BoxCollider2D> ();
        float boxHeight = topRight.y - bottomLeft.y;
        float boxWidth = 1f;
        boxCol.size = new Vector2 (boxWidth, boxHeight);
        boxCol.offset = new Vector2 (-boxWidth, boxHeight / 2f);
        transform.position = new Vector3(bottomLeft.x, bottomLeft.y, 0f);

        BoxCollider2D chunkBoxCol = terrainChunk.GetComponent<BoxCollider2D> ();
        float chunkBoxWidth = 2f * ((float) grid.numCellsX) * grid.cellSizeX;
        float chunkBoxHeight = topRight.y - bottomLeft.y;
        chunkBoxCol.size = new Vector2 (chunkBoxWidth, chunkBoxHeight);
        chunkBoxCol.offset = new Vector2 (chunkBoxWidth/2f, chunkBoxHeight/2f);
        chunkBoxCol.isTrigger = true;

        genPlants = false;
        genPlatforms = false;

        GenerateTerrain (transform.position);
    }