Ejemplo n.º 1
0
    void GetEnemyTarget()
    {
        Collider[] colliders = Physics.OverlapSphere(transform.position, 200, enemyLayerMask);

        for (int i = 0; i < colliders.Length; i++)
        {
            EnemyInput enemy = colliders[i].GetComponent <EnemyInput>();

            if (enemy != null)
            {
                if (states.enemyTarget == null)
                {
                    states.enemyTarget = enemy;
                    states.engagedBy   = states;
                }
                else
                {
                    Vector3 to       = colliders[i].transform.position - transform.position;
                    float   newAngle = Vector3.SignedAngle(cameraManager.transform.forward, to, cameraManager.transform.up);

                    to = states.enemyTarget.lockonPosition - transform.position;
                    float oldAngle = Vector3.SignedAngle(cameraManager.transform.forward, to, cameraManager.transform.up);

                    if (Mathf.Abs(newAngle) < Mathf.Abs(oldAngle))
                    {
                        states.enemyTarget = enemy;
                        states.engagedBy   = states;
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
 void Awake()
 {
     input = new EnemyInput();
     banditController.Setup(input);
     banditController.AttackHitEvent += CheckIfTargetInRange;
     banditController.DiedEvent      += Despawn;
     banditController.DiedEvent      += HandleDeath;
 }
Ejemplo n.º 3
0
 public Enemy(Vector2 position) : base(position)
 {
     body  = AddComponent <PawnBody>(new PawnBody());
     input = AddComponent <EnemyInput>(new EnemyInput());
     AddComponent(new PawnGraphics());
     Health = AddComponent <Health>(new Health(100));
     Vision = AddComponent <EnemyVision>(new EnemyVision());
     //AddComponent(new EnemyAI());
     ChangeMotionState(new MotionIdleState(this));
 }
Ejemplo n.º 4
0
 public void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 5
0
 public void SetDelegate(Move move, Collect collect, Build build, BuildTap buildTap, bool isPlayerGround, EnemyInput enemyInput, EnemyBuildingInput enemyBuildingInput, EnemyLevelUp enemyLevelUp)
 {
     this.move               = move;
     this.collect            = collect;
     this.build              = build;
     this.buildTap           = buildTap;
     this.isPlayerGround     = isPlayerGround;
     this.enemyInput         = enemyInput;
     this.enemyBuildingInput = enemyBuildingInput;
     this.enemyLevelUp       = enemyLevelUp;
 }
Ejemplo n.º 6
0
 private void Start()
 {
     m_Abilities  = GetComponent <Abilities>();
     m_Sprite     = GetComponent <SpriteRenderer>();
     m_EnemyInput = GetComponent <EnemyInput>();
     m_Animator   = GetComponent <Animator>();
     m_Attacker   = GetComponent <Attacker>();
     movingHash   = Animator.StringToHash("moving");
     attackHash   = Animator.StringToHash("attack");
     deathHash    = Animator.StringToHash("death");
     GetEnemyName();
     Instantiate(spawnVFX, transform);
 }
Ejemplo n.º 7
0
    void Awake()
    {
        input = new EnemyInput();
        banditController.Setup(input);
        banditController.AttackHitEvent += CheckIfTargetInRange;
        banditController.DiedEvent      += Despawn;
        banditController.DiedEvent      += HandleDeath;

        banditController.AttackedEvent += () => RuntimeManager.PlayOneShot(attackEvent);
        banditController.JumpedEvent   += () => RuntimeManager.PlayOneShot(jumpEvent);
        banditController.LandedEvent   += () => RuntimeManager.PlayOneShot(landingEvent);
        banditController.DiedEvent     += () => RuntimeManager.PlayOneShot(deathEvent);
        banditController.FootstepEvent += () => RuntimeManager.PlayOneShot(footstepEvent);
    }
Ejemplo n.º 8
0
        public MotionRoamingState(Enemy enemy) : base(enemy)
        {
            input          = enemy.GetComponent <EnemyInput>();
            input.InMotion = true;
            setCurrentCell();
            List <Cell> healthyCells = enemy.Vision.HollowCells();

            destination = healthyCells[Randomizer.Random.Next(healthyCells.Count)] as Cell;
            AStar path = new AStar(enemy.CellGraph, currentCell, destination);

            if (path.Length > 0)
            {
                this.path = path;
            }
        }
Ejemplo n.º 9
0
    void Awake()
    {
        input = new EnemyInput();
        banditController.Setup(input);
        banditController.AttackHitEvent += CheckIfTargetInRange;
        banditController.DiedEvent      += Despawn;
        banditController.DiedEvent      += HandleDeath;

        banditController.JumpedEvent     += () => NotifySubsystemsAboutNewEvent(PlayerEventType.Jump);
        banditController.LandedEvent     += () => NotifySubsystemsAboutNewEvent(PlayerEventType.Landing);
        banditController.AttackedEvent   += () => NotifySubsystemsAboutNewEvent(PlayerEventType.Attack);
        banditController.DiedEvent       += () => NotifySubsystemsAboutNewEvent(PlayerEventType.Death);
        banditController.FootstepEvent   += () => NotifySubsystemsAboutNewEvent(PlayerEventType.Footstep);
        banditController.BlockedHitEvent += () => NotifySubsystemsAboutNewEvent(PlayerEventType.BlockHit);
        banditController.GotHitEvent     += () => NotifySubsystemsAboutNewEvent(PlayerEventType.GotHit);
    }
Ejemplo n.º 10
0
    void Awake()
    {
        iEnemy = new EnemyController();
        iEnemy.SetPlayerGameObject(GameObject.Find("Player"));
        iEnemy.SetRigidbody2D(GetComponent <Rigidbody2D>());
        iEnemy.SetMovementSpeed(movementSpeed);
        iEnemy.SetPlayerDetectionDistance(playerDetectionDistance);
        iEnemy.SetAttackPlayerDistance(attackPlayerDistance);
        iEnemy.SetAttackTimer(attackTimer);
        iEnemy.SetAttackLine(gameObject.transform.Find("AttackLine").gameObject);

        enemyMovementScript = GetComponent <EnemyMovement>();
        enemyInputScript    = GetComponent <EnemyInput>();
        enemyAttackScript   = GetComponent <EnemyAttack>();

        enemyMovementScript.enabled = true;
        enemyInputScript.enabled    = true;
        enemyAttackScript.enabled   = true;
    }
Ejemplo n.º 11
0
 // Use this for initialization
 void Start()
 {
     input = this.GetComponent<EnemyInput>();
 }
Ejemplo n.º 12
0
 private void Start()
 {
     input = GetComponentInParent <EnemyInput>();
 }
Ejemplo n.º 13
0
 public WeaponAttackingState(Enemy enemy, Player target) : base(enemy)
 {
     input       = enemy.GetComponent <EnemyInput>();
     this.target = target;
 }
Ejemplo n.º 14
0
    private void OnEnable()
    {
        input = GetComponent <EnemyInput>();

        isGoingLeft = initialMoveDirection == MoveDirection.Left;
    }