Compare commits

...

9 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
Bragin Stepan
1356b8bfb2 fix: attack trigger entered 2026-03-06 21:17:51 +05:00
Bragin Stepan
51fd4cdc8d feat: add tank tower rotation [ [] ]=[] ------- 2026-03-06 21:03:45 +05:00
Bragin Stepan
ffeb1655c8 fix 2026-03-06 21:03:33 +05:00
Bragin Stepan
d3dce07cf5 feat: add teleport to target 2026-03-03 21:44:07 +05:00
Bragin Stepan
11e28b1e09 feat: add random auto teleport state 2026-03-03 19:28:16 +05:00
Bragin Stepan
c04b0a259a feat: add auto attack state 2026-03-03 17:34:02 +05:00
89 changed files with 1614 additions and 98 deletions

4
.gitignore vendored
View File

@@ -28,6 +28,7 @@
# Visual Studio cache directory # Visual Studio cache directory
.vs/ .vs/
.agent/ .agent/
.agents/
# Gradle cache directory # Gradle cache directory
.gradle/ .gradle/
@@ -65,6 +66,9 @@ sysinfo.txt
*.unitypackage.meta *.unitypackage.meta
*.app *.app
# AI
Antigravity.Ide.Editor.csproj
# Crashlytics generated file # Crashlytics generated file
crashlytics-build.properties crashlytics-build.properties

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;
using System.Collections.Generic; using System.Collections.Generic;
using _Project.Develop.Runtime.Configs.Gameplay.Entities;
using _Project.Develop.Runtime.Configs.Meta; using _Project.Develop.Runtime.Configs.Meta;
using _Project.Develop.Runtime.UI.Common; using _Project.Develop.Runtime.UI.Common;
using _Project.Develop.Runtime.UI.Features.LevelsMenuPopup; 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(StartWalletConfigSO), "Configs/Meta/Wallet/StartWalletConfig" },
{ typeof(CurrencyIconsConfigSO), "Configs/Meta/Wallet/CurrencyIconsConfig" }, { 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() private static readonly Dictionary<Type, string> _uiPaths = new()

View File

@@ -32,6 +32,7 @@ namespace Assets._Project.Develop.Runtime.Infrastructure.EntryPoint
container.RegisterAsSingle(CreateSceneSwitcherService); container.RegisterAsSingle(CreateSceneSwitcherService);
container.RegisterAsSingle(CreateInputFactory); container.RegisterAsSingle(CreateInputFactory);
container.RegisterAsSingle(CreateInputStateMachine);
container.RegisterAsSingle<IPlayerInput>(CreatePlayerInput); container.RegisterAsSingle<IPlayerInput>(CreatePlayerInput);
container.RegisterAsSingle<IUIInput>(CreateUIInput); container.RegisterAsSingle<IUIInput>(CreateUIInput);
@@ -65,6 +66,7 @@ namespace Assets._Project.Develop.Runtime.Infrastructure.EntryPoint
private static ResourcesAssetsLoader CreateResourcesAssetsLoader(DIContainer c) => new(); private static ResourcesAssetsLoader CreateResourcesAssetsLoader(DIContainer c) => new();
private static InputFactory CreateInputFactory(DIContainer c) => new(); private static InputFactory CreateInputFactory(DIContainer c) => new();
private static InputStateMachine CreateInputStateMachine(DIContainer c) => new(c);
private static TimerServiceFactory CreateTimerServiceFactory(DIContainer c) => new (c); private static TimerServiceFactory CreateTimerServiceFactory(DIContainer c) => new (c);

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.Attack.Systems.Shoot;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Damage; using _Project.Develop.Runtime.Logic.Gameplay.Features.Damage;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Energy.Systems; 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.Lifetime.Systems;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Movement; using _Project.Develop.Runtime.Logic.Gameplay.Features.Movement;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Sensors.Systems; 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.Logic.Gameplay.Features.Teleport.Systems;
using _Project.Develop.Runtime.Utilities; using _Project.Develop.Runtime.Utilities;
using _Project.Develop.Runtime.Utilities.Conditions; using _Project.Develop.Runtime.Utilities.Conditions;
@@ -22,17 +24,15 @@ namespace _Project.Develop.Runtime.Entities
private readonly EntitiesLifeContext _entitiesLifeContext; private readonly EntitiesLifeContext _entitiesLifeContext;
private readonly MonoEntitiesFactory _monoEntitiesFactory; private readonly MonoEntitiesFactory _monoEntitiesFactory;
private readonly CollidersRegistryService _collidersRegistryService; private readonly CollidersRegistryService _collidersRegistryService;
private readonly IPlayerInput _playerInput;
public EntitiesFactory(DIContainer container) public EntitiesFactory(DIContainer container)
{ {
_collidersRegistryService = container.Resolve<CollidersRegistryService>(); _collidersRegistryService = container.Resolve<CollidersRegistryService>();
_entitiesLifeContext = container.Resolve<EntitiesLifeContext>(); _entitiesLifeContext = container.Resolve<EntitiesLifeContext>();
_monoEntitiesFactory = container.Resolve<MonoEntitiesFactory>(); _monoEntitiesFactory = container.Resolve<MonoEntitiesFactory>();
_playerInput = container.Resolve<IPlayerInput>();
} }
public Entity CreateHero(Vector3 position) public Entity CreateHero(Vector3 position, HeroConfigSO config)
{ {
Entity entity = CreateEmpty(); Entity entity = CreateEmpty();
@@ -41,26 +41,26 @@ namespace _Project.Develop.Runtime.Entities
entity entity
.AddMoveDirection() .AddMoveDirection()
.AddRotateDirection() .AddRotateDirection()
.AddMoveSpeed(new ReactiveVariable<float>(10)) .AddMoveSpeed(new ReactiveVariable<float>(config.MoveSpeed))
.AddRotationSpeed(new ReactiveVariable<float>(800)) .AddRotationSpeed(new ReactiveVariable<float>(config.RotationSpeed))
.AddMaxHealth(new ReactiveVariable<float>(150)) .AddMaxHealth(new ReactiveVariable<float>(config.MaxHealth))
.AddCurrentHealth(new ReactiveVariable<float>(150)) .AddCurrentHealth(new ReactiveVariable<float>(config.MaxHealth))
.AddTakeDamageRequest() .AddTakeDamageRequest()
.AddTakeDamageEvent() .AddTakeDamageEvent()
.AddIsDead() .AddIsDead()
.AddIsMoving() .AddIsMoving()
.AddInDeathProcess() .AddInDeathProcess()
.AddDeathProcessInitialTime(new ReactiveVariable<float>(2)) .AddDeathProcessInitialTime(new ReactiveVariable<float>(config.DeathProcessTime))
.AddDeathProcessCurrentTime() .AddDeathProcessCurrentTime()
.AddAttackProcessInitialTime(new ReactiveVariable<float>(3)) .AddAttackProcessInitialTime(new ReactiveVariable<float>(config.AttackProcessTime))
.AddAttackProcessCurrentTime() .AddAttackProcessCurrentTime()
.AddInAttackProcess() .AddInAttackProcess()
.AddStartAttackRequest() .AddStartAttackRequest()
.AddStartAttackEvent() .AddStartAttackEvent()
.AddEndAttackEvent() .AddEndAttackEvent()
.AddAttackDelayTime(new ReactiveVariable<float>(2)) .AddAttackDelayTime(new ReactiveVariable<float>(config.AttackDelayTime))
.AddAttackDelayEndEvent() .AddAttackDelayEndEvent()
.AddInstantAttackDamage(new ReactiveVariable<float>(50)) .AddInstantAttackDamage(new ReactiveVariable<float>(config.InstantAttackDamage))
.AddAttackCanceledEvent() .AddAttackCanceledEvent()
.AddAttackCooldownInitialTime() .AddAttackCooldownInitialTime()
.AddAttackCooldownCurrentTime() .AddAttackCooldownCurrentTime()
@@ -102,9 +102,6 @@ namespace _Project.Develop.Runtime.Entities
.AddMustCancelAttack(mustCancelAttack); .AddMustCancelAttack(mustCancelAttack);
entity entity
.AddSystem(new AttackByInputSystem(_playerInput))
.AddSystem(new MoveDirectionByInputSystem(_playerInput))
.AddSystem(new RotateDirectionByMoveInputSystem(_playerInput))
.AddSystem(new RigidbodyMovementSystem()) .AddSystem(new RigidbodyMovementSystem())
.AddSystem(new RigidbodyRotationSystem()) .AddSystem(new RigidbodyRotationSystem())
@@ -125,12 +122,10 @@ namespace _Project.Develop.Runtime.Entities
.AddSystem(new DisableCollidersOnDeathSystem()) .AddSystem(new DisableCollidersOnDeathSystem())
.AddSystem(new SelfReleaseSystem(_entitiesLifeContext)); .AddSystem(new SelfReleaseSystem(_entitiesLifeContext));
_entitiesLifeContext.Add(entity);
return entity; return entity;
} }
public Entity CreateGhost(Vector3 position) public Entity CreateGhost(Vector3 position, GhostConfigSO config)
{ {
Entity entity = CreateEmpty(); Entity entity = CreateEmpty();
@@ -142,17 +137,17 @@ namespace _Project.Develop.Runtime.Entities
.AddContactEntitiesBuffer(new Buffer<Entity>(64)) .AddContactEntitiesBuffer(new Buffer<Entity>(64))
.AddMoveDirection() .AddMoveDirection()
.AddRotateDirection() .AddRotateDirection()
.AddMoveSpeed(new ReactiveVariable<float>(10)) .AddMoveSpeed(new ReactiveVariable<float>(config.MoveSpeed))
.AddRotationSpeed(new ReactiveVariable<float>(800)) .AddRotationSpeed(new ReactiveVariable<float>(config.RotationSpeed))
.AddMaxHealth(new ReactiveVariable<float>(50)) .AddMaxHealth(new ReactiveVariable<float>(config.MaxHealth))
.AddCurrentHealth(new ReactiveVariable<float>(50)) .AddCurrentHealth(new ReactiveVariable<float>(config.MaxHealth))
.AddBodyContactDamage(new ReactiveVariable<float>(50)) .AddBodyContactDamage(new ReactiveVariable<float>(config.BodyContactDamage))
.AddTakeDamageRequest() .AddTakeDamageRequest()
.AddTakeDamageEvent() .AddTakeDamageEvent()
.AddIsDead() .AddIsDead()
.AddIsMoving() .AddIsMoving()
.AddInDeathProcess() .AddInDeathProcess()
.AddDeathProcessInitialTime(new ReactiveVariable<float>(2)) .AddDeathProcessInitialTime(new ReactiveVariable<float>(config.DeathProcessTime))
.AddDeathProcessCurrentTime(); .AddDeathProcessCurrentTime();
ICompositeCondition canMove = new CompositeCondition() ICompositeCondition canMove = new CompositeCondition()
@@ -194,12 +189,10 @@ namespace _Project.Develop.Runtime.Entities
.AddSystem(new DisableCollidersOnDeathSystem()) .AddSystem(new DisableCollidersOnDeathSystem())
.AddSystem(new SelfReleaseSystem(_entitiesLifeContext)); .AddSystem(new SelfReleaseSystem(_entitiesLifeContext));
_entitiesLifeContext.Add(entity);
return entity; return entity;
} }
public Entity CreateTeleportWizard(Vector3 position) public Entity CreateTeleportWizard(Vector3 position, WizardConfigSO config)
{ {
Entity entity = CreateEmpty(); Entity entity = CreateEmpty();
@@ -210,10 +203,10 @@ namespace _Project.Develop.Runtime.Entities
.AddContactCollidersBuffer(new Buffer<Collider>(32)) .AddContactCollidersBuffer(new Buffer<Collider>(32))
.AddContactEntitiesBuffer(new Buffer<Entity>(32)) .AddContactEntitiesBuffer(new Buffer<Entity>(32))
.AddMaxHealth(new ReactiveVariable<float>(150)) .AddMaxHealth(new ReactiveVariable<float>(config.MaxHealth))
.AddCurrentHealth(new ReactiveVariable<float>(150)) .AddCurrentHealth(new ReactiveVariable<float>(config.MaxHealth))
.AddTeleportTarget(entity.Transform) .AddTeleportSource(entity.Transform)
.AddTeleportToPoint(entity.Transform) .AddTeleportToPoint(entity.Transform)
.AddStartTeleportEvent() .AddStartTeleportEvent()
.AddStartTeleportRequest() .AddStartTeleportRequest()
@@ -221,31 +214,35 @@ namespace _Project.Develop.Runtime.Entities
.AddFindTeleportPointEvent() .AddFindTeleportPointEvent()
.AddFindTeleportPointRequest() .AddFindTeleportPointRequest()
.AddEndTeleportEvent() .AddEndTeleportEvent()
.AddCurrentTarget()
.AddTeleportDamage(new ReactiveVariable<float>(50)) .AddTeleportDamage(new ReactiveVariable<float>(config.TeleportDamage))
.AddTeleportDamageRadius(new ReactiveVariable<float>(6)) .AddTeleportDamageRadius(new ReactiveVariable<float>(config.TeleportDamageRadius))
.AddTeleportDamageMask(Layers.CharactersMask) .AddTeleportDamageMask(Layers.CharactersMask)
.AddTeleportEnergyCost(new ReactiveVariable<int>(20)) .AddTeleportEnergyCost(new ReactiveVariable<int>(config.TeleportEnergyCast))
.AddTeleportSearchRadius(new ReactiveVariable<float>(6)) .AddTeleportSearchRadius(new ReactiveVariable<float>(config.TeleportSearchRadius))
.AddCurrentEnergy(new ReactiveVariable<int>(60)) .AddTeleportCooldownInitialTime(new ReactiveVariable<float>(config.TeleportCooldownTime))
.AddMaxEnergy(new ReactiveVariable<int>(60)) .AddTeleportCooldownCurrentTime(new ReactiveVariable<float>(config.TeleportCooldownTime))
.AddInTeleportCooldown(new ReactiveVariable<bool>(true))
.AddCurrentEnergy(new ReactiveVariable<int>(config.MaxEnergy))
.AddMaxEnergy(new ReactiveVariable<int>(config.MaxEnergy))
.AddUseEnergyEvent() .AddUseEnergyEvent()
.AddUseEnergyRequest() .AddUseEnergyRequest()
.AddRegenEnergyEvent() .AddRegenEnergyEvent()
.AddRegenEnergyRequest() .AddRegenEnergyRequest()
.AddAutoRegenEnergyAmount(new ReactiveVariable<int>(10)) .AddAutoRegenEnergyAmount(new ReactiveVariable<int>(config.RegenEnergyAmount))
.AddIsAutoRegenEnergy(new ReactiveVariable<bool>(true)) .AddIsAutoRegenEnergy(new ReactiveVariable<bool>(true))
.AddEnergyAutoRegenCurrentTime() .AddEnergyAutoRegenCurrentTime()
.AddEnergyAutoRegenInitialTime(new ReactiveVariable<float>(3)) .AddEnergyAutoRegenInitialTime(new ReactiveVariable<float>(config.AutoRegenEnergyTime))
.AddBodyContactDamage(new ReactiveVariable<float>(50))
.AddTakeDamageRequest() .AddTakeDamageRequest()
.AddTakeDamageEvent() .AddTakeDamageEvent()
.AddIsDead() .AddIsDead()
.AddInDeathProcess() .AddInDeathProcess()
.AddDeathProcessInitialTime(new ReactiveVariable<float>(2)) .AddDeathProcessInitialTime(new ReactiveVariable<float>(config.DeathProcessTime))
.AddDeathProcessCurrentTime(); .AddDeathProcessCurrentTime();
ICompositeCondition canRegenEnergy = new CompositeCondition() ICompositeCondition canRegenEnergy = new CompositeCondition()
@@ -256,7 +253,10 @@ namespace _Project.Develop.Runtime.Entities
ICompositeCondition canStartTeleport = new CompositeCondition() ICompositeCondition canStartTeleport = new CompositeCondition()
.Add(new FuncCondition(() => entity.IsDead.Value == false)) .Add(new FuncCondition(() => entity.IsDead.Value == false))
.Add(new FuncCondition(() => entity.CurrentEnergy.Value >= entity.TeleportEnergyCost.Value)); .Add(new FuncCondition(() => entity.InTeleportCooldown.Value == false))
.Add(new FuncCondition(() => entity.CurrentEnergy.Value >= entity.TeleportEnergyCost.Value))
.Add(new FuncCondition(() => entity.CurrentEnergy.Value >= entity.MaxEnergy.Value * 0.4f))
.Add(new FuncCondition(() => entity.CurrentTarget.Value != null));
ICompositeCondition mustDie = new CompositeCondition() ICompositeCondition mustDie = new CompositeCondition()
.Add(new FuncCondition(() => entity.CurrentHealth.Value <= 0)); .Add(new FuncCondition(() => entity.CurrentHealth.Value <= 0));
@@ -277,8 +277,6 @@ namespace _Project.Develop.Runtime.Entities
.AddMustSelfRelease(mustSelfRelease); .AddMustSelfRelease(mustSelfRelease);
entity entity
.AddSystem(new TeleportByInputSystem(_playerInput))
// .AddSystem(new RegenEnergyByValueSystem()) // .AddSystem(new RegenEnergyByValueSystem())
.AddSystem(new RegenEnergyByPercentageSystem()) .AddSystem(new RegenEnergyByPercentageSystem())
.AddSystem(new UseEnergySystem()) .AddSystem(new UseEnergySystem())
@@ -286,15 +284,17 @@ namespace _Project.Develop.Runtime.Entities
.AddSystem(new TeleportStartByEnergySystem()) .AddSystem(new TeleportStartByEnergySystem())
.AddSystem(new TeleportProcessSystem()) .AddSystem(new TeleportProcessSystem())
.AddSystem(new FindRandomPointForTeleportSystem()) // .AddSystem(new FindRandomPointForTeleportSystem())
.AddSystem(new FindTargetPointForTeleportSystem())
.AddSystem(new EndTeleportSystem()) .AddSystem(new EndTeleportSystem())
.AddSystem(new InstantTeleportSystem()) .AddSystem(new InstantTeleportSystem())
.AddSystem(new TeleportCooldownTimerSystem())
.AddSystem(new DealDamageAfterTeleportSystem(_collidersRegistryService)) .AddSystem(new DealDamageAfterTeleportSystem(_collidersRegistryService))
.AddSystem(new BodyContactsDetectingSystem()) .AddSystem(new BodyContactsDetectingSystem())
.AddSystem(new BodyContactsEntitiesFilterSystem(_collidersRegistryService)) .AddSystem(new BodyContactsEntitiesFilterSystem(_collidersRegistryService))
.AddSystem(new DealDamageOnContactSystem()) // .AddSystem(new DealDamageOnContactSystem())
.AddSystem(new ApplyDamageSystem()) .AddSystem(new ApplyDamageSystem())
.AddSystem(new DeathSwitcherSystem()) .AddSystem(new DeathSwitcherSystem())
@@ -303,12 +303,10 @@ namespace _Project.Develop.Runtime.Entities
.AddSystem(new DisableCollidersOnDeathSystem()) .AddSystem(new DisableCollidersOnDeathSystem())
.AddSystem(new SelfReleaseSystem(_entitiesLifeContext)); .AddSystem(new SelfReleaseSystem(_entitiesLifeContext));
_entitiesLifeContext.Add(entity);
return 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(); Entity entity = CreateEmpty();
@@ -323,10 +321,12 @@ namespace _Project.Develop.Runtime.Entities
.AddMoveSpeed(new ReactiveVariable<float>(16)) .AddMoveSpeed(new ReactiveVariable<float>(16))
.AddRotationSpeed(new ReactiveVariable<float>(9999)) .AddRotationSpeed(new ReactiveVariable<float>(9999))
.AddBodyContactDamage(new ReactiveVariable<float>(damage)) .AddBodyContactDamage(new ReactiveVariable<float>(damage))
.AddTeam(new ReactiveVariable<Teams>(owner.Team.Value))
.AddIsDead() .AddIsDead()
.AddIsMoving() .AddIsMoving()
.AddDeathMask(Layers.CharactersMask | Layers.EnvironmentMask) .AddDeathMask(Layers.CharactersMask | Layers.EnvironmentMask)
.AddIsTouchDeathMask(); .AddIsTouchDeathMask()
.AddIsTouchAnotherTeam();
ICompositeCondition canMove = new CompositeCondition() ICompositeCondition canMove = new CompositeCondition()
.Add(new FuncCondition(() => entity.IsDead.Value == false)); .Add(new FuncCondition(() => entity.IsDead.Value == false));
@@ -334,7 +334,8 @@ namespace _Project.Develop.Runtime.Entities
ICompositeCondition canRotate = new CompositeCondition() ICompositeCondition canRotate = new CompositeCondition()
.Add(new FuncCondition(() => entity.IsDead.Value == false)); .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)); .Add(new FuncCondition(() => entity.IsTouchDeathMask.Value));
ICompositeCondition mustSelfRelease = new CompositeCondition() ICompositeCondition mustSelfRelease = new CompositeCondition()
@@ -357,6 +358,7 @@ namespace _Project.Develop.Runtime.Entities
.AddSystem(new DeathMaskTouchDetectorSystem()) .AddSystem(new DeathMaskTouchDetectorSystem())
.AddSystem(new DeathSwitcherSystem()) .AddSystem(new DeathSwitcherSystem())
.AddSystem(new AnotherTeamTouchDetectorSystem())
.AddSystem(new DisableCollidersOnDeathSystem()) .AddSystem(new DisableCollidersOnDeathSystem())
.AddSystem(new SelfReleaseSystem(_entitiesLifeContext)); .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

@@ -78,13 +78,13 @@ namespace _Project.Develop.Runtime.Entities
return AddComponent(new Assets._Project.Develop.Runtime.Gameplay.Common.NavMeshAgentComponent() {Value = value}); return AddComponent(new Assets._Project.Develop.Runtime.Gameplay.Common.NavMeshAgentComponent() {Value = value});
} }
public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportTarget TeleportTargetC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportTarget>(); public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportSource TeleportSourceC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportSource>();
public UnityEngine.Transform TeleportTarget => TeleportTargetC.Value; public UnityEngine.Transform TeleportSource => TeleportSourceC.Value;
public bool TryGetTeleportTarget(out UnityEngine.Transform value) public bool TryGetTeleportSource(out UnityEngine.Transform value)
{ {
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportTarget component); bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportSource component);
if(result) if(result)
value = component.Value; value = component.Value;
else else
@@ -92,9 +92,9 @@ namespace _Project.Develop.Runtime.Entities
return result; return result;
} }
public _Project.Develop.Runtime.Entities.Entity AddTeleportTarget(UnityEngine.Transform value) public _Project.Develop.Runtime.Entities.Entity AddTeleportSource(UnityEngine.Transform value)
{ {
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportTarget() {Value = value}); return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportSource() {Value = value});
} }
public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportToPoint TeleportToPointC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportToPoint>(); public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportToPoint TeleportToPointC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportToPoint>();
@@ -327,6 +327,78 @@ namespace _Project.Develop.Runtime.Entities
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportEnergyCost() {Value = value}); return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportEnergyCost() {Value = value});
} }
public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportCooldownInitialTime TeleportCooldownInitialTimeC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportCooldownInitialTime>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> TeleportCooldownInitialTime => TeleportCooldownInitialTimeC.Value;
public bool TryGetTeleportCooldownInitialTime(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportCooldownInitialTime component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddTeleportCooldownInitialTime()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportCooldownInitialTime() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>() });
}
public _Project.Develop.Runtime.Entities.Entity AddTeleportCooldownInitialTime(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportCooldownInitialTime() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportCooldownCurrentTime TeleportCooldownCurrentTimeC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportCooldownCurrentTime>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> TeleportCooldownCurrentTime => TeleportCooldownCurrentTimeC.Value;
public bool TryGetTeleportCooldownCurrentTime(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportCooldownCurrentTime component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddTeleportCooldownCurrentTime()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportCooldownCurrentTime() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>() });
}
public _Project.Develop.Runtime.Entities.Entity AddTeleportCooldownCurrentTime(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportCooldownCurrentTime() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.InTeleportCooldown InTeleportCooldownC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.InTeleportCooldown>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean> InTeleportCooldown => InTeleportCooldownC.Value;
public bool TryGetInTeleportCooldown(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.InTeleportCooldown component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddInTeleportCooldown()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.InTeleportCooldown() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean>() });
}
public _Project.Develop.Runtime.Entities.Entity AddInTeleportCooldown(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Boolean> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.InTeleportCooldown() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportDamage TeleportDamageC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportDamage>(); public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportDamage TeleportDamageC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportDamage>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> TeleportDamage => TeleportDamageC.Value; public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> TeleportDamage => TeleportDamageC.Value;
@@ -394,6 +466,30 @@ namespace _Project.Develop.Runtime.Entities
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportDamageMask() {Value = value}); 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 _Project.Develop.Runtime.Logic.Gameplay.Features.Sensors.CapsuleColliderComponent CapsuleColliderC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Sensors.CapsuleColliderComponent>();
public UnityEngine.CapsuleCollider CapsuleCollider => CapsuleColliderC.Value; public UnityEngine.CapsuleCollider CapsuleCollider => CapsuleColliderC.Value;
@@ -738,6 +834,13 @@ namespace _Project.Develop.Runtime.Entities
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.CanJump() {Value = value}); 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.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; public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> CurrentHealth => CurrentHealthC.Value;
@@ -1682,5 +1785,29 @@ namespace _Project.Develop.Runtime.Entities
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Attack.InAttackCooldown() {Value = value}); return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Attack.InAttackCooldown() {Value = value});
} }
public _Project.Develop.Runtime.Logic.Gameplay.Features.AI.CurrentTarget CurrentTargetC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.AI.CurrentTarget>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<_Project.Develop.Runtime.Entities.Entity> CurrentTarget => CurrentTargetC.Value;
public bool TryGetCurrentTarget(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<_Project.Develop.Runtime.Entities.Entity> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.AI.CurrentTarget component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<_Project.Develop.Runtime.Entities.Entity>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddCurrentTarget()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.AI.CurrentTarget() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<_Project.Develop.Runtime.Entities.Entity>() });
}
public _Project.Develop.Runtime.Entities.Entity AddCurrentTarget(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<_Project.Develop.Runtime.Entities.Entity> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.AI.CurrentTarget() {Value = value});
}
} }
} }

View File

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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 78216e3102e549f39cb690e777d00e88
timeCreated: 1772470309

View File

@@ -0,0 +1,16 @@
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI
{
public class AIParallelState : ParallelState<IUpdatableState>, IUpdatableState
{
public AIParallelState(params IUpdatableState[] states) : base(states)
{ }
public void Update(float deltaTime)
{
foreach (IUpdatableState state in States)
state.Update(deltaTime);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d0ae2666ed0a43d590866fff4686222a
timeCreated: 1772538444

View File

@@ -3,23 +3,27 @@ using System.Collections.Generic;
using _Project.Develop.Runtime.Entities; using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States; using _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States;
using _Project.Develop.Runtime.Utilities.Conditions; using _Project.Develop.Runtime.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.InputManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using Assets._Project.Develop.Runtime.Infrastructure.DI; using Assets._Project.Develop.Runtime.Infrastructure.DI;
using Assets._Project.Develop.Runtime.Utilities.Timer; using Assets._Project.Develop.Runtime.Utilities.Timer;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI
{ {
public class BrainsFactory public class BrainsFactory
{ {
private readonly DIContainer _container; private readonly EntitiesLifeContext _entitiesLifeContext;
private readonly AIBrainsContext _aiBrainsContext; private readonly AIBrainsContext _aiBrainsContext;
private readonly TimerServiceFactory _timerServiceFactory; private readonly TimerServiceFactory _timerServiceFactory;
private readonly IPlayerInput _playerInput;
public BrainsFactory(DIContainer container) public BrainsFactory(DIContainer container)
{ {
_container = container; _playerInput = container.Resolve<IPlayerInput>();
_aiBrainsContext = _container.Resolve<AIBrainsContext>(); _aiBrainsContext = container.Resolve<AIBrainsContext>();
_timerServiceFactory = _container.Resolve<TimerServiceFactory>(); _timerServiceFactory = container.Resolve<TimerServiceFactory>();
_entitiesLifeContext = container.Resolve<EntitiesLifeContext>();
} }
public StateMachineBrain CreateGhostBrain(Entity entity) public StateMachineBrain CreateGhostBrain(Entity entity)
@@ -32,6 +36,98 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI
return brain; return brain;
} }
public StateMachineBrain CreateWizardBrain(Entity entity)
{
AIStateMachine stateMachine = CreateRandomTeleportStateMachine(entity);
StateMachineBrain brain = new (stateMachine);
_aiBrainsContext.SetFor(entity, brain);
return brain;
}
// самый лучший нейминг
public StateMachineBrain CreateDangerWizardBrain(Entity entity, ITargetSelector targetSelector)
{
AIStateMachine teleportStateMachine = CreateRandomTeleportStateMachine(entity);
FindTargetState findTargetState = new (_entitiesLifeContext, entity, targetSelector);
AIParallelState parallelState = new (findTargetState, teleportStateMachine);
AIStateMachine rootStateMachine = new ();
rootStateMachine.AddState(parallelState);
StateMachineBrain brain = new (rootStateMachine);
_aiBrainsContext.SetFor(entity, brain);
return brain;
}
public StateMachineBrain CreateArcheroHeroBrain(Entity entity, ITargetSelector targetSelector)
{
AIStateMachine combatState = CreateAutoAttackStateMachine(entity);
PlayerInputMovementState movementState = new (entity, _playerInput);
ReactiveVariable<Entity> currentTarget = entity.CurrentTarget;
ICompositeCondition fromMovementToCombatStateCondition = new CompositeCondition()
.Add(new FuncCondition(() => currentTarget.Value != null))
.Add(new FuncCondition(() => _playerInput.Move.Value == Vector2.zero));
ICompositeCondition fromCombatToMovementStateCondition = new CompositeCondition(LogicOperationsUtils.Or)
.Add(new FuncCondition(() => currentTarget.Value == null))
.Add(new FuncCondition(() => _playerInput.Move.Value != Vector2.zero));
AIStateMachine behaviour = new ();
behaviour.AddState(combatState);
behaviour.AddState(movementState);
behaviour.AddTransition(combatState, movementState, fromCombatToMovementStateCondition);
behaviour.AddTransition(movementState, combatState, fromMovementToCombatStateCondition);
FindTargetState findTargetState = new (_entitiesLifeContext, entity, targetSelector);
AIParallelState parallelState = new (findTargetState, behaviour);
AIStateMachine rootStateMachine = new ();
rootStateMachine.AddState(parallelState);
StateMachineBrain brain = new (rootStateMachine);
_aiBrainsContext.SetFor(entity, brain);
return brain;
}
public StateMachineBrain CreateMainHeroBrain(Entity entity)
{
AIStateMachine combatState = CreateSteeringAttackStateMachine(entity);
PlayerInputMovementState movementState = new (entity, _playerInput);
ICompositeCondition fromMovementToCombatStateCondition = new CompositeCondition()
.Add(new FuncCondition(() => _playerInput.Move.Value == Vector2.zero));
ICompositeCondition fromCombatToMovementStateCondition = new CompositeCondition()
.Add(new FuncCondition(() => _playerInput.Move.Value != Vector2.zero));
AIStateMachine behaviour = new ();
behaviour.AddState(combatState);
behaviour.AddState(movementState);
behaviour.AddTransition(combatState, movementState, fromCombatToMovementStateCondition);
behaviour.AddTransition(movementState, combatState, fromMovementToCombatStateCondition);
StateMachineBrain brain = new (behaviour);
_aiBrainsContext.SetFor(entity, brain);
return brain;
}
private AIStateMachine CreateRandomMovementStateMachine(Entity entity) private AIStateMachine CreateRandomMovementStateMachine(Entity entity)
{ {
List<IDisposable> disposables = new (); List<IDisposable> disposables = new ();
@@ -60,5 +156,112 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI
return stateMachine; return stateMachine;
} }
// На сколько хорошая идея дробить на маленькие стейтмашины?
private AIStateMachine CreateSteeringAttackStateMachine(Entity entity)
{
AIStateMachine steeringState = CreateSteeringInputStateMachine(entity); // просто это уже 3 по вложенности
PlayerInputAttackTriggerState attackTriggerState = new (entity, _playerInput);
AIParallelState parallelState = new (steeringState, attackTriggerState);
AIStateMachine stateMachine = new ();
stateMachine.AddState(parallelState);
return stateMachine;
}
private AIStateMachine CreateSteeringInputStateMachine(Entity entity)
{
EmptyState emptyState = new ();
PlayerInputRotationState rotationState = new (entity, _playerInput);
ICondition fromIdleToRotateStateCondition = new CompositeCondition()
.Add(new FuncCondition(() => _playerInput.Look.Value != Vector2.zero));
ICondition fromRotateToIdleStateCondition = new CompositeCondition()
.Add(new FuncCondition(() => _playerInput.Look.Value == Vector2.zero));
AIStateMachine stateMachine = new ();
stateMachine.AddState(emptyState);
stateMachine.AddState(rotationState);
stateMachine.AddTransition(rotationState, emptyState, fromRotateToIdleStateCondition);
stateMachine.AddTransition(emptyState, rotationState, fromIdleToRotateStateCondition);
return stateMachine;
}
private AIStateMachine CreateAutoAttackStateMachine(Entity entity)
{
RotateToTargetState rotateToTargetState = new (entity);
AttackTriggerState attackTriggerState = new (entity);
ICondition canAttack = entity.CanStartAttack;
Transform transform = entity.Transform;
ReactiveVariable<Entity> currentTarget = entity.CurrentTarget;
ICompositeCondition fromRotateToAttackCondition = new CompositeCondition()
.Add(canAttack)
.Add(new FuncCondition(() =>
{
Entity target = currentTarget.Value;
if (target == null)
return false;
float angleToTarget = Quaternion.Angle(
transform.rotation,
Quaternion.LookRotation(target.Transform.position - transform.position));
return angleToTarget < 1f;
}
));
ReactiveVariable<bool> inAttackProcess = entity.InAttackProcess;
ICondition fromAttackToRotateStateCondition = new FuncCondition(() => inAttackProcess.Value == false);
AIStateMachine stateMachine = new ();
stateMachine.AddState(rotateToTargetState);
stateMachine.AddState(attackTriggerState);
stateMachine.AddTransition(rotateToTargetState, attackTriggerState, fromRotateToAttackCondition);
stateMachine.AddTransition(attackTriggerState, rotateToTargetState, fromAttackToRotateStateCondition);
return stateMachine;
}
private AIStateMachine CreateRandomTeleportStateMachine(Entity entity)
{
TeleportTriggerState teleportTriggerState = new (entity);
EmptyState emptyState = new ();
ICompositeCondition fromIdleToTeleportCondition = new CompositeCondition()
.Add(entity.CanStartTeleport);
ICompositeCondition fromTeleportToIdleCondition = new CompositeCondition()
.Add(new FuncCondition(() => entity.InTeleportProcess.Value == false));
AIStateMachine stateMachine = new ();
stateMachine.AddState(emptyState);
stateMachine.AddState(teleportTriggerState);
stateMachine.AddTransition(emptyState, teleportTriggerState, fromIdleToTeleportCondition);
stateMachine.AddTransition(teleportTriggerState, emptyState, fromTeleportToIdleCondition);
return stateMachine;
}
private AIStateMachine CreateToTargetTeleportStateMachine(Entity entity)
{
TeleportTriggerState teleportTriggerState = new (entity);
return null;
}
} }
} }

View File

@@ -0,0 +1,25 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement.Event;
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States
{
public class AttackTriggerState : State, IUpdatableState
{
private ReactiveEvent _request;
public AttackTriggerState(Entity entity)
{
_request = entity.StartAttackRequest;
}
public override void Enter()
{
base.Enter();
_request.Invoke();
}
public void Update(float deltaTime)
{ }
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9d58a80b452346bda2d968af0f76fdfa
timeCreated: 1772469124

View File

@@ -0,0 +1,28 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States
{
public class FindTargetState : State, IUpdatableState
{
private ITargetSelector _targetSelector;
private EntitiesLifeContext _entitiesLifeContext;
private ReactiveVariable<Entity> _currentTarget;
public FindTargetState(
EntitiesLifeContext entitiesLifeContext,
Entity entity,
ITargetSelector targetSelector)
{
_currentTarget = entity.CurrentTarget;
_targetSelector = targetSelector;
_entitiesLifeContext = entitiesLifeContext;
}
public void Update(float deltaTime)
{
_currentTarget.Value = _targetSelector.SelectTargetFrom(_entitiesLifeContext.Entities);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1c92a70ea84c48f49ae461eae381a1ce
timeCreated: 1772539593

View File

@@ -0,0 +1,10 @@
using System.Collections.Generic;
using _Project.Develop.Runtime.Entities;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States
{
public interface ITargetSelector
{
public Entity SelectTargetFrom(IEnumerable<Entity> targets);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 15c5398fa2f84d109f74fbe2cd14bcda
timeCreated: 1772538651

View File

@@ -0,0 +1,39 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.InputManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement.Event;
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States
{
public class PlayerInputAttackTriggerState : State, IUpdatableState
{
private readonly IPlayerInput _playerInput;
private ReactiveEvent _request;
public PlayerInputAttackTriggerState(Entity entity, IPlayerInput playerInput)
{
_playerInput = playerInput;
_request = entity.StartAttackRequest;
}
public override void Enter()
{
base.Enter();
_playerInput.Attack.Enter += OnAttack;
}
public void Update(float deltaTime)
{ }
public override void Exit()
{
base.Exit();
_playerInput.Attack.Enter -= OnAttack;
}
private void OnAttack(float value)
{
_request.Invoke();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6e82caaf47984b6982642cf87f3bf1fc
timeCreated: 1772810576

View File

@@ -0,0 +1,34 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.InputManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States
{
public class PlayerInputMovementState : State, IUpdatableState
{
private readonly IPlayerInput _playerInput;
private ReactiveVariable<Vector3> _moveDirection;
public PlayerInputMovementState(Entity entity, IPlayerInput playerInput)
{
_playerInput = playerInput;
_moveDirection = entity.MoveDirection;
}
public void Update(float deltaTime)
{
_moveDirection.Value = new Vector3(_playerInput.Move.Value.x, 0, _playerInput.Move.Value.y);
}
public override void Exit()
{
base.Exit();
_moveDirection.Value = Vector3.zero;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 449f5d14d62348c5a770bd34869f384f
timeCreated: 1772468559

View File

@@ -0,0 +1,52 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.InputManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States
{
public class PlayerInputRotationState : State, IUpdatableState
{
private readonly IPlayerInput _playerInput;
private readonly Transform _transform;
private ReactiveVariable<Vector3> _rotateDirection;
private const float Sensitivity = 0.5f;
private const float DeadZone = 0.1f;
public PlayerInputRotationState(Entity entity, IPlayerInput playerInput)
{
_playerInput = playerInput;
_transform = entity.Transform;
_rotateDirection = entity.RotateDirection;
}
public void Update(float deltaTime)
{
float lookX = _playerInput.Look.Value.x;
if (Mathf.Abs(lookX) > DeadZone)
{
Vector3 currentDirection = _rotateDirection.Value;
if (currentDirection == Vector3.zero)
currentDirection = _transform.forward;
currentDirection.y = 0;
if (currentDirection.sqrMagnitude < DeadZone)
currentDirection = Vector3.forward;
currentDirection.Normalize();
float angle = lookX * Sensitivity;
Quaternion rotation = Quaternion.Euler(0, angle, 0);
_rotateDirection.Value = rotation * currentDirection;
}
}
}
}

View File

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

View File

@@ -0,0 +1,28 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States
{
public class RotateToTargetState : State, IUpdatableState
{
private ReactiveVariable<Vector3> _rotateDirection;
private ReactiveVariable<Entity> _currentTarget;
private Transform _transform;
public RotateToTargetState(Entity entity)
{
_rotateDirection = entity.RotateDirection;
_currentTarget = entity.CurrentTarget;
_transform = entity.Transform;
}
public void Update(float deltaTime)
{
if (_currentTarget.Value != null)
_rotateDirection.Value = (_currentTarget.Value.Transform.position - _transform.position).normalized;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5a16d8f8d923476b9a5544d64f3b469e
timeCreated: 1772473180

View File

@@ -0,0 +1,25 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement.Event;
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States
{
public class TeleportTriggerState : State, IUpdatableState
{
private ReactiveEvent _request;
public TeleportTriggerState(Entity entity)
{
_request = entity.StartTeleportRequest;
}
public override void Enter()
{
base.Enter();
_request.Invoke();
}
public void Update(float deltaTime)
{ }
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 399ae3c830b94229a8b94350eca901d2
timeCreated: 1772543966

View File

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

View File

@@ -1,4 +1,4 @@
using System; using System;
using _Project.Develop.Runtime.Entities; using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement; using _Project.Develop.Runtime.Utils.ReactiveManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement.Event; using _Project.Develop.Runtime.Utils.ReactiveManagement.Event;
@@ -38,7 +38,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Attack.Systems.Shoot
private void OnAttackDelayEnd() private void OnAttackDelayEnd()
{ {
_entitiesFactory.CreateProjectile(_shootPoint.position, _shootPoint.forward, _damage.Value); _entitiesFactory.CreateProjectile(_shootPoint.position, _shootPoint.forward, _damage.Value, _entity);
} }
public void OnDispose() 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.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.ReactiveManagement; using _Project.Develop.Runtime.Utils.ReactiveManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement.Event; 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.Entities;
using _Project.Develop.Runtime.Utilities.Conditions; using _Project.Develop.Runtime.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.ReactiveManagement; 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.Entities;
using _Project.Develop.Runtime.Utilities; using _Project.Develop.Runtime.Utilities;
using _Project.Develop.Runtime.Utils.ReactiveManagement; using _Project.Develop.Runtime.Utils.ReactiveManagement;
@@ -34,6 +34,9 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Damage
{ {
_processedEntities.Add(contactEntity); _processedEntities.Add(contactEntity);
if (EntitiesHelper.AreOnSameTeam(contactEntity, _entity))
continue;
if (contactEntity.TryGetTakeDamageRequest(out ReactiveEvent<float> takeDamageRequest)) if (contactEntity.TryGetTakeDamageRequest(out ReactiveEvent<float> takeDamageRequest))
takeDamageRequest.Invoke(_damage.Value); 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

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

View File

@@ -0,0 +1,62 @@
using System.Collections.Generic;
using System.Linq;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Damage;
using _Project.Develop.Runtime.Utilities.Conditions;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Selectors
{
public class LowestHealthTargetSelector : ITargetSelector
{
private readonly Entity _source;
public LowestHealthTargetSelector(Entity entity)
{
_source = entity;
}
public Entity SelectTargetFrom(IEnumerable<Entity> targets)
{
IEnumerable<Entity> selectedTargets = FindSelectedTargets(targets);
IEnumerable<Entity> enumerable = selectedTargets.ToList();
if (enumerable.Any() == false)
return null;
Entity lowestHealthTarget = enumerable.First();
float minHealth = lowestHealthTarget.CurrentHealth.Value;
foreach (Entity target in enumerable)
{
float health = target.CurrentHealth.Value;
if (health < minHealth)
{
minHealth = health;
lowestHealthTarget = target;
}
}
return lowestHealthTarget;
}
private IEnumerable<Entity> FindSelectedTargets(IEnumerable<Entity> targets)
{
return targets.Where(target =>
{
bool result = target.HasComponent<TakeDamageRequest>();
if (target.TryGetCanApplyDamage(out ICompositeCondition value))
result = result && value.Evaluate();
result = result
&& (target != _source)
&& (EntitiesHelper.AreOnSameTeam(_source, target) == false);
return result;
});
}
}
}

View File

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

View File

@@ -0,0 +1,67 @@
using System.Collections.Generic;
using System.Linq;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Logic.Gameplay.Features.AI.States;
using _Project.Develop.Runtime.Logic.Gameplay.Features.Damage;
using _Project.Develop.Runtime.Utilities.Conditions;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Selectors
{
public class NearestDamageableTargetSelector : ITargetSelector
{
private readonly Entity _source;
private readonly Transform _sourceTransform;
public NearestDamageableTargetSelector(Entity entity)
{
_source = entity;
_sourceTransform = entity.Transform;
}
public Entity SelectTargetFrom(IEnumerable<Entity> targets)
{
IEnumerable<Entity> selectedTargets = FindSelectedTargets(targets);
IEnumerable<Entity> enumerable = selectedTargets.ToList();
if (enumerable.Any() == false)
return null;
Entity closetsTarget = enumerable.First();
float minDistance = GetDistanceTo(closetsTarget);
foreach (Entity target in enumerable)
{
float distance = GetDistanceTo(target);
if (distance < minDistance)
{
minDistance = distance;
closetsTarget = target;
}
}
return closetsTarget;
}
private IEnumerable<Entity> FindSelectedTargets(IEnumerable<Entity> targets)
{
return targets.Where(target =>
{
bool result = target.HasComponent<TakeDamageRequest>();
if (target.TryGetCanApplyDamage(out ICompositeCondition value))
result = result && value.Evaluate();
result = result
&& (target != _source)
&& (EntitiesHelper.AreOnSameTeam(_source, target) == false);
return result;
});
}
private float GetDistanceTo(Entity target) => (_sourceTransform.position - target.Transform.position).magnitude;
}
}

View File

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

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

@@ -46,7 +46,8 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
private void OnEndTeleport() private void OnEndTeleport()
{ {
if (_radius <= 0 || _damage <= 0) return; if (_radius <= 0 || _damage <= 0)
return;
int count = Physics.OverlapSphereNonAlloc( int count = Physics.OverlapSphereNonAlloc(
_toPoint.position, _toPoint.position,
@@ -63,6 +64,9 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
&& contactEntity != _entity && contactEntity != _entity
&& contactEntity.TryGetTakeDamageRequest(out ReactiveEvent<float> takeDamageRequest)) && contactEntity.TryGetTakeDamageRequest(out ReactiveEvent<float> takeDamageRequest))
{ {
if (EntitiesHelper.AreOnSameTeam(contactEntity, _entity))
continue;
takeDamageRequest.Invoke(_damage); takeDamageRequest.Invoke(_damage);
} }
} }

View File

@@ -9,7 +9,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
{ {
public class FindRandomPointForTeleportSystem : IInitializableSystem, IDisposableSystem public class FindRandomPointForTeleportSystem : IInitializableSystem, IDisposableSystem
{ {
private Transform _target; private Transform _source;
private Transform _toPoint; private Transform _toPoint;
private ReactiveEvent _findPointRequest; private ReactiveEvent _findPointRequest;
@@ -21,7 +21,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
public void OnInit(Entity entity) public void OnInit(Entity entity)
{ {
_target = entity.TeleportTarget; _source = entity.TeleportSource;
_toPoint = entity.TeleportToPoint; _toPoint = entity.TeleportToPoint;
_radius = entity.TeleportSearchRadius; _radius = entity.TeleportSearchRadius;
_findPointRequest = entity.FindTeleportPointRequest; _findPointRequest = entity.FindTeleportPointRequest;
@@ -37,13 +37,14 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
private void OnFindPointRequest() private void OnFindPointRequest()
{ {
_toPoint.position = GetRandomPointInRadius(_target.position, _radius.Value); _toPoint.position = GetRandomPointInRadius(_source.position, _radius.Value);
_findPointEvent.Invoke(); _findPointEvent.Invoke();
} }
private Vector3 GetRandomPointInRadius(Vector3 center, float radius) private Vector3 GetRandomPointInRadius(Vector3 center, float radius)
{ {
Vector2 randomPoint = Random.insideUnitCircle * radius; Vector2 randomPoint = Random.insideUnitCircle * radius;
return center + new Vector3(randomPoint.x, 0f, randomPoint.y); return center + new Vector3(randomPoint.x, 0f, randomPoint.y);
} }
} }

View File

@@ -0,0 +1,62 @@
using System;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement.Event;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
{
public class FindTargetPointForTeleportSystem : IInitializableSystem, IDisposableSystem
{
private Transform _source;
private Transform _toPoint;
private ReactiveEvent _findPointRequest;
private ReactiveEvent _findPointEvent;
private ReactiveVariable<float> _radius;
private ReactiveVariable<Entity> _currentTarget;
private IDisposable _findPointRequestDisposable;
public void OnInit(Entity entity)
{
_source = entity.TeleportSource;
_toPoint = entity.TeleportToPoint;
_radius = entity.TeleportSearchRadius;
_currentTarget = entity.CurrentTarget;
_findPointRequest = entity.FindTeleportPointRequest;
_findPointEvent = entity.FindTeleportPointEvent;
_findPointRequestDisposable = _findPointRequest.Subscribe(OnFindPointRequest);
}
public void OnDispose()
{
_findPointRequestDisposable.Dispose();
}
private void OnFindPointRequest()
{
Entity target = _currentTarget.Value;
if (target == null)
{
_toPoint.position = _source.position;
_findPointEvent.Invoke();
return;
}
Vector3 sourcePosition = _source.position;
Vector3 targetPosition = target.Transform.position;
Vector3 direction = targetPosition - sourcePosition;
if (direction.magnitude <= _radius.Value)
_toPoint.position = targetPosition;
else
_toPoint.position = sourcePosition + direction.normalized * _radius.Value;
_findPointEvent.Invoke();
}
}
}

View File

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

View File

@@ -16,7 +16,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
public void OnInit(Entity entity) public void OnInit(Entity entity)
{ {
_target = entity.TeleportTarget; _target = entity.TeleportSource;
_toPoint = entity.TeleportToPoint; _toPoint = entity.TeleportToPoint;
_endTeleportEvent = entity.EndTeleportEvent; _endTeleportEvent = entity.EndTeleportEvent;

View File

@@ -0,0 +1,52 @@
using System;
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement.Event;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
{
public class TeleportCooldownTimerSystem : IInitializableSystem, IUpdatableSystem, IDisposableSystem
{
private ReactiveVariable<float> _currentTime;
private ReactiveVariable<float> _initialTime;
private ReactiveVariable<bool> _inTeleportCooldown;
private ReactiveEvent _endTeleportEvent;
private IDisposable _endTeleportEventDisposable;
public void OnInit(Entity entity)
{
_currentTime = entity.TeleportCooldownCurrentTime;
_initialTime = entity.TeleportCooldownInitialTime;
_inTeleportCooldown = entity.InTeleportCooldown;
_endTeleportEvent = entity.EndTeleportEvent;
_endTeleportEventDisposable = _endTeleportEvent.Subscribe(OnEndTeleport);
}
private void OnEndTeleport()
{
_currentTime.Value = _initialTime.Value;
_inTeleportCooldown.Value = true;
}
public void OnUpdate(float deltaTime)
{
if (_inTeleportCooldown.Value == false)
return;
_currentTime.Value -= deltaTime;
if (CooldownIsOver())
_inTeleportCooldown.Value = false;
}
private bool CooldownIsOver() => _currentTime.Value <= 0;
public void OnDispose()
{
_endTeleportEventDisposable.Dispose();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 203bcf3a28764fb7bfac1482c48bad2f
timeCreated: 1772546509

View File

@@ -6,7 +6,7 @@ using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport
{ {
public class TeleportTarget : IEntityComponent { public Transform Value; } public class TeleportSource : IEntityComponent { public Transform Value; }
public class TeleportToPoint : IEntityComponent { public Transform Value; } public class TeleportToPoint : IEntityComponent { public Transform Value; }
public class TeleportSearchRadius : IEntityComponent { public ReactiveVariable<float> Value; } public class TeleportSearchRadius : IEntityComponent { public ReactiveVariable<float> Value; }
@@ -23,6 +23,10 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport
public class TeleportEnergyCost : IEntityComponent { public ReactiveVariable<int> Value; } public class TeleportEnergyCost : IEntityComponent { public ReactiveVariable<int> Value; }
public class TeleportCooldownInitialTime : IEntityComponent { public ReactiveVariable<float> Value; }
public class TeleportCooldownCurrentTime : IEntityComponent { public ReactiveVariable<float> Value; }
public class InTeleportCooldown : IEntityComponent { public ReactiveVariable<bool> Value; }
public class TeleportDamage : IEntityComponent { public ReactiveVariable<float> Value; } public class TeleportDamage : IEntityComponent { public ReactiveVariable<float> Value; }
public class TeleportDamageRadius : IEntityComponent { public ReactiveVariable<float> Value; } public class TeleportDamageRadius : IEntityComponent { public ReactiveVariable<float> Value; }
public class TeleportDamageMask : IEntityComponent { public LayerMask Value; } public class TeleportDamageMask : IEntityComponent { public LayerMask Value; }

View File

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

View File

@@ -1,8 +1,14 @@
using System; using System;
using _Project.Develop.Runtime.Configs.Gameplay.Entities;
using _Project.Develop.Runtime.Entities; using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Logic.Gameplay.Features.AI; 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 _Project.Develop.Runtime.Utils.InputManagement;
using Assets._Project.Develop.Runtime.Infrastructure.DI; using Assets._Project.Develop.Runtime.Infrastructure.DI;
using Assets._Project.Develop.Runtime.Utilities.AssetsManagement;
using Assets._Project.Develop.Runtime.Utilities.ConfigsManagement;
using UnityEngine; using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features namespace _Project.Develop.Runtime.Logic.Gameplay.Features
@@ -10,11 +16,12 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features
public class TestGameplay : MonoBehaviour public class TestGameplay : MonoBehaviour
{ {
private DIContainer _container; private DIContainer _container;
private EntitiesFactory _entitiesFactory; private EnemiesFactory _enemiesFactory;
private MainHeroFactory _mainHeroFactory;
private BrainsFactory _brainsFactory; private BrainsFactory _brainsFactory;
private Entity _hero; private Entity _hero;
private Entity _ghost; private Entity _enemy;
private bool _isRunning; private bool _isRunning;
@@ -23,17 +30,19 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features
_container = container; _container = container;
_container.Resolve<IPlayerInput>().Enable(); _container.Resolve<IPlayerInput>().Enable();
_entitiesFactory = _container.Resolve<EntitiesFactory>();
_enemiesFactory = _container.Resolve<EnemiesFactory>();
_mainHeroFactory = _container.Resolve<MainHeroFactory>();
_brainsFactory = _container.Resolve<BrainsFactory>(); _brainsFactory = _container.Resolve<BrainsFactory>();
_hero = _mainHeroFactory.Create(Vector3.zero);
_enemy = _enemiesFactory.Create(
Vector3.zero + Vector3.forward * 5,
_container.Resolve<ConfigsProviderService>().GetConfig<WizardConfigSO>());
} }
public void Run() public void Run()
{ {
_hero = _entitiesFactory.CreateTeleportWizard(Vector3.zero);
_ghost = _entitiesFactory.CreateGhost(Vector3.zero + Vector3.forward * 5);
_brainsFactory.CreateGhostBrain(_ghost);
_isRunning = true; _isRunning = true;
} }
@@ -45,11 +54,11 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features
private void OnGUI() private void OnGUI()
{ {
if (_hero == null) if (_hero == null || _enemy == null)
return; return;
GUI.Label(new Rect(10, 20, 200, 50), $"Health: {_hero.CurrentHealth.Value}/{_hero.MaxHealth.Value}"); GUI.Label(new Rect(10, 20, 200, 50), $"Health: {_hero.CurrentHealth.Value}/{_hero.MaxHealth.Value}");
GUI.Label(new Rect(10, 40, 200, 50), $"Energy: {_hero.CurrentEnergy.Value}/{_hero.MaxEnergy.Value}"); GUI.Label(new Rect(10, 40, 200, 50), $"Energy: {_enemy.CurrentEnergy.Value}/{_enemy.MaxEnergy.Value}");
} }
} }
} }

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using _Project.Develop.Runtime.Utilities.Conditions;
using _Project.Develop.Runtime.Utils.InputManagement.States;
using Assets._Project.Develop.Runtime.Infrastructure.DI;
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
namespace _Project.Develop.Runtime.Utils.InputManagement
{
public class InputStateMachine : StateMachine<IState>, IInitializable, IDisposable
{
private readonly IPlayerInput _playerInput;
private readonly IUIInput _uiInput;
public InputStateMachine(List<IDisposable> disposables) : base(disposables)
{ }
public InputStateMachine(DIContainer container) : base(new List<IDisposable>())
{
_playerInput = container.Resolve<IPlayerInput>();
_uiInput = container.Resolve<IUIInput>();
}
public void Initialize()
{
PlayerInputState playerInputState = new(_playerInput);
UIInputState uiInputState = new(_uiInput);
ICompositeCondition playerToUiStateCondition = new CompositeCondition(LogicOperationsUtils.Or)
.Add(new FuncCondition(() => _uiInput.IsEnabled));
// .Add(new FuncCondition(() => _playerHorseInput.IsEnabled)); просто как пример что включен только 1 вариант
ICompositeCondition uiToPlayerStateCondition = new CompositeCondition(LogicOperationsUtils.Or)
.Add(new FuncCondition(() => _playerInput.IsEnabled));
// .Add(new FuncCondition(() => _playerHorseInput.IsEnabled));
AddState(playerInputState);
AddState(uiInputState);
AddTransition(playerInputState, uiInputState, playerToUiStateCondition);
AddTransition(uiInputState, playerInputState, uiToPlayerStateCondition);
Enter();
}
public void Dispose()
{
Exit();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b1a3543621b74566aa3f737018932731
timeCreated: 1772547242

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 60ce6781167b4204a72055d939441a5b
timeCreated: 1772547589

View File

@@ -0,0 +1,26 @@
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
namespace _Project.Develop.Runtime.Utils.InputManagement.States
{
public class PlayerInputState : State
{
private readonly IPlayerInput _playerInput;
public PlayerInputState(IPlayerInput playerInput)
{
_playerInput = playerInput;
}
public override void Enter()
{
base.Enter();
_playerInput.Enable();
}
public override void Exit()
{
_playerInput.Disable();
base.Exit();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0efa0cca886c45e295d4adcb82d59f8b
timeCreated: 1770556305

View File

@@ -0,0 +1,26 @@
using Assets._Project.Develop.Runtime.Utilities.StateMachineCore;
namespace _Project.Develop.Runtime.Utils.InputManagement.States
{
public class UIInputState : State
{
private readonly IUIInput _uiInput;
public UIInputState(IUIInput uiInput)
{
_uiInput = uiInput;
}
public override void Enter()
{
base.Enter();
_uiInput.Enable();
}
public override void Exit()
{
_uiInput.Disable();
base.Exit();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2cac35b3aedd43b1959f82e36c30ac47
timeCreated: 1770556297

View File

@@ -3,17 +3,24 @@ using System.Collections.Generic;
namespace _Project.Develop.Runtime.Utils.ReactiveManagement namespace _Project.Develop.Runtime.Utils.ReactiveManagement
{ {
public class ReactiveVariable<T> : IReadOnlyVariable<T> where T : IEquatable<T> public class ReactiveVariable<T> : IReadOnlyVariable<T>
{ {
private readonly List<Subscriber<T, T>> _subscribers = new List<Subscriber<T, T>>(); private readonly List<Subscriber<T, T>> _subscribers = new ();
private readonly List<Subscriber<T, T>> _toAddList = new List<Subscriber<T, T>>(); private readonly List<Subscriber<T, T>> _toAddList = new ();
private readonly List<Subscriber<T, T>> _toRemoveList = new List<Subscriber<T, T>>(); private readonly List<Subscriber<T, T>> _toRemoveList = new ();
public ReactiveVariable() => _value = default(T);
public ReactiveVariable(T value) => _value = value;
private T _value; private T _value;
private IEqualityComparer<T> _comparer;
public ReactiveVariable() : this(default) { }
public ReactiveVariable(T value) : this(value, EqualityComparer<T>.Default){ }
public ReactiveVariable(T value, IEqualityComparer<T> comparer)
{
_value = value;
_comparer = comparer;
}
public T Value public T Value
{ {
@@ -23,14 +30,14 @@ namespace _Project.Develop.Runtime.Utils.ReactiveManagement
T oldValue = _value; T oldValue = _value;
_value = value; _value = value;
if (_value.Equals(oldValue) == false) if (_comparer.Equals(oldValue, value) == false)
Invoke(oldValue, _value); Invoke(oldValue, _value);
} }
} }
public IDisposable Subscribe(Action<T, T> action) public IDisposable Subscribe(Action<T, T> action)
{ {
Subscriber<T, T> subscriber = new Subscriber<T, T>(action, RemoveSubscriber); Subscriber<T, T> subscriber = new (action, RemoveSubscriber);
_toAddList.Add(subscriber); _toAddList.Add(subscriber);
return subscriber; return subscriber;

View File

@@ -73,6 +73,8 @@ namespace Assets._Project.Develop.Runtime.Utilities.StateMachineCore
if (_currentState == null) if (_currentState == null)
SwitchState(_states[0]); SwitchState(_states[0]);
else
_currentState.State.Enter();
_isRunning = true; _isRunning = true;
} }

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:

View File

@@ -654,8 +654,8 @@ Camera:
near clip plane: 0.3 near clip plane: 0.3
far clip plane: 1000 far clip plane: 1000
field of view: 60 field of view: 60
orthographic: 0 orthographic: 1
orthographic size: 5 orthographic size: 14.12
m_Depth: -1 m_Depth: -1
m_CullingMask: m_CullingMask:
serializedVersion: 2 serializedVersion: 2
@@ -680,7 +680,7 @@ Transform:
m_GameObject: {fileID: 1496566168} m_GameObject: {fileID: 1496566168}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0.34130225, y: -0, z: -0, w: 0.9399536} m_LocalRotation: {x: 0.34130225, y: -0, z: -0, w: 0.9399536}
m_LocalPosition: {x: 0, y: 11.01, z: -12.32} m_LocalPosition: {x: -0.8, y: 41.4, z: -39.5}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []