コード例 #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));
    }