Exemplo n.º 1
0
        /// <summary>
        /// Gets teleport destinations via all spawn points.
        /// </summary>
        /// <returns>TeleportInfo, with name, position and object</returns>
        public static IEnumerable <TeleportInfo> GetSpawnDestinations()
        {
            var placeGameObjects = UnityEngine.Object.FindObjectsOfType(typeof(SpawnPoint));

            if (placeGameObjects == null)            //If list of SpawnPoints is empty dont run rest of code.
            {
                yield break;
            }

            foreach (SpawnPoint place in placeGameObjects)
            {
                var nameOfPlace = place.name;

                if (nameOfPlace.Length == 0)
                {
                    nameOfPlace = "Has No Name";
                }

                var placePosition = place.transform.position;                // Only way to get position of this object.

                var teleportInfo = new TeleportInfo(nameOfPlace, placePosition.CutToInt(), place.gameObject);

                yield return(teleportInfo);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets teleport destinations via all security cameras.
        /// For AI use only
        /// </summary>
        /// <returns>TeleportInfo, with name, position and object</returns>
        public static IEnumerable <TeleportInfo> GetCameraDestinations()
        {
            if (PlayerManager.LocalPlayer.TryGetComponent <AiPlayer>(out var aiPlayer) == false)
            {
                yield break;
            }

            var securityCameras = UnityEngine.Object.FindObjectsOfType <SecurityCamera>();

            if (securityCameras == null)
            {
                yield break;
            }

            foreach (var camera in securityCameras)
            {
                if (aiPlayer.OpenNetworks.Contains(camera.SecurityCameraChannel) == false)
                {
                    continue;
                }

                var placePosition = camera.transform.position;                // Only way to get position of this object.

                var name = camera.CameraName + " - SecCam";

                if (camera.CameraActive == false)
                {
                    name += " INACTIVE";
                }

                var teleportInfo = new TeleportInfo(name, placePosition.CutToInt(), camera.gameObject);

                yield return(teleportInfo);
            }
        }
Exemplo n.º 3
0
        public static void TeleportLocalGhostTo(TeleportInfo teleportInfo)
        {
            var latestPosition = teleportInfo.gameObject.transform.position;
            var playerPosition = PlayerManager.LocalPlayer.gameObject.GetComponent <RegisterTile>().WorldPositionClient; //Finds current player coords

            if (latestPosition != playerPosition)                                                                        //Spam Prevention
            {
                TeleportLocalGhostTo(latestPosition);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets teleport destinations for all objects with PlayerScript.
        /// </summary>
        /// <returns>TeleportInfo, with name, position and object</returns>
        public static IEnumerable <TeleportInfo> GetMobDestinations()
        {
            var playerBodies = UnityEngine.Object.FindObjectsOfType(typeof(PlayerScript));

            if (playerBodies == null)            //If list of PlayerScripts is empty dont run rest of code.
            {
                yield break;
            }

            foreach (PlayerScript player in playerBodies)
            {
                if (player == PlayerManager.LocalPlayerScript)
                {
                    continue;
                }

                //Gets Name of Player
                string nameOfObject = player.name;

                if (player.gameObject.name.Length == 0 || player.gameObject.name == null)
                {
                    nameOfObject = "Spectator";
                }

                string status;
                //Gets Status of Player
                if (player.IsGhost)
                {
                    status = "(Ghost)";
                }
                else if (!player.IsGhost & player.playerHealth.IsDead)
                {
                    status = "(Dead)";
                }
                else if (!player.IsGhost)
                {
                    status = "(Alive)";
                }
                else
                {
                    status = "(Cant tell if Dead/Alive or Ghost)";
                }

                //Gets Position of Player
                var tile = player.gameObject.GetComponent <RegisterTile>();

                var teleportInfo = new TeleportInfo(nameOfObject + "\n" + status, tile.WorldPositionClient, player.gameObject);

                yield return(teleportInfo);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets teleport destinations via all players in security camera vision.
        /// For AI use only
        /// </summary>
        /// <returns>TeleportInfo, with name, position and object</returns>
        public static IEnumerable <TeleportInfo> GetCameraTrackPlayerDestinations()
        {
            if (PlayerManager.LocalPlayer.TryGetComponent <AiPlayer>(out var aiPlayer) == false)
            {
                yield break;
            }

            //Check for players
            var playerScripts = UnityEngine.Object.FindObjectsOfType <PlayerScript>();

            if (playerScripts != null)
            {
                foreach (var playerScript in playerScripts)
                {
                    if (aiPlayer.CanSeeObject(playerScript.gameObject) == null)
                    {
                        continue;
                    }

                    var placePosition = playerScript.transform.position;                    // Only way to get position of this object.

                    var teleportInfo = new TeleportInfo(playerScript.gameObject.ExpensiveName(), placePosition.CutToInt(), playerScript.gameObject);

                    yield return(teleportInfo);
                }
            }

            //Check for mobs
            var mobScripts = UnityEngine.Object.FindObjectsOfType <MobAI>();

            if (mobScripts != null)
            {
                foreach (var mobAI in mobScripts)
                {
                    if (aiPlayer.CanSeeObject(mobAI.gameObject) == null)
                    {
                        continue;
                    }

                    var placePosition = mobAI.transform.position;                    // Only way to get position of this object.

                    var teleportInfo = new TeleportInfo(mobAI.gameObject.ExpensiveName(), placePosition.CutToInt(), mobAI.gameObject);

                    yield return(teleportInfo);
                }
            }
        }