void CalculateDownSpeedInc() { float toMaxSpeed = currentMoveAfter - maxMoveAfter; //we find how much we need to increase the currentMoveAfter till we reach the max value downSpeedInc = toMaxSpeed / distance; //then we check how much to increase the current moveAfter each time the aliens move down downSpeedInc = ProjectMethods.TwoDecimalRound(downSpeedInc); }
void DisplayError() { if (gameController == null) { ProjectMethods.NoGameControllerComponentMsg(); ProjectMethods.QuitGame(); } }
void Move() { //moves in the direction of the x axis Vector2 newPosition = transform.right * speed * Time.deltaTime; Vector2 moveTo = rb2d.position + newPosition; moveTo.x = ProjectMethods.TwoDecimalRound(moveTo.x); rb2d.MovePosition(moveTo); }
void MoveDown() { Vector3 moveTo = transform.position; moveTo.y -= moveDownBy; moveTo.y = ProjectMethods.TwoDecimalRound(moveTo.y); transform.position = moveTo; GoingDownSpeedUp(); }
public void Move(float direction) { Vector2 newPosition = new Vector2(direction * speed * Time.deltaTime, 0f); BoundToScreen(rb2d.position, ref newPosition); Vector2 moveTo = rb2d.position + newPosition; moveTo.x = ProjectMethods.TwoDecimalRound(moveTo.x); rb2d.MovePosition(moveTo); //apply the new position to the object }
private void DoWork(object parent) { MyMISService m = (MyMISService)parent; LogMethods.Log.Warn("-------------- *** Starting MISService *** ------------"); int polling = 1; bool exist = false; int pollingInterval = Int32.Parse(ConfigurationManager.AppSettings["PollingInterval"]) * 1000; string userName = Convert.ToString(ConfigurationManager.AppSettings["SFUsername"]); string password = Convert.ToString(ConfigurationManager.AppSettings["SFPassword"]); string token = Convert.ToString(ConfigurationManager.AppSettings["SFToken"]); while (!exist) { if (SalesForceMethods.AuthenticateSfdcEnterpriseUser(userName, password, token)) { while (m.Running) { LogMethods.Log.Warn("Polling:" + polling++); ProjectMethods pm = new ProjectMethods(); pm.GetAllProjects(); DateTime dt = DateTime.Now; DateTime lowerPoint = new DateTime(dt.Year, dt.Month, dt.Day, 20, 0, 0); //DateTime nextDate = dt.AddDays(1); //DateTime higherPoint = new DateTime(nextDate.Year, nextDate.Month, nextDate.Day, 8, 0, 0); if (dt > lowerPoint) { LogMethods.Log.Warn("Start sleeping from 8:00 PM to 8:00 AM next day!"); Thread.Sleep(43200000); //sleep around 12 hours from 8:00 PM to 8:00 AM next day LogMethods.Log.Warn("Waking up!"); } else { // wait 60 seconds for next polling Thread.Sleep(pollingInterval); } } } if (m.Running) { LogMethods.Log.Warn("Trying another connection to Salesforce after 30 seconds!"); Thread.Sleep(30000); } else { exist = true; } } LogMethods.Log.Warn("-------------- *** Endings MISService *** ------------"); }
void DisplayError() { if (gameController == null) { ProjectMethods.NoGameControllerComponentMsg(); ProjectMethods.QuitGame(); } if (owner == null && testMode == false) { ProjectMethods.NoAlienControllerComponentMsg(); ProjectMethods.QuitGame(); } }
private void BoundToScreen(Vector2 startPos, ref Vector2 position) { //we add the speed to the current position Vector2 positionToCheck = startPos + position; positionToCheck.x = ProjectMethods.TwoDecimalRound(positionToCheck.x); //check if the player is going to go off the screen if (Camera.main.WorldToScreenPoint(positionToCheck + (bc2d.size / 2)).x > Screen.width || Camera.main.WorldToScreenPoint(positionToCheck - bc2d.size / 2).x < 0) { //if it does the speed gets set to zero position = Vector2.zero; } }
/* Delta time Movement * void MoveAliens() * { * Vector2 newPosition = new Vector2(currentSpeed * Time.deltaTime, 0f); //we calculate the newposition * ChangeDirection(newPosition); //checks to see if direction should change * newPosition *= direction; //apply the direction to the newposition * for (int i = 0; i < alienRb2ds.Count; i++) //apply the newposition to all aliens * { * Vector2 moveTo = alienRb2ds[i].position + newPosition; * moveTo.x = ProjectMethods.PixelRound(moveTo.x); * alienRb2ds[i].MovePosition(moveTo); * } * } */ void MoveAliens() { Vector2 newPosition = new Vector2(speed, 0f); //we calculate the newposition ChangeDirection(newPosition); //checks to see if direction should change newPosition *= direction; //apply the direction to the newposition for (int i = 0; i < alienComps.Count; i++) //apply the newposition to all aliens { Vector2 moveTo = alienComps[i].rb2d.position + newPosition; moveTo.x = ProjectMethods.TwoDecimalRound(moveTo.x); if (alienComps[i].rb2d != null) { alienComps[i].rb2d.MovePosition(moveTo); } alienComps[i].animController.SetTick(); } }
void ChangeDirection(Vector2 moveBy) { //Here we look for the alien that is going to reach the edge of the screen for (int i = 0; i < alienComps.Count; i++) { //we apply the current direction to the newposition //and we add it to the current position of the allien Vector2 moveTo = alienComps[i].rb2d.position + (moveBy * direction); moveTo.x = ProjectMethods.TwoDecimalRound(moveTo.x); //rounds the position so it had 2 decimal points //then we check if we reached the edge of the screen if (Camera.main.WorldToScreenPoint(moveTo + (alienComps[i].bc2d.size / 2)).x > Screen.width || Camera.main.WorldToScreenPoint(moveTo - (alienComps[i].bc2d.size / 2)).x < 0) { direction *= -1; //direction gets changed MoveDown(); //and all aliens are moved down break; //we break from the loop because we changed direction } } }
void DisplayError() { if (player == null) { ProjectMethods.NoPlayerObjectMsg(); ProjectMethods.QuitGame(); } else if (playerLives == null) { ProjectMethods.NoLivesComponentMsg(); ProjectMethods.QuitGame(); } else if (aController == null) { ProjectMethods.NoAlienControllerComponentMsg(); ProjectMethods.QuitGame(); } }