Merge pull request #47 from progtime-net/Colleclables

Colleclables
This commit is contained in:
Andrey 2024-08-17 18:59:32 +03:00 committed by GitHub
commit 2a5dde0169
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 83 additions and 37 deletions

View file

@ -4,7 +4,7 @@ using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using DangerousD.GameCore.Graphics;
using ZoFo.GameCore.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

View file

@ -38,11 +38,13 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
//events
//events DoorInteraction
public event EventHandler<CollisionComponent> OnTriggerEnter;
public event EventHandler<CollisionComponent> OnTriggerZone;
public event EventHandler<CollisionComponent> OnTriggerExit;
public event EventHandler<CollisionComponent> OnTriggerInteract;
// methods-event
public void TriggerEnter(object component, Player player,
EventArgs e)

View file

@ -12,5 +12,6 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
public class UpdateGameObjectDeleted : UpdateData
{
public UpdateGameObjectDeleted() { UpdateType = "UpdateGameObjectDeleted"; }
public string GameObjectType;
}
}

View file

@ -5,6 +5,11 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
/// </summary>
public class UpdateInteraction : UpdateData
{
public UpdateInteraction(int id)
{
IdEntity = id;
}
public int IdEntity { get; set; }
public string UpdateType { get; set; }
}

View file

@ -26,7 +26,17 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates
public class UpdateData
{
public int IdEntity { get; set; } //Id объекта
public int IdEntity { get; set; } //Id объекта
public string UpdateType { get; protected set; } //тип обновления
public UpdateData()
{
}
public UpdateData(int idEntity)
{
this.IdEntity = idEntity;
}
}
}

View file

@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.ZoFo_graphics;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects.Entities
{

View file

@ -4,7 +4,6 @@ using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.ZoFo_graphics;
namespace ZoFo.GameCore.GameObjects.Entities
{

View file

@ -1,5 +1,8 @@
using Microsoft.Xna.Framework;
using System;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
public class Collectable : Interactable
@ -7,4 +10,11 @@ public class Collectable : Interactable
public Collectable(Vector2 position) : base(position)
{
}
public override void OnInteraction(object sender, CollisionComponent e)
{
//
AppManager.Instance.server.AddData(new UpdateLoot());
AppManager.Instance.server.DeleteObject(this);
}
}

View file

@ -0,0 +1,14 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
public class Wood : Collectable
{
public override GraphicsComponent graphicsComponent { get; } = new(new List<string> { "Wood" }, "Wood");
public Wood(Vector2 position) : base(position)
{
}
}

View file

@ -1,6 +1,7 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using ZoFo.GameCore.ZoFo_graphics;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables;
@ -15,11 +16,9 @@ public class Door : Interactable
graphicsComponent.OnAnimationEnd += _ => { isOpened = !isOpened; };
}
public override void OnInteraction()
public override void OnInteraction(object sender, CollisionComponent e)
{
graphicsComponent.AnimationInit("DoorInteraction", isOpened);
graphicsComponent.StartAnimation();
graphicsComponent.AnimationSelect("DoorInteraction", isOpened);
graphicsComponent.AnimationStep();
}
}

View file

@ -3,7 +3,7 @@ using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
using ZoFo.GameCore.ZoFo_graphics;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables;
@ -15,6 +15,7 @@ public class Interactable : Entity
{
collisionComponent.OnTriggerEnter += (sender, e) => ChangeInteraction(sender, e, true);
collisionComponent.OnTriggerExit += (sender, e) => ChangeInteraction(sender, e, false);
collisionComponent.OnTriggerInteract += OnInteraction;
}
private void ChangeInteraction(object sender, CollisionComponent e, bool isReady)
@ -22,7 +23,7 @@ public class Interactable : Entity
AppManager.Instance.server.AddData(new UpdateInteractionReady((sender as Player).Id, isReady));
}
public virtual void OnInteraction()
public virtual void OnInteraction(object sender, CollisionComponent e)
{
}

View file

@ -2,9 +2,9 @@
using Microsoft.Xna.Framework.Graphics;
using System;
using ZoFo.GameCore.GameObjects.Entities;
using ZoFo.GameCore.ZoFo_graphics;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities;
public class LivingEntity : Entity

View file

@ -3,8 +3,8 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.ZoFo_graphics;
using ZoFo.GameCore;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects;

View file

@ -8,7 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.ZoFo_graphics;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects.MapObjects
{

View file

@ -1,7 +1,6 @@
using Microsoft.Xna.Framework;
using System;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.ZoFo_graphics;
namespace ZoFo.GameCore.GameObjects.MapObjects.StopObjects;

View file

@ -3,9 +3,8 @@ using System.Collections.Generic;
using System.Text;
using System.IO;
using Newtonsoft.Json;
using Zofo.GameCore.ZoFo_grafics;
namespace DangerousD.GameCore.Graphics
namespace ZoFo.GameCore.Graphics
{
public class AnimationBuilder
{

View file

@ -1,10 +1,9 @@
using Microsoft.Xna.Framework;
using Newtonsoft.Json;
using System;
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Newtonsoft.Json;
namespace Zofo.GameCore.ZoFo_grafics
namespace ZoFo.GameCore.Graphics
{
[Serializable]
public class AnimationContainer

View file

@ -1,16 +1,11 @@
using ZoFo.GameCore.GameObjects;
using ZoFo.GameCore.GameManagers;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using Zofo.GameCore.ZoFo_grafics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ZoFo.GameCore.GameManagers;
namespace ZoFo.GameCore.ZoFo_graphics
namespace ZoFo.GameCore.Graphics
{
public class GraphicsComponent
@ -129,7 +124,7 @@ namespace ZoFo.GameCore.ZoFo_graphics
}
}
public void AnimationInit(string animationId, bool reverse = false)
public void AnimationSelect(string animationId, bool reverse = false)
{
currentAnimation = animations.Find(x => x.Id == animationId);
if (reverse)
@ -151,7 +146,7 @@ namespace ZoFo.GameCore.ZoFo_graphics
animating = true;
}
public void StepAnimation()
public void AnimationStep()
{
currentFrame += step;
}

View file

@ -137,10 +137,23 @@ namespace ZoFo.GameCore
}
AddData(new UpdateGameObjectCreated()
{ GameObjectType = gameObject.GetType().Name }
{ GameObjectType = gameObject.GetType().Name }
);
}
/// <summary>
/// Удаляет игровой объект
/// </summary>
/// <param name="gameObject"></param>
public void DeleteObject(GameObject gameObject)
{
gameObjects.Remove(gameObject);
AddData(new UpdateGameObjectDeleted()
{ GameObjectType = gameObject.GetType().Name}
);
}
}
#endregion
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,019 KiB

After

Width:  |  Height:  |  Size: 1 MiB