void Update() { if (isEnabledGameplay) { if (gc.GetIsGameplay() && box.GetComponent <BoxCollider2D>().enabled == false) //enables during gameplay { Debug.Log("Enabled trigger box"); box.GetComponent <BoxCollider2D>().enabled = true; } if (gc.GetIsBuilding() && box.GetComponent <BoxCollider2D>().enabled == true) //disabled during building { Debug.Log("Disabled trigger box"); box.GetComponent <BoxCollider2D>().enabled = false; } } if (!isEnabledGameplay) { if (isEnabledGameplay) { if (gc.GetIsGameplay() && box.GetComponent <BoxCollider2D>().enabled == true) //enables during gameplay { Debug.Log("Disabled trigger box"); box.GetComponent <BoxCollider2D>().enabled = false; } if (gc.GetIsBuilding() && box.GetComponent <BoxCollider2D>().enabled == false) //enabled during building { Debug.Log("Enabled trigger box"); box.GetComponent <BoxCollider2D>().enabled = true; } } } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Camera" && gc.GetIsGameplay() && !hasActivated) { Debug.Log("1"); hasActivated = true; isMoving = true; } }
void Update() { if (gc.GetIsGameplay() && needsEnable && !isDefeated && !gc.GetIsPaused()) { Debug.Log("Waking rigidbody"); rb.velocity = new Vector2(0, 0); currentTimer = 0.0f; rb.constraints = RigidbodyConstraints2D.None; anim.SetBool("isGameplay", true); needsEnable = false; } else if (gc.GetIsBuilding() && !needsEnable || gc.GetIsPaused() && !needsEnable || isDefeated) { Debug.Log("Sleeping rigidbody"); rb.constraints = RigidbodyConstraints2D.FreezePosition; needsEnable = true; anim.SetBool("isGameplay", false); rb.velocity = new Vector2(0, 0); isDefeated = false; currentTimer = 0.0f; this.transform.position = thisObject.GetDefaultPosition(); this.transform.rotation = Quaternion.Euler(0, 0, 0); } if (gc.GetIsGameplay() && !gc.GetIsPaused() && !isDefeated) { if (currentTimer <= 0.0f) { currentTimer = maxTimer; } if (currentTimer > 0.0f) { currentTimer -= Time.deltaTime; if (currentTimer <= 0.0f) { Debug.Log("Flipping"); Flip(); } } transform.Translate(Vector2.right * speed * Time.deltaTime); } }
private void Update() { if (currentITime > 0.0f) { currentITime -= Time.deltaTime; } if (isSwimming) { } if (!gc.GetIsGameplay()) { Debug.Log("Gameplay ended"); Erase(); } }
void Update() { if (gc.GetIsGameplay() && !gc.GetIsPaused() && currentTimer <= 0.0f) { currentTimer = interval; Shoot(); } if (currentTimer > 0.0f) { currentTimer -= Time.deltaTime; } if (gc.GetIsBuilding()) { currentTimer = 0.0f; } }
void Update() { if (gc.GetIsGameplay()) //gameplay specific in here { if (!needReset) //allows for a reset when the player goes to gameplay { needReset = true; } if (build.GetPlayerSpawned() && needPlayer) //initialises the player this loop { Debug.Log("Initialising player(Platforming)"); player = FindObjectOfType <Player>(); needPlayer = false; } if (!hasInitialised) //initalises values for this script on play { player = null; timeLeft = build.GetTime(); timeText.text = "Time: " + timeLeft; coinText.text = "Coins: " + coins; scoreText.text = "Score: " + score; hasInitialised = true; } if (player == null) { player = FindObjectOfType <Player>(); } if (!gc.GetIsPaused()) { timeLeft -= Time.deltaTime; } roundedTime = Mathf.FloorToInt(timeLeft); if (player != null) { UpdateUI(); } if (timeLeft <= 0.0f) //boot to build if failed clear in time { gc.SetIsBuilding(true); } } if (gc.GetIsBuilding() && needReset) //resets, etc. here when entering building { ResetPlatformStats(); } }
void Update() { if (gc.GetIsGameplay()) { player = null; } //music switch if (gc.GetIsGameplay() && playMusic.mute == true) { buildMusic.mute = true; buildMusic.Stop(); playMusic.mute = false; playMusic.Play(); } if (gc.GetIsBuilding() && buildMusic.mute == true) { playMusic.mute = true; playMusic.Stop(); buildMusic.mute = false; buildMusic.Play(); } if (buildMusic.mute == false && buildMusic.volume != musicSlider.value) { buildMusic.volume = musicSlider.value; } if (playMusic.mute == false && playMusic.volume != musicSlider.value) { playMusic.volume = musicSlider.value; } //switching states of camera if (gc.GetIsGameplay() && isGameplay == false) { isGameplay = true; } if (!gc.GetIsGameplay() && isGameplay == true) { isGameplay = false; ResetPosition(); } if (player == null && isGameplay) { player = FindObjectOfType <Player>(); } if (isGameplay && player != null) //follows the payer location with a slight offset to allow for visibility { MoveToPlayer(); } if (isBoosting) { isBoosting = false; moveScale /= 2; } if (!isGameplay) //panning/button presses to change positions { if (Input.GetAxis("Boost") != 0) { isBoosting = true; moveScale *= 2; } if (Input.GetAxis("Horizontal") != 0) { if (Input.GetAxis("Horizontal") < 0) { transform.position += new Vector3(-1 * moveScale, 0, 0); } if (Input.GetAxis("Horizontal") > 0) { transform.position += new Vector3(1 * moveScale, 0, 0); } } if (Input.GetAxis("Vertical") != 0) { if (Input.GetAxis("Vertical") < 0) { transform.position += new Vector3(0, -1 * moveScale, 0); } if (Input.GetAxis("Vertical") > 0) { transform.position += new Vector3(0, 1 * moveScale, 0); } } } if (transform.position.x < 19.3f && !isGameplay) { transform.position = new Vector3(19.3f, transform.position.y, zOffset); } if (transform.position.x < 19.3f + xOffset && isGameplay) { transform.position = new Vector3(19.3f + xOffset, transform.position.y, zOffset); } if (transform.position.y < 10.5f) { transform.position = new Vector3(transform.position.x, 10.5f, zOffset); } }