Merge branch 'main' of https://github.com/progtime-net/DangerousD
This commit is contained in:
commit
44cf28c30a
3 changed files with 83 additions and 14 deletions
|
@ -13,6 +13,19 @@
|
||||||
|
|
||||||
#---------------------------------- Content ---------------------------------#
|
#---------------------------------- Content ---------------------------------#
|
||||||
|
|
||||||
|
#begin animation1.png
|
||||||
|
/importer:TextureImporter
|
||||||
|
/processor:TextureProcessor
|
||||||
|
/processorParam:ColorKeyColor=255,0,255,255
|
||||||
|
/processorParam:ColorKeyEnabled=True
|
||||||
|
/processorParam:GenerateMipmaps=False
|
||||||
|
/processorParam:PremultiplyAlpha=True
|
||||||
|
/processorParam:ResizeToPowerOfTwo=False
|
||||||
|
/processorParam:MakeSquare=False
|
||||||
|
/processorParam:TextureFormat=Color
|
||||||
|
/build:animation1.png
|
||||||
|
|
||||||
|
|
||||||
#begin ButtonFont.spritefont
|
#begin ButtonFont.spritefont
|
||||||
/importer:FontDescriptionImporter
|
/importer:FontDescriptionImporter
|
||||||
/processor:FontDescriptionProcessor
|
/processor:FontDescriptionProcessor
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace DangerousD.GameCore.Graphics
|
||||||
{
|
{
|
||||||
public class GraphicsComponent
|
public class GraphicsComponent
|
||||||
{
|
{
|
||||||
|
public Action actionOfAnimationEnd;
|
||||||
private List<AnimationContainer> animations;
|
private List<AnimationContainer> animations;
|
||||||
private List<Texture2D> textures;
|
private List<Texture2D> textures;
|
||||||
private List<string> texturesNames;
|
private List<string> texturesNames;
|
||||||
|
@ -115,9 +116,11 @@ namespace DangerousD.GameCore.Graphics
|
||||||
if (!currentAnimation.IsCycle)
|
if (!currentAnimation.IsCycle)
|
||||||
{
|
{
|
||||||
currentAnimation = neitralAnimation;
|
currentAnimation = neitralAnimation;
|
||||||
|
actionOfAnimationEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
currentFrame = 0;
|
currentFrame = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildSourceRectangle();
|
buildSourceRectangle();
|
||||||
|
@ -146,6 +149,28 @@ namespace DangerousD.GameCore.Graphics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_spriteBatch.Draw(texture,
|
||||||
|
destinationRectangle, sourceRectangle, Color.White);
|
||||||
|
}
|
||||||
|
public void DrawAnimation(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
||||||
|
{
|
||||||
|
Texture2D texture = textures[texturesNames.FindIndex(x => x == currentAnimation.TextureName)];
|
||||||
|
float scale;
|
||||||
|
if (currentAnimation.Offset.X != 0)
|
||||||
|
{
|
||||||
|
destinationRectangle.X -= (int)currentAnimation.Offset.X;
|
||||||
|
scale = destinationRectangle.Height / sourceRectangle.Height;
|
||||||
|
destinationRectangle.Width = (int)(sourceRectangle.Width * scale);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (currentAnimation.Offset.Y != 0)
|
||||||
|
{
|
||||||
|
destinationRectangle.Y -= (int)currentAnimation.Offset.Y;
|
||||||
|
scale = destinationRectangle.Width / sourceRectangle.Width;
|
||||||
|
destinationRectangle.Height = (int)(sourceRectangle.Height * scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_spriteBatch.Draw(texture,
|
_spriteBatch.Draw(texture,
|
||||||
destinationRectangle, sourceRectangle, Color.White);
|
destinationRectangle, sourceRectangle, Color.White);
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,11 +144,30 @@ namespace DangerousD.GameCore.Managers
|
||||||
{
|
{
|
||||||
rectangle.X = (int)(entity2.Pos.X + (i / length) * distance.X);
|
rectangle.X = (int)(entity2.Pos.X + (i / length) * distance.X);
|
||||||
rectangle.Y = (int)(entity2.Pos.Y + (i / length) * distance.Y);
|
rectangle.Y = (int)(entity2.Pos.Y + (i / length) * distance.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < AppManager.Instance.GameManager.entities.Count; i++)
|
||||||
|
{
|
||||||
|
if (AppManager.Instance.GameManager.entities[i].Rectangle.Intersects(rectangle))
|
||||||
|
{
|
||||||
|
return AppManager.Instance.GameManager.entities[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < AppManager.Instance.GameManager.mapObjects.Count; i++)
|
||||||
|
{
|
||||||
|
if (AppManager.Instance.GameManager.mapObjects[i].Rectangle.Intersects(rectangle))
|
||||||
|
{
|
||||||
|
return AppManager.Instance.GameManager.mapObjects[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//if (rectangle.Intersects(GameManager.Rectangle))
|
|
||||||
//{
|
for (int i = 0; i < AppManager.Instance.GameManager.livingEntities.Count; i++)
|
||||||
// return game
|
{
|
||||||
//}
|
if (AppManager.Instance.GameManager.livingEntities[i].Rectangle.Intersects(rectangle))
|
||||||
|
{
|
||||||
|
return AppManager.Instance.GameManager.livingEntities[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return gameObject;
|
return gameObject;
|
||||||
}
|
}
|
||||||
|
@ -156,23 +175,35 @@ namespace DangerousD.GameCore.Managers
|
||||||
{
|
{
|
||||||
Rectangle rectangle;
|
Rectangle rectangle;
|
||||||
Vector2 direction = entity1.Pos - targetCast;
|
Vector2 direction = entity1.Pos - targetCast;
|
||||||
rectangle = new Rectangle((int)entity1.Pos.X, (int)entity1.Pos.Y, 1, 1);
|
rectangle = new Rectangle((int)targetCast.X, (int)targetCast.Y, 1, 1);
|
||||||
GameObject gameObject = null;
|
|
||||||
double k = direction.Length();
|
double k = direction.Length();
|
||||||
|
|
||||||
for (int i = 0; i < k; i++)
|
for (int i = 0; i < k; i++)
|
||||||
{
|
{
|
||||||
rectangle.X = (int)(entity1.Pos.X + (i / k) * direction.X);
|
rectangle.X = (int)(targetCast.X + (i / k) * direction.X);
|
||||||
rectangle.Y = (int)(entity1.Pos.Y + (i / k) * direction.X);
|
rectangle.Y = (int)(targetCast.Y + (i / k) * direction.X);
|
||||||
if (gameObject != null)
|
}
|
||||||
|
for (int i = 0; i < AppManager.Instance.GameManager.entities.Count; i++)
|
||||||
|
{
|
||||||
|
if (AppManager.Instance.GameManager.entities[i].Rectangle.Intersects(rectangle))
|
||||||
{
|
{
|
||||||
break;
|
return AppManager.Instance.GameManager.entities[i];
|
||||||
return gameObject;
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < AppManager.Instance.GameManager.mapObjects.Count; i++)
|
||||||
|
{
|
||||||
|
if (AppManager.Instance.GameManager.mapObjects[i].Rectangle.Intersects(rectangle))
|
||||||
|
{
|
||||||
|
return AppManager.Instance.GameManager.mapObjects[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < AppManager.Instance.GameManager.livingEntities.Count; i++)
|
||||||
|
{
|
||||||
|
if (AppManager.Instance.GameManager.livingEntities[i].Rectangle.Intersects(rectangle))
|
||||||
|
{
|
||||||
|
return AppManager.Instance.GameManager.livingEntities[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue