示例#1
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);
        }
示例#2
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);
            }
        }
示例#3
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);
 }
示例#4
0
        public EnemySerpent(
            Game game,
            PlayingField pf,
            ModelWrapper modelHead,
            ModelWrapper modelSegment,
            Camera camera,
            Whereabouts whereabouts,
            int x)
            : base(game, pf, modelHead, modelSegment, whereabouts)
        {
            _whereabouts = whereabouts;
             _rnd.NextBytes(new byte[x]);
            _camera = camera;

            addTail();
            addTail();
        }