Advertisement
dimmpixeye

Untitled

Jan 21st, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. namespace Homebrew
  4. {
  5.     public partial class ProcessingEnemy
  6.     {
  7.         void AttackSetup()
  8.         {
  9.             var state = new AIState();
  10.             statesMap.Add(Tag.AIStateAttack, state);
  11.             state.Handle = AttackHandle;
  12.             state.OnStart = AttackStart;
  13.             state.OnEnd = entity =>
  14.             {
  15.             };
  16.             state.Condition = AttackCondition;
  17.         }
  18.  
  19.         void AttackCondition(int entity)
  20.         {
  21.      
  22.         }
  23.  
  24.  
  25.         void AttackHandle(int entity)
  26.         {
  27.             var cMotion  = entity.ComponentMotion();
  28.             var cAI      = entity.ComponentEnemy();
  29.             var cObject  = entity.ComponentObject();
  30.             var cView    = entity.ComponentView();
  31.            
  32.             var position = cObject.transform.position;
  33.             cMotion.direction = Vector2.zero;
  34.             cView.facingOverride = cAI.targetInFront;
  35.  
  36.             cAI.positionTo = cAI.targetPosition - position + new Vector3(AI.directionsOnAttack[cAI.indexAttacking].x, AI.directionsOnAttack[cAI.indexAttacking].y) * cAI.template.attackDistance;
  37.             cAI.positionTo.y = cAI.target.entity.Has(Tag.ComponentInAir) ? position.y : cAI.positionTo.y;
  38.             cAI.positionTo.z = 0;
  39.             var vel = entity.Move(position, cAI.template.attackMoveSpeed, cAI, delta);
  40.  
  41.             cMotion.positionTo = position + vel;
  42.             cMotion.direction = vel;
  43.         }
  44.  
  45.         void AttackStart(int entity)
  46.         {
  47.             var cAI = entity.ComponentEnemy();
  48.             ComponentAI.entitiesAttackingPlayers[cAI.indexAttacking] = entity;
  49.  
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement