public void checkValidBoundsTotalTest() { double[] bounds = new double[2]; bounds[0] = 0; bounds[1] = 10; Assert.IsTrue(BoundsChecker.checkValidBoundsTotal(2, bounds)); }
public void Initialize(Vector2 velocity, int size) { Size = size; _sizes = transform.Find("Sizes"); SetSize(); var rb = GetComponent <Rigidbody2D>(); rb.velocity = velocity; rb.angularVelocity = BoundsChecker.GetRandomAngularVelocity(); }
//When a message is received to apply the slow powerup public void OnReceiveSlowMessage(NetworkMessage networkMessage) { PowerupMessage slowMessage = networkMessage.ReadMessage <PowerupMessage> (); Debug.Log(slowMessage.x + " " + bounds[0] + " " + bounds[1]); if (!BoundsChecker.checkValidBoundsTotal(slowMessage.x, bounds)) { Debug.Log("Slow powerup in effect"); activeVel = -0.2f; activeBlockControl.setVelocity(new Vector3(0, -0.2f, 0)); } }
private void Spawn() { if (_holder.childCount >= MaxAsteroidCount) { return; } var pos = BoundsChecker.GetRandomPos(); var vel = BoundsChecker.GetRandomVelocity(); int size = Random.Range(2, Asteroid.AsteroidTypes); // don't spawn tinies ForceSpawn(pos, vel, size); }
//When a message is received to end the game public void OnReceiveEndGameMessage(NetworkMessage networkMessage) { EndGameMessage endgame = networkMessage.ReadMessage <EndGameMessage> (); if (isLocalPlayer) { Debug.Log("IsLocalPlayer"); if (BoundsChecker.checkValidBoundsTotal(endgame.x, bounds)) { Instantiate(this.gameWinUI); this.CmdReceiveEndGameMessage(false); } else { Instantiate(this.gameOverUI); this.CmdReceiveEndGameMessage(true); } } }
// Update is called once per frame void Update() { //Only transform the local objects, othewise ignore if (isLocalPlayer) { if (fortuneWheelController.getState() == PowerupState.Refreshing) { powerUpPresent = false; } if (powerUpControl != null) { if (powerUpControl.getCollected()) { //Rotate according to powerup needs powerUpControl.setClient(NetworkManager.singleton.client); fortuneWheelController.HandlePowerup(powerUpControl); } } if (activeBlockControl != null) { activeBlockControl.setVelocity(new Vector3(0, activeVel, 0)); if (BoundsChecker.checkValidBoundsLeft(activeBlock.transform, bounds[0])) { if (moveLeft) { activeBlock.transform.position += new Vector3((float)-0.5, 0, 0); moveLeft = false; } } if (BoundsChecker.checkValidBoundsRight(activeBlock.transform, bounds[1])) { if (moveRight) { activeBlock.transform.position += new Vector3((float)0.5, 0, 0); moveRight = false; } } if (rotate) { if (BoundsChecker.checkValidBoundsLeft(activeBlock.transform, bounds[0]) && BoundsChecker.checkValidBoundsRight(activeBlock.transform, bounds[1])) { activeBlock.transform.Rotate(0, 0, -90); } rotate = false; } if (BoundsChecker.checkValidBoundsLeft(activeBlock.transform, bounds[0])) { if (Input.GetKeyDown(KeyCode.LeftArrow)) { activeBlock.transform.position += new Vector3((float)-0.5, 0, 0); } } if (BoundsChecker.checkValidBoundsRight(activeBlock.transform, bounds[1])) { if (Input.GetKeyDown(KeyCode.RightArrow)) { activeBlock.transform.position += new Vector3((float)0.5, 0, 0); } } if (Input.GetKeyDown(KeyCode.UpArrow)) { activeBlock.transform.Rotate(0, 0, -90); if (!(BoundsChecker.checkValidBoundsLeft(activeBlock.transform, bounds[0]) && BoundsChecker.checkValidBoundsRight(activeBlock.transform, bounds[1]))) { activeBlock.transform.Rotate(0, 0, 90); } } if (Input.GetKeyDown(KeyCode.DownArrow) && this.activeVel != 0.2f) { activeBlockControl.applyDownwardForce(); } //Spawn block if necessary based on the status player if (activeBlockControl.GetSpawnNext()) { this.activeBlockControl = null; this.SpawnBlock(); } } } }