/// <summary>
        /// Creates a new hud
        /// </summary>
        /// <param name="layer"></param>
        public SpritesetHud(SceneLayer layer, PointsController controller, InputControllerState source, Int32 width, Int32 height)
            : base(layer)
        {
            _source = source;
            _controller = controller;

            _cursorStandard = new Sprite(layer, "Graphics/Pointer-Standard");
            _cursorDelete = new Sprite(layer, "Graphics/Pointer-Delete");
           
            _placingBlock = new DataBlock(source.GridPosition, source.Type == BlockType.None ? BlockType.Normal : source.Type, null);
            _placingSprite = new SpriteBlock(layer, _placingBlock);

            _spriteLogo = new Sprite(layer, "Graphics/Logo") { Position = Vector2.UnitY * 40 + Vector2.UnitX * 50 };

            if (width > 1000)
            {
                _spriteHappyPoints = new Sprite(layer, "Graphics/Icon-HappyPoints") { Position = Vector2.UnitY * 40 + Vector2.UnitX * 520 * (width / 1280f) };
                _spriteTime = new Sprite(layer, "Graphics/Icon-Time") { Position = Vector2.UnitY * 40 + Vector2.UnitX * 1130 * (width / 1280f) };
            }
            else
            {
                _spriteTime = new Sprite(layer, "Graphics/Icon-Time") { Position = Vector2.UnitY * 40 + Vector2.UnitX * (width - (1280 - 1130)) };
                _spriteHappyPoints = new Sprite(layer, "Graphics/Icon-HappyPoints") { Position = Vector2.UnitY * 90 + Vector2.UnitX * 50 };
            }
        }
        /// <summary>
        /// Creates a new jump spot
        /// </summary>
        /// <param name="source"></param>
        public DataJumpSpot(DataBlock source)
        {
            Source = source;

            _hasCompleted = new HashSet<DataPea>();
            _hasStarted = new HashSet<DataPea>();
            _hasFailed  = new HashSet<DataPea>();

            source.CreateJumpSpot(this);
        }
        /// <summary>
        /// Hits a block
        /// </summary>
        /// <param name="block"></param>
        public Int32 Hit(DataBlock block, Vector2 speed)
        {
            Int32 saved;
            if (!this.Times.TryGetValue(block == null ? BlockType.None : block.BlockType, out saved))
                saved = 0;

            // Only register if hitting hard enough
            if (speed.Length() > 1)
            {
                this.Times[block == null ? BlockType.None : block.BlockType] = ++saved;

                if (block != null)
                    RecentHit(block);
            }

            return saved;
        }
예제 #4
0
        /// <summary>
        /// Constructs a new grid
        /// </summary>
        /// <param name="game">Game to bind to</param>
        /// <param name="fx">Static physics body</param>
        public DataGrid(Game game, Body fx) : base(game)
        {
            _fx = fx;

            // Create grid
            _grid = new DataBlock[Width][];
            for (int i = 0; i < Width; i++)
            {
                _grid[i] = new DataBlock[Height];
                for (int j = 0; j < Height; j++)
                {
                    _grid[i][j] = new DataBlock(new Point(i, j), BlockType.None, _fx);
                }
            }

            _controllers = new List<PeaController>();
        }
        /// <summary>
        /// Finds a jump spot
        /// </summary>
        /// <param name="spot"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        private Boolean IsJumpSpot(DataBlock spot, DataJumpSpot.Location location)
        {
            /// -----
            /// --X--
            /// -LSR-
            /// S = spot, X = jump location (up)
            ///
            /// upup should be clear
            /// up should be clear
            /// 
            /// left should be clear
            /// leftleft should be clear
            /// leftup should be clear
            /// leftleftup should be clear
            /// leftupup questionable

            var position = spot.GridPosition;
            var down = (position.Y < DataGrid.Height - 1) ? _grid.Grid[position.X][position.Y + 1] : null;
            var solid = (spot == null || spot.IsFlatTop);

            var upup = (position.Y > 1) ? _grid.Grid[position.X][position.Y - 2] : null;
            var up = (position.Y > 0) ? _grid.Grid[position.X][position.Y - 1] : null;
            
            var left = (position.X > 0) ? _grid.Grid[position.X - 1][position.Y] : null;
            var leftleft = (position.X > 1) ? _grid.Grid[position.X - 2][position.Y] : null;
            var leftup = (position.X > 0 && (position.Y > 0)) ? _grid.Grid[position.X - 1][position.Y - 1] : null;
            var leftdown = (position.X > 0 && (position.Y < DataGrid.Height - 1)) ? _grid.Grid[position.X - 1][position.Y + 1] : null;
            var leftleftdown = (position.X > 1 && (position.Y < DataGrid.Height - 1)) ? _grid.Grid[position.X - 2][position.Y + 1] : null;
            var leftleftup = (position.X > 1 && (position.Y > 0)) ? _grid.Grid[position.X - 2][position.Y - 1] : null;
            var leftupup = (position.X > 0 && (position.Y > 1)) ? _grid.Grid[position.X - 1][position.Y - 2] : null;
            
            var right = (position.X < DataGrid.Width - 1) ? _grid.Grid[position.X + 1][position.Y] : null;
            var rightright = (position.X < DataGrid.Width - 2) ? _grid.Grid[position.X + 2][position.Y] : null;
            var rightup = (position.X < DataGrid.Width - 1 && (position.Y > 0)) ? _grid.Grid[position.X + 1][position.Y - 1] : null;
            var rightdown = (position.X < DataGrid.Width - 1 && (position.Y < DataGrid.Height - 1)) ? _grid.Grid[position.X + 1][position.Y + 1] : null;
            var rightrightdown = (position.X < DataGrid.Width - 2 && (position.Y < DataGrid.Height - 1)) ? _grid.Grid[position.X + 2][position.Y + 1] : null;
            var rightrightup = (position.X < DataGrid.Width - 2 && (position.Y > 0)) ? _grid.Grid[position.X + 2][position.Y - 1] : null;
            var rightupup = (position.X < DataGrid.Width - 1 && (position.Y > 1)) ? _grid.Grid[position.X + 1][position.Y - 2] : null;

            // Above and above that should be clear
            if (!solid || (up != null && (!up.IsClear || up.IsTransitioning)) || (upup != null && (!upup.IsClear || upup.IsTransitioning)))
                return false;

            if (location == DataJumpSpot.Location.Left)
                return ((left != null && left.IsClear && !left.IsTransitioning) &&
                    (leftleft != null && leftleft.IsClear && !leftleft.IsTransitioning) &&
                    (leftupup == null || (leftupup.IsClear && !leftupup.IsTransitioning)) &&
                    (leftleftup == null || (leftleftup.IsClear && !leftleftup.IsTransitioning)) &&
                    (leftup == null || (leftup.IsClear)));

            if (location == DataJumpSpot.Location.Right)
                return ((right != null && right.IsClear && !right.IsTransitioning) &&
                    (rightright != null && rightright.IsClear && !rightright.IsTransitioning) &&
                    (rightupup == null || (rightupup.IsClear && !rightupup.IsTransitioning)) &&
                    (rightrightup == null || (rightrightup.IsClear && !rightrightup.IsTransitioning)) &&
                    (rightup == null || (rightup.IsClear && !rightup.IsTransitioning)));

            return false;
        }
 /// <summary>
 /// Create a node for a move node
 /// </summary>
 /// <param name="position"></param>
 /// <param name="action"></param>
 /// <param name="dir"></param>
 /// <returns></returns>
 protected Node<MoveNode> CreateNode(DataBlock block, MoveNode.Type action, MoveNode.Direction dir)
 {
     return CreateNode(block.GridPosition, action, dir);
 }
예제 #7
0
 /// <summary>
 /// Creates new SpriteBlock
 /// </summary>
 /// <param name="layer"></param>
 /// <param name="source"></param>
 public SpriteBlock(SceneLayer layer, DataBlock source) : base(layer)
 {
     _source = source;
 }
        /// <summary>
        /// Process collision
        /// </summary>
        /// <param name="pea"></param>
        /// <param name="speed"></param>
        /// <param name="block"></param>
        private void DoHappyCollision(DataPea pea, Vector2 speed, DataBlock block)
        {
            PointsControllerState state;
            if (block != null && !block.IsPlaced)
                return;

            if ((state = _active.FirstOrDefault(p => p.Pea == pea)) != null)
                if (!state.IncreaseHappiness(speed, block))
                    pea.Trap();
        }
예제 #9
0
 /// <summary>
 /// Hits a block (mark as recent)
 /// </summary>
 /// <param name="block"></param>
 private void RecentHit(DataBlock block)
 {
     this.RecentHits.Enqueue(block);
     if (this.RecentHits.Count > 20)
         this.RecentHits.Dequeue();
 }
예제 #10
0
 /// <summary>
 /// Gets the score for a block
 /// </summary>
 /// <param name="block"></param>
 /// <returns></returns>
 private static Single BlockScore(DataBlock block)
 {
     return BlockScore(block.BlockType);
 }
        /// <summary>
        /// Increase Happiness by processing a collision
        /// </summary>
        /// <param name="speed"></param>
        /// <param name="block"></param>
        internal Boolean IncreaseHappiness(Vector2 speed, DataBlock block)
        {
            var times = Hit(block, speed);
            var recent = this.RecentHits.Count(b => b == block);
            //var newmultiplier

            //System.Diagnostics.Debug.WriteLine("speed: {0}, recent = {1}, times = {2}", speed, recent, times);

            return recent < 10 || Math.Abs(speed.Y) < 0.5f;
        } 
예제 #12
0
 /// <summary>
 /// Removes a block (changes to clear)
 /// </summary>
 /// <param name="block"></param>
 private void Remove(DataBlock block)
 {
     block.Place(BlockType.None);
 }
예제 #13
0
        /// <summary>
        /// Constructs a new grid
        /// </summary>
        /// <param name="game">Game to bind to</param>
        /// <param name="fx">Static physics body</param>
        private DataGrid(Game game, Body fx, Int32 width = 17, Int32 height = 10) : base(game)
        {
            // There should be only one datagrid
            DataGrid.Width = width;
            DataGrid.Height = height;
            DataGrid.WidthInPixels = 70 * (Width);
            DataGrid.HeightInPixels = 49 * (Height);


            _fx = fx;

            // Create grid
            _grid = new DataBlock[Width][];
            for (int i = 0; i < Width; i++)
            {
                _grid[i] = new DataBlock[Height];
                for (int j = 0; j < Height; j++)
                {
                    _grid[i][j] = new DataBlock(new Point(i, j), BlockType.None, _fx);
                }
            }

            _controllers = new List<PeaController>();
        }
예제 #14
0
 /// <summary>
 /// Removes a block (changes to clear)
 /// </summary>
 /// <param name="block"></param>
 private void Remove(DataBlock block)
 {
     block.Place(BlockType.None);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="block"></param>
 /// <param name="state"></param>
 public BlockStateArgs(DataBlock block, BlockState state) : base() 
 {
     this.Block = block;
     this.State = state;
 }