Compare commits

..

3 Commits

Author SHA1 Message Date
Bragin Stepan
aeadf43425 fix: logic team selector 2026-03-13 15:36:04 +05:00
Bragin Stepan
96058b6c58 feat: add team touch system 2026-03-13 15:29:57 +05:00
Bragin Stepan
f9b0996922 feat: att team feature 2026-03-13 14:46:21 +05:00
46 changed files with 552 additions and 62 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 47798a9b41024584bf29ffa69e9494cc
timeCreated: 1773387604

View File

@@ -0,0 +1,8 @@
using UnityEngine;
namespace _Project.Develop.Runtime.Configs.Gameplay.Entities
{
public abstract class EntityConfigSO : ScriptableObject
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4dcd8eabefd749a8810f76f851e13888
timeCreated: 1773387622

View File

@@ -0,0 +1,16 @@
using UnityEngine;
namespace _Project.Develop.Runtime.Configs.Gameplay.Entities
{
[CreateAssetMenu(menuName = "Configs/Gameplay/Entities/NewGhostConfig", fileName = "GhostConfig")]
public class GhostConfigSO : EntityConfigSO
{
[field: SerializeField] public string PrefabPath { get; private set; } = "Entities/Ghost";
[field: SerializeField, Min(0)] public float MoveSpeed { get; private set; } = 9;
[field: SerializeField, Min(0)] public float RotationSpeed { get; private set; } = 900;
[field: SerializeField, Min(0)] public float MaxHealth { get; private set; } = 100;
[field: SerializeField, Min(0)] public float BodyContactDamage { get; private set; } = 50;
[field: SerializeField, Min(0)] public float DeathProcessTime { get; private set; } = 2;
[field: SerializeField, Min(0)] public float SpawnProcessTime { get; private set; } = 2;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2ad52b8e426e442d8a1f4646107c8abf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using UnityEngine;
namespace _Project.Develop.Runtime.Configs.Gameplay.Entities
{
[CreateAssetMenu(menuName = "Configs/Gameplay/Entities/NewHeroConfig", fileName = "HeroConfig")]
public class HeroConfigSO : EntityConfigSO
{
[field: SerializeField] public string PrefabPath { get; private set; } = "Entities/Hero";
[field: SerializeField, Min(0)] public float MoveSpeed { get; private set; } = 10;
[field: SerializeField, Min(0)] public float RotationSpeed { get; private set; } = 900;
[field: SerializeField, Min(0)] public float AttackProcessTime { get; private set; } = 1f;
[field: SerializeField, Min(0)] public float AttackDelayTime { get; private set; } = 0.1f;
[field: SerializeField, Min(0)] public float AttackCooldown { get; private set; } = 1f;
[field: SerializeField, Min(0)] public float InstantAttackDamage { get; private set; } = 50;
[field: SerializeField, Min(0)] public float MaxHealth { get; private set; } = 150;
[field: SerializeField, Min(0)] public float DeathProcessTime { get; private set; } = 2;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8df99bcd491f481c8c48d0d74110db7a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
using UnityEngine;
namespace _Project.Develop.Runtime.Configs.Gameplay.Entities
{
[CreateAssetMenu(menuName = "Configs/Gameplay/Entities/NewWizardConfig", fileName = "WizardConfig")]
public class WizardConfigSO : EntityConfigSO
{
[field: SerializeField] public string PrefabPath { get; private set; } = "Entities/Wizard";
[field: SerializeField, Min(0)] public float MoveSpeed { get; private set; } = 9;
[field: SerializeField, Min(0)] public float RotationSpeed { get; private set; } = 900;
[field: SerializeField, Min(0)] public float MaxHealth { get; private set; } = 100;
[field: SerializeField, Min(0)] public float TeleportDamage { get; private set; } = 50;
[field: SerializeField, Min(0)] public float TeleportDamageRadius { get; private set; } = 6;
[field: SerializeField, Min(0)] public int TeleportEnergyCast { get; private set; } = 50;
[field: SerializeField, Min(0)] public float TeleportSearchRadius { get; private set; } = 50;
[field: SerializeField, Min(0)] public float TeleportCooldownTime { get; private set; } = 3;
[field: SerializeField, Min(0)] public int MaxEnergy { get; private set; } = 60;
[field: SerializeField, Min(0)] public int RegenEnergyAmount { get; private set; } = 10;
[field: SerializeField, Min(0)] public float AutoRegenEnergyTime { get; private set; } = 2;
[field: SerializeField, Min(0)] public float DeathProcessTime { get; private set; } = 2;
[field: SerializeField, Min(0)] public float SpawnProcessTime { get; private set; } = 2;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d0a272842ebd44ab92e7c414ba3371bd
timeCreated: 1773391238

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using _Project.Develop.Runtime.Configs.Gameplay.Entities;
using _Project.Develop.Runtime.Configs.Meta;
using _Project.Develop.Runtime.UI.Common;
using _Project.Develop.Runtime.UI.Features.LevelsMenuPopup;
@@ -44,6 +45,9 @@ namespace Assets._Project.Develop.Runtime.Utilities.SceneManagement
{
{ typeof(StartWalletConfigSO), "Configs/Meta/Wallet/StartWalletConfig" },
{ typeof(CurrencyIconsConfigSO), "Configs/Meta/Wallet/CurrencyIconsConfig" },
{ typeof(HeroConfigSO), "Configs/Gameplay/Entities/HeroConfig" },
{ typeof(GhostConfigSO), "Configs/Gameplay/Entities/GhostConfig" },
{ typeof(WizardConfigSO), "Configs/Gameplay/Entities/WizardConfig" },
};
private static readonly Dictionary<Type, string> _uiPaths = new()

View File

@@ -1,4 +1,5 @@
using _Project.Develop.Runtime.Logic.Gameplay.Features.Attack.Systems;
using _Project.Develop.Runtime.Configs.Gameplay.Entities;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Attack.Systems;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Attack.Systems.Shoot;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Damage;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Energy.Systems;
@@ -6,6 +7,7 @@ using _Project.Develop.Runtime.Logic.Gameplay.Features.Input;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.Systems;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Movement;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Sensors.Systems;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Teams;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems;
using _Project.Develop.Runtime.Utilities;
using _Project.Develop.Runtime.Utilities.Conditions;
@@ -30,7 +32,7 @@ namespace _Project.Develop.Runtime.Entities
_monoEntitiesFactory = container.Resolve<MonoEntitiesFactory>();
}
public Entity CreateHero(Vector3 position)
public Entity CreateHero(Vector3 position, HeroConfigSO config)
{
Entity entity = CreateEmpty();
@@ -39,31 +41,30 @@ namespace _Project.Develop.Runtime.Entities
entity
.AddMoveDirection()
.AddRotateDirection()
.AddMoveSpeed(new ReactiveVariable<float>(10))
.AddRotationSpeed(new ReactiveVariable<float>(800))
.AddMaxHealth(new ReactiveVariable<float>(150))
.AddCurrentHealth(new ReactiveVariable<float>(150))
.AddMoveSpeed(new ReactiveVariable<float>(config.MoveSpeed))
.AddRotationSpeed(new ReactiveVariable<float>(config.RotationSpeed))
.AddMaxHealth(new ReactiveVariable<float>(config.MaxHealth))
.AddCurrentHealth(new ReactiveVariable<float>(config.MaxHealth))
.AddTakeDamageRequest()
.AddTakeDamageEvent()
.AddIsDead()
.AddIsMoving()
.AddInDeathProcess()
.AddDeathProcessInitialTime(new ReactiveVariable<float>(2))
.AddDeathProcessInitialTime(new ReactiveVariable<float>(config.DeathProcessTime))
.AddDeathProcessCurrentTime()
.AddAttackProcessInitialTime(new ReactiveVariable<float>(1))
.AddAttackProcessInitialTime(new ReactiveVariable<float>(config.AttackProcessTime))
.AddAttackProcessCurrentTime()
.AddInAttackProcess()
.AddStartAttackRequest()
.AddStartAttackEvent()
.AddEndAttackEvent()
.AddAttackDelayTime(new ReactiveVariable<float>(0.1f))
.AddAttackDelayTime(new ReactiveVariable<float>(config.AttackDelayTime))
.AddAttackDelayEndEvent()
.AddInstantAttackDamage(new ReactiveVariable<float>(50))
.AddInstantAttackDamage(new ReactiveVariable<float>(config.InstantAttackDamage))
.AddAttackCanceledEvent()
.AddAttackCooldownInitialTime()
.AddAttackCooldownCurrentTime()
.AddInAttackCooldown()
.AddCurrentTarget();
.AddInAttackCooldown();
ICompositeCondition canMove = new CompositeCondition()
.Add(new FuncCondition(() => entity.IsDead.Value == false));
@@ -121,12 +122,10 @@ namespace _Project.Develop.Runtime.Entities
.AddSystem(new DisableCollidersOnDeathSystem())
.AddSystem(new SelfReleaseSystem(_entitiesLifeContext));
_entitiesLifeContext.Add(entity);
return entity;
}
public Entity CreateGhost(Vector3 position)
public Entity CreateGhost(Vector3 position, GhostConfigSO config)
{
Entity entity = CreateEmpty();
@@ -138,17 +137,17 @@ namespace _Project.Develop.Runtime.Entities
.AddContactEntitiesBuffer(new Buffer<Entity>(64))
.AddMoveDirection()
.AddRotateDirection()
.AddMoveSpeed(new ReactiveVariable<float>(10))
.AddRotationSpeed(new ReactiveVariable<float>(800))
.AddMaxHealth(new ReactiveVariable<float>(50))
.AddCurrentHealth(new ReactiveVariable<float>(50))
.AddBodyContactDamage(new ReactiveVariable<float>(50))
.AddMoveSpeed(new ReactiveVariable<float>(config.MoveSpeed))
.AddRotationSpeed(new ReactiveVariable<float>(config.RotationSpeed))
.AddMaxHealth(new ReactiveVariable<float>(config.MaxHealth))
.AddCurrentHealth(new ReactiveVariable<float>(config.MaxHealth))
.AddBodyContactDamage(new ReactiveVariable<float>(config.BodyContactDamage))
.AddTakeDamageRequest()
.AddTakeDamageEvent()
.AddIsDead()
.AddIsMoving()
.AddInDeathProcess()
.AddDeathProcessInitialTime(new ReactiveVariable<float>(2))
.AddDeathProcessInitialTime(new ReactiveVariable<float>(config.DeathProcessTime))
.AddDeathProcessCurrentTime();
ICompositeCondition canMove = new CompositeCondition()
@@ -190,12 +189,10 @@ namespace _Project.Develop.Runtime.Entities
.AddSystem(new DisableCollidersOnDeathSystem())
.AddSystem(new SelfReleaseSystem(_entitiesLifeContext));
_entitiesLifeContext.Add(entity);
return entity;
}
public Entity CreateTeleportWizard(Vector3 position)
public Entity CreateTeleportWizard(Vector3 position, WizardConfigSO config)
{
Entity entity = CreateEmpty();
@@ -206,8 +203,8 @@ namespace _Project.Develop.Runtime.Entities
.AddContactCollidersBuffer(new Buffer<Collider>(32))
.AddContactEntitiesBuffer(new Buffer<Entity>(32))
.AddMaxHealth(new ReactiveVariable<float>(150))
.AddCurrentHealth(new ReactiveVariable<float>(150))
.AddMaxHealth(new ReactiveVariable<float>(config.MaxHealth))
.AddCurrentHealth(new ReactiveVariable<float>(config.MaxHealth))
.AddTeleportSource(entity.Transform)
.AddTeleportToPoint(entity.Transform)
@@ -219,34 +216,33 @@ namespace _Project.Develop.Runtime.Entities
.AddEndTeleportEvent()
.AddCurrentTarget()
.AddTeleportDamage(new ReactiveVariable<float>(50))
.AddTeleportDamageRadius(new ReactiveVariable<float>(6))
.AddTeleportDamage(new ReactiveVariable<float>(config.TeleportDamage))
.AddTeleportDamageRadius(new ReactiveVariable<float>(config.TeleportDamageRadius))
.AddTeleportDamageMask(Layers.CharactersMask)
.AddTeleportEnergyCost(new ReactiveVariable<int>(20))
.AddTeleportSearchRadius(new ReactiveVariable<float>(6))
.AddTeleportEnergyCost(new ReactiveVariable<int>(config.TeleportEnergyCast))
.AddTeleportSearchRadius(new ReactiveVariable<float>(config.TeleportSearchRadius))
.AddTeleportCooldownInitialTime(new ReactiveVariable<float>(3))
.AddTeleportCooldownCurrentTime(new ReactiveVariable<float>(3))
.AddTeleportCooldownInitialTime(new ReactiveVariable<float>(config.TeleportCooldownTime))
.AddTeleportCooldownCurrentTime(new ReactiveVariable<float>(config.TeleportCooldownTime))
.AddInTeleportCooldown(new ReactiveVariable<bool>(true))
.AddCurrentEnergy(new ReactiveVariable<int>(60))
.AddMaxEnergy(new ReactiveVariable<int>(60))
.AddCurrentEnergy(new ReactiveVariable<int>(config.MaxEnergy))
.AddMaxEnergy(new ReactiveVariable<int>(config.MaxEnergy))
.AddUseEnergyEvent()
.AddUseEnergyRequest()
.AddRegenEnergyEvent()
.AddRegenEnergyRequest()
.AddAutoRegenEnergyAmount(new ReactiveVariable<int>(10))
.AddAutoRegenEnergyAmount(new ReactiveVariable<int>(config.RegenEnergyAmount))
.AddIsAutoRegenEnergy(new ReactiveVariable<bool>(true))
.AddEnergyAutoRegenCurrentTime()
.AddEnergyAutoRegenInitialTime(new ReactiveVariable<float>(3))
.AddEnergyAutoRegenInitialTime(new ReactiveVariable<float>(config.AutoRegenEnergyTime))
.AddBodyContactDamage(new ReactiveVariable<float>(50))
.AddTakeDamageRequest()
.AddTakeDamageEvent()
.AddIsDead()
.AddInDeathProcess()
.AddDeathProcessInitialTime(new ReactiveVariable<float>(2))
.AddDeathProcessInitialTime(new ReactiveVariable<float>(config.DeathProcessTime))
.AddDeathProcessCurrentTime();
ICompositeCondition canRegenEnergy = new CompositeCondition()
@@ -298,7 +294,7 @@ namespace _Project.Develop.Runtime.Entities
.AddSystem(new BodyContactsDetectingSystem())
.AddSystem(new BodyContactsEntitiesFilterSystem(_collidersRegistryService))
.AddSystem(new DealDamageOnContactSystem())
// .AddSystem(new DealDamageOnContactSystem())
.AddSystem(new ApplyDamageSystem())
.AddSystem(new DeathSwitcherSystem())
@@ -307,12 +303,10 @@ namespace _Project.Develop.Runtime.Entities
.AddSystem(new DisableCollidersOnDeathSystem())
.AddSystem(new SelfReleaseSystem(_entitiesLifeContext));
_entitiesLifeContext.Add(entity);
return entity;
}
public Entity CreateProjectile(Vector3 position, Vector3 direction, float damage)
public Entity CreateProjectile(Vector3 position, Vector3 direction, float damage, Entity owner)
{
Entity entity = CreateEmpty();
@@ -327,10 +321,12 @@ namespace _Project.Develop.Runtime.Entities
.AddMoveSpeed(new ReactiveVariable<float>(16))
.AddRotationSpeed(new ReactiveVariable<float>(9999))
.AddBodyContactDamage(new ReactiveVariable<float>(damage))
.AddTeam(new ReactiveVariable<Teams>(owner.Team.Value))
.AddIsDead()
.AddIsMoving()
.AddDeathMask(Layers.CharactersMask | Layers.EnvironmentMask)
.AddIsTouchDeathMask();
.AddIsTouchDeathMask()
.AddIsTouchAnotherTeam();
ICompositeCondition canMove = new CompositeCondition()
.Add(new FuncCondition(() => entity.IsDead.Value == false));
@@ -338,7 +334,8 @@ namespace _Project.Develop.Runtime.Entities
ICompositeCondition canRotate = new CompositeCondition()
.Add(new FuncCondition(() => entity.IsDead.Value == false));
ICompositeCondition mustDie = new CompositeCondition()
ICompositeCondition mustDie = new CompositeCondition(LogicOperationsUtils.Or)
.Add(new FuncCondition(() => entity.IsTouchAnotherTeam.Value))
.Add(new FuncCondition(() => entity.IsTouchDeathMask.Value));
ICompositeCondition mustSelfRelease = new CompositeCondition()
@@ -361,6 +358,7 @@ namespace _Project.Develop.Runtime.Entities
.AddSystem(new DeathMaskTouchDetectorSystem())
.AddSystem(new DeathSwitcherSystem())
.AddSystem(new AnotherTeamTouchDetectorSystem())
.AddSystem(new DisableCollidersOnDeathSystem())
.AddSystem(new SelfReleaseSystem(_entitiesLifeContext));

View File

@@ -0,0 +1,19 @@
using _Project.Develop.Runtime.Logic.Gameplay.Features.Teams;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
namespace _Project.Develop.Runtime.Entities
{
public static class EntitiesHelper
{
public static bool AreOnSameTeam(Entity first, Entity second)
{
if (first.TryGetTeam(out ReactiveVariable<Teams> firstTeam) &&
second.TryGetTeam(out ReactiveVariable<Teams> secondTeam))
{
return firstTeam.Value == secondTeam.Value;
}
return false;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 240aa716b4304420b9ff4ef3cbb14b6b
timeCreated: 1773396722

View File

@@ -466,6 +466,30 @@ namespace _Project.Develop.Runtime.Entities
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportDamageMask() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Teams.Team TeamC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teams.Team>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<_Project.Develop.Runtime.Logic.Gameplay.Features.Teams.Teams> Team => TeamC.Value;
public bool TryGetTeam(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<_Project.Develop.Runtime.Logic.Gameplay.Features.Teams.Teams> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Teams.Team component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<_Project.Develop.Runtime.Logic.Gameplay.Features.Teams.Teams>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddTeam()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teams.Team() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<_Project.Develop.Runtime.Logic.Gameplay.Features.Teams.Teams>() });
}
public _Project.Develop.Runtime.Entities.Entity AddTeam(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<_Project.Develop.Runtime.Logic.Gameplay.Features.Teams.Teams> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teams.Team() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Sensors.CapsuleColliderComponent CapsuleColliderC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Sensors.CapsuleColliderComponent>();
public UnityEngine.CapsuleCollider CapsuleCollider => CapsuleColliderC.Value;
@@ -810,6 +834,13 @@ namespace _Project.Develop.Runtime.Entities
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanJump() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.MainHero.IsMainHero IsMainHeroC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.MainHero.IsMainHero>();
public _Project.Develop.Runtime.Entities.Entity AddIsMainHero()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.MainHero.IsMainHero() );
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.CurrentHealth CurrentHealthC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Lifetime.CurrentHealth>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> CurrentHealth => CurrentHealthC.Value;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
@@ -14,15 +14,21 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Attack.Systems
private ReactiveVariable<bool> _inAttackProcess;
private ICompositeCondition _canStartAttack;
private Entity _entity;
private ReactiveVariable<Entity> _currentTarget;
private IDisposable _attackRequestDisposable;
public void OnInit(Entity entity)
{
_entity = entity;
_startAttackRequest = entity.StartAttackRequest;
_startAttackEvent = entity.StartAttackEvent;
_inAttackProcess = entity.InAttackProcess;
_canStartAttack = entity.CanStartAttack;
if (entity.TryGetCurrentTarget(out var currentTarget))
_currentTarget = currentTarget;
_attackRequestDisposable = _startAttackRequest.Subscribe(OnAttackRequest);
}
@@ -30,6 +36,15 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Attack.Systems
{
if (_canStartAttack.Evaluate())
{
if (_currentTarget != null && _currentTarget.Value != null)
{
if (EntitiesHelper.AreOnSameTeam(_entity, _currentTarget.Value))
{
Debug.Log("Не могу атаковать своего!");
return;
}
}
_inAttackProcess.Value = true;
_startAttackEvent.Invoke();
Debug.Log("Старт атаки");

View File

@@ -1,4 +1,4 @@
using System;
using System;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement.Event;
@@ -38,7 +38,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Attack.Systems.Shoot
private void OnAttackDelayEnd()
{
_entitiesFactory.CreateProjectile(_shootPoint.position, _shootPoint.forward, _damage.Value);
_entitiesFactory.CreateProjectile(_shootPoint.position, _shootPoint.forward, _damage.Value, _entity);
}
public void OnDispose()

View File

@@ -1,4 +1,4 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement.Event;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.ReactiveManagement;

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
@@ -34,6 +34,9 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Damage
{
_processedEntities.Add(contactEntity);
if (EntitiesHelper.AreOnSameTeam(contactEntity, _entity))
continue;
if (contactEntity.TryGetTakeDamageRequest(out ReactiveEvent<float> takeDamageRequest))
takeDamageRequest.Invoke(_damage.Value);
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 073e06f2bd1243408c61652926dbac9a
timeCreated: 1773390931

View File

@@ -0,0 +1,52 @@
using System;
using _Project.Develop.Runtime.Configs.Gameplay.Entities;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Logic.Gameplay.Features.AI;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Selectors;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using Assets._Project.Develop.Runtime.Infrastructure.DI;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Enemies
{
public class EnemiesFactory
{
private readonly EntitiesFactory _entitiesFactory;
private readonly BrainsFactory _brainsFactory;
private readonly EntitiesLifeContext _entitiesLifeContext;
public EnemiesFactory(DIContainer container)
{
_entitiesFactory = container.Resolve<EntitiesFactory>();
_brainsFactory = container.Resolve<BrainsFactory>();
_entitiesLifeContext = container.Resolve<EntitiesLifeContext>();
}
public Entity Create(Vector3 position, EntityConfigSO config)
{
Entity entity;
switch (config)
{
case GhostConfigSO ghostConfig:
entity = _entitiesFactory.CreateGhost(position, ghostConfig);
_brainsFactory.CreateGhostBrain(entity);
break;
case WizardConfigSO wizardConfig:
entity = _entitiesFactory.CreateTeleportWizard(position, wizardConfig);
_brainsFactory.CreateDangerWizardBrain(entity, new LowestHealthTargetSelector(entity));
break;
default:
throw new ArgumentException($"Not support {config.GetType()} type config");
}
entity.AddTeam(new ReactiveVariable<Teams.Teams>(Teams.Teams.Enemies));
_entitiesLifeContext.Add(entity);
return entity;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 51102a09ab584bd8a413995baf3ed9b9
timeCreated: 1773390941

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3bfebd749d5b44a295ddf91039d598a4
timeCreated: 1773389854

View File

@@ -0,0 +1,6 @@
using _Project.Develop.Runtime.Entities;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.MainHero
{
public class IsMainHero : IEntityComponent { }
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1d7f214ebbb94ba3a40b05d47a56ea32
timeCreated: 1773389869

View File

@@ -0,0 +1,44 @@
using _Project.Develop.Runtime.Configs.Gameplay.Entities;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Logic.Gameplay.Features.AI;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using Assets._Project.Develop.Runtime.Infrastructure.DI;
using Assets._Project.Develop.Runtime.Utilities.ConfigsManagement;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.MainHero
{
public class MainHeroFactory
{
private readonly EntitiesFactory _entitiesFactory;
private readonly BrainsFactory _brainsFactory;
private readonly ConfigsProviderService _configLoader;
private readonly EntitiesLifeContext _entitiesLifeContext;
public MainHeroFactory(DIContainer container)
{
_entitiesFactory = container.Resolve<EntitiesFactory>();
_brainsFactory = container.Resolve<BrainsFactory>();
_configLoader = container.Resolve<ConfigsProviderService>();
_entitiesLifeContext = container.Resolve<EntitiesLifeContext>();
}
public Entity Create(Vector3 position)
{
HeroConfigSO config = _configLoader.GetConfig<HeroConfigSO>();
Entity entity = _entitiesFactory.CreateHero(position, config);
entity
.AddIsMainHero()
.AddTeam(new ReactiveVariable<Teams.Teams>(Teams.Teams.MainHero));
entity.AddCurrentTarget();
_brainsFactory.CreateMainHeroBrain(entity);
_entitiesLifeContext.Add(entity);
return entity;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f02ea9aeb6334badac37cab0a5e69da0
timeCreated: 1773390441

View File

@@ -51,7 +51,9 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Selectors
if (target.TryGetCanApplyDamage(out ICompositeCondition value))
result = result && value.Evaluate();
result = result && (target != _source);
result = result
&& (target != _source)
&& (EntitiesHelper.AreOnSameTeam(_source, target) == false);
return result;
});

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States;
@@ -54,7 +54,9 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Selectors
if (target.TryGetCanApplyDamage(out ICompositeCondition value))
result = result && value.Evaluate();
result = result && (target != _source);
result = result
&& (target != _source)
&& (EntitiesHelper.AreOnSameTeam(_source, target) == false);
return result;
});

View File

@@ -0,0 +1,39 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Sensors.Systems
{
public class AnotherTeamTouchDetectorSystem : IInitializableSystem, IUpdatableSystem
{
private Buffer<Entity> _contacts;
private ReactiveVariable<bool> _isTouchAnotherTeam;
private ReactiveVariable<Teams.Teams> _sourceTeam;
public void OnInit(Entity entity)
{
_contacts = entity.ContactEntitiesBuffer;
_isTouchAnotherTeam = entity.IsTouchAnotherTeam;
_sourceTeam = entity.Team;
}
public void OnUpdate(float deltaTime)
{
for (int i = 0; i < _contacts.Count; i++)
{
Entity contact = _contacts.Items[i];
if (contact.TryGetTeam(out ReactiveVariable<Teams.Teams> anotherTeam))
{
if (_sourceTeam.Value != anotherTeam.Value)
{
_isTouchAnotherTeam.Value = true;
return;
}
}
}
_isTouchAnotherTeam.Value = false;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 54420a8777b740ce9a5300530cd661be
timeCreated: 1773397526

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2bf870f1fd6247d7aaa3343f010cfd52
timeCreated: 1773394525

View File

@@ -0,0 +1,8 @@
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teams
{
public enum Teams
{
MainHero,
Enemies
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6b5919366f522d048bcde4e406462f16
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teams
{
public class Team : IEntityComponent
{
public ReactiveVariable<Teams> Value;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2d8073d07bb648c5b6e3dc920591e9db
timeCreated: 1773394552

View File

@@ -64,6 +64,9 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
&& contactEntity != _entity
&& contactEntity.TryGetTakeDamageRequest(out ReactiveEvent<float> takeDamageRequest))
{
if (EntitiesHelper.AreOnSameTeam(contactEntity, _entity))
continue;
takeDamageRequest.Invoke(_damage);
}
}

View File

@@ -1,5 +1,7 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Logic.Gameplay.Features.AI;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Enemies;
using _Project.Develop.Runtime.Logic.Gameplay.Features.MainHero;
using _Project.Develop.Runtime.UI;
using _Project.Develop.Runtime.UI.Core;
using _Project.Develop.Runtime.UI.Screens.Gameplay;
@@ -25,12 +27,17 @@ namespace Assets._Project.Develop.Runtime.Gameplay.Infrastructure
container.RegisterAsSingle(CreateAIBrainContext);
container.RegisterAsSingle(CreateBrainsFactory);
container.RegisterAsSingle(CreateMonoEntitiesFactory).NonLazy();
container.RegisterAsSingle(CreateMainHeroFactory);
container.RegisterAsSingle(CreateEnemiesFactory);
}
private static AIBrainsContext CreateAIBrainContext(DIContainer c) => new();
private static BrainsFactory CreateBrainsFactory(DIContainer c) => new(c);
private static EntitiesLifeContext CreateEntitiesLifeContext(DIContainer c) => new();
private static EnemiesFactory CreateEnemiesFactory(DIContainer c) => new (c);
private static MainHeroFactory CreateMainHeroFactory(DIContainer c) => new (c);
private static EntitiesFactory CreateEntitiesFactory(DIContainer c) => new(c);
private static GameplayPresentersFactory CreateGameplayPresentersFactory(DIContainer c) => new(c);

View File

@@ -1,9 +1,14 @@
using System;
using _Project.Develop.Runtime.Configs.Gameplay.Entities;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Logic.Gameplay.Features.AI;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Enemies;
using _Project.Develop.Runtime.Logic.Gameplay.Features.MainHero;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Selectors;
using _Project.Develop.Runtime.Utils.InputManagement;
using Assets._Project.Develop.Runtime.Infrastructure.DI;
using Assets._Project.Develop.Runtime.Utilities.AssetsManagement;
using Assets._Project.Develop.Runtime.Utilities.ConfigsManagement;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features
@@ -11,7 +16,8 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features
public class TestGameplay : MonoBehaviour
{
private DIContainer _container;
private EntitiesFactory _entitiesFactory;
private EnemiesFactory _enemiesFactory;
private MainHeroFactory _mainHeroFactory;
private BrainsFactory _brainsFactory;
private Entity _hero;
@@ -24,14 +30,15 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features
_container = container;
_container.Resolve<IPlayerInput>().Enable();
_entitiesFactory = _container.Resolve<EntitiesFactory>();
_enemiesFactory = _container.Resolve<EnemiesFactory>();
_mainHeroFactory = _container.Resolve<MainHeroFactory>();
_brainsFactory = _container.Resolve<BrainsFactory>();
_hero = _entitiesFactory.CreateHero(Vector3.zero);
_brainsFactory.CreateMainHeroBrain(_hero);
_enemy = _entitiesFactory.CreateTeleportWizard(Vector3.zero + Vector3.forward * 5);
_brainsFactory.CreateDangerWizardBrain(_enemy, new LowestHealthTargetSelector(_enemy));
_hero = _mainHeroFactory.Create(Vector3.zero);
_enemy = _enemiesFactory.Create(
Vector3.zero + Vector3.forward * 5,
_container.Resolve<ConfigsProviderService>().GetConfig<WizardConfigSO>());
}
public void Run()

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fc56c1fb94541f1438fa6474b69863f8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2ad52b8e426e442d8a1f4646107c8abf, type: 3}
m_Name: GhostConfig
m_EditorClassIdentifier:
<PrefabPath>k__BackingField: Entities/Ghost
<MoveSpeed>k__BackingField: 9
<RotationSpeed>k__BackingField: 900
<MaxHealth>k__BackingField: 100
<BodyContactDamage>k__BackingField: 50
<DeathProcessTime>k__BackingField: 2
<SpawnProcessTime>k__BackingField: 2

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c8d883f310a9bf54dbb319d1fbb73bb6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8df99bcd491f481c8c48d0d74110db7a, type: 3}
m_Name: HeroConfig
m_EditorClassIdentifier:
<PrefabPath>k__BackingField: Entities/Hero
<MoveSpeed>k__BackingField: 10
<RotationSpeed>k__BackingField: 900
<AttackProcessTime>k__BackingField: 1
<AttackDelayTime>k__BackingField: 0.1
<AttackCooldown>k__BackingField: 1
<InstantAttackDamage>k__BackingField: 50
<MaxHealth>k__BackingField: 150
<DeathProcessTime>k__BackingField: 2

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0b3771ea520252a4387be141615738d2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,28 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0a272842ebd44ab92e7c414ba3371bd, type: 3}
m_Name: WizardConfig
m_EditorClassIdentifier:
<PrefabPath>k__BackingField: Entities/Wizard
<MoveSpeed>k__BackingField: 9
<RotationSpeed>k__BackingField: 900
<MaxHealth>k__BackingField: 100
<TeleportDamage>k__BackingField: 50
<TeleportDamageRadius>k__BackingField: 4
<TeleportEnergyCast>k__BackingField: 20
<TeleportSearchRadius>k__BackingField: 4
<TeleportCooldownTime>k__BackingField: 3
<MaxEnergy>k__BackingField: 60
<RegenEnergyAmount>k__BackingField: 10
<AutoRegenEnergyTime>k__BackingField: 2
<DeathProcessTime>k__BackingField: 2
<SpawnProcessTime>k__BackingField: 2

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 08a5a589bbbbb2d4da29f807a8696040
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant: