I have 2 classes that references a list inside the main game function. Classes Block and MovingPlatform both have a list that holds all the objects.
public List<Block> Blocks;
public List<MovingPlatform> Platforms;
I also have a Collision Manager class which uses the 2 lists to see if platforms is colliding with a block and then make platforms go another direction.
I then transfer over the lists to the class Collision Manager:
public class Collision_Manager
{
Game1 game1;
public void Initialize(Game1 game1)
{
this.game1 = new Game1();
}
public void Update(GameTime gameTime, Game1 game1)
{
this.game1 = game1;
for (int i = 0; i < game1.Blocks.Count; i++)
{
Rectangle BlockBounds = new Rectangle(
(int)game1.Blocks[i].Position.X,
(int)game1.Blocks[i].Position.Y,
game1.Blocks[i].Texture.Width,
game1.Blocks[i].Texture.Height);
Rectangle top = new Rectangle((int)BlockBounds.X + 5, (int)BlockBounds.Y - 10, BlockBounds.Width - 10, 10);
Rectangle bottom = new Rectangle((int)BlockBounds.X + 5, (int)BlockBounds.Y + BlockBounds.Height, BlockBounds.Width - 10, 10);
Rectangle left = new Rectangle((int)BlockBounds.X - 10, (int)BlockBounds.Y + 5, 10, BlockBounds.Height - 10);
Rectangle right = new Rectangle((int)BlockBounds.X + BlockBounds.Width, (int)BlockBounds.Y + 5, 10, BlockBounds.Height - 10);
for (int b = 0; b < game1.Platforms.Count; b++)
{
Rectangle PlatformBounds = new Rectangle(
(int)game1.Platforms[i].Position.X,
(int)game1.Platforms[i].Position.Y,
game1.Platforms[i].Texture.Width,
game1.Platforms[i].Texture.Height);
if (top.Intersects(new Rectangle(PlatformBounds.X, PlatformBounds.Y, PlatformBounds.Width, PlatformBounds.Height)) && game1.Blocks[i].BlockState == 3)
{
game1.Platforms[i].Thing = false;
}
if (bottom.Intersects(new Rectangle(PlatformBounds.X, PlatformBounds.Y, PlatformBounds.Width, PlatformBounds.Height)) && game1.Blocks[i].BlockState == 3)
{
game1.Platforms[i].Thing = true;
}
if (left.Intersects(new Rectangle(PlatformBounds.X, PlatformBounds.Y, PlatformBounds.Width, PlatformBounds.Height)) && game1.Blocks[i].BlockState == 3)
{
game1.Platforms[i].Thing = false;
}
if (right.Intersects(new Rectangle(PlatformBounds.X, PlatformBounds.Y, PlatformBounds.Width, PlatformBounds.Height)) && game1.Blocks[i].BlockState == 3)
{
game1.Platforms[i].Thing = true ;
}
}
}
}
}
For some reason I am getting the error: Inconsistent accessibility: field type 'System.Collections.Generic.List<Game.Block>' is less accessible than field 'Game.Game1.Blocks'
Inconsistent accessibility: field type 'System.Collections.Generic.List<Game.MovingPlatform>' is less accessible than field 'Game.Game1.Platforms'
How do I fix my problem?
Game.Block
declared as internal. – Hamlet Hakobyan