Silly enemy, attack bug fix
This commit is contained in:
1 parent
b02e201cd0
commit
1d107924bf
567 files changed
+197825
-635242
No files matched your search
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
@@ -6,6 +7,8 @@ namespace Code.OfficeGame.BattleMode.Actions.AI
|
||||
public abstract class EnemyDecider
|
||||
{
|
||||
public abstract UniTask<(BattleActionDecisionResult decisionResult, BattleActionData actionData)>
|
||||
DecideEnemy(CancellationToken ctx, EntityProperties entity);
|
||||
DecideEnemy(CancellationToken ctx, EntityProperties entity, Dictionary<BattleActionType, BattleAction> battleActions);
|
||||
|
||||
public abstract EnemyDeciderTypes EnemyDeciderType { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1bba480028a459a960d731f9ae971d5
|
||||
timeCreated: 1794940179
|
||||
guid: bbfe8fd114bf4814b5efecee9b2bf086
|
||||
timeCreated: 1794949033
|
||||
@@ -0,0 +1,66 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Actions.AI.EnemyDeciders
|
||||
{
|
||||
public class FrankAttackDecider : EnemyDecider
|
||||
{
|
||||
private EntityProperties _player;
|
||||
|
||||
public FrankAttackDecider(EntityProperties player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public override async UniTask<(BattleActionDecisionResult decisionResult, BattleActionData actionData)> DecideEnemy(
|
||||
CancellationToken ctx,
|
||||
EntityProperties entity,
|
||||
Dictionary<BattleActionType,BattleAction> battleActions)
|
||||
{
|
||||
await UniTask.Yield();
|
||||
|
||||
var entityPosition = entity.transform.position;
|
||||
var playerPosition = _player.transform.position;
|
||||
|
||||
var enemyToPlayer = playerPosition - entityPosition;
|
||||
var rotateToPlayer = Quaternion.LookRotation(
|
||||
playerPosition - entityPosition,
|
||||
Vector3.up);
|
||||
|
||||
BattleActionDecisionResult decisionResult = null;
|
||||
BattleActionData actionData = null;
|
||||
|
||||
if (enemyToPlayer.magnitude > 1f)
|
||||
{
|
||||
var positionToPlayer = entityPosition + enemyToPlayer.normalized * (enemyToPlayer.magnitude - 0.5f);
|
||||
|
||||
decisionResult = new PositionBattleActionDeciderResult()
|
||||
{
|
||||
ActionType = BattleActionType.Move,
|
||||
Position = positionToPlayer,
|
||||
Rotation = rotateToPlayer,
|
||||
ResultCode = BattleActionDecisionResultCode.Decided
|
||||
};
|
||||
|
||||
actionData = battleActions[BattleActionType.Move].MountAndGetFrames(entity, decisionResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
decisionResult = new RotationBattleActionDeciderResult()
|
||||
{
|
||||
ActionType = BattleActionType.PlayerAttackMMA,
|
||||
Rotation = rotateToPlayer,
|
||||
ResultCode = BattleActionDecisionResultCode.Decided
|
||||
};
|
||||
|
||||
actionData = battleActions[BattleActionType.PlayerAttackMMA].MountAndGetFrames(entity, decisionResult);
|
||||
}
|
||||
|
||||
return (decisionResult, actionData);
|
||||
}
|
||||
|
||||
public override EnemyDeciderTypes EnemyDeciderType => EnemyDeciderTypes.FrankAttack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2dfe2052460497c938ce9fdcc3826c1
|
||||
timeCreated: 1794949053
|
||||
Reference in new issue
Block a user