コード例 #1
0
        private void SelectNewPath()
        {
            GhostPath oldPath = path;

            path = GetRandomPath();
            oldPath.SetUsed(false);
            debugger.Info("has selected a new path: " + path.transform.name);
        }
コード例 #2
0
        /// <summary>
        /// Randomly selects a GhostPath to use as the waypoint path from the paths in the scene.
        /// Selects a path that is currently not being used by another ghost.
        /// </summary>
        private GhostPath GetRandomPath()
        {
            List <GhostPath>        allPaths    = new List <GhostPath>(GameObject.FindObjectsOfType <GhostPath>());
            IEnumerable <GhostPath> unusedPaths = allPaths.Where(x => !x.isUsed());
            GhostPath path = unusedPaths.ElementAt(Random.Range(0, unusedPaths.Count()));

            path.SetUsed(true);
            return(path);
        }
コード例 #3
0
        private void Start()
        {
            rb           = GetComponent <Rigidbody>();
            debugger     = GetComponent <Debugger>();
            audioManager = AudioManager.instance;

            originalPosition = transform.position;

            path = GetRandomPath();
            debugger.Info("has selected path: " + path.gameObject.name);

            ShowBody();
        }