Beispiel #1
0
        public Data( Game game1 )
        {
            if ( Instance != null )
                Instance.Dispose();
            Instance = this;

            var texture = game1.Content.Load<Texture2D>(@"Textures\grass");

            if ( PlayingField == null )
                PlayingField = new PlayingField(
                    game1.GraphicsDevice,
                    texture );

            var serpentHead = new ModelWrapper( game1, game1.Content.Load<Model>(@"Models\SerpentHead") );
            var serpentSegment = new ModelWrapper( game1, game1.Content.Load<Model>(@"Models\serpentsegment") );

            PlayerSerpent = new PlayerSerpent(
                game1,
                PlayingField,
                serpentHead,
                serpentSegment);

            for (var i = 0; i < 5; i++)
            {
                var enemy = new EnemySerpent(
                    game1,
                    PlayingField,
                    serpentHead,
                    serpentSegment,
                    PlayerSerpent.Camera,
                    new Whereabouts(0, new Point(20, 0), Direction.West),
                    i);
                Enemies.Add(enemy);
            }
        }
Beispiel #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);
        }
Beispiel #3
0
 public Vector3 GetPosition(PlayingField pf)
 {
     var d = Direction.DirectionAsPoint();
     return new Vector3(
         Location.X + d.X * Fraction,
         pf.GetElevation(this),
         Location.Y + d.Y * Fraction);
 }
Beispiel #4
0
 public PlayerSerpent(
     Game game,
     PlayingField pf,
     ModelWrapper modelHead,
     ModelWrapper modelSegment)
     : base(game, pf, modelHead, modelSegment, new Whereabouts(0, Point.Zero, Direction.East))
 {
     _camera = new Camera(
         game.Window.ClientBounds,
         new Vector3(0, 20, 2),
         Vector3.Zero,
         CameraBehavior.FollowSerpent);
 }
Beispiel #5
0
        public EnemySerpent(
            PlayingField pf,
            Model modelHead,
            Model modelSegment,
            Camera camera,
            Whereabouts whereabouts,
            int x)
            : base(pf, modelHead, modelSegment, whereabouts)
        {
            _whereabouts = whereabouts;
             _rnd.NextBytes(new byte[x]);
            _camera = camera;

            addTail();
            addTail();
        }
 public SerpentTailSegment(PlayingField pf, Whereabouts w)
 {
     _pf = pf;
     PathToWalk = new List<Whereabouts> { w };
 }