コード例 #1
0
    private void Awake()
    {
        chasingState   = new ChasingState(this);
        idleState      = new EnemyIdleState(this);
        returningState = new ReturningState(this);
        attackingState = new AttackingState(this);
        visiblePlayers = new List <GameObject>();

        returnPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z);

        eyes         = transform.FindChild("Eyes");
        health       = GetComponent <EnemyHealth>();
        attack       = GetComponent <EnemyAttack>();
        sounds       = GetComponent <EnemySoundController>();
        animator     = GetComponent <EnemyAnimationController>();
        navMeshAgent = GetComponent <NavMeshAgent>();

        isTargetting = false;

        if (transform.parent.CompareTag("EnemyMob"))
        {
            mobKnowledge = GetComponentInParent <EnemyMobKnowledge>();
        }

        tm = GameObject.FindWithTag("TeamManager").GetComponent <TeamManager>();
    }
コード例 #2
0
ファイル: Pet.cs プロジェクト: xenonsin/HackThePlanet2015
        void Returning()
        {
            switch (_currentReturningState)
            {
                case ReturningState.NONE:
                    break;
                case ReturningState.LOOKING_FOR_TARGET:
                    targetLocation = RandomPointInPlayerSphere();
                    _currentReturningState = ReturningState.MOVING;

                    break;
                case ReturningState.MOVING:
                    transform.position = Vector3.MoveTowards(transform.position, targetLocation,Time.deltaTime / movementRate);
                    if (ReachedTarget())
                        _currentReturningState = ReturningState.REACHED_TARGET;
                    break;
                case ReturningState.REACHED_TARGET:
                    _currentAIState = AIStates.DECIDING;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
コード例 #3
0
ファイル: Pet.cs プロジェクト: xenonsin/HackThePlanet2015
 void ResetAIStates()
 {
     idleTimeLeft = Random.Range(5, 10);
     _currentReturningState = ReturningState.NONE;
     _currentIdleState = IdleState.NONE;
     _currentRoamingState = RoamingState.NONE;
     _currentPlayingState = PlayingState.NONE;
 }
コード例 #4
0
ファイル: Pet.cs プロジェクト: xenonsin/HackThePlanet2015
        void Deciding()
        {
            ResetAIStates();

            if (IsOutOfPlayerLimits())
            {
                _currentAIState = AIStates.RETURNING;
                if (_currentReturningState == ReturningState.NONE)
                    _currentReturningState = ReturningState.LOOKING_FOR_TARGET;
            }
            else
            {
                if (Random.value < 0.5f)
                {
                    _currentAIState = AIStates.IDLING;
                    if (_currentIdleState == IdleState.NONE)
                        _currentIdleState = IdleState.DOIN_MY_THANG;
                }
                else
                {
                    _currentAIState = AIStates.ROAMING;
                    if (_currentRoamingState == RoamingState.NONE)
                        _currentRoamingState = RoamingState.LOOKING_FOR_TARGET;
                }
            }
        }