コード例 #1
0
        // 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);
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
ファイル: World.cs プロジェクト: SweetTsunami/GRIPDigital
 /// <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);
 }
コード例 #4
0
 /// <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);
 }