protected BaseSerpent( Game game, PlayingField pf, ModelWrapper modelHead, ModelWrapper modelSegment, Whereabouts whereabouts) { _pf = pf; _modelHead = modelHead; _modelSegment = modelSegment; _whereabouts = whereabouts; _headDirection = _whereabouts.Direction; _headRotation.Add(Direction.West, Matrix.CreateRotationY(MathHelper.PiOver2) * Matrix.CreateRotationY(MathHelper.Pi)); _headRotation.Add(Direction.East, Matrix.CreateRotationY(MathHelper.PiOver2)); _headRotation.Add(Direction.South, Matrix.CreateRotationY(MathHelper.PiOver2) * Matrix.CreateRotationY(MathHelper.PiOver2)); _headRotation.Add(Direction.North, Matrix.CreateRotationY(MathHelper.PiOver2) * Matrix.CreateRotationY(-MathHelper.PiOver2)); _tail = new SerpentTailSegment(_pf, _whereabouts); _serpentLength = 1; _layingEgg = (float)(-5 - new Random().NextDouble() * 30); }
protected BaseSerpent( Game game, PlayingField pf, ModelWrapper modelHead, ModelWrapper modelSegment, Whereabouts whereabouts) { _pf = pf; _modelHead = modelHead; _modelSegment = modelSegment; _whereabouts = whereabouts; _headDirection = _whereabouts.Direction; _headRotation.Add(Direction.West, Matrix.CreateRotationY(MathHelper.PiOver2)*Matrix.CreateRotationY(MathHelper.Pi)); _headRotation.Add(Direction.East, Matrix.CreateRotationY(MathHelper.PiOver2)); _headRotation.Add(Direction.South, Matrix.CreateRotationY(MathHelper.PiOver2)*Matrix.CreateRotationY(MathHelper.PiOver2)); _headRotation.Add(Direction.North, Matrix.CreateRotationY(MathHelper.PiOver2)*Matrix.CreateRotationY(-MathHelper.PiOver2)); _tail = new SerpentTailSegment(_pf, _whereabouts); _serpentLength = 1; _layingEgg = (float)(-5 - new Random().NextDouble()*30); }
private int removeTail(SerpentTailSegment tail) { if (tail != _tail && tail != null) { var length = 1; for (var test = _tail; test != null; test = test.Next, length++) { if (test.Next == tail) { test.Next = null; var removedSegments = _serpentLength - length; _serpentLength = length; return(removedSegments); } } } throw new Exception(); }
private int removeTail(SerpentTailSegment tail) { if (tail != _tail && tail != null) { var length = 1; for (var test = _tail; test != null; test = test.Next, length++) if (test.Next == tail) { test.Next = null; var removedSegments = _serpentLength - length; _serpentLength = length; return removedSegments; } } throw new Exception(); }