Exemple #1
0
        public float GetElevation(
            Whereabouts whereabouts)
        {
            if (whereabouts.Direction == Direction.None)
            {
            }
            var p      = whereabouts.NextLocation;
            var square = fieldValue(whereabouts.Floor, p);

            if (square.IsNone)
            {
                return(0);
            }
            switch (square.PlayingFieldSquareType)
            {
            case PlayingFieldSquareType.None:
                throw new Exception();

            case PlayingFieldSquareType.Flat:
                return(whereabouts.Floor * 1.333f);

            default:
                var fraction = whereabouts.Fraction;
                if (square.SlopeDirection.Backward == whereabouts.Direction)
                {
                    fraction = 1 - fraction;
                }
                else if (square.SlopeDirection != whereabouts.Direction)
                {
                    throw new Exception();
                }
                return(whereabouts.Floor * 1.33f + (square.Elevation + fraction) / 3f);
            }
        }
Exemple #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);
        }
 public SerpentTailSegment(PlayingField pf, Whereabouts w)
 {
     _pf        = pf;
     PathToWalk = new List <Whereabouts> {
         w
     };
 }
Exemple #4
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);
        }
        public void AddPathToWalk(Whereabouts w)
        {
            if (PathToWalk.Exists(e => e.Location == w.Location))
                return;

            w.Fraction = 0;
            PathToWalk.Add(w);
            if (Next != null)
                Next.AddPathToWalk(PathToWalk[0]);
        }
        public void AddPathToWalk(Whereabouts w)
        {
            if (PathToWalk.Exists(e => e.Location == w.Location))
            {
                return;
            }

            w.Fraction = 0;
            PathToWalk.Add(w);
            if (Next != null)
            {
                Next.AddPathToWalk(PathToWalk[0]);
            }
        }
Exemple #7
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();
        }
Exemple #8
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 };
 }
Exemple #10
0
        public float GetElevation(
            Whereabouts whereabouts )
        {
            if ( whereabouts.Direction == Direction.None )
            {

            }
            var p = whereabouts.NextLocation;
            var square = fieldValue(whereabouts.Floor, p);
            if (square.IsNone)
                return 0;
            switch ( square.PlayingFieldSquareType )
            {
                case PlayingFieldSquareType.None:
                    throw new Exception();
                case PlayingFieldSquareType.Flat:
                    return whereabouts.Floor * 1.333f;
                default:
                    var fraction = whereabouts.Fraction;
                    if (square.SlopeDirection.Backward == whereabouts.Direction )
                        fraction = 1-fraction;
                    else if (square.SlopeDirection != whereabouts.Direction)
                        throw new Exception();
                    return whereabouts.Floor * 1.33f + (square.Elevation + fraction) / 3f;
            }
        }