Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- namespace Homebrew
- {
- public partial class ProcessingEnemy
- {
- void AttackSetup()
- {
- var state = new AIState();
- statesMap.Add(Tag.AIStateAttack, state);
- state.Handle = AttackHandle;
- state.OnStart = AttackStart;
- state.OnEnd = entity =>
- {
- };
- state.Condition = AttackCondition;
- }
- void AttackCondition(int entity)
- {
- }
- void AttackHandle(int entity)
- {
- var cMotion = entity.ComponentMotion();
- var cAI = entity.ComponentEnemy();
- var cObject = entity.ComponentObject();
- var cView = entity.ComponentView();
- var position = cObject.transform.position;
- cMotion.direction = Vector2.zero;
- cView.facingOverride = cAI.targetInFront;
- cAI.positionTo = cAI.targetPosition - position + new Vector3(AI.directionsOnAttack[cAI.indexAttacking].x, AI.directionsOnAttack[cAI.indexAttacking].y) * cAI.template.attackDistance;
- cAI.positionTo.y = cAI.target.entity.Has(Tag.ComponentInAir) ? position.y : cAI.positionTo.y;
- cAI.positionTo.z = 0;
- var vel = entity.Move(position, cAI.template.attackMoveSpeed, cAI, delta);
- cMotion.positionTo = position + vel;
- cMotion.direction = vel;
- }
- void AttackStart(int entity)
- {
- var cAI = entity.ComponentEnemy();
- ComponentAI.entitiesAttackingPlayers[cAI.indexAttacking] = entity;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement