private void Shoot(ref Character _Main, Rectangle _Bound) { Random r = new Random(); _Food = new ThrownFood(_FoodList[r.Next(3)].EnemyClone(), _Bound, 6.5f); if ((_Rectangle.Top < _Main._Rec.Top && _Main._Rec.Top < _Rectangle.Bottom) || (_Rectangle.Top < _Main._Rec.Bottom && _Main._Rec.Bottom < _Rectangle.Bottom)) { if (_Rectangle.Right < _Main._Rec.Left) _Food.SetDirection(Direction.East); else _Food.SetDirection(Direction.West); } else if ((_Rectangle.Left < _Main._Rec.Left && _Main._Rec.Left < _Rectangle.Right) || (_Rectangle.Left < _Main._Rec.Right && _Main._Rec.Right < _Rectangle.Right)) { if (_Rectangle.Top < _Main._Rec.Bottom) _Food.SetDirection(Direction.South); else _Food.SetDirection(Direction.North); } else if (_Rectangle.Bottom < _Main._Rec.Top && _Rectangle.Right < _Main._Rec.Left) _Food.SetDirection(Direction.SouthEast); else if (_Rectangle.Top > _Main._Rec.Bottom && _Rectangle.Right < _Main._Rec.Left) _Food.SetDirection(Direction.NorthEast); else if (_Rectangle.Bottom < _Main._Rec.Top && _Rectangle.Left > _Main._Rec.Right) _Food.SetDirection(Direction.SouthWest); else if (_Rectangle.Top > _Main._Rec.Bottom && _Rectangle.Left > _Main._Rec.Right) _Food.SetDirection(Direction.NorthWest); _Food.SetPosition(_Position); _FoodThrown.Add(_Food); }
public void PickUp(KeyboardState ks, Food obj) { if (obj.HasFood() && ks.IsKeyUp(Keys.Space) && _Rec.Intersects(obj._Rectangle) && !_hasThrownFood) { _hasThrownFood = !_hasThrownFood; _Food = new ThrownFood(obj.Clone(), _Bound, 6.5f); } }