private void Player_MoveFinished(object sender, System.EventArgs e) { var playerArea = new Rectangle((int)Player.Position.X, (int)Player.Position.Y, 16, 16); // Check if the player is inside one of the row rectangles foreach (var row in Rows) { var riverRow = row as RiverRowModel; if (riverRow != null) { if (riverRow.Bounds.Contains(playerArea)) { var rect = Rectangle.Empty; if (TouchesObject(riverRow, playerArea, out rect)) { _reset.SetForce(riverRow.Speed * (riverRow.Direction == VehicleDirection.LeftToRight ? 1f : -1f)); } else { _reset.Reset(ResetMode.Death); } _onRiverLane = true; return; } } } _onRiverLane = false; _reset.SetForce(0); }
public void Reset() { var scoreBG = GameObject.Find("scoreBG"); if (scoreBG != null) { scoreBG.GetComponent <Renderer>().enabled = false; } SetGO(false); var balls = GameObject.FindGameObjectsWithTag("Ball"); foreach (var ball in balls) { Destroy(ball); } level = MapMakker.GetMap(GameMaster.levelName); IsWinningCheckAlreadyHappened = false; finishedIpis = 0; var resetebelList = FindAllByInterface <IReset>();; foreach (var gunsObject in resetebelList) { IReset resetebelGameObject = gunsObject as IReset; resetebelGameObject.Reset(); } IpiCounter.Reset(); }
public async Task <IActionResult> Verify(VerifiedResetInput c) { if (ModelState.IsValid) { var reset = await _reset.Reset(new VerifiedReset(c.UserId, c.Code, c.Password)); if (reset is Ok <Unit> resetOk) { return(RedirectToAction("Index", "ProfileSpa", new { returnUrl = c.ReturnUrl })); } else { if (reset is Error <Unit> resetErr) { _logger.LogError(resetErr.Description); } ModelState.AddModelError("Code", "Not accepted. Please double-check."); return(View(v("Token"), c)); } } else { return(View(v("Token"), c)); } }
/// <summary> /// Update the controller. /// </summary> /// <param name="deltaTime">Delta time</param> public void Update(float deltaTime) { var playerArea = new Rectangle((int)_player.Position.X, (int)_player.Position.Y, 16, 16); foreach (var goal in _goals.Goals) { if (goal.Area.Intersects(playerArea)) { if (goal.Occupied) { _playerReset.Reset(ResetMode.Death); } else { goal.Occupied = true; _playerReset.Reset(ResetMode.Goal); } return; } } }
/// <summary> /// Move bullets to the direction given for the bullets /// </summary> private void MoveBullets() { foreach (var bullet in _bulletListModel.Bullets) { bullet.Position += bullet.Direction; var bulletArea = new Rectangle((int)bullet.Position.X, (int)bullet.Position.Y, 8, 8); if (!bullet.ShotByEnemy && bullet.Visible) { foreach (var enemy in _enemyListModel.Enemies) { if (enemy.Area.Intersects(bulletArea) && !enemy.IsDead) { bullet.Visible = false; enemy.HPLeft -= bullet.BulletDamage; if (enemy.HPLeft <= 0) { _enemyDies.Play(0.3f, 1f, 0f); enemy.IsDead = true; _playerModel.AddXp(enemy.IsBoss ? 50 : (1 + _playerModel.Level)); } } } } if (bullet.ShotByEnemy && bullet.Visible) { var playerArea = new Rectangle((int)_playerModel.Position.X + 4, (int)_playerModel.Position.Y + 4, 56, 56); if (bulletArea.Intersects(playerArea) && !_playerModel.Invulnerable) { bullet.Visible = false; _playerModel.HPLeft -= bullet.BulletDamage; if (_playerModel.HPLeft <= 0) { _playerDies.Play(0.3f, 1f, 0f); _reset.Reset(ResetMode.Death); } } } if (bullet.Position.Y < 0 || bullet.Position.Y >= VirtualScreenSize.Height * VirtualScreenSize.ScreenSizeMultiplier || bullet.Position.X < 0 || bullet.Position.X >= VirtualScreenSize.Width * VirtualScreenSize.ScreenSizeMultiplier) { bullet.Visible = false; } } }
/// <summary> /// Move the enemies randomly and kill player on collision. /// </summary> /// <param name="gameTime">Game time</param> public void Update(GameTime gameTime) { var enemiesAlive = _enemyListModel.Enemies.Where(enemy => !enemy.IsDead).ToList(); if (enemiesAlive.Count > 0) { var playerArea = new Rectangle((int)_playerModel.Position.X + 4, (int)_playerModel.Position.Y + 4, 56, 56); foreach (var enemy in _enemyListModel.Enemies) { if (enemy.Area.Intersects(playerArea) && !enemy.IsDead && !_playerModel.Invulnerable) { _playerDies.Play(0.3f, 1f, 0f); _reset.Reset(ResetMode.Death); } // Check if enemy area intersects the target position area // Randomize new target position if true var targetArea = new Rectangle((int)enemy.TargetPosition.X, (int)enemy.TargetPosition.Y, 8, 8); if (enemy.Area.Intersects(targetArea)) { Random random = new Random(); var x = random.Next(VirtualScreenSize.Width * VirtualScreenSize.ScreenSizeMultiplier - XOffset); var y = random.Next(VirtualScreenSize.Height * VirtualScreenSize.ScreenSizeMultiplier - YOffset); enemy.TargetPosition = new Vector2(x, y); } else { var speed = 0f; if (_playerModel.Stage > 20) { speed = 1f; } else if (_playerModel.Stage > 30) { speed = 3f; } else if (_playerModel.Stage > 50) { speed = 5f; } var width = enemy.IsBoss ? 60 : 26; var height = enemy.IsBoss ? 55 : 26; Move(enemy, _distance + speed, width, height); } } } }
protected override void OnCollision(Rectangle rect) { _reset.Reset(ResetMode.Death); }