void UpdateTouch() { PopzGameManager gameMngr = FindObjectOfType(typeof(PopzGameManager)) as PopzGameManager; if (!gameMngr.Modes().Contains(GameModes.Nback)) { return; } foreach (Touch touch in Input.touches) { if (touch.phase == TouchPhase.Began) { //Jump (); if (onGround) { StartCoroutine("InitJumpDelay", jumpDelayNum); } else { this.GetComponent <Animator>().SetInteger("PlayerState", 2); Jump(); } } } }
void UpdateTouch() { PopzGameManager gameMngr = FindObjectOfType(typeof(PopzGameManager)) as PopzGameManager; if (!gameMngr.Modes().Contains(GameModes.Nback)) { return; } foreach (Touch touch in Input.touches) { if (touch.phase == TouchPhase.Began) { Jump(); } } }
// 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); }
// 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); }
// Update is called once per frame void Update() { // Quick and dirty game disable. Need more state machines. PopzGameManager mngr = FindObjectOfType(typeof(PopzGameManager)) as PopzGameManager; if (!mngr.Modes().Contains(GameModes.Pattern)) { LivesText.SetActive(false); RoundsText.SetActive(false); return; } //Vector3 bottomLeft = Camera.main.ScreenToWorldPoint (new Vector3 (0f, 0f, 0f)); //Debug.Log ("BottomLeft: " + bottomLeft); LivesText.GetComponent <Text>().text = "Lives: " + numLives.ToString(); RoundsText.GetComponent <Text>().text = "Rounds: " + numRounds.ToString(); if (gameStarted) { //Debug.Log("Spawn Pattern NOW"); int rand = Random.Range(0, 2); if (rand == 0) { pattern.isReverse = true; } else { pattern.isReverse = false; } pattern.GeneratePattern(patternLength); gameStarted = false; } if (pattern.startGeneratingPlatforms) { //Debug.Log("Spawn Cloud NOW"); pattern.startGeneratingPlatforms = false; terrainGen.GenerateCloud(); } /*if(pattern.startGeneratingPlatforms) * { * terrainGen.genPlants = true; * terrainGen.genPlatforms = true; * pattern.startGeneratingPlatforms = false; * }*/ // Skips and generates new pattern is "s" is pressed /*if (Input.GetKeyDown ("s")) { * int rand = Random.Range (0, 2); * * if(rand == 0) * { * collectReverse = true; * * StartCoroutine("RevealCollectionStatus",2f); * } * else * { * collectReverse = false; * } * pattern.GeneratePattern(patternLength); * numLives = livesPerCollection; * } * //Press h * if (Input.GetKeyDown ("h") && numHints > 0 && !pattern.display) { * pattern.RevealPattern(); * numHints--; * }*/ }