Ejemplo n.º 1
0
        private void map_onRenderGameObject(GameObject gameObject)
        {
            if (gameObject.Type == GameObject.GameObjectType.Player)
            {
                GetPlayer(0).SetGameObject(gameObject);
                GetPlayer(0).TurnDown();
                gameObject.SetPosition(new System.Windows.Point(gameObject.GetPosition().X, gameObject.GetPosition().Y - 5));
                gameObject.Render(this.GetLayerByIndex(1));
            }
            else if (gameObject.Type == GameObject.GameObjectType.Target)
            {
                GameSpriteSheet foodSheet = new GameSpriteSheet(ResourceTextures.food_sheet, new System.Drawing.Point(32, 32));
                gameObject.SetTexture(foodSheet.GetSprite(4, 7));
                gameObject.Render(this.GetLayerByIndex(1));
            }
            else if (gameObject.Type == GameObject.GameObjectType.Batery)
            {
                gameObject.SetTexture(ResourceTextures.batery);
                gameObject.SetSize(new System.Windows.Size(15, 15));
                gameObject.SetPosition(new System.Windows.Point(gameObject.GetPosition().X + 5, gameObject.GetPosition().Y));
                gameObject.Render(this.GetLayerByIndex(1));
            }
            else if (gameObject.Type == GameObject.GameObjectType.Wall)
            {
                gameObject.SetTexture(ResourceTextures.wall);

                if (!IsWallGameObject(gameObject.Neighbors.Bottom))
                {
                    gameObject.SetTexture(ResourceTextures.wall_bottom);
                }

                if (!IsWallGameObject(gameObject.Neighbors.Top) && !IsWallGameObject(gameObject.Neighbors.Right))
                {
                    gameObject.SetTexture(ResourceTextures.wall_top);
                }

                if (IsWallGameObject(gameObject.Neighbors.Bottom) && IsWallGameObject(gameObject.Neighbors.Right) && !IsWallGameObject(gameObject.Neighbors.BottomRight))
                {
                    gameObject.SetTexture(ResourceTextures.wall_3);
                }

                if (!IsWallGameObject(gameObject.Neighbors.Bottom) && !IsWallGameObject(gameObject.Neighbors.Right) && !IsWallGameObject(gameObject.Neighbors.Left))
                {
                    gameObject.SetTexture(ResourceTextures.wall_bottom_right);
                }

                if (!IsWallGameObject(gameObject.Neighbors.Bottom) && !IsWallGameObject(gameObject.Neighbors.Right) && IsWallGameObject(gameObject.Neighbors.Top))
                {
                    gameObject.SetTexture(ResourceTextures.wall_7);
                }

                if (!IsWallGameObject(gameObject.Neighbors.Bottom) && !IsWallGameObject(gameObject.Neighbors.Right) &&
                    IsWallGameObject(gameObject.Neighbors.Top) &&
                    IsWallGameObject(gameObject.Neighbors.Left))
                {
                    gameObject.SetTexture(ResourceTextures.wall_6);
                }

                if (IsWallGameObject(gameObject.Neighbors.Bottom) &&
                    IsWallGameObject(gameObject.Neighbors.Top) &&
                    !IsWallGameObject(gameObject.Neighbors.Right))
                {
                    gameObject.SetTexture(ResourceTextures.wall_side_right);
                }

                if (!IsWallGameObject(gameObject.Neighbors.Bottom) && !IsWallGameObject(gameObject.Neighbors.Right) && !IsWallGameObject(gameObject.Neighbors.Top) &&
                    IsWallGameObject(gameObject.Neighbors.Left))
                {
                    gameObject.SetTexture(ResourceTextures.wall_5);
                }

                if (!IsWallGameObject(gameObject.Neighbors.Bottom) &&
                    IsWallGameObject(gameObject.Neighbors.Right) &&
                    !IsWallGameObject(gameObject.Neighbors.Left))
                {
                    gameObject.SetTexture(ResourceTextures.wall_4);
                }

                gameObject.Render(this.GetLayerByIndex(2));
            }
        }
Ejemplo n.º 2
0
        private void setPlayers()
        {
            GameSpriteSheet playerSpriteSheet = new GameSpriteSheet(ResourceTextures.player_sheet, new System.Drawing.Point(32, 32));

            players[0] = new GamePlayer(this);
            players[0].SetEnergy(MaximumEnergy);
            players[0].AddTexture(GamePlayer.GamePlayerDirection.Up, playerSpriteSheet.GetSprite(3, 1));
            players[0].AddTexture(GamePlayer.GamePlayerDirection.UpLeft, playerSpriteSheet.GetSprite(2, 7));
            players[0].AddTexture(GamePlayer.GamePlayerDirection.UpRight, playerSpriteSheet.GetSprite(3, 10));
            players[0].AddTexture(GamePlayer.GamePlayerDirection.Left, playerSpriteSheet.GetSprite(1, 1));
            players[0].AddTexture(GamePlayer.GamePlayerDirection.Right, playerSpriteSheet.GetSprite(2, 4));
            players[0].AddTexture(GamePlayer.GamePlayerDirection.Bottom, playerSpriteSheet.GetSprite(0, 1));
            players[0].AddTexture(GamePlayer.GamePlayerDirection.BottomLeft, playerSpriteSheet.GetSprite(1, 7));
            players[0].AddTexture(GamePlayer.GamePlayerDirection.BottomRight, playerSpriteSheet.GetSprite(0, 7));

            players[0].AddWalkAnimation(GamePlayer.GamePlayerDirection.Up, createWalkAnimation(new Bitmap[] {
                playerSpriteSheet.GetSprite(3, 0),
                playerSpriteSheet.GetSprite(3, 1),
                playerSpriteSheet.GetSprite(3, 2),
                playerSpriteSheet.GetSprite(3, 3),
                playerSpriteSheet.GetSprite(3, 4)
            }, new System.Windows.Point(0, BlockSize * -1)));

            players[0].AddWalkAnimation(GamePlayer.GamePlayerDirection.UpLeft, createWalkAnimation(new Bitmap[] {
                playerSpriteSheet.GetSprite(2, 6),
                playerSpriteSheet.GetSprite(2, 7),
                playerSpriteSheet.GetSprite(2, 8),
                playerSpriteSheet.GetSprite(2, 9),
                playerSpriteSheet.GetSprite(2, 10)
            }, new System.Windows.Point(BlockSize * -1, BlockSize * -1)));

            players[0].AddWalkAnimation(GamePlayer.GamePlayerDirection.UpRight, createWalkAnimation(new Bitmap[] {
                playerSpriteSheet.GetSprite(3, 6),
                playerSpriteSheet.GetSprite(3, 7),
                playerSpriteSheet.GetSprite(3, 8),
                playerSpriteSheet.GetSprite(3, 9),
                playerSpriteSheet.GetSprite(3, 10)
            }, new System.Windows.Point(BlockSize, BlockSize * -1)));


            players[0].AddWalkAnimation(GamePlayer.GamePlayerDirection.Left, createWalkAnimation(new Bitmap[] {
                playerSpriteSheet.GetSprite(1, 0),
                playerSpriteSheet.GetSprite(1, 1),
                playerSpriteSheet.GetSprite(1, 2),
                playerSpriteSheet.GetSprite(1, 3),
                playerSpriteSheet.GetSprite(1, 4)
            }, new System.Windows.Point(BlockSize * -1, 0)));

            players[0].AddWalkAnimation(GamePlayer.GamePlayerDirection.Right, createWalkAnimation(new Bitmap[] {
                playerSpriteSheet.GetSprite(2, 0),
                playerSpriteSheet.GetSprite(2, 1),
                playerSpriteSheet.GetSprite(2, 2),
                playerSpriteSheet.GetSprite(2, 3),
                playerSpriteSheet.GetSprite(2, 4)
            }, new System.Windows.Point(BlockSize, 0)));

            players[0].AddWalkAnimation(GamePlayer.GamePlayerDirection.Bottom, createWalkAnimation(new Bitmap[] {
                playerSpriteSheet.GetSprite(0, 0),
                playerSpriteSheet.GetSprite(0, 1),
                playerSpriteSheet.GetSprite(0, 2),
                playerSpriteSheet.GetSprite(0, 3),
                playerSpriteSheet.GetSprite(0, 4)
            }, new System.Windows.Point(0, BlockSize)));

            players[0].AddWalkAnimation(GamePlayer.GamePlayerDirection.BottomLeft, createWalkAnimation(new Bitmap[] {
                playerSpriteSheet.GetSprite(1, 6),
                playerSpriteSheet.GetSprite(1, 7),
                playerSpriteSheet.GetSprite(1, 8),
                playerSpriteSheet.GetSprite(1, 9),
                playerSpriteSheet.GetSprite(1, 10)
            }, new System.Windows.Point(BlockSize * -1, BlockSize)));

            players[0].AddWalkAnimation(GamePlayer.GamePlayerDirection.BottomRight, createWalkAnimation(new Bitmap[] {
                playerSpriteSheet.GetSprite(0, 6),
                playerSpriteSheet.GetSprite(0, 7),
                playerSpriteSheet.GetSprite(0, 8),
                playerSpriteSheet.GetSprite(0, 9),
                playerSpriteSheet.GetSprite(0, 10)
            }, new System.Windows.Point(BlockSize, BlockSize)));

            refreshEnergyBar();
        }