Ejemplo n.º 1
0
        private void Awake()
        {
            rightSensor.enabled = false;
            leftSensor.enabled  = false;

            audioPlayer       = GetComponent <AudioSource>();
            rigid             = GetComponent <Rigidbody>();
            waypointNavigator = GetComponent <WaypointNavigator>();

            showStopSignals(false);
            updateSignalsStatus(true);
        }
Ejemplo n.º 2
0
        void setupNavigator(WaypointNavigator navigator, WaypointData waypoint)
        {
            if (waypoint == null)
            {
                return;
            }

            // make sure this waypoint isn't reused for spawning more entities
            waypoint.occupied = true;

            Vector3 spawnPosition = waypoint.centerPosition;

            spawnPosition.y += 0.5f;

            navigator.gameObject.transform.position = spawnPosition;

            // Point spawned entities looking at their next waypoint
            Vector3 lookPos = spawnPosition;

            if (waypoint.nextWaypoint != null)
            {
                lookPos = waypoint.nextWaypoint.centerPosition;
            }
            else if (waypoint.previousWaypoint != null)
            {
                lookPos = waypoint.previousWaypoint.centerPosition;
            }

            lookPos.y = navigator.gameObject.transform.position.y;
            navigator.gameObject.transform.LookAt(lookPos);


            int direction;

            if (allowedDirection == Direction.Both)
            {
                direction = Mathf.RoundToInt(Random.Range(0f, 1f));
            }
            else
            {
                direction = (int)allowedDirection;
            }

            navigator.init(direction, waypoint);
        }
Ejemplo n.º 3
0
 private void Awake()
 {
     animator          = GetComponent <Animator>();
     waypointNavigator = GetComponent <WaypointNavigator>();
 }