Exemplo n.º 1
0
 public Whereabouts( int floor, Point location, Direction direction )
 {
     Floor = floor;
     Location = location;
     Direction = direction;
     Fraction = 0;
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public PlayingFieldSquare(
     PlayingFieldSquareType playingFieldSquareType,
     int elevation,
     Direction slopeDirection )
 {
     PlayingFieldSquareType = playingFieldSquareType;
     Elevation = elevation;
     SlopeDirection = slopeDirection;
 }
Exemplo n.º 4
0
 static Direction()
 {
     None = new Direction(DirectionValue.None);
     South = new Direction(DirectionValue.South);
     West = new Direction(DirectionValue.West);
     North = new Direction(DirectionValue.North);
     East = new Direction(DirectionValue.East);
     AllDirections = new[] {South, West, North, East};
 }
Exemplo n.º 5
0
 public static Point Add(this Point p1, Direction dir)
 {
     return p1.Add(dir.DirectionAsPoint());
 }
Exemplo n.º 6
0
        public void Update( GameTime gameTime, Vector3 target, Direction direction)
        {
            switch (CameraBehavior)
            {
                case CameraBehavior.FollowSerpent:
                    var target2D = new Vector2(target.X, target.Z);
                    var position2D = moveTo(
                        new Vector2(_position.X, _position.Z),
                        target2D,
                        target2D - direction.DirectionAsVector2()*9,
                        gameTime.ElapsedGameTime.TotalMilliseconds);

                    var newPosition = new Vector3(
                        position2D.X,
                        target.Y + 5,
                        position2D.Y);

                    _acc += (float) Math.Sqrt(Vector3.Distance(newPosition, _position))*
                            (float) gameTime.ElapsedGameTime.TotalMilliseconds*0.1f;
                    _acc *= 0.5f;
                    var v = MathHelper.Clamp(_acc, 0.1f, 0.3f);
                    _position = Vector3.Lerp(_position, newPosition, v);
                    _target = Vector3.Lerp(_target, target, v);
                    break;

                case CameraBehavior.Static:
                    _position = Vector3.Lerp(_position, new Vector3(10, 30, 10), 0.02f);
                    _target = Vector3.Lerp(_target, new Vector3(10, 0, 10), 0.02f);
                    break;

                case CameraBehavior.FreeFlying:
                    freeFlyingCamera(gameTime);
                    return;

                default:
                    return;
            }

            _upVector = Vector3.Lerp(_upVector, _desiredUpVector, 0.03f);
            View = Matrix.CreateLookAt(
                _position,
                _target,
                _upVector);
        }
Exemplo n.º 7
0
 protected bool tryMove(Direction dir)
 {
     if (dir == Direction.None)
         return false;
     var possibleLocationTo = _whereabouts.Location.Add(dir);
     if (!_pf.CanMoveHere(ref _whereabouts.Floor, _whereabouts.Location, possibleLocationTo))
         return false;
     _whereabouts.Direction = dir;
     _tail.AddPathToWalk(_whereabouts);
     return true;
 }
Exemplo n.º 8
0
        public virtual void Update(GameTime gameTime)
        {
            var lengthSpeed = (11 - _serpentLength)/10f;
            var speed = (float) gameTime.ElapsedGameTime.TotalMilliseconds*0.0045f*lengthSpeed*modifySpeed();

            if (_whereabouts.Direction != Direction.None)
            {
                _fractionAngle += speed;
                if (_fractionAngle >= 1)
                {
                    _fractionAngle = 0;
                    _whereabouts.Location = _whereabouts.NextLocation;
                    takeDirection();
                }
                _whereabouts.Fraction = (float) Math.Sin(_fractionAngle*MathHelper.PiOver2);
            }
            else
                takeDirection();

            if (_tail != null)
                _tail.Update(gameTime, GetPosition(), speed);

            if (_whereabouts.Direction != Direction.None)
                _headDirection = _whereabouts.Direction;
        }