Exemple #1
0
 public void AfterAllDetection()
 {
     if (CollidedList.Count > 0)
     {
         foreach (Entity one in CollidedList)
         {
             Intersection = Rectangle.Intersect(FutureBox, one.BoundBox);
             if (one.EntityCollision.FirstContact < min.EntityCollision.FirstContact)
             {
                 third = two;
                 two   = min;
                 min   = one;
             }
             one.EntityCollision.Response(this);
             CurrentSprite.CollisionResponse(true); //tint sprite
             one.Sprite.CollisionResponse(true);    //tint sprite
         }
         Intersection = Rectangle.Intersect(FutureBox, min.BoundBox);
         Response(min.EntityCollision);
         if (two != null && FutureBox.Intersects(two.BoundBox) && two != min)
         {
             Intersection = Rectangle.Intersect(FutureBox, two.BoundBox);
             Response(two.EntityCollision);
         }
         if (third != null && FutureBox.Intersects(third.BoundBox) && third != two && third != min)
         {
             Intersection = Rectangle.Intersect(FutureBox, third.BoundBox);
             Response(third.EntityCollision);
         }
         CollidedList.Clear();
     }
 }
        public async Task <FutureBoxDto> Handle(CreateUserFutureBoxCommand request, CancellationToken cancellationToken)
        {
            var user = await _userRepository.GetUserByIdAsync(request.UserId);

            var futureBox = new FutureBox(Guid.NewGuid(), request.Name);

            user.CreateFutureBox(futureBox);

            var result = await _userRepository.CommitAsync();

            return(new FutureBoxDto {
                Id = futureBox.Id, Name = futureBox.Name
            });
        }
Exemple #3
0
        public virtual void Detection(GameTime gameTime, ICollision collideObject) //detect IF it will collide.
        {
            if (FutureBox.Intersects(collideObject.CurrentEntity.BoundBox) && !collideObject.CurrentEntity.Dead)
            {
                third = two;
                two   = min;
                collideObject.FirstContact = gameTime.ElapsedGameTime.Milliseconds;
                min = collideObject.CurrentEntity;
                CollidedList.Add(min);
                Intersection = Rectangle.Intersect(FutureBox, collideObject.CurrentSprite.BoundBox);
            }

            _elapsed += gameTime.ElapsedGameTime.Milliseconds;
            if (_elapsed >= Delay)//To show a black color for collision response.
            {
                CurrentSprite.CollisionResponse(false);
                collideObject.CurrentSprite.CollisionResponse(false);
                _elapsed = 0;
            }
        }
Exemple #4
0
 public void CreateFutureBox(FutureBox box)
 {
     _futureBoxes.Add(box);
 }