Пример #1
0
 void CountAttacks()
 {
     numberOfAttacks++;
     if (numberOfAttacks >= statePatternEnemy.numberOfAttacks)
     {
         statePatternEnemy.ChangeState(new RedManChaseState(statePatternEnemy));
     }
 }
Пример #2
0
    public void UpdateState()
    {
        Movement player = statePatternEnemy.GetPlayer();

        if (player != null)
        {
            statePatternEnemy.movement.MoveTowardsObject(player);
            if (Vector2.Distance(statePatternEnemy.transform.position, statePatternEnemy.player.transform.position) < statePatternEnemy.maxAttackDistance && statePatternEnemy.CanSeePlayer() && (Time.time - statePatternEnemy.lastAttackTime > statePatternEnemy.timeBetweenAttacks))
            {
                statePatternEnemy.ChangeState(new AttackState(statePatternEnemy));
            }
            else if ((Time.time - statePatternEnemy.lastAttackTime > 2 * statePatternEnemy.timeBetweenAttacks))
            {
                statePatternEnemy.ChangeState(new AttackState(statePatternEnemy));
            }
        }
    }
Пример #3
0
 void CountAttacks()
 {
     numberOfAttacks++;
     Debug.Log("Attacked");
     if (numberOfAttacks >= statePatternEnemy.numberOfAttacks)
     {
         statePatternEnemy.ChangeState(new ChaseState(statePatternEnemy));
     }
 }
Пример #4
0
    public void UpdateState()
    {
        Movement player = statePatternEnemy.GetPlayer();

        if (player != null)
        {
            if (Vector2.Distance(statePatternEnemy.transform.position, statePatternEnemy.player.transform.position) < statePatternEnemy.minObserveDistance)
            {
                statePatternEnemy.ChangeState(new ChaseState(statePatternEnemy));
            }
        }
    }
Пример #5
0
    IEnumerator WaitRandomTime()
    {
        yield return(new WaitForSeconds(UnityEngine.Random.Range(min, max)));

        spe.ChangeState(new ChaseState(spe));
    }