// 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); }
/// <summary> /// Sets up the player ship data. /// </summary> virtual protected void Init() { health = maxHealth; shields = maxShields; myDetector = GetComponent <SphereDetector>(); myFaction = GetComponent <Faction>(); if (myFaction != null) { if (myShooter != null) { myShooter.SetWeaponFaction(myFaction.FactionName); } if (mySecondaryShooter != null) { mySecondaryShooter.SetWeaponFaction(myFaction.FactionName); } } // Set the current position as the desired destination //SetDestinationInput(transform.position); }
/// <summary> /// Get SphereDetector and start repeating the PopulateWorld (running it in Update() drains FPS like crazy) /// </summary> private void Start() { sphereDetector = GetComponent <SphereDetector>(); InvokeRepeating("PopulateWorld", 0, 1); }
/// <summary> /// Get SphereDetector and start repeating the GenerateChunkPositions (running it in Update() drains FPS like crazy) /// </summary> private void Start() { sphereDetector = GetComponent <SphereDetector>(); InvokeRepeating("HandleChunkPositionsLists", 0, 1); }