Collisions ara Working!!!! Next Is Trigger! it is 2:40... help me....

This commit is contained in:
SergoDobro 2024-08-18 02:41:09 +03:00
parent 7226b99075
commit e2ac9286e5
11 changed files with 262 additions and 72 deletions

View file

@ -103,18 +103,6 @@
#begin Textures/Animations/testAnimationExample.animation #begin Textures/Animations/testAnimationExample.animation
/copy:Textures/Animations/testAnimationExample.animation /copy:Textures/Animations/testAnimationExample.animation
#begin Textures/AnimationTextures/Character/hr-level1_idle.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:Textures/AnimationTextures/Character/hr-level1_idle.png
#begin Textures/AnimationTextures/Character/hr-level1_idle_gun.png #begin Textures/AnimationTextures/Character/hr-level1_idle_gun.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -127,6 +115,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_idle_gun.png /build:Textures/AnimationTextures/Character/hr-level1_idle_gun.png
#begin Textures/AnimationTextures/Character/hr-level1_idle.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:Textures/AnimationTextures/Character/hr-level1_idle.png
#begin Textures/AnimationTextures/Character/hr-level1_mining_tool-1.png #begin Textures/AnimationTextures/Character/hr-level1_mining_tool-1.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -151,18 +151,6 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_mining_tool-2.png /build:Textures/AnimationTextures/Character/hr-level1_mining_tool-2.png
#begin Textures/AnimationTextures/Character/hr-level1_running.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:Textures/AnimationTextures/Character/hr-level1_running.png
#begin Textures/AnimationTextures/Character/hr-level1_running_gun.png #begin Textures/AnimationTextures/Character/hr-level1_running_gun.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -175,6 +163,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_running_gun.png /build:Textures/AnimationTextures/Character/hr-level1_running_gun.png
#begin Textures/AnimationTextures/Character/hr-level1_running.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:Textures/AnimationTextures/Character/hr-level1_running.png
#begin Textures/AnimationTextures/unicorn.png #begin Textures/AnimationTextures/unicorn.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -271,18 +271,6 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/GUI/background/waiting.png /build:Textures/GUI/background/waiting.png
#begin Textures/GUI/checkboxs_off.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:Textures/GUI/checkboxs_off.png
#begin Textures/GUI/checkboxs_off-on.png #begin Textures/GUI/checkboxs_off-on.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -295,6 +283,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/GUI/checkboxs_off-on.png /build:Textures/GUI/checkboxs_off-on.png
#begin Textures/GUI/checkboxs_off.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:Textures/GUI/checkboxs_off.png
#begin Textures/GUI/checkboxs_on.png #begin Textures/GUI/checkboxs_on.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -331,6 +331,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/GUI/mouse.png /build:Textures/GUI/mouse.png
#begin Textures/GUI/Switch_backgrownd.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:Textures/GUI/Switch_backgrownd.png
#begin Textures/GUI/switch.png #begin Textures/GUI/switch.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -343,7 +355,7 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/GUI/switch.png /build:Textures/GUI/switch.png
#begin Textures/GUI/Switch_backgrownd.png #begin Textures/icons/12.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255 /processorParam:ColorKeyColor=255,0,255,255
@ -353,7 +365,115 @@
/processorParam:ResizeToPowerOfTwo=False /processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False /processorParam:MakeSquare=False
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/GUI/Switch_backgrownd.png /build:Textures/icons/12.png
#begin Textures/icons/13.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:Textures/icons/13.png
#begin Textures/icons/14.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:Textures/icons/14.png
#begin Textures/icons/21.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:Textures/icons/21.png
#begin Textures/icons/22.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:Textures/icons/22.png
#begin Textures/icons/5.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:Textures/icons/5.png
#begin Textures/icons/6.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:Textures/icons/6.png
#begin Textures/icons/7.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:Textures/icons/7.png
#begin Textures/icons/8.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:Textures/icons/8.png
#begin Textures/icons/9.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:Textures/icons/9.png
#begin Textures/TileSetImages/Tilelist1.png #begin Textures/TileSetImages/Tilelist1.png
/importer:TextureImporter /importer:TextureImporter
@ -415,15 +535,3 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/TileSetImages/TilesetFloor.png /build:Textures/TileSetImages/TilesetFloor.png
#begin Textures/TileSetImages/TilesetFloor.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:Textures/TileSetImages/TilesetFloor.png

View file

@ -19,6 +19,8 @@ using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using ZoFo.GameCore.GUI; using ZoFo.GameCore.GUI;
using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
namespace ZoFo.GameCore namespace ZoFo.GameCore
{ {
public class Client public class Client
@ -63,6 +65,7 @@ namespace ZoFo.GameCore
List<MapObject> mapObjects = new List<MapObject>(); List<MapObject> mapObjects = new List<MapObject>();
List<GameObject> gameObjects = new List<GameObject>(); List<GameObject> gameObjects = new List<GameObject>();
List<StopObject> stopObjects = new List<StopObject>();
/// <summary> /// <summary>
/// Клиент должен обнговлять игру анимаций /// Клиент должен обнговлять игру анимаций
/// </summary> /// </summary>
@ -80,6 +83,10 @@ namespace ZoFo.GameCore
{ {
mapObjects[i].Draw(spriteBatch); mapObjects[i].Draw(spriteBatch);
} }
for (int i = 0; i < stopObjects.Count; i++)
{
stopObjects[i].Draw(spriteBatch);
}
for (int i = 0; i < gameObjects.Count; i++) for (int i = 0; i < gameObjects.Count; i++)
{ {
gameObjects[i].Draw(spriteBatch); gameObjects[i].Draw(spriteBatch);
@ -88,7 +95,7 @@ namespace ZoFo.GameCore
internal void GotData(UpdateData update) internal void GotData(UpdateData update)
{ {
if (update is UpdateTileCreated) if (update is UpdateTileCreated)
{ {
mapObjects.Add( mapObjects.Add(
new MapObject( new MapObject(
@ -98,13 +105,26 @@ namespace ZoFo.GameCore
(update as UpdateTileCreated).tileSetName (update as UpdateTileCreated).tileSetName
)); ));
} }
else if (update is UpdateStopObjectCreated)
{
stopObjects.Add(
new StopObject(
(update as UpdateStopObjectCreated).Position,
(update as UpdateStopObjectCreated).Size.ToVector2(),
(update as UpdateStopObjectCreated).sourceRectangle,
(update as UpdateStopObjectCreated).tileSetName,
(update as UpdateStopObjectCreated).collisions
));
}
else if (update is UpdateGameObjectCreated) else if (update is UpdateGameObjectCreated)
{ {
if ((update as UpdateGameObjectCreated).GameObjectType == "EntittyForAnimationTests") if ((update as UpdateGameObjectCreated).GameObjectType == "EntittyForAnimationTests")
gameObjects.Add(new EntittyForAnimationTests((update as UpdateGameObjectCreated).position)); gameObjects.Add(new EntittyForAnimationTests((update as UpdateGameObjectCreated).position));
if ((update as UpdateGameObjectCreated).GameObjectType == "Player") if ((update as UpdateGameObjectCreated).GameObjectType == "Player")
gameObjects.Add(new Player((update as UpdateGameObjectCreated).position)); gameObjects.Add(new Player((update as UpdateGameObjectCreated).position));
if ((update as UpdateGameObjectCreated).GameObjectType == "Ammo")
gameObjects.Add(new Ammo((update as UpdateGameObjectCreated).position));
(gameObjects.Last() as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity); (gameObjects.Last() as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity);
//var a = Assembly.GetAssembly(typeof(GameObject)); //var a = Assembly.GetAssembly(typeof(GameObject));
//gameObjects.Add( TODO reflection //gameObjects.Add( TODO reflection

View file

@ -26,7 +26,7 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
{ {
this.gameObject = gameObject; this.gameObject = gameObject;
hasCollision = hasCollision; this.hasCollision = hasCollision;
this.isTrigger = isTrigger; this.isTrigger = isTrigger;
if (hasCollision) if (hasCollision)
this.stopRectangle = collisionRectangle.Value; this.stopRectangle = collisionRectangle.Value;

View file

@ -44,9 +44,12 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
foreach (var item in ObjectsWithCollisions)//фильтрация foreach (var item in ObjectsWithCollisions)//фильтрация
{ {
if (Math.Abs(item.stopRectangle.X - entity.collisionComponent.stopRectangle.X) < 550 if (item == componentOfEntity) continue;
&& Math.Abs(item.stopRectangle.Y - entity.collisionComponent.stopRectangle.Y) < 550
&& tryingRectX.Intersects(item.stopRectangle)) Rectangle rectChecking = item.stopRectangle.SetOrigin(item.gameObject.position);
if (Math.Abs(item.gameObject.position.X - componentOfEntity.gameObject.position.X) < 550
&& Math.Abs(item.gameObject.position.Y - componentOfEntity.gameObject.position.Y) < 550
&& tryingRectX.Intersects(rectChecking))
{ {
collidedX = true;// меняем значение соприкосновения на true collidedX = true;// меняем значение соприкосновения на true
@ -75,9 +78,11 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
foreach (var item in ObjectsWithCollisions)//фильтрация foreach (var item in ObjectsWithCollisions)//фильтрация
{ {
if (Math.Abs(item.stopRectangle.X - entity.collisionComponent.stopRectangle.X) < 550 if (item == componentOfEntity) continue;
&& Math.Abs(item.stopRectangle.Y - entity.collisionComponent.stopRectangle.Y) < 550 Rectangle rectChecking = item.stopRectangle.SetOrigin(item.gameObject.position);
&& tryingRectY.Intersects(item.stopRectangle)) if (Math.Abs(item.gameObject.position.X - componentOfEntity.gameObject.position.X) < 550
&& Math.Abs(item.gameObject.position.Y - componentOfEntity.gameObject.position.Y) < 550
&& tryingRectY.Intersects(rectChecking))
{ {
collidedY = true;// меняем значение соприкосновения на true collidedY = true;// меняем значение соприкосновения на true
@ -135,4 +140,14 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
} }
public static class ExtentionClass
{
public static Rectangle SetOrigin(this Rectangle rectangle, Vector2 origin)
{
rectangle.X = (int)origin.X;
rectangle.Y = (int)origin.Y;
return rectangle;
}
}
} }

View file

@ -81,7 +81,7 @@ namespace ZoFo.GameCore.GameManagers.MapManager
break; break;
case "StopObject": case "StopObject":
var collisionRectangles = LoadRectangles(tile); // Грузит коллизии обьектов var collisionRectangles = LoadRectangles(tile); // Грузит коллизии обьектов
AppManager.Instance.server.RegisterGameObject(new StopObject(position, AppManager.Instance.server.RegisterGameObject(new StopObject(position/4,//TODO
new Vector2(tileSet.TileWidth, tileSet.TileHeight), new Vector2(tileSet.TileWidth, tileSet.TileHeight),
sourceRectangle, sourceRectangle,
"Textures/TileSetImages/" + "Textures/TileSetImages/" +

View file

@ -23,4 +23,17 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
public Rectangle sourceRectangle { get; set; } public Rectangle sourceRectangle { get; set; }
public string tileSetName { get; set; } public string tileSetName { get; set; }
} }
/// <summary>
/// При создании тайла TODO move to another file
/// </summary>
public class UpdateStopObjectCreated : UpdateData
{
public UpdateStopObjectCreated() { UpdateType = "UpdateStopObjectCreated"; }
public Texture2D TextureTile { get; set; }
public Vector2 Position { get; set; }
public Point Size { get; set; }
public Rectangle sourceRectangle { get; set; }
public string tileSetName { get; set; }
public Rectangle[] collisions { get; set; }
}
} }

View file

@ -13,10 +13,11 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
{ {
class Ammo:Collectable class Ammo:Collectable
{ {
public override GraphicsComponent graphicsComponent { get; } = new(new List<string> { "Ammo" }, "Ammo"); public override GraphicsComponent graphicsComponent { get; } = new("Textures/icons/8");
public Ammo(Vector2 position) : base(position) public Ammo(Vector2 position) : base(position)
{ {
graphicsComponent.ObjectDrawRectangle.Width = 20;
graphicsComponent.ObjectDrawRectangle.Height = 20;
} }
public override void OnInteraction(object sender, CollisionComponent e) public override void OnInteraction(object sender, CollisionComponent e)
{ {

View file

@ -13,7 +13,7 @@ public class Door : Interactable
public Door(Vector2 position) : base(position) public Door(Vector2 position) : base(position)
{ {
graphicsComponent.OnAnimationEnd += _ => { isOpened = !isOpened; }; graphicsComponent.OnAnimationEnd += _ => { isOpened = !isOpened; };//приколько, что через нижнее подчеркивание - SD
} }
public override void OnInteraction(object sender, CollisionComponent e) public override void OnInteraction(object sender, CollisionComponent e)

View file

@ -36,6 +36,8 @@ namespace ZoFo.GameCore.GameObjects.MapObjects
public override void Draw(SpriteBatch spriteBatch) public override void Draw(SpriteBatch spriteBatch)
{ {
graphicsComponent.DrawAnimation(graphicsComponent.ObjectDrawRectangle, spriteBatch, sourceRectangle); graphicsComponent.DrawAnimation(graphicsComponent.ObjectDrawRectangle, spriteBatch, sourceRectangle);
} }
} }

View file

@ -1,23 +1,32 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Security.Cryptography.X509Certificates;
using ZoFo.GameCore.GameManagers.CollisionManager; using ZoFo.GameCore.GameManagers.CollisionManager;
namespace ZoFo.GameCore.GameObjects.MapObjects.StopObjects; namespace ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
public class StopObject : MapObject public class StopObject : MapObject
{ {
CollisionComponent[] collisionComponent; public CollisionComponent[] collisionComponents;
public StopObject(Vector2 position, Vector2 size, Rectangle sourceRectangle, string textureName, Rectangle[] collisions) : base(position, size, sourceRectangle, textureName) public StopObject(Vector2 position, Vector2 size, Rectangle sourceRectangle, string textureName, Rectangle[] collisions) : base(position, size, sourceRectangle, textureName)
{ {
collisionComponent = new CollisionComponent[collisions.Length];
for (int i = 0; i < collisionComponent.Length; i++) collisionComponents = new CollisionComponent[collisions.Length];
for (int i = 0; i < collisionComponents.Length; i++)
{ {
collisionComponent[i] = new CollisionComponent(this, true, collisions[i]); collisionComponents[i] = new CollisionComponent(this, true, new Rectangle(0,0, (int)size.X, (int)size.Y)/*collisions[i]*/);
} }
//REDO
// TODO: Написать коллизию, пусть тразмер будет чисто таким же как и текстурка. // TODO: Написать коллизию, пусть тразмер будет чисто таким же как и текстурка.
// Поменяйте уровень защиты конструктора, после снимите в MapManager комментарий в методе LoadMap с создания StopObject-а // Поменяйте уровень защиты конструктора, после снимите в MapManager комментарий в методе LoadMap с создания StopObject-а
} }
public override void Draw(SpriteBatch spriteBatch)
{
base.Draw(spriteBatch);
DrawDebugRectangle(spriteBatch, new Rectangle((int)position.X, (int)position.Y, collisionComponents[0].stopRectangle.Width, collisionComponents[0].stopRectangle.Height));
}
} }

View file

@ -15,9 +15,11 @@ using ZoFo.GameCore.GameManagers.NetworkManager.Updates;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GameObjects; using ZoFo.GameCore.GameObjects;
using ZoFo.GameCore.GameObjects.Entities; using ZoFo.GameCore.GameObjects.Entities;
using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies; using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies;
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player; using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
using ZoFo.GameCore.GameObjects.MapObjects; using ZoFo.GameCore.GameObjects.MapObjects;
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
namespace ZoFo.GameCore namespace ZoFo.GameCore
{ {
@ -95,11 +97,11 @@ namespace ZoFo.GameCore
collisionManager = new CollisionManager(); collisionManager = new CollisionManager();
gameObjects = new List<GameObject>(); gameObjects = new List<GameObject>();
entities = new List<Entity>(); entities = new List<Entity>();
//new MapManager().LoadMap(); new MapManager().LoadMap();
AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(40, 40))); AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(40, 40)));
AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(140, 140))); AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(740, 140)));
AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(140, 140))); AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(140, 440)));
} }
/// <summary> /// <summary>
@ -139,6 +141,23 @@ namespace ZoFo.GameCore
{ {
gameObjects.Add(gameObject); gameObjects.Add(gameObject);
if (gameObject is StopObject)
{
AddData(new UpdateStopObjectCreated()
{
Position = (gameObject as StopObject).position,
sourceRectangle = (gameObject as StopObject).sourceRectangle,
Size = (gameObject as StopObject).graphicsComponent.ObjectDrawRectangle.Size,
collisions = (gameObject as StopObject).collisionComponents.Select(x=>x.stopRectangle).ToArray(),
tileSetName = (gameObject as StopObject).graphicsComponent.mainTextureName
});//TODO
foreach (var item in (gameObject as StopObject).collisionComponents)
{
collisionManager.Register(item);
}
return;
}
if (gameObject is MapObject) if (gameObject is MapObject)
{ {
AddData(new UpdateTileCreated() AddData(new UpdateTileCreated()
@ -152,11 +171,14 @@ namespace ZoFo.GameCore
} }
if (gameObject is Entity) if (gameObject is Entity)
{ {
AddData(new UpdateGameObjectCreated() { GameObjectType = gameObject.GetType().Name, IdEntity = (gameObject as Entity).Id }); AddData(new UpdateGameObjectCreated() { GameObjectType = gameObject.GetType().Name, IdEntity = (gameObject as Entity).Id,
position = gameObject.position});
collisionManager.Register((gameObject as Entity).collisionComponent); collisionManager.Register((gameObject as Entity).collisionComponent);
} }
else else
AddData(new UpdateGameObjectCreated() { GameObjectType = gameObject.GetType().Name }); AddData(new UpdateGameObjectCreated() { GameObjectType = gameObject.GetType().Name,
position = gameObject.position
});
////var elems = gameObject.GetType().GetProperties(System.Reflection.BindingFlags.Public); ////var elems = gameObject.GetType().GetProperties(System.Reflection.BindingFlags.Public);