// Use this for initialization
        protected virtual void Start()
        {
            model       = GetComponent <GenericShipModel>();
            view        = GetComponent <GenericShipView>();
            _myDetector = GetComponent <SphereDetector>();

            if (_myDetector == null)
            {
                Debug.LogError("No Detector attached to " + gameObject + "!");
            }

            // Check if initial state is specified. If not, and there is no waypoint manager, then begin in square patrol mode.
            // Otherwise, begin in waypoint patrol mode.
            if (_startState == GenericShipAiState.Idle && _waypointManager == null)
            {
                _currentState = GenericShipAiState.SquarePatrolling;
            }
            if (_startState == GenericShipAiState.Idle && _waypointManager != null)
            {
                _currentState = GenericShipAiState.WaypointPatrolling;
            }

            // If we are patrolling and have no waypoints, then begin patrolling in square formation.
            if (_currentState == GenericShipAiState.SquarePatrolling)
            {
                StartCoroutine(SquareFormationPatrol());
            }

            // Begin custom update loop for AI.
            InvokeRepeating(nameof(UpdateAiController), 0.0f, _behaviorChangeRate);
        }
Esempio n. 2
0
        // Use this for initialization
        protected virtual void Start()
        {
            myShipModel = GetComponent<GenericShipModel>();
            myShipView = GetComponent<GenericShipView>();
            myDetector = GetComponent<Detector>();
            myController = GetComponent<BaseAIController>();

            if (myDetector == null)
            {
                Debug.LogError("No Detector attached to " + gameObject + "!");
            }

            if (myController == null)
            {
                Debug.LogError("No AI Controller attached to " + gameObject + "!");
            }

            myController.SetAIControl(true);
            myShipView.setAIControlled(true);

            // Begin custom update loop for AI.
            InvokeRepeating("UpdateAIController", 0.0f, behaviorChangeRate);
        }
 protected virtual void Start()
 {
     myShip = GetComponent<GenericShipView>();
 }