Merge branch 'DevelopmentX' into MapDevelopment
This commit is contained in:
commit
15f92ad95b
49 changed files with 1579 additions and 243 deletions
|
@ -199,6 +199,21 @@
|
||||||
#begin Textures/Animations/testAnimationExample.animation
|
#begin Textures/Animations/testAnimationExample.animation
|
||||||
/copy:Textures/Animations/testAnimationExample.animation
|
/copy:Textures/Animations/testAnimationExample.animation
|
||||||
|
|
||||||
|
#begin Textures/Animations/zombie_attack.animation
|
||||||
|
/copy:Textures/Animations/zombie_attack.animation
|
||||||
|
|
||||||
|
#begin Textures/Animations/zombie_damaged.animation
|
||||||
|
/copy:Textures/Animations/zombie_damaged.animation
|
||||||
|
|
||||||
|
#begin Textures/Animations/zombie_death.animation
|
||||||
|
/copy:Textures/Animations/zombie_death.animation
|
||||||
|
|
||||||
|
#begin Textures/Animations/zombie_idle.animation
|
||||||
|
/copy:Textures/Animations/zombie_idle.animation
|
||||||
|
|
||||||
|
#begin Textures/Animations/zombie_walk.animation
|
||||||
|
/copy:Textures/Animations/zombie_walk.animation
|
||||||
|
|
||||||
#begin Textures/AnimationTextures/Character/hr-level1_idle.png
|
#begin Textures/AnimationTextures/Character/hr-level1_idle.png
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
|
@ -283,6 +298,30 @@
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:Textures/AnimationTextures/unicorn.png
|
/build:Textures/AnimationTextures/unicorn.png
|
||||||
|
|
||||||
|
#begin Textures/AnimationTextures/Zombie/zombie_spritesheet_v1.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/Zombie/zombie_spritesheet_v1.png
|
||||||
|
|
||||||
|
#begin Textures/AnimationTextures/Zombie/zombie_spritesheet_v2.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/Zombie/zombie_spritesheet_v2.png
|
||||||
|
|
||||||
#begin Textures/GUI/background/base.png
|
#begin Textures/GUI/background/base.png
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/processor:TextureProcessor
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
},
|
},
|
||||||
"activeFile": "TileMaps/main.tmj",
|
"activeFile": "TileMaps/main.tmj",
|
||||||
"expandedProjectPaths": [
|
"expandedProjectPaths": [
|
||||||
|
".",
|
||||||
"TileSets",
|
"TileSets",
|
||||||
"TileMaps",
|
"TileMaps"
|
||||||
"."
|
|
||||||
],
|
],
|
||||||
"fileStates": {
|
"fileStates": {
|
||||||
"": {
|
"": {
|
||||||
|
@ -17,11 +17,11 @@
|
||||||
"scaleInDock": 1
|
"scaleInDock": 1
|
||||||
},
|
},
|
||||||
"TileMaps/main.tmj": {
|
"TileMaps/main.tmj": {
|
||||||
"scale": 0.5,
|
"scale": 0.33,
|
||||||
"selectedLayer": 1,
|
"selectedLayer": 1,
|
||||||
"viewCenter": {
|
"viewCenter": {
|
||||||
"x": 895,
|
"x": 1010.6060606060606,
|
||||||
"y": 270
|
"y": 553.0303030303031
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"TileMaps/main.tmj#IconSet": {
|
"TileMaps/main.tmj#IconSet": {
|
||||||
|
@ -42,24 +42,27 @@
|
||||||
},
|
},
|
||||||
"TileSets/TilesetNature.tsj": {
|
"TileSets/TilesetNature.tsj": {
|
||||||
"dynamicWrapping": false
|
"dynamicWrapping": false
|
||||||
|
"scaleInDock": 1
|
||||||
},
|
},
|
||||||
"TileSets/WallSet.tsj": {
|
"TileSets/WallSet.tsj": {
|
||||||
"scaleInDock": 1,
|
"scaleInDock": 1,
|
||||||
"scaleInEditor": 1
|
"scaleInEditor": 1
|
||||||
|
},
|
||||||
|
"TileSets/tileset 1 collision.tsj": {
|
||||||
|
"scaleInDock": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"last.imagePath": "D:/C#/Я смотрел ваши ХАКАТОНЫ/ZoFo/ZoFo/Content/Textures/icons",
|
"last.imagePath": "D:/C#/Я смотрел ваши ХАКАТОНЫ/ZoFo/ZoFo/Content/Textures/icons",
|
||||||
"last.objectTemplatePath": "D:/C#/Я смотрел ваши ХАКАТОНЫ/ZoFo/ZoFo/Content/MapData/Templates",
|
"last.objectTemplatePath": "D:/C#/Я смотрел ваши ХАКАТОНЫ/ZoFo/ZoFo/Content/MapData/Templates",
|
||||||
"openFiles": [
|
"openFiles": [
|
||||||
"TileSets/TileSet 1.tsj",
|
"TileSets/TileSet 1.tsj",
|
||||||
"TileMaps/main.tmj",
|
"TileMaps/main.tmj"
|
||||||
"TileSets/CollisionTileSet.tsj"
|
|
||||||
],
|
],
|
||||||
"project": "MapSession.tiled-project",
|
"project": "MapSession.tiled-project",
|
||||||
"recentFiles": [
|
"recentFiles": [
|
||||||
|
"TileSets/TileSet 1.tsj",
|
||||||
"TileMaps/main.tmj",
|
"TileMaps/main.tmj",
|
||||||
"TileSets/CollisionTileSet.tsj",
|
"TileSets/CollisionTileSet.tsj",
|
||||||
"TileSets/TileSet 1.tsj",
|
|
||||||
"TileSets/WallSet.tsj"
|
"TileSets/WallSet.tsj"
|
||||||
],
|
],
|
||||||
"stampsFolder": "D:/C#/Я смотрел ваши ХАКАТОНЫ/ZoFo/ZoFo/Content/MapData/TileStamps",
|
"stampsFolder": "D:/C#/Я смотрел ваши ХАКАТОНЫ/ZoFo/ZoFo/Content/MapData/TileStamps",
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
After Width: | Height: | Size: 5 KiB |
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
1
ZoFo/Content/Textures/Animations/zombie_attack.animation
Normal file
1
ZoFo/Content/Textures/Animations/zombie_attack.animation
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"zombie_attack","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":64,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":5}],"textureFrameInterval":0,"framesCount":3,"isCycle":true,"offset":"0, 0"}
|
|
@ -0,0 +1 @@
|
||||||
|
{"id":"zombie_damaged","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":128,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":5}],"textureFrameInterval":0,"framesCount":1,"isCycle":true,"offset":"0, 0"}
|
1
ZoFo/Content/Textures/Animations/zombie_death.animation
Normal file
1
ZoFo/Content/Textures/Animations/zombie_death.animation
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"zombie_death","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":96,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":5}],"textureFrameInterval":0,"framesCount":9,"isCycle":true,"offset":"0, 0"}
|
1
ZoFo/Content/Textures/Animations/zombie_idle.animation
Normal file
1
ZoFo/Content/Textures/Animations/zombie_idle.animation
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"zombie_idle","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":0,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":60}],"textureFrameInterval":0,"framesCount":2,"isCycle":true,"offset":"0, 0"}
|
1
ZoFo/Content/Textures/Animations/zombie_walk.animation
Normal file
1
ZoFo/Content/Textures/Animations/zombie_walk.animation
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"zombie_walk","textureName":"Textures/AnimationTextures/Zombie/zombie_spritesheet_v1","startSpriteRectangle":{"X":0,"Y":32,"Width":32,"Height":32},"frameSecond":[{"Item1":0,"Item2":5}],"textureFrameInterval":0,"framesCount":8,"isCycle":true,"offset":"0, 0"}
|
|
@ -24,6 +24,9 @@ using ZoFo.GameCore.GUI;
|
||||||
using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
|
using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
|
||||||
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
|
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
|
||||||
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies;
|
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies;
|
||||||
|
using ZoFo.GameCore.Graphics;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
namespace ZoFo.GameCore
|
namespace ZoFo.GameCore
|
||||||
{
|
{
|
||||||
public class Client
|
public class Client
|
||||||
|
@ -47,20 +50,37 @@ namespace ZoFo.GameCore
|
||||||
networkManager.AddData(new UpdateInput()
|
networkManager.AddData(new UpdateInput()
|
||||||
{
|
{
|
||||||
InputMovementDirection = AppManager.Instance.InputManager.InputMovementDirection,
|
InputMovementDirection = AppManager.Instance.InputManager.InputMovementDirection,
|
||||||
InputAttackDirection = AppManager.Instance.InputManager.InputAttackDirection
|
InputAttackDirection = AppManager.Instance.InputManager.InputAttackDirection
|
||||||
});
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
AppManager.Instance.InputManager.OnInteract += () =>
|
||||||
|
{
|
||||||
|
networkManager.AddData(new UpdateInputInteraction() { });
|
||||||
|
};
|
||||||
|
AppManager.Instance.InputManager.ShootEvent += () =>
|
||||||
|
{
|
||||||
|
networkManager.AddData(new UpdateInputShoot() { });
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDataSend(string data)
|
public void OnDataSend(string data)
|
||||||
{
|
{
|
||||||
List<UpdateData> updateDatas = JsonSerializer.Deserialize<List<UpdateData>>(data);
|
//List<UpdateTileCreated> updateDatas = JsonSerializer.Deserialize<List<UpdateTileCreated>>(data);
|
||||||
|
JArray jToken = JsonConvert.DeserializeObject(data) as JArray;
|
||||||
|
|
||||||
|
//string[] brands = jToken.SelectToken("")?.ToObject<string[]>();
|
||||||
|
foreach (JToken update in jToken.Children())
|
||||||
|
{
|
||||||
|
string a = update.ToString();
|
||||||
|
UpdateTileCreated u = System.Text.Json.JsonSerializer.Deserialize<UpdateTileCreated>(a);
|
||||||
|
}
|
||||||
// тут будет switch
|
// тут будет switch
|
||||||
AppManager.Instance.debugHud.Log(data);
|
AppManager.Instance.debugHud.Log(data);
|
||||||
foreach (var item in updateDatas)
|
//foreach (var item in updateDatas)
|
||||||
{
|
//{
|
||||||
GotData(item);
|
// GotData(item);
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void GameEndedUnexpectedly() { }
|
public void GameEndedUnexpectedly() { }
|
||||||
|
@ -77,6 +97,7 @@ namespace ZoFo.GameCore
|
||||||
List<GameObject> gameObjects = new List<GameObject>();
|
List<GameObject> gameObjects = new List<GameObject>();
|
||||||
List<Player> players = new List<Player>();
|
List<Player> players = new List<Player>();
|
||||||
List<StopObject> stopObjects = new List<StopObject>();
|
List<StopObject> stopObjects = new List<StopObject>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Клиент должен обнговлять игру анимаций
|
/// Клиент должен обнговлять игру анимаций
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -88,6 +109,8 @@ namespace ZoFo.GameCore
|
||||||
AppManager.Instance.debugHud.Set("GameTime", gameTime.TotalGameTime.ToString());
|
AppManager.Instance.debugHud.Set("GameTime", gameTime.TotalGameTime.ToString());
|
||||||
gameObjects[i].UpdateAnimations();
|
gameObjects[i].UpdateAnimations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
networkManager.SendData();//set to ticks
|
||||||
}
|
}
|
||||||
internal void Draw(SpriteBatch spriteBatch)
|
internal void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
|
@ -112,22 +135,21 @@ namespace ZoFo.GameCore
|
||||||
mapObjects.Add(
|
mapObjects.Add(
|
||||||
new MapObject(
|
new MapObject(
|
||||||
(update as UpdateTileCreated).Position,
|
(update as UpdateTileCreated).Position,
|
||||||
(update as UpdateTileCreated).Size.ToVector2(),
|
(update as UpdateTileCreated).Size.GetPoint().ToVector2(),
|
||||||
(update as UpdateTileCreated).sourceRectangle,
|
(update as UpdateTileCreated).sourceRectangle.GetRectangle(),
|
||||||
(update as UpdateTileCreated).tileSetName
|
(update as UpdateTileCreated).tileSetName
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
else if (update is UpdateStopObjectCreated)
|
//else if (update is UpdateStopObjectCreated)
|
||||||
{
|
//{
|
||||||
stopObjects.Add(
|
// stopObjects.Add(
|
||||||
new StopObject(
|
// new StopObject(
|
||||||
(update as UpdateStopObjectCreated).Position,
|
// (update as UpdateStopObjectCreated).Position,
|
||||||
(update as UpdateStopObjectCreated).Size.ToVector2(),
|
// (update as UpdateStopObjectCreated).Size.ToVector2(),
|
||||||
(update as UpdateStopObjectCreated).sourceRectangle,
|
// (update as UpdateStopObjectCreated).sourceRectangle,
|
||||||
(update as UpdateStopObjectCreated).tileSetName,
|
// (update as UpdateStopObjectCreated).tileSetName
|
||||||
(update as UpdateStopObjectCreated).collisions
|
// ));
|
||||||
));
|
//}
|
||||||
}
|
|
||||||
else if (update is UpdateGameObjectCreated)
|
else if (update is UpdateGameObjectCreated)
|
||||||
{
|
{
|
||||||
GameObject created_gameObject;
|
GameObject created_gameObject;
|
||||||
|
@ -156,9 +178,23 @@ namespace ZoFo.GameCore
|
||||||
else if (update is UpdatePosition)
|
else if (update is UpdatePosition)
|
||||||
{
|
{
|
||||||
var ent = FindEntityById(update.IdEntity);
|
var ent = FindEntityById(update.IdEntity);
|
||||||
|
|
||||||
ent.position = (update as UpdatePosition).NewPosition;
|
ent.position = (update as UpdatePosition).NewPosition;
|
||||||
DebugHUD.Instance.Log("newPosition " + ent.position);
|
}
|
||||||
|
else if (update is UpdateAnimation)
|
||||||
|
{
|
||||||
|
var ent = FindEntityById(update.IdEntity);
|
||||||
|
if (ent != null)
|
||||||
|
((ent as Entity).graphicsComponent as AnimatedGraphicsComponent).StartAnimation((update as UpdateAnimation).animationId);
|
||||||
|
//DebugHUD.Instance.Log("new Animation " + ent.position);
|
||||||
|
}
|
||||||
|
else if (update is UpdateGameObjectDeleted)
|
||||||
|
{
|
||||||
|
var ent = FindEntityById(update.IdEntity);
|
||||||
|
|
||||||
|
if (ent != null)
|
||||||
|
DeleteObject(ent);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +213,16 @@ namespace ZoFo.GameCore
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public void DeleteObject(Entity entity)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (gameObjects.Contains(entity))
|
||||||
|
gameObjects.Remove(entity);
|
||||||
|
//if (entities.Contains(entity))
|
||||||
|
// entities.Remove(entity);
|
||||||
|
if (players.Contains(entity))
|
||||||
|
players.Remove(entity as Player);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -62,6 +62,10 @@ public class DebugHUD
|
||||||
{
|
{
|
||||||
_text[key] = value;
|
_text[key] = value;
|
||||||
}
|
}
|
||||||
|
public static void DebugSet(string key, string value)
|
||||||
|
{
|
||||||
|
Instance._text[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
public void Log(string value)
|
public void Log(string value)
|
||||||
{
|
{
|
||||||
|
@ -71,4 +75,12 @@ public class DebugHUD
|
||||||
_log.RemoveAt(0);
|
_log.RemoveAt(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void DebugLog(string value)
|
||||||
|
{
|
||||||
|
Instance._log.Add(value);
|
||||||
|
if (Instance._log.Count > 30)
|
||||||
|
{
|
||||||
|
Instance._log.RemoveAt(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -43,12 +43,11 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
|
||||||
public GameObject gameObject { get; set; }
|
public GameObject gameObject { get; set; }
|
||||||
|
|
||||||
|
|
||||||
bool doesStop;
|
public bool hasCollision;
|
||||||
bool hasCollision;
|
|
||||||
public Rectangle stopRectangle;
|
public Rectangle stopRectangle;
|
||||||
|
|
||||||
// triggers for rectangle
|
// triggers for rectangle
|
||||||
bool isTrigger;
|
public bool isTrigger;
|
||||||
public Rectangle triggerRectangle;
|
public Rectangle triggerRectangle;
|
||||||
|
|
||||||
//delegate
|
//delegate
|
||||||
|
@ -58,13 +57,21 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
|
||||||
|
|
||||||
|
|
||||||
//events DoorInteraction
|
//events DoorInteraction
|
||||||
public event EventHandler<CollisionComponent> OnTriggerEnter;
|
public delegate void CollisionAction(Player player);
|
||||||
public event EventHandler<CollisionComponent> OnTriggerZone;
|
public event CollisionAction? OnTriggerEnter;
|
||||||
public event EventHandler<CollisionComponent> OnTriggerExit;
|
public event CollisionAction? OnTriggerZone;
|
||||||
|
public event CollisionAction? OnTriggerExit;
|
||||||
public event EventHandler<CollisionComponent> OnCollision;
|
|
||||||
|
public delegate void CoollisionEvent(GameObject gameObject);
|
||||||
|
public event CoollisionEvent? OnCollision;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void PlayerInZone(Player player) => OnTriggerZone?.Invoke(player);
|
||||||
|
public void PlayerEnter(Player player) => OnTriggerEnter?.Invoke(player);
|
||||||
|
public void PlayerExit(Player player) => OnTriggerExit?.Invoke(player);
|
||||||
|
public void OnCollisionWithObject(GameObject gameObject) => OnCollision?.Invoke(gameObject);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ using ZoFo.GameCore.GameObjects.Entities;
|
||||||
using ZoFo.GameCore.GameObjects.Entities.LivingEntities;
|
using ZoFo.GameCore.GameObjects.Entities.LivingEntities;
|
||||||
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
||||||
using ZoFo.GameCore.Graphics;
|
using ZoFo.GameCore.Graphics;
|
||||||
|
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameManagers.CollisionManager
|
namespace ZoFo.GameCore.GameManagers.CollisionManager
|
||||||
{
|
{
|
||||||
|
@ -25,119 +26,185 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
|
||||||
|
|
||||||
|
|
||||||
//чекаем коллизии в листе
|
//чекаем коллизии в листе
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// минимальный накоп изменения перед перевдижением
|
||||||
|
/// </summary>
|
||||||
|
const float minimalValueToChange = 4;
|
||||||
public void CheckComponentCollision(CollisionComponent componentOfEntity)
|
public void CheckComponentCollision(CollisionComponent componentOfEntity)
|
||||||
{
|
{
|
||||||
var entity = componentOfEntity.gameObject as LivingEntity;
|
var entity = componentOfEntity.gameObject as LivingEntity;
|
||||||
//for (int i = 0; i < ObjectsWithCollisions.Count; i++)
|
//for (int i = 0; i < ObjectsWithCollisions.Count; i++)
|
||||||
//{
|
//{
|
||||||
var currentRect = entity.collisionComponent.stopRectangle;//задаём РЕК
|
var currentRect = entity.collisionComponent.stopRectangle;//задаём РЕК
|
||||||
currentRect.X+=(int)entity.position.X;
|
currentRect.X += (int)entity.position.X;
|
||||||
currentRect.Y+=(int)entity.position.Y;
|
currentRect.Y += (int)entity.position.Y;
|
||||||
|
|
||||||
var newRect = currentRect; // задаём значение старого РЕК новому РЕК
|
var newRect = currentRect; // задаём значение старого РЕК новому РЕК
|
||||||
|
|
||||||
|
|
||||||
var collidedX = false; // соприкосновение
|
if (Math.Abs((int)entity.velocity.X) > minimalValueToChange ) //TODO
|
||||||
var tryingRectX = currentRect;//переменная для попытки перемещения по X
|
|
||||||
|
|
||||||
tryingRectX.Offset((int)(entity.velocity.X), 0);//задаём значения для tryingRectX по X и по Y
|
|
||||||
|
|
||||||
foreach (var item in ObjectsWithCollisions)//фильтрация
|
|
||||||
{
|
{
|
||||||
if (item == componentOfEntity) continue;
|
var collidedX = false; // соприкосновение
|
||||||
|
var tryingRectX = currentRect;//переменная для попытки перемещения по X
|
||||||
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))
|
|
||||||
|
|
||||||
|
tryingRectX.Offset((int)(entity.velocity.X), 0);//задаём значения для tryingRectX по X и по Y
|
||||||
|
|
||||||
|
foreach (var item in ObjectsWithCollisions)//фильтрация
|
||||||
{
|
{
|
||||||
collidedX = true;// меняем значение соприкосновения на true
|
if (item == componentOfEntity) continue;
|
||||||
entity.OnCollision(item);//подписываем entity на ивент коллизии
|
|
||||||
|
|
||||||
break;// выход
|
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
|
||||||
|
//entity.OnCollision(item);//подписываем entity на ивент коллизии
|
||||||
|
item.OnCollisionWithObject(entity);
|
||||||
|
entity.collisionComponent.OnCollisionWithObject(item.gameObject);
|
||||||
|
break;// выход
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (collidedX)// срабатывает, если перемещение блокируется
|
if (collidedX)// срабатывает, если перемещение блокируется
|
||||||
{
|
{
|
||||||
entity.velocity.X = 0;// задаём значение смещения entity на 0
|
entity.velocity.X = 0;// задаём значение смещения entity на 0
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
entity.position.X += entity.velocity.X; //update player position
|
entity.position.X += entity.velocity.X; //update player position
|
||||||
newRect.X = tryingRectX.X;//значение по X для нового РЕК приравниваем к значению испытуемого РЕК
|
newRect.X = tryingRectX.X;//значение по X для нового РЕК приравниваем к значению испытуемого РЕК
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entity.velocity.X = 0;
|
||||||
|
}
|
||||||
//==ПОВТОРЯЕМ ТОЖЕ САМОЕ ДЛЯ Y==
|
//==ПОВТОРЯЕМ ТОЖЕ САМОЕ ДЛЯ Y==
|
||||||
|
|
||||||
var collidedY = false; // соприкосновение
|
var collidedY = false; // соприкосновение
|
||||||
var tryingRectY = currentRect;//переменная для попытки перемещения по X
|
var tryingRectY = currentRect;//переменная для попытки перемещения по X
|
||||||
|
|
||||||
tryingRectY.Offset(new Point(0, (int)entity.velocity.Y));//задаём значения для tryingRectX по X и по Y
|
if (Math.Abs((int)entity.velocity.Y)> minimalValueToChange) //TODO
|
||||||
|
|
||||||
foreach (var item in ObjectsWithCollisions)//фильтрация
|
|
||||||
{
|
{
|
||||||
if (item == componentOfEntity) continue;
|
|
||||||
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
|
|
||||||
&& tryingRectY.Intersects(rectChecking))
|
|
||||||
|
|
||||||
|
tryingRectY.Offset(new Point(0, (int)entity.velocity.Y));//задаём значения для tryingRectX по X и по Y
|
||||||
|
|
||||||
|
foreach (var item in ObjectsWithCollisions)//фильтрация
|
||||||
{
|
{
|
||||||
collidedY = true;// меняем значение соприкосновения на true
|
if (item == componentOfEntity) continue;
|
||||||
entity.OnCollision(item);//подписываем entity на ивент коллизии
|
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
|
||||||
|
&& tryingRectY.Intersects(rectChecking))
|
||||||
|
|
||||||
break;// выход
|
{
|
||||||
|
collidedY = true;// меняем значение соприкосновения на true
|
||||||
|
entity.OnCollision(item);//подписываем entity на ивент коллизии
|
||||||
|
|
||||||
|
break;// выход
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (collidedY)// срабатывает, если перемещение блокируется
|
||||||
|
{
|
||||||
|
entity.velocity.Y = 0;// задаём значение смещения entity на 0
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entity.position.Y += entity.velocity.Y;
|
||||||
|
newRect.Y = tryingRectY.Y;//значение по X для нового РЕК приравниваем к значению испытуемого РЕК
|
||||||
|
}
|
||||||
|
entity.velocity.Y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collidedY)// срабатывает, если перемещение блокируется
|
|
||||||
{
|
|
||||||
entity.velocity.Y = 0;// задаём значение смещения entity на 0
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
entity.position.Y += entity.velocity.Y;
|
|
||||||
newRect.Y = tryingRectY.Y;//значение по X для нового РЕК приравниваем к значению испытуемого РЕК
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.graphicsComponent.ObjectDrawRectangle.X = (int)entity.position.X;
|
entity.graphicsComponent.ObjectDrawRectangle.X = (int)entity.position.X;
|
||||||
entity.graphicsComponent.ObjectDrawRectangle.Y = (int)entity.position.Y;
|
entity.graphicsComponent.ObjectDrawRectangle.Y = (int)entity.position.Y;
|
||||||
AppManager.Instance.server.AddData(new UpdatePosition() { NewPosition = entity.position, IdEntity = entity.Id });
|
AppManager.Instance.server.AddData(new UpdatePosition() { NewPosition = entity.position, IdEntity = entity.Id });
|
||||||
AppManager.Instance.debugHud.Set("testPos", entity.position.ToString()); //TODO remove
|
AppManager.Instance.debugHud.Set("testPos", entity.position.ToString()); //TODO remove
|
||||||
entity.velocity = Vector2.Zero;
|
}
|
||||||
|
|
||||||
|
public void UpdateTriggerZones(Player player)
|
||||||
|
{
|
||||||
|
|
||||||
|
var entity = player as LivingEntity;
|
||||||
|
var currentRect = entity.collisionComponent.stopRectangle;//задаём РЕК
|
||||||
|
currentRect.X += (int)entity.position.X;
|
||||||
|
currentRect.Y += (int)entity.position.Y;
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < ObjectsWithTriggers.Count; i++)
|
||||||
|
{
|
||||||
|
int c = ObjectsWithTriggers.Count;
|
||||||
|
|
||||||
|
if (ObjectsWithTriggers[i].triggerRectangle.SetOrigin(ObjectsWithTriggers[i].gameObject.position).Intersects(currentRect))
|
||||||
|
{
|
||||||
|
ObjectsWithTriggers[i].PlayerInZone(player);
|
||||||
|
}
|
||||||
|
i -= c - ObjectsWithTriggers.Count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//обновление позиции объекта
|
//обновление позиции объекта
|
||||||
|
|
||||||
public void UpdatePositions()
|
public void ResolvePhysics()
|
||||||
{
|
{
|
||||||
foreach (var item in EntitiesWithMovements)
|
foreach (var item in EntitiesWithMovements)
|
||||||
{
|
{
|
||||||
CheckComponentCollision(item);
|
CheckComponentCollision(item);
|
||||||
}
|
}
|
||||||
|
foreach (var item in AppManager.Instance.server.players)
|
||||||
|
{
|
||||||
|
UpdateTriggerZones(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CollisionManager()
|
public CollisionManager()
|
||||||
{
|
{
|
||||||
//graphicsComponent
|
|
||||||
//.ObjectDrawRectangle = new Rectangle(0, 0, 16 * 12, 16 * 16);
|
|
||||||
EntitiesWithMovements = new List<CollisionComponent>();
|
EntitiesWithMovements = new List<CollisionComponent>();
|
||||||
ObjectsWithCollisions = new List<CollisionComponent>();
|
ObjectsWithCollisions = new List<CollisionComponent>();
|
||||||
|
ObjectsWithTriggers = new List<CollisionComponent>();
|
||||||
}
|
}
|
||||||
//регистрация компонента(его коллизии)
|
//регистрация компонента(его коллизии)
|
||||||
public void Register(CollisionComponent component)
|
public void Register(CollisionComponent component)
|
||||||
{
|
{
|
||||||
ObjectsWithCollisions.Add(component);
|
if (component.hasCollision)
|
||||||
|
ObjectsWithCollisions.Add(component);
|
||||||
|
if (component.isTrigger)
|
||||||
|
ObjectsWithTriggers.Add(component);
|
||||||
if (component.gameObject is LivingEntity)
|
if (component.gameObject is LivingEntity)
|
||||||
{
|
{
|
||||||
EntitiesWithMovements.Add(component);
|
EntitiesWithMovements.Add(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void Deregister(CollisionComponent component)
|
||||||
|
{
|
||||||
|
if (ObjectsWithCollisions.Contains(component))
|
||||||
|
ObjectsWithCollisions.Remove(component);
|
||||||
|
if (ObjectsWithTriggers.Contains(component))
|
||||||
|
ObjectsWithTriggers.Remove(component);
|
||||||
|
if (component.gameObject is LivingEntity)
|
||||||
|
{
|
||||||
|
if (EntitiesWithMovements.Contains(component))
|
||||||
|
EntitiesWithMovements.Remove(component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player[] GetPlayersInZone(Rectangle rectangle)
|
||||||
|
{
|
||||||
|
|
||||||
|
List<Player> players = new List<Player>();
|
||||||
|
foreach (var item in AppManager.Instance.server.players)//фильтрация
|
||||||
|
{
|
||||||
|
if (item.collisionComponent.stopRectangle.SetOrigin(item.position).Intersects(rectangle))
|
||||||
|
{
|
||||||
|
players.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return players.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public static class ExtentionClass
|
public static class ExtentionClass
|
||||||
|
|
|
@ -10,6 +10,7 @@ using System.Linq;
|
||||||
using System.Reflection.Metadata.Ecma335;
|
using System.Reflection.Metadata.Ecma335;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using ZoFo.GameCore.GUI;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameManagers
|
namespace ZoFo.GameCore.GameManagers
|
||||||
{
|
{
|
||||||
|
@ -27,9 +28,6 @@ namespace ZoFo.GameCore.GameManagers
|
||||||
private Vector2 prevInputMovementDirection;
|
private Vector2 prevInputMovementDirection;
|
||||||
public Vector2 InputAttackDirection;
|
public Vector2 InputAttackDirection;
|
||||||
private Vector2 prevInputAttackDirection;
|
private Vector2 prevInputAttackDirection;
|
||||||
|
|
||||||
public event Action TalkEvent;
|
|
||||||
|
|
||||||
public ScopeState currentScopeState; // Положение оружия. Left, Right, Straight, Back, StraightLeft, StraightRight, BackLeft, BackRight.
|
public ScopeState currentScopeState; // Положение оружия. Left, Right, Straight, Back, StraightLeft, StraightRight, BackLeft, BackRight.
|
||||||
private ScopeState prevCurrentScopeState;
|
private ScopeState prevCurrentScopeState;
|
||||||
private bool _cheatsEnabled = false;
|
private bool _cheatsEnabled = false;
|
||||||
|
@ -48,6 +46,7 @@ namespace ZoFo.GameCore.GameManagers
|
||||||
|
|
||||||
public InputManager()
|
public InputManager()
|
||||||
{
|
{
|
||||||
|
isInteract = true;
|
||||||
InputMovementDirection = new Vector2(0, 0);
|
InputMovementDirection = new Vector2(0, 0);
|
||||||
InputAttackDirection = new Vector2(0, 0);
|
InputAttackDirection = new Vector2(0, 0);
|
||||||
this.isShoot = false;
|
this.isShoot = false;
|
||||||
|
@ -173,38 +172,46 @@ namespace ZoFo.GameCore.GameManagers
|
||||||
if (keyBoardState.IsKeyDown(Keys.Up) || keyBoardState.IsKeyDown(Keys.W))
|
if (keyBoardState.IsKeyDown(Keys.Up) || keyBoardState.IsKeyDown(Keys.W))
|
||||||
{
|
{
|
||||||
currentScopeState = ScopeState.Straight;
|
currentScopeState = ScopeState.Straight;
|
||||||
|
InputMovementDirection = new Vector2(0, -1);
|
||||||
}
|
}
|
||||||
else if (keyBoardState.IsKeyDown(Keys.Down) || keyBoardState.IsKeyDown(Keys.S))
|
else if (keyBoardState.IsKeyDown(Keys.Down) || keyBoardState.IsKeyDown(Keys.S))
|
||||||
{
|
{
|
||||||
currentScopeState = ScopeState.Back;
|
currentScopeState = ScopeState.Back;
|
||||||
|
InputMovementDirection = new Vector2(0, 1);
|
||||||
}
|
}
|
||||||
else if(keyBoardState.IsKeyDown(Keys.Left) || keyBoardState.IsKeyDown(Keys.A))
|
else if(keyBoardState.IsKeyDown(Keys.Left) || keyBoardState.IsKeyDown(Keys.A))
|
||||||
{
|
{
|
||||||
currentScopeState = ScopeState.Left;
|
currentScopeState = ScopeState.Left;
|
||||||
|
InputMovementDirection = new Vector2(-1, 0);
|
||||||
}
|
}
|
||||||
else if(keyBoardState.IsKeyDown(Keys.Right) || keyBoardState.IsKeyDown(Keys.D))
|
else if(keyBoardState.IsKeyDown(Keys.Right) || keyBoardState.IsKeyDown(Keys.D))
|
||||||
{
|
{
|
||||||
currentScopeState = ScopeState.Right;
|
currentScopeState = ScopeState.Right;
|
||||||
|
InputMovementDirection = new Vector2(1, 0);
|
||||||
}
|
}
|
||||||
else if(keyBoardState.IsKeyDown(Keys.Right) && keyBoardState.IsKeyDown(Keys.Up) ||
|
else if(keyBoardState.IsKeyDown(Keys.Right) && keyBoardState.IsKeyDown(Keys.Up) ||
|
||||||
keyBoardState.IsKeyDown(Keys.D) && keyBoardState.IsKeyDown(Keys.W))
|
keyBoardState.IsKeyDown(Keys.D) && keyBoardState.IsKeyDown(Keys.W))
|
||||||
{
|
{
|
||||||
currentScopeState = ScopeState.StraightRight;
|
currentScopeState = ScopeState.StraightRight;
|
||||||
|
InputMovementDirection = new Vector2(1, 1);
|
||||||
}
|
}
|
||||||
else if(keyBoardState.IsKeyDown(Keys.Left) && keyBoardState.IsKeyDown(Keys.Up) ||
|
else if(keyBoardState.IsKeyDown(Keys.Left) && keyBoardState.IsKeyDown(Keys.Up) ||
|
||||||
keyBoardState.IsKeyDown(Keys.A) && keyBoardState.IsKeyDown(Keys.W))
|
keyBoardState.IsKeyDown(Keys.A) && keyBoardState.IsKeyDown(Keys.W))
|
||||||
{
|
{
|
||||||
currentScopeState = ScopeState.StraightLeft;
|
currentScopeState = ScopeState.StraightLeft;
|
||||||
|
InputMovementDirection = new Vector2(-1, 1);
|
||||||
}
|
}
|
||||||
else if(keyBoardState.IsKeyDown(Keys.Right) && keyBoardState.IsKeyDown(Keys.Down) ||
|
else if(keyBoardState.IsKeyDown(Keys.Right) && keyBoardState.IsKeyDown(Keys.Down) ||
|
||||||
keyBoardState.IsKeyDown(Keys.D) && keyBoardState.IsKeyDown(Keys.S))
|
keyBoardState.IsKeyDown(Keys.D) && keyBoardState.IsKeyDown(Keys.S))
|
||||||
{
|
{
|
||||||
currentScopeState = ScopeState.BackRight;
|
currentScopeState = ScopeState.BackRight;
|
||||||
|
InputMovementDirection = new Vector2(1, -1);
|
||||||
}
|
}
|
||||||
else if(keyBoardState.IsKeyDown(Keys.Left) && keyBoardState.IsKeyDown(Keys.Down) ||
|
else if(keyBoardState.IsKeyDown(Keys.Left) && keyBoardState.IsKeyDown(Keys.Down) ||
|
||||||
keyBoardState.IsKeyDown(Keys.A) && keyBoardState.IsKeyDown(Keys.S))
|
keyBoardState.IsKeyDown(Keys.A) && keyBoardState.IsKeyDown(Keys.S))
|
||||||
{
|
{
|
||||||
currentScopeState = ScopeState.BackLeft;
|
currentScopeState = ScopeState.BackLeft;
|
||||||
|
InputMovementDirection = new Vector2(-1, -1);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -247,6 +254,8 @@ namespace ZoFo.GameCore.GameManagers
|
||||||
prevInputAttackDirection = InputAttackDirection;
|
prevInputAttackDirection = InputAttackDirection;
|
||||||
prevCurrentScopeState = currentScopeState;
|
prevCurrentScopeState = currentScopeState;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
DebugHUD.Instance.Set("controls", currentScopeState.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace ZoFo.GameCore.GameManagers.MapManager
|
||||||
// Загрузка TileSet-ов по TileSetInfo
|
// Загрузка TileSet-ов по TileSetInfo
|
||||||
foreach (TileSetInfo tileSetInfo in _tileMap.TileSets)
|
foreach (TileSetInfo tileSetInfo in _tileMap.TileSets)
|
||||||
{
|
{
|
||||||
TileSet tileSet = LoadTileSet(Path.Combine("Content", "MapData", "TileMaps", tileSetInfo.Source));
|
TileSet tileSet = LoadTileSet(Path.Combine(AppContext.BaseDirectory, "Content", "MapData", "TileMaps", tileSetInfo.Source));
|
||||||
tileSet.FirstGid = tileSetInfo.FirstGid;
|
tileSet.FirstGid = tileSetInfo.FirstGid;
|
||||||
_tileSets.Add(tileSet);
|
_tileSets.Add(tileSet);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,13 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
||||||
|
|
||||||
public void SendData()
|
public void SendData()
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < updates.Count; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
AppManager.Instance.server.ProcessIUpdateData(updates[i]);
|
||||||
|
}
|
||||||
|
updates.Clear();
|
||||||
|
return;// TODO remove
|
||||||
byte[] bytes = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(updates)); //нужно сериализовать
|
byte[] bytes = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(updates)); //нужно сериализовать
|
||||||
socket.Send(bytes);
|
socket.Send(bytes);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +105,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
||||||
|
|
||||||
public static IPAddress GetIp()
|
public static IPAddress GetIp()
|
||||||
{
|
{
|
||||||
string hostName = Dns.GetHostName(); // Retrive the Name of HOST
|
/*string hostName = Dns.GetHostName(); // Retrive the Name of HOST
|
||||||
var ipList = Dns.GetHostByName(hostName).AddressList;
|
var ipList = Dns.GetHostByName(hostName).AddressList;
|
||||||
|
|
||||||
foreach (var ip in ipList)
|
foreach (var ip in ipList)
|
||||||
|
@ -107,8 +114,8 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
||||||
{
|
{
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
return IPAddress.Loopback;
|
return IPAddress.Parse("127.0.0.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
//поток 2
|
//поток 2
|
||||||
|
@ -116,8 +123,8 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
||||||
{
|
{
|
||||||
while(socket.Connected)
|
while(socket.Connected)
|
||||||
{
|
{
|
||||||
byte[] bytes = new byte[2048];
|
byte[] bytes = new byte[65535];
|
||||||
var countAnsw = socket.Receive(bytes); //Вылетает если кто то закрыл
|
var countAnsw = socket.Receive(bytes, SocketFlags.Partial); //Вылетает если кто то закрыл
|
||||||
string update = Encoding.UTF8.GetString(bytes, 0, countAnsw); // обновление отосланные сервером
|
string update = Encoding.UTF8.GetString(bytes, 0, countAnsw); // обновление отосланные сервером
|
||||||
GetDataSent(update);
|
GetDataSent(update);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO
|
||||||
|
{
|
||||||
|
public class SerializablePoint
|
||||||
|
{
|
||||||
|
public int X;
|
||||||
|
public int Y;
|
||||||
|
|
||||||
|
public SerializablePoint(Point point) { X = point.X; Y = point.Y;}
|
||||||
|
public Point GetPoint() { return new Point(X, Y);}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO;
|
||||||
|
|
||||||
|
namespace ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
[JsonSerializable(typeof(SerializableRectangle))]
|
||||||
|
public class SerializableRectangle
|
||||||
|
{
|
||||||
|
public SerializablePoint Size { get; set; }
|
||||||
|
public SerializablePoint Location { get; set; }
|
||||||
|
public int X { get; set; }
|
||||||
|
public int Y { get; set; }
|
||||||
|
public SerializableRectangle()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public SerializableRectangle(Rectangle rectangle) { X = rectangle.X; Y = rectangle.Y;
|
||||||
|
Size = new SerializablePoint(rectangle.Size); Location = new SerializablePoint(rectangle.Location); }
|
||||||
|
|
||||||
|
public Rectangle GetRectangle()
|
||||||
|
{
|
||||||
|
return new Rectangle() { X = X, Y = Y, Size = Size.GetPoint(), Location = Location.GetPoint() };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,18 +51,17 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IPAddress GetIp()
|
public static IPAddress GetIp()
|
||||||
{
|
{
|
||||||
string hostName = Dns.GetHostName(); // Retrive the Name of HOST
|
/*string hostName = Dns.GetHostName(); // Retrive the Name of HOST
|
||||||
var ipList = Dns.GetHostByName(hostName).AddressList;
|
var ipList = Dns.GetHostByName(hostName).AddressList;
|
||||||
|
|
||||||
foreach (var ip in ipList)
|
foreach (var ip in ipList)
|
||||||
{
|
{
|
||||||
if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
|
if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
|
||||||
{
|
{
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
return IPAddress.Loopback;
|
return IPAddress.Parse("127.0.0.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -80,15 +79,15 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
||||||
//Что это?
|
//Что это?
|
||||||
//по 10 паков за раз TODO FIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXIT
|
//по 10 паков за раз TODO FIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXIT
|
||||||
List<UpdateData> datasToSend = new List<UpdateData>();
|
List<UpdateData> datasToSend = new List<UpdateData>();
|
||||||
for (int i = 0; i < 5 && i<updates.Count; i++)
|
for (int i = 0; i < 200 && i<updates.Count; i++)
|
||||||
datasToSend.Add(updates[i]);
|
datasToSend.Add(updates[i]);
|
||||||
string data = JsonSerializer.Serialize(datasToSend);
|
string data = JsonSerializer.Serialize(datasToSend);
|
||||||
var databytes = Encoding.UTF8.GetBytes(data);
|
var databytes = Encoding.UTF8.GetBytes(data);
|
||||||
foreach (var item in clients)
|
foreach (Socket socket in clients)
|
||||||
{
|
{
|
||||||
item.SendAsync(databytes);
|
clients[0].SendAsync(databytes, SocketFlags.Partial);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 5 && i< datasToSend.Count; i++)
|
for (int i = 0; i < 200 && i< datasToSend.Count; i++)
|
||||||
updates.RemoveAt(0);
|
updates.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,8 +170,8 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
||||||
Socket client = (Socket)socket;
|
Socket client = (Socket)socket;
|
||||||
while (client.Connected)
|
while (client.Connected)
|
||||||
{
|
{
|
||||||
var buff = new byte[1024];
|
var buff = new byte[65535];
|
||||||
var answ = client.Receive(buff);
|
var answ = client.Receive(buff, SocketFlags.Partial);
|
||||||
string response = Encoding.UTF8.GetString(buff, 0, answ);
|
string response = Encoding.UTF8.GetString(buff, 0, answ);
|
||||||
GetDataSend(response);
|
GetDataSend(response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using ZoFo.GameCore.GameManagers.NetworkManager;
|
||||||
|
|
||||||
|
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// уведомляет сервер о том, что игрок взаимодействует
|
||||||
|
/// </summary>
|
||||||
|
public class UpdateInputInteraction : UpdateData
|
||||||
|
{
|
||||||
|
public UpdateInputInteraction() { UpdateType = "UpdateInputInteraction"; }
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
using System;
|
||||||
|
using ZoFo.GameCore.GameManagers.NetworkManager.Updates;
|
||||||
|
|
||||||
|
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
|
||||||
|
|
||||||
|
public class UpdateInputShoot : UpdateData
|
||||||
|
{
|
||||||
|
public UpdateInputShoot() { UpdateType = "UpdateInputShoot"; }
|
||||||
|
}
|
|
@ -12,5 +12,6 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
|
||||||
public class UpdateAnimation : UpdateData
|
public class UpdateAnimation : UpdateData
|
||||||
{
|
{
|
||||||
public UpdateAnimation() { UpdateType = "UpdateAnimation"; }
|
public UpdateAnimation() { UpdateType = "UpdateAnimation"; }
|
||||||
|
public string animationId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// При попытке взаимодействия с объектом
|
/// При попытке взаимодействия с объектом
|
||||||
|
/// отправляет пользователю разрешение на взаимодействие
|
||||||
|
/// TODO: Вероятно убрать(обсудить)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UpdateInteraction : UpdateData
|
public class UpdateInteraction : UpdateData
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO;
|
||||||
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
|
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
|
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
|
||||||
|
@ -18,22 +19,9 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
|
||||||
{
|
{
|
||||||
public UpdateTileCreated() { UpdateType = "UpdateTileCreated"; }
|
public UpdateTileCreated() { UpdateType = "UpdateTileCreated"; }
|
||||||
public Texture2D TextureTile { get; set; }
|
public Texture2D TextureTile { get; set; }
|
||||||
public Vector2 Position { get; set; }
|
public Vector2 Position { get; set; }
|
||||||
public Point Size { get; set; }
|
public SerializablePoint Size { get; set; }
|
||||||
public Rectangle sourceRectangle { get; set; }
|
public SerializableRectangle 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; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,15 +24,7 @@ namespace ZoFo.GameCore.GameManagers
|
||||||
{
|
{
|
||||||
//List<string> sounds = AppManager.Instance.Content.Load<List<string>>("sounds/");
|
//List<string> sounds = AppManager.Instance.Content.Load<List<string>>("sounds/");
|
||||||
|
|
||||||
string a = Path.Combine("Content", "sounds");
|
string[] k = Directory.GetFiles(Path.Combine(AppContext.BaseDirectory, "Content", "sounds")).Where(x => x.EndsWith("xnb")).ToArray();
|
||||||
string[] k;
|
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
|
||||||
{
|
|
||||||
k = Directory.GetFiles(Path.Combine("bin", "Debug", "net8.0", "Content", "sounds")).Where(x => x.EndsWith("xnb")).ToArray();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
k = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "Content", "sounds")).Where(x => x.EndsWith("xnb")).ToArray();
|
|
||||||
}
|
|
||||||
if (k.Length > 0)
|
if (k.Length > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,11 @@ namespace ZoFo.GameCore.GameObjects.Entities
|
||||||
//public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List<string> { "тут пишите название анимации" }, "сдублируйте " +
|
//public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List<string> { "тут пишите название анимации" }, "сдублируйте " +
|
||||||
|
|
||||||
|
|
||||||
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "player_idle_rotate_weapon" }, "player_idle_rotate_weapon");
|
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "zombie_idle" }, "zombie_idle");
|
||||||
|
|
||||||
public EntittyForAnimationTests(Vector2 position) : base(position)
|
public EntittyForAnimationTests(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0,16*12, 16 * 16);
|
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0,16*20, 16 * 20);
|
||||||
position = new Vector2(10, 10);
|
position = new Vector2(10, 10);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using ZoFo.GameCore.GameManagers;
|
||||||
using ZoFo.GameCore.GameManagers.CollisionManager;
|
using ZoFo.GameCore.GameManagers.CollisionManager;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities
|
namespace ZoFo.GameCore.GameObjects.Entities
|
||||||
|
@ -36,6 +37,23 @@ namespace ZoFo.GameCore.GameObjects.Entities
|
||||||
Update();
|
Update();
|
||||||
base.UpdateLogic();
|
base.UpdateLogic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void StartAnimation(string animationId)
|
||||||
|
{
|
||||||
|
(graphicsComponent as Graphics.AnimatedGraphicsComponent).StartAnimation(animationId);
|
||||||
|
AppManager.Instance.server.AddData(new GameManagers.NetworkManager.Updates.ServerToClient.UpdateAnimation()
|
||||||
|
{
|
||||||
|
animationId = animationId,
|
||||||
|
IdEntity = Id
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
|
{
|
||||||
|
DrawDebugRectangle(spriteBatch, collisionComponent.stopRectangle.SetOrigin(position), Color.Orange);
|
||||||
|
|
||||||
|
base.Draw(spriteBatch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ using ZoFo.GameCore.GameManagers.CollisionManager;
|
||||||
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
|
||||||
using ZoFo.GameCore.GameManagers;
|
using ZoFo.GameCore.GameManagers;
|
||||||
using ZoFo.GameCore.Graphics;
|
using ZoFo.GameCore.Graphics;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using ZoFo.GameCore.GUI;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
|
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
|
||||||
{
|
{
|
||||||
|
@ -18,11 +20,19 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
|
||||||
{
|
{
|
||||||
graphicsComponent.ObjectDrawRectangle.Width = 20;
|
graphicsComponent.ObjectDrawRectangle.Width = 20;
|
||||||
graphicsComponent.ObjectDrawRectangle.Height = 20;
|
graphicsComponent.ObjectDrawRectangle.Height = 20;
|
||||||
|
|
||||||
|
collisionComponent.triggerRectangle = new Rectangle(0, 0, 20, 20);
|
||||||
}
|
}
|
||||||
public override void OnInteraction(object sender, CollisionComponent e)
|
public override void OnInteraction(GameObject sender)
|
||||||
{
|
{
|
||||||
|
DebugHUD.DebugLog("collected");
|
||||||
AppManager.Instance.server.AddData(new UpdateLoot("Ammo"));
|
AppManager.Instance.server.AddData(new UpdateLoot("Ammo"));
|
||||||
AppManager.Instance.server.DeleteObject(this);
|
AppManager.Instance.server.DeleteObject(this);
|
||||||
}
|
}
|
||||||
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
|
{
|
||||||
|
DrawDebugRectangle(spriteBatch, collisionComponent.triggerRectangle.SetOrigin(position), Color.Blue);
|
||||||
|
base.Draw(spriteBatch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public override void OnInteraction(object sender, CollisionComponent e)
|
public override void OnInteraction(GameObject sender)
|
||||||
{
|
{
|
||||||
AppManager.Instance.server.AddData(new UpdateLoot("Antiradine"));
|
AppManager.Instance.server.AddData(new UpdateLoot("Antiradine"));
|
||||||
AppManager.Instance.server.DeleteObject(this);
|
AppManager.Instance.server.DeleteObject(this);
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public override void OnInteraction(object sender, CollisionComponent e)
|
public override void OnInteraction(GameObject sender)
|
||||||
{
|
{
|
||||||
AppManager.Instance.server.AddData(new UpdateLoot("BottleOfWater"));
|
AppManager.Instance.server.AddData(new UpdateLoot("BottleOfWater"));
|
||||||
AppManager.Instance.server.DeleteObject(this);
|
AppManager.Instance.server.DeleteObject(this);
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class Collectable : Interactable
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnInteraction(object sender, CollisionComponent e)
|
public override void OnInteraction(GameObject sender)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
AppManager.Instance.server.AddData(new UpdateLoot());
|
AppManager.Instance.server.AddData(new UpdateLoot());
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public override void OnInteraction(object sender, CollisionComponent e)
|
public override void OnInteraction(GameObject sender)
|
||||||
{
|
{
|
||||||
AppManager.Instance.server.AddData(new UpdateLoot("Peeble"));
|
AppManager.Instance.server.AddData(new UpdateLoot("Peeble"));
|
||||||
AppManager.Instance.server.DeleteObject(this);
|
AppManager.Instance.server.DeleteObject(this);
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
|
||||||
public PureBottleOfWater(Vector2 position) : base(position)
|
public PureBottleOfWater(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public override void OnInteraction(object sender, CollisionComponent e)
|
public override void OnInteraction(GameObject sender)
|
||||||
{
|
{
|
||||||
AppManager.Instance.server.AddData(new UpdateLoot("PureBottleOfWater"));
|
AppManager.Instance.server.AddData(new UpdateLoot("PureBottleOfWater"));
|
||||||
AppManager.Instance.server.DeleteObject(this);
|
AppManager.Instance.server.DeleteObject(this);
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public override void OnInteraction(object sender, CollisionComponent e)
|
public override void OnInteraction(GameObject sender)
|
||||||
{
|
{
|
||||||
AppManager.Instance.server.AddData(new UpdateLoot("RottenFlesh"));
|
AppManager.Instance.server.AddData(new UpdateLoot("RottenFlesh"));
|
||||||
AppManager.Instance.server.DeleteObject(this);
|
AppManager.Instance.server.DeleteObject(this);
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
|
||||||
public Steel(Vector2 position) : base(position)
|
public Steel(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public override void OnInteraction(object sender, CollisionComponent e)
|
public override void OnInteraction(GameObject sender)
|
||||||
{
|
{
|
||||||
AppManager.Instance.server.AddData(new UpdateLoot("Steel"));
|
AppManager.Instance.server.AddData(new UpdateLoot("Steel"));
|
||||||
AppManager.Instance.server.DeleteObject(this);
|
AppManager.Instance.server.DeleteObject(this);
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class Wood : Collectable
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public override void OnInteraction(object sender, CollisionComponent e)
|
public override void OnInteraction(GameObject sender)
|
||||||
{
|
{
|
||||||
AppManager.Instance.server.AddData(new UpdateLoot("Wood"));
|
AppManager.Instance.server.AddData(new UpdateLoot("Wood"));
|
||||||
AppManager.Instance.server.DeleteObject(this);
|
AppManager.Instance.server.DeleteObject(this);
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class Door : Interactable
|
||||||
//graphicsComponent.OnAnimationEnd += _ => { isOpened = !isOpened; };//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - SD
|
//graphicsComponent.OnAnimationEnd += _ => { isOpened = !isOpened; };//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - SD
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnInteraction(object sender, CollisionComponent e)
|
public override void OnInteraction(GameObject sender)
|
||||||
{
|
{
|
||||||
//graphicsComponent.AnimationSelect("DoorInteraction", isOpened);
|
//graphicsComponent.AnimationSelect("DoorInteraction", isOpened);
|
||||||
//graphicsComponent.AnimationStep();
|
//graphicsComponent.AnimationStep();
|
||||||
|
|
|
@ -13,17 +13,19 @@ public class Interactable : Entity
|
||||||
|
|
||||||
public Interactable(Vector2 position) : base(position)
|
public Interactable(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
collisionComponent.OnTriggerEnter += (sender, e) => ChangeInteraction(sender, e, true);
|
collisionComponent.isTrigger = true;
|
||||||
collisionComponent.OnTriggerExit += (sender, e) => ChangeInteraction(sender, e, false);
|
collisionComponent.hasCollision = false;
|
||||||
|
collisionComponent.OnTriggerEnter += (sender) => ChangeInteraction(sender, true);
|
||||||
|
collisionComponent.OnTriggerExit += (sender) => ChangeInteraction(sender, false);
|
||||||
collisionComponent.OnTriggerZone += OnInteraction;
|
collisionComponent.OnTriggerZone += OnInteraction;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangeInteraction(object sender, CollisionComponent e, bool isReady)
|
private void ChangeInteraction(GameObject sender, bool isReady)
|
||||||
{
|
{
|
||||||
AppManager.Instance.server.AddData(new UpdateInteractionReady((sender as Player).Id, isReady));
|
AppManager.Instance.server.AddData(new UpdateInteractionReady((sender as Player).Id, isReady));
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnInteraction(object sender, CollisionComponent e)
|
public virtual void OnInteraction(GameObject sender)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,12 @@ namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies
|
||||||
{
|
{
|
||||||
class Zombie : Enemy
|
class Zombie : Enemy
|
||||||
{
|
{
|
||||||
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent("Textures/icons/8");
|
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "zombie_damaged","zombie_walk","zombie_idle","zombie_attack","zombie_death" }, "zombie_walk");
|
||||||
public Zombie(Vector2 position) : base(position)
|
public Zombie(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
health = 5;
|
health = 5;
|
||||||
speed =2;
|
speed =2;
|
||||||
collisionComponent.stopRectangle = new Rectangle(0, 0, 100, 100);
|
collisionComponent.stopRectangle = new Rectangle(0, 0, 52, 100);
|
||||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 100, 100);
|
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,13 +25,18 @@ namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies
|
||||||
Vector2 duration = Vector2.Normalize(
|
Vector2 duration = Vector2.Normalize(
|
||||||
AppManager.Instance.server.players[0].position - position
|
AppManager.Instance.server.players[0].position - position
|
||||||
);
|
);
|
||||||
velocity=new Vector2(duration.X * speed, duration.Y*speed);
|
velocity+=new Vector2(duration.X * speed, duration.Y*speed);
|
||||||
if(position.X>595 && 605>position.X && position.Y>495 && 505>position.Y)
|
if (Random.Shared.NextDouble() > 0.9)
|
||||||
{
|
{
|
||||||
velocity = Vector2.Zero;
|
|
||||||
|
StartAnimation("zombie_damaged");
|
||||||
}
|
}
|
||||||
//position.X += velocity.X*t;
|
if (Random.Shared.NextDouble() > 0.9)
|
||||||
//position.Y += velocity.Y * t;
|
{
|
||||||
|
|
||||||
|
StartAnimation("zombie_idle");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class LivingEntity : Entity
|
||||||
public LivingEntity(Vector2 position) : base(position)
|
public LivingEntity(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
inputManager = new InputManager();
|
inputManager = new InputManager();
|
||||||
|
collisionComponent.hasCollision = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override GraphicsComponent graphicsComponent { get; } = null;
|
public override GraphicsComponent graphicsComponent { get; } = null;
|
||||||
|
@ -34,7 +35,21 @@ public class LivingEntity : Entity
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void UpdateAnimations()
|
||||||
|
{
|
||||||
|
base.UpdateAnimations();
|
||||||
|
}
|
||||||
|
Vector2 prevPosition_forClient;
|
||||||
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
|
{
|
||||||
|
if ((position - prevPosition_forClient).X< 0)
|
||||||
|
graphicsComponent.Flip = SpriteEffects.FlipHorizontally;
|
||||||
|
else if((position - prevPosition_forClient).X > 0)
|
||||||
|
graphicsComponent.Flip = SpriteEffects.None;
|
||||||
|
base.Draw(spriteBatch);
|
||||||
|
prevPosition_forClient = position;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,17 +18,21 @@ public class Player : LivingEntity
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Факт того, что плеер в этом апдейте пытается стрелять
|
/// Факт того, что плеер в этом апдейте пытается стрелять
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsTryingToShoot { get; set; }
|
//public bool IsTryingToShoot { get; set; }
|
||||||
private float speed;
|
private float speed;
|
||||||
private int health;
|
private int health;
|
||||||
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "player_look_down" }, "player_look_down");
|
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "player_look_down" }, "player_look_down");
|
||||||
private LootData lootData;
|
private LootData lootData;
|
||||||
|
//public bool isTryingToInteract { get; set; }
|
||||||
public Player(Vector2 position) : base(position)
|
public Player(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
//InputWeaponRotation = new Vector2(0, 0);
|
|
||||||
//InputPlayerRotation = new Vector2(0, 0);
|
|
||||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 100, 100);
|
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 100, 100);
|
||||||
collisionComponent.stopRectangle = new Rectangle(0, 0, 100, 100);
|
collisionComponent.stopRectangle = new Rectangle(0, 0, 100, 100);
|
||||||
|
speed = 10;
|
||||||
|
//isTryingToInteract = false;
|
||||||
|
//IsTryingToShoot = false;
|
||||||
|
|
||||||
|
StartAnimation("player_look_down");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,20 +41,21 @@ public class Player : LivingEntity
|
||||||
|
|
||||||
MovementLogic();
|
MovementLogic();
|
||||||
}
|
}
|
||||||
float t;
|
public void MovementLogic()
|
||||||
public void MovementLogic()
|
|
||||||
{
|
{
|
||||||
//velocity.X = 3+(float)Math.Sin(t);
|
velocity = InputPlayerRotation * speed;
|
||||||
t++;
|
|
||||||
if (InputPlayerRotation.X > 0.9)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
if (Keyboard.GetState().IsKeyDown(Keys.D)) velocity.X = 5;
|
|
||||||
if (Keyboard.GetState().IsKeyDown(Keys.A)) velocity.X = -5;
|
|
||||||
if (Keyboard.GetState().IsKeyDown(Keys.S)) velocity.Y = 5;
|
|
||||||
if (Keyboard.GetState().IsKeyDown(Keys.W)) velocity.Y = -5;
|
|
||||||
}
|
}
|
||||||
public void HandleNewInput(UpdateInput updateInput)
|
public void HandleNewInput(UpdateInput updateInput)
|
||||||
|
{
|
||||||
|
InputPlayerRotation = updateInput.InputMovementDirection;
|
||||||
|
InputWeaponRotation = updateInput.InputAttackDirection;
|
||||||
|
|
||||||
|
}
|
||||||
|
public void HandleInteract(UpdateInputInteraction updateInputInteraction)
|
||||||
|
{
|
||||||
|
//isTryingToInteract = true;
|
||||||
|
}
|
||||||
|
public void HandleShoot(UpdateInputShoot updateInputShoot)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,8 +83,6 @@ public abstract class GameObject
|
||||||
{
|
{
|
||||||
graphicsComponent.Draw(graphicsComponent.ObjectDrawRectangle, spriteBatch);
|
graphicsComponent.Draw(graphicsComponent.ObjectDrawRectangle, spriteBatch);
|
||||||
//debug
|
//debug
|
||||||
DrawDebugRectangle(spriteBatch, graphicsComponent.ObjectDrawRectangle);
|
|
||||||
|
|
||||||
if (AppManager.Instance.InputManager.CollisionsCheat)
|
if (AppManager.Instance.InputManager.CollisionsCheat)
|
||||||
DrawDebugRectangle(spriteBatch, graphicsComponent.ObjectDrawRectangle);
|
DrawDebugRectangle(spriteBatch, graphicsComponent.ObjectDrawRectangle);
|
||||||
|
|
||||||
|
|
|
@ -125,8 +125,9 @@ namespace ZoFo.GameCore.Graphics
|
||||||
|
|
||||||
buildSourceRectangle();
|
buildSourceRectangle();
|
||||||
SetInterval();
|
SetInterval();
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void StopAnimation()
|
public void StopAnimation()
|
||||||
{
|
{
|
||||||
currentFrame = 0;
|
currentFrame = 0;
|
||||||
|
@ -163,6 +164,7 @@ namespace ZoFo.GameCore.Graphics
|
||||||
}
|
}
|
||||||
|
|
||||||
interval--;
|
interval--;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
|
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
|
||||||
|
@ -187,8 +189,9 @@ namespace ZoFo.GameCore.Graphics
|
||||||
destinationRectangle.Y -= CameraPosition.Y;
|
destinationRectangle.Y -= CameraPosition.Y;
|
||||||
|
|
||||||
destinationRectangle = Scaling(destinationRectangle);
|
destinationRectangle = Scaling(destinationRectangle);
|
||||||
_spriteBatch.Draw(texture,
|
|
||||||
destinationRectangle, sourceRectangle, Color.White);
|
_spriteBatch.Draw(texture, destinationRectangle, sourceRectangle, Color.White, Rotation,
|
||||||
|
Vector2.Zero, Flip, 0);
|
||||||
}
|
}
|
||||||
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
||||||
{
|
{
|
||||||
|
@ -213,7 +216,8 @@ namespace ZoFo.GameCore.Graphics
|
||||||
|
|
||||||
destinationRectangle = Scaling(destinationRectangle);
|
destinationRectangle = Scaling(destinationRectangle);
|
||||||
_spriteBatch.Draw(texture,
|
_spriteBatch.Draw(texture,
|
||||||
destinationRectangle, sourceRectangle, Color.White);
|
destinationRectangle, sourceRectangle, Color.White, 0,
|
||||||
|
Vector2.Zero, Flip, 0);
|
||||||
}
|
}
|
||||||
private void buildSourceRectangle()
|
private void buildSourceRectangle()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ZoFo.GameCore.Graphics
|
||||||
public void LoadAnimations()
|
public void LoadAnimations()
|
||||||
{
|
{
|
||||||
Animations = new List<AnimationContainer>();
|
Animations = new List<AnimationContainer>();
|
||||||
string[] animationFilesNames = Directory.GetFiles("Content/Textures/Animations");
|
string[] animationFilesNames = Directory.GetFiles(Path.Combine(AppContext.BaseDirectory, "Content", "Textures", "Animations"));
|
||||||
|
|
||||||
StreamReader reader;
|
StreamReader reader;
|
||||||
foreach (var fileName in animationFilesNames)
|
foreach (var fileName in animationFilesNames)
|
||||||
|
|
|
@ -9,6 +9,9 @@ public abstract class GraphicsComponent
|
||||||
public static int scaling = 1;
|
public static int scaling = 1;
|
||||||
public string mainTextureName;//TODO костыль - пофиксить
|
public string mainTextureName;//TODO костыль - пофиксить
|
||||||
|
|
||||||
|
public SpriteEffects Flip = SpriteEffects.None;
|
||||||
|
public float Rotation;
|
||||||
|
|
||||||
public abstract void LoadContent();
|
public abstract void LoadContent();
|
||||||
public abstract void Update();
|
public abstract void Update();
|
||||||
public abstract void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch);
|
public abstract void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch);
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
using Microsoft.Xna.Framework;
|
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
|
||||||
|
|
||||||
namespace ZoFo.GameCore.Graphics;
|
|
||||||
|
|
||||||
public interface IGraphicsComponent
|
|
||||||
{
|
|
||||||
public Rectangle ObjectDrawRectangle { get; set; }
|
|
||||||
public static int scaling = 1;
|
|
||||||
public string mainTextureName { get; set; }//TODO костыль - пофиксить
|
|
||||||
|
|
||||||
public abstract void LoadContent();
|
|
||||||
public abstract void Update();
|
|
||||||
public abstract void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch);
|
|
||||||
public abstract void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle);
|
|
||||||
}
|
|
|
@ -8,7 +8,6 @@ using ZoFo.GameCore.GUI;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.Graphics
|
namespace ZoFo.GameCore.Graphics
|
||||||
{
|
{
|
||||||
|
|
||||||
public class StaticGraphicsComponent : GraphicsComponent
|
public class StaticGraphicsComponent : GraphicsComponent
|
||||||
{
|
{
|
||||||
private Texture2D texture;
|
private Texture2D texture;
|
||||||
|
@ -18,7 +17,7 @@ namespace ZoFo.GameCore.Graphics
|
||||||
{
|
{
|
||||||
LoadContent();
|
LoadContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StaticGraphicsComponent(string textureName)
|
public StaticGraphicsComponent(string textureName)
|
||||||
{
|
{
|
||||||
BuildComponent(textureName);
|
BuildComponent(textureName);
|
||||||
|
@ -29,7 +28,7 @@ namespace ZoFo.GameCore.Graphics
|
||||||
{
|
{
|
||||||
_textureName = textureName;
|
_textureName = textureName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void LoadContent()
|
public override void LoadContent()
|
||||||
{
|
{
|
||||||
|
@ -37,7 +36,7 @@ namespace ZoFo.GameCore.Graphics
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
texture = AppManager.Instance.Content.Load<Texture2D>(_textureName);
|
texture = AppManager.Instance.Content.Load<Texture2D>(_textureName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,24 +47,28 @@ namespace ZoFo.GameCore.Graphics
|
||||||
|
|
||||||
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
|
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
|
||||||
{
|
{
|
||||||
DebugHUD.Instance.Log("draw ");
|
//DebugHUD.Instance.Log("draw ");
|
||||||
|
|
||||||
destinationRectangle.X -= CameraPosition.X;
|
destinationRectangle.X -= CameraPosition.X;
|
||||||
destinationRectangle.Y -= CameraPosition.Y;
|
destinationRectangle.Y -= CameraPosition.Y;
|
||||||
destinationRectangle = Scaling(destinationRectangle);
|
destinationRectangle = Scaling(destinationRectangle);
|
||||||
_spriteBatch.Draw(texture, destinationRectangle, Color.White);
|
_spriteBatch.Draw(texture, destinationRectangle, texture.Bounds, Color.White, Rotation,
|
||||||
|
Vector2.Zero, Flip, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
||||||
{
|
{
|
||||||
DebugHUD.Instance.Log("draw ");
|
//DebugHUD.Instance.Log("draw ");
|
||||||
|
// Uncomment to go brrrr
|
||||||
|
//Rotation = new Random().Next(1, 365);
|
||||||
|
|
||||||
destinationRectangle.X -= CameraPosition.X;
|
destinationRectangle.X -= CameraPosition.X;
|
||||||
destinationRectangle.Y -= CameraPosition.Y;
|
destinationRectangle.Y -= CameraPosition.Y;
|
||||||
|
|
||||||
destinationRectangle = Scaling(destinationRectangle);
|
destinationRectangle = Scaling(destinationRectangle);
|
||||||
_spriteBatch.Draw(texture,
|
_spriteBatch.Draw(texture,
|
||||||
destinationRectangle, sourceRectangle, Color.White);
|
destinationRectangle, sourceRectangle, Color.White, Rotation,
|
||||||
|
Vector2.Zero, Flip, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,6 +12,7 @@ using ZoFo.GameCore.GameManagers.CollisionManager;
|
||||||
using ZoFo.GameCore.GameManagers.MapManager;
|
using ZoFo.GameCore.GameManagers.MapManager;
|
||||||
using ZoFo.GameCore.GameManagers.NetworkManager;
|
using ZoFo.GameCore.GameManagers.NetworkManager;
|
||||||
using ZoFo.GameCore.GameManagers.NetworkManager.Updates;
|
using ZoFo.GameCore.GameManagers.NetworkManager.Updates;
|
||||||
|
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
|
||||||
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;
|
||||||
|
@ -21,6 +22,7 @@ using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
|
||||||
using ZoFo.GameCore.GameObjects.MapObjects;
|
using ZoFo.GameCore.GameObjects.MapObjects;
|
||||||
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
|
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
|
||||||
using ZoFo.GameCore.Graphics;
|
using ZoFo.GameCore.Graphics;
|
||||||
|
using ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO;
|
||||||
|
|
||||||
namespace ZoFo.GameCore
|
namespace ZoFo.GameCore
|
||||||
{
|
{
|
||||||
|
@ -77,11 +79,17 @@ namespace ZoFo.GameCore
|
||||||
break;
|
break;
|
||||||
case "UpdatePlayerParametrs":
|
case "UpdatePlayerParametrs":
|
||||||
break;
|
break;
|
||||||
case "UpdatePosition":
|
case "UpdateInput":
|
||||||
|
players[0].HandleNewInput(updateData as UpdateInput);
|
||||||
break;
|
break;
|
||||||
case "UpdateTileCreated":
|
case "UpdateTileCreated":
|
||||||
break;
|
break;
|
||||||
|
case "UpdateInputInteraction":
|
||||||
|
players[0].HandleInteract(updateData as UpdateInputInteraction);
|
||||||
|
break;
|
||||||
|
case "UpdateInputShoot":
|
||||||
|
players[0].HandleShoot(updateData as UpdateInputShoot);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +138,9 @@ namespace ZoFo.GameCore
|
||||||
//AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(0, 0)));
|
//AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(0, 0)));
|
||||||
AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(740, 140)));
|
AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(740, 140)));
|
||||||
AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1000, 1000)));
|
AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1000, 1000)));
|
||||||
|
AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1300, 1000)));
|
||||||
|
AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1500, 1000)));
|
||||||
|
AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1700, 1000)));
|
||||||
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(140, 440)));
|
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(140, 440)));
|
||||||
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(240, 440)));
|
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(240, 440)));
|
||||||
}
|
}
|
||||||
|
@ -155,7 +166,7 @@ namespace ZoFo.GameCore
|
||||||
{
|
{
|
||||||
go.UpdateLogic();
|
go.UpdateLogic();
|
||||||
}
|
}
|
||||||
collisionManager.UpdatePositions();
|
collisionManager.ResolvePhysics();
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
networkManager.SendData();
|
networkManager.SendData();
|
||||||
}
|
}
|
||||||
|
@ -172,30 +183,13 @@ 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 as StaticGraphicsComponent)._textureName
|
|
||||||
});//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()
|
||||||
{
|
{
|
||||||
Position = (gameObject as MapObject).position,
|
Position = (gameObject as MapObject).position,
|
||||||
sourceRectangle = (gameObject as MapObject).sourceRectangle,
|
sourceRectangle = new SerializableRectangle((gameObject as MapObject).sourceRectangle),
|
||||||
Size = (gameObject as MapObject).graphicsComponent.ObjectDrawRectangle.Size,
|
Size = new SerializablePoint((gameObject as MapObject).graphicsComponent.ObjectDrawRectangle.Size),
|
||||||
tileSetName = ((gameObject as MapObject).graphicsComponent as StaticGraphicsComponent)._textureName
|
tileSetName = ((gameObject as MapObject).graphicsComponent as StaticGraphicsComponent)._textureName
|
||||||
});//TODO
|
});//TODO
|
||||||
return;
|
return;
|
||||||
|
@ -228,12 +222,18 @@ namespace ZoFo.GameCore
|
||||||
/// Удаляет игровой объект
|
/// Удаляет игровой объект
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gameObject"></param>
|
/// <param name="gameObject"></param>
|
||||||
public void DeleteObject(GameObject gameObject)
|
public void DeleteObject(Entity entity)
|
||||||
{
|
{
|
||||||
gameObjects.Remove(gameObject);
|
if (gameObjects.Contains(entity))
|
||||||
|
gameObjects.Remove(entity);
|
||||||
|
if (entities.Contains(entity))
|
||||||
|
entities.Remove(entity);
|
||||||
|
if (players.Contains(entity))
|
||||||
|
players.Remove(entity as Player);
|
||||||
AddData(new UpdateGameObjectDeleted()
|
AddData(new UpdateGameObjectDeleted()
|
||||||
{ GameObjectType = gameObject.GetType().Name}
|
{ GameObjectType = entity.GetType().Name, IdEntity = entity .Id}
|
||||||
);
|
);
|
||||||
|
collisionManager.Deregister(entity.collisionComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue