Merge branch 'AddPlayers' of github.com:progtime-net/ZoFo into AddPlayers

This commit is contained in:
AnloGames 2024-08-20 18:00:00 +03:00
commit 23b32fa2f0
2 changed files with 28 additions and 19 deletions

View file

@ -22,9 +22,9 @@ using System.Linq;
using System.Web;
using ZoFo.GameCore.GUI;
using ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
using ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO;
using ZoFo.GameCore.Graphics;
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
using ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO;
using ZoFo.GameCore.Graphics;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using ZoFo.GameCore.GameManagers.CollisionManager;
@ -122,21 +122,21 @@ namespace ZoFo.GameCore
{
UpdateShaking();
for (int i = 0; i < gameObjects.Count; i++)
{
{
gameObjects[i].UpdateAnimations();
}
for (int i = 0; i < particles.Count; i++)
{
{
particles[i].UpdateAnimations();
}
networkManager.SendData();//set to ticks
if (myPlayer != null)
GraphicsComponent.CameraPosition =
((GraphicsComponent.CameraPosition.ToVector2() *0.9f +
((GraphicsComponent.CameraPosition.ToVector2() * 0.9f +
(myPlayer.position + myPlayer.graphicsComponent.ObjectDrawRectangle.Size.ToVector2() / 2 - AppManager.Instance.CurentScreenResolution.ToVector2() / (2 * GraphicsComponent.scaling)
) * 0.1f
) )
))
.ToPoint();
}
public void SendData()
@ -151,14 +151,14 @@ namespace ZoFo.GameCore
}
for (int i = 0; i < stopObjects.Count; i++)
{
stopObjects[i].Draw(spriteBatch);
stopObjects[i].Draw(spriteBatch);
}
for (int i = 0; i < gameObjects.Count; i++)
{
gameObjects[i].Draw(spriteBatch);
}
for (int i = 0; i < particles.Count; i++)
{
{
particles[i].Draw(spriteBatch);
}
@ -203,7 +203,7 @@ namespace ZoFo.GameCore
{
created_gameObject = new Player((update as UpdateGameObjectCreated).position.GetVector2());
gameObjects.Add(created_gameObject);
}
}
else
{
Type t = Type.GetType("ZoFo.GameCore.GameObjects." + (update as UpdateGameObjectCreated).GameObjectType);
@ -211,7 +211,7 @@ namespace ZoFo.GameCore
if (gameObject is Entity)
(gameObject as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity);
gameObjects.Add(gameObject);
}
}
(gameObjects.Last() as Entity).SetIdByClient((update as UpdateGameObjectCreated).IdEntity);
}
@ -221,7 +221,7 @@ namespace ZoFo.GameCore
GameObject gameObject = Activator.CreateInstance(t, (update as UpdateGameObjectWithoutIdCreated).position.GetVector2()) as GameObject;
if (gameObject is Particle)
particles.Add(gameObject as Particle);
}
}
else if (update is UpdatePosition)
{
var ent = FindEntityById(update.IdEntity);
@ -244,11 +244,11 @@ namespace ZoFo.GameCore
DeleteObject(ent);
}
else if (update is UpdatePlayerParametrs)
else if (update is UpdatePlayerParametrs && update.IdEntity == myPlayer.Id) //aaa
{
UpdatePlayerHealth(update as UpdatePlayerParametrs);
}
else if (update is UpdateLoot)
else if (update is UpdateLoot && update.IdEntity == myPlayer.Id)//aaa
{
if ((update as UpdateLoot).quantity == 0)
{
@ -258,7 +258,14 @@ namespace ZoFo.GameCore
if (ent != null)
(ent as Player).lootData.AddLoot_Client((update as UpdateLoot).lootName, (update as UpdateLoot).quantity);
}
else if (update is UpdateCreatePlayer)
{
Vector2 pos = (update as UpdateCreatePlayer).position.GetVector2();
Player player = new Player(pos);
myPlayer = player;
players.Add(player);
}
}
public void UpdatePlayerHealth(UpdatePlayerParametrs update)
{
@ -288,16 +295,16 @@ namespace ZoFo.GameCore
return;
}
var ent = FindEntityById(update.IdEntity);
if (ent != null)
{
(ent as Player).health = (update as UpdatePlayerParametrs).health;
(ent as Player).rad = (update as UpdatePlayerParametrs).radiatoin;
(ent as Player).rad = (update as UpdatePlayerParametrs).radiatoin;
}
}
@ -327,7 +334,7 @@ namespace ZoFo.GameCore
if (particles.Contains(gameObject))
particles.Remove(gameObject as Particle);
}
}
}
public void DeleteEntity(Entity entity)
{

View file

@ -3,12 +3,14 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdateCreatePlayer : UpdateData
{
public int PlayerId { get; set; }
public SerializableVector2 position { get; set; }
public UpdateCreatePlayer()
{
isImportant = true;