first commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3bc8abbc245e39e792c21645e565b03
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,664 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public static class Lab5SceneBuilder
|
||||
{
|
||||
private const string SceneDirectory = "Assets/Scenes";
|
||||
private const string ScenePath = SceneDirectory + "/Lab5_StealthMechanics.unity";
|
||||
private const string MaterialDirectory = "Assets/Materials/Lab5";
|
||||
|
||||
private sealed class BuildContext
|
||||
{
|
||||
public Font font;
|
||||
public Material floorMaterial;
|
||||
public Material wallMaterial;
|
||||
public Material coverMaterial;
|
||||
public Material enemyMaterial;
|
||||
public Material playerMaterial;
|
||||
public Material zoneMaterial;
|
||||
public Material visionMaterial;
|
||||
public int playerLayer;
|
||||
public int coverLayer;
|
||||
public int obstacleLayer;
|
||||
public int visionLayer;
|
||||
public LayerMask obstacleMask;
|
||||
public LayerMask targetMask;
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Lab5/Create Full Test Scene")]
|
||||
public static void CreateFullTestScene()
|
||||
{
|
||||
// Builder пересобирает лабораторную с нуля, чтобы не требовать ручной настройки в инспекторе.
|
||||
EnsureFolders();
|
||||
EnsureTag("Player");
|
||||
|
||||
BuildContext context = new BuildContext
|
||||
{
|
||||
playerLayer = EnsureLayer("Player", 8),
|
||||
coverLayer = EnsureLayer("Cover", 9),
|
||||
obstacleLayer = EnsureLayer("Obstacle", 10),
|
||||
visionLayer = EnsureLayer("Vision", 11)
|
||||
};
|
||||
|
||||
context.obstacleMask = (1 << context.coverLayer) | (1 << context.obstacleLayer);
|
||||
context.targetMask = 1 << context.playerLayer;
|
||||
context.font = LoadBuiltinFont();
|
||||
context.floorMaterial = GetOrCreateOpaqueMaterial(MaterialDirectory + "/Lab5_Floor.mat", new Color(0.21f, 0.24f, 0.28f));
|
||||
context.wallMaterial = GetOrCreateOpaqueMaterial(MaterialDirectory + "/Lab5_Wall.mat", new Color(0.63f, 0.65f, 0.69f));
|
||||
context.coverMaterial = GetOrCreateOpaqueMaterial(MaterialDirectory + "/Lab5_Cover.mat", new Color(0.48f, 0.31f, 0.2f));
|
||||
context.enemyMaterial = GetOrCreateOpaqueMaterial(MaterialDirectory + "/Lab5_Enemy.mat", new Color(0.78f, 0.2f, 0.18f));
|
||||
context.playerMaterial = GetOrCreateOpaqueMaterial(MaterialDirectory + "/Lab5_Player.mat", new Color(0.15f, 0.46f, 0.9f));
|
||||
context.zoneMaterial = GetOrCreateTransparentMaterial(MaterialDirectory + "/Lab5_Zone.mat", new Color(0.15f, 0.95f, 0.95f, 0.3f));
|
||||
context.visionMaterial = GetOrCreateTransparentMaterial(MaterialDirectory + "/Lab5_Vision.mat", new Color(0.2f, 0.95f, 0.35f, 0.22f));
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
Scene scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
|
||||
|
||||
GameObject sceneRoot = new GameObject("Lab5_Root");
|
||||
GameObject environmentRoot = new GameObject("Environment");
|
||||
environmentRoot.transform.SetParent(sceneRoot.transform);
|
||||
GameObject systemsRoot = new GameObject("Systems");
|
||||
systemsRoot.transform.SetParent(sceneRoot.transform);
|
||||
GameObject patrolRoot = new GameObject("PatrolRoutes");
|
||||
patrolRoot.transform.SetParent(sceneRoot.transform);
|
||||
GameObject enemiesRoot = new GameObject("Enemies");
|
||||
enemiesRoot.transform.SetParent(sceneRoot.transform);
|
||||
|
||||
CreateLighting();
|
||||
CreateEnvironment(context, environmentRoot.transform);
|
||||
|
||||
GameObject noiseManager = new GameObject("NoiseManager");
|
||||
noiseManager.transform.SetParent(systemsRoot.transform);
|
||||
noiseManager.AddComponent<NoiseManager>();
|
||||
|
||||
GameObject player = CreatePlayer(context, sceneRoot.transform);
|
||||
CreateUI(context, sceneRoot.transform, player);
|
||||
CreateEnemies(context, enemiesRoot.transform, patrolRoot.transform, player);
|
||||
|
||||
bool navMeshBaked = TryBakeNavMesh();
|
||||
EditorSceneManager.MarkSceneDirty(scene);
|
||||
EditorSceneManager.SaveScene(scene, ScenePath);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
Selection.activeObject = AssetDatabase.LoadAssetAtPath<SceneAsset>(ScenePath);
|
||||
EditorUtility.DisplayDialog(
|
||||
"Lab 5",
|
||||
navMeshBaked
|
||||
? "Сцена создана и сохранена. NavMesh был перестроен автоматически."
|
||||
: "Сцена создана и сохранена. Если враги не встают на NavMesh, откройте Window -> AI -> Navigation и нажмите Bake.",
|
||||
"OK");
|
||||
}
|
||||
|
||||
private static void CreateLighting()
|
||||
{
|
||||
GameObject lightObject = new GameObject("Directional Light");
|
||||
Light directionalLight = lightObject.AddComponent<Light>();
|
||||
directionalLight.type = LightType.Directional;
|
||||
directionalLight.intensity = 1.15f;
|
||||
lightObject.transform.rotation = Quaternion.Euler(50f, -30f, 0f);
|
||||
|
||||
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Flat;
|
||||
RenderSettings.ambientLight = new Color(0.45f, 0.47f, 0.5f);
|
||||
}
|
||||
|
||||
private static void CreateEnvironment(BuildContext context, Transform parent)
|
||||
{
|
||||
GameObject floor = GameObject.CreatePrimitive(PrimitiveType.Plane);
|
||||
floor.name = "Floor";
|
||||
floor.transform.SetParent(parent);
|
||||
floor.transform.position = Vector3.zero;
|
||||
floor.transform.localScale = new Vector3(4f, 1f, 4f);
|
||||
floor.GetComponent<Renderer>().sharedMaterial = context.floorMaterial;
|
||||
floor.layer = LayerMask.NameToLayer("Default");
|
||||
SetNavigationStatic(floor);
|
||||
|
||||
CreateWall(context, parent, "NorthWall", new Vector3(0f, 1.5f, 20f), new Vector3(40f, 3f, 1f));
|
||||
CreateWall(context, parent, "SouthWall", new Vector3(0f, 1.5f, -20f), new Vector3(40f, 3f, 1f));
|
||||
CreateWall(context, parent, "EastWall", new Vector3(20f, 1.5f, 0f), new Vector3(1f, 3f, 40f));
|
||||
CreateWall(context, parent, "WestWall", new Vector3(-20f, 1.5f, 0f), new Vector3(1f, 3f, 40f));
|
||||
|
||||
CreateWall(context, parent, "LeftDividerA", new Vector3(-5f, 1.5f, -12f), new Vector3(1f, 3f, 12f));
|
||||
CreateWall(context, parent, "LeftDividerB", new Vector3(-5f, 1.5f, 3f), new Vector3(1f, 3f, 6f));
|
||||
CreateWall(context, parent, "LeftDividerC", new Vector3(-5f, 1.5f, 14f), new Vector3(1f, 3f, 8f));
|
||||
CreateWall(context, parent, "RightDividerA", new Vector3(5f, 1.5f, -14f), new Vector3(1f, 3f, 8f));
|
||||
CreateWall(context, parent, "RightDividerB", new Vector3(5f, 1.5f, -3f), new Vector3(1f, 3f, 6f));
|
||||
CreateWall(context, parent, "RightDividerC1", new Vector3(5f, 1.5f, 6f), new Vector3(1f, 3f, 8f));
|
||||
CreateWall(context, parent, "RightDividerC2", new Vector3(5f, 1.5f, 16f), new Vector3(1f, 3f, 8f));
|
||||
|
||||
CreateWall(context, parent, "LeftRoomTopA", new Vector3(-15f, 1.5f, 7f), new Vector3(8f, 3f, 1f));
|
||||
CreateWall(context, parent, "LeftRoomTopB", new Vector3(-7f, 1.5f, 7f), new Vector3(2f, 3f, 1f));
|
||||
CreateWall(context, parent, "LeftRoomBottomA", new Vector3(-15f, 1.5f, -7f), new Vector3(8f, 3f, 1f));
|
||||
CreateWall(context, parent, "LeftRoomBottomB", new Vector3(-7f, 1.5f, -7f), new Vector3(2f, 3f, 1f));
|
||||
CreateWall(context, parent, "RightRoomTopA", new Vector3(8f, 1.5f, 7f), new Vector3(4f, 3f, 1f));
|
||||
CreateWall(context, parent, "RightRoomTopB", new Vector3(16f, 1.5f, 7f), new Vector3(6f, 3f, 1f));
|
||||
CreateWall(context, parent, "RightRoomBottomA", new Vector3(8f, 1.5f, -7f), new Vector3(4f, 3f, 1f));
|
||||
CreateWall(context, parent, "RightRoomBottomB", new Vector3(16f, 1.5f, -7f), new Vector3(6f, 3f, 1f));
|
||||
CreateCover(context, parent, "CenterBarrier", new Vector3(0f, 1f, 0f), new Vector3(2.5f, 2f, 2f));
|
||||
|
||||
CreateCover(context, parent, "CoverBox_A", new Vector3(-10f, 1f, -3f), new Vector3(2f, 2f, 2f));
|
||||
CreateCover(context, parent, "CoverBox_B", new Vector3(-1.5f, 1f, -10f), new Vector3(2f, 2f, 2f));
|
||||
CreateCover(context, parent, "CoverBox_C", new Vector3(2f, 1f, 5f), new Vector3(2.5f, 2f, 2f));
|
||||
CreateCover(context, parent, "CoverWall_A", new Vector3(10f, 1.25f, 2f), new Vector3(3.5f, 2.5f, 1f));
|
||||
CreateCover(context, parent, "CoverWall_B", new Vector3(13f, 1f, 13f), new Vector3(2f, 2f, 2f));
|
||||
CreateCover(context, parent, "CoverBox_D", new Vector3(-15f, 1f, 14f), new Vector3(2f, 2f, 2f));
|
||||
|
||||
GameObject exitZone = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
|
||||
exitZone.name = "ExitZone";
|
||||
exitZone.transform.SetParent(parent);
|
||||
exitZone.transform.position = new Vector3(15f, 0.2f, 15f);
|
||||
exitZone.transform.localScale = new Vector3(2f, 0.2f, 2f);
|
||||
exitZone.GetComponent<Renderer>().sharedMaterial = context.zoneMaterial;
|
||||
exitZone.layer = context.visionLayer;
|
||||
exitZone.GetComponent<Collider>().isTrigger = true;
|
||||
exitZone.AddComponent<LevelExit>();
|
||||
}
|
||||
|
||||
private static GameObject CreatePlayer(BuildContext context, Transform parent)
|
||||
{
|
||||
GameObject player = new GameObject("Player");
|
||||
player.transform.SetParent(parent);
|
||||
player.transform.position = new Vector3(-15f, 0f, 14f);
|
||||
player.tag = "Player";
|
||||
player.layer = context.playerLayer;
|
||||
|
||||
CharacterController controller = player.AddComponent<CharacterController>();
|
||||
controller.height = 2f;
|
||||
controller.radius = 0.35f;
|
||||
controller.center = new Vector3(0f, 1f, 0f);
|
||||
controller.stepOffset = 0.35f;
|
||||
controller.slopeLimit = 45f;
|
||||
|
||||
GameObject body = GameObject.CreatePrimitive(PrimitiveType.Capsule);
|
||||
body.name = "PlayerBody";
|
||||
body.transform.SetParent(player.transform);
|
||||
body.transform.localPosition = new Vector3(0f, 1f, 0f);
|
||||
body.transform.localRotation = Quaternion.identity;
|
||||
body.GetComponent<Renderer>().sharedMaterial = context.playerMaterial;
|
||||
body.layer = context.playerLayer;
|
||||
UnityEngine.Object.DestroyImmediate(body.GetComponent<Collider>());
|
||||
|
||||
GameObject cameraObject = new GameObject("PlayerCamera");
|
||||
cameraObject.transform.SetParent(player.transform);
|
||||
cameraObject.transform.localPosition = new Vector3(0f, 0.8f, 0f);
|
||||
cameraObject.transform.localRotation = Quaternion.identity;
|
||||
Camera cameraComponent = cameraObject.AddComponent<Camera>();
|
||||
cameraComponent.nearClipPlane = 0.03f;
|
||||
cameraObject.AddComponent<AudioListener>();
|
||||
|
||||
SimpleFPSController fpsController = player.AddComponent<SimpleFPSController>();
|
||||
fpsController.characterController = controller;
|
||||
fpsController.playerCamera = cameraComponent;
|
||||
fpsController.walkSpeed = 4.1f;
|
||||
fpsController.runSpeed = 7.1f;
|
||||
fpsController.mouseSensitivity = 2.2f;
|
||||
|
||||
PlayerStealth stealth = player.AddComponent<PlayerStealth>();
|
||||
stealth.characterController = controller;
|
||||
stealth.fpsController = fpsController;
|
||||
stealth.playerCamera = cameraComponent;
|
||||
|
||||
player.AddComponent<PlayerHealth>();
|
||||
return player;
|
||||
}
|
||||
|
||||
private static StealthIndicator CreateUI(BuildContext context, Transform parent, GameObject player)
|
||||
{
|
||||
GameObject canvasObject = new GameObject("Canvas");
|
||||
canvasObject.transform.SetParent(parent);
|
||||
Canvas canvas = canvasObject.AddComponent<Canvas>();
|
||||
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||
CanvasScaler scaler = canvasObject.AddComponent<CanvasScaler>();
|
||||
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
|
||||
scaler.referenceResolution = new Vector2(1920f, 1080f);
|
||||
scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
|
||||
scaler.matchWidthOrHeight = 0.7f;
|
||||
canvasObject.AddComponent<GraphicRaycaster>();
|
||||
|
||||
GameObject eventSystem = new GameObject("EventSystem");
|
||||
eventSystem.transform.SetParent(parent);
|
||||
eventSystem.AddComponent<UnityEngine.EventSystems.EventSystem>();
|
||||
eventSystem.AddComponent<UnityEngine.EventSystems.StandaloneInputModule>();
|
||||
|
||||
GameObject panel = CreateUIObject("StealthPanel", canvasObject.transform, new Vector2(20f, -20f), new Vector2(390f, 240f), new Vector2(0f, 1f), new Vector2(0f, 1f));
|
||||
Image panelImage = panel.AddComponent<Image>();
|
||||
panelImage.color = new Color(0.06f, 0.08f, 0.1f, 0.62f);
|
||||
|
||||
GameObject barObject = CreateUIObject("StateBar", panel.transform, new Vector2(14f, -14f), new Vector2(362f, 18f), new Vector2(0f, 1f), new Vector2(0f, 1f));
|
||||
Image barImage = barObject.AddComponent<Image>();
|
||||
barImage.color = new Color(0.18f, 0.85f, 0.34f, 0.95f);
|
||||
|
||||
Text statusText = CreateText(context, panel.transform, "StatusText", "Скрытность: безопасно", 18, FontStyle.Bold, new Vector2(14f, -40f), new Vector2(362f, 28f));
|
||||
Text controlsText = CreateText(context, panel.transform, "ControlsText", string.Empty, 14, FontStyle.Normal, new Vector2(14f, -74f), new Vector2(362f, 94f));
|
||||
Text debugText = CreateText(context, panel.transform, "DebugText", string.Empty, 14, FontStyle.Normal, new Vector2(14f, -172f), new Vector2(362f, 56f));
|
||||
|
||||
GameObject healthPanel = CreateUIObject("HealthPanel", canvasObject.transform, new Vector2(-20f, -20f), new Vector2(190f, 42f), new Vector2(1f, 1f), new Vector2(1f, 1f));
|
||||
Image healthPanelImage = healthPanel.AddComponent<Image>();
|
||||
healthPanelImage.color = new Color(0.06f, 0.08f, 0.1f, 0.62f);
|
||||
Text healthText = CreateText(context, healthPanel.transform, "HealthText", "Здоровье: 100", 18, FontStyle.Bold, new Vector2(10f, -6f), new Vector2(170f, 28f));
|
||||
|
||||
Text gameOverText = CreateCenteredText(context, canvasObject.transform, "GameOverText", "Игрок устранен", 28, FontStyle.Bold, new Vector2(520f, 70f));
|
||||
gameOverText.color = new Color(1f, 0.2f, 0.2f, 1f);
|
||||
gameOverText.gameObject.SetActive(false);
|
||||
|
||||
StealthIndicator indicator = panel.AddComponent<StealthIndicator>();
|
||||
indicator.stateBar = barImage;
|
||||
indicator.statusText = statusText;
|
||||
indicator.controlsText = controlsText;
|
||||
indicator.debugText = debugText;
|
||||
indicator.healthText = healthText;
|
||||
indicator.gameOverText = gameOverText;
|
||||
indicator.playerStealth = player.GetComponent<PlayerStealth>();
|
||||
indicator.playerHealth = player.GetComponent<PlayerHealth>();
|
||||
return indicator;
|
||||
}
|
||||
|
||||
private static void CreateEnemies(BuildContext context, Transform enemiesParent, Transform patrolParent, GameObject player)
|
||||
{
|
||||
CreateEnemy(
|
||||
context,
|
||||
enemiesParent,
|
||||
patrolParent,
|
||||
"Enemy_LeftWing",
|
||||
new Vector3(-12f, 0f, -10f),
|
||||
new[]
|
||||
{
|
||||
new Vector3(-15f, 0f, -15f),
|
||||
new Vector3(-10f, 0f, -15f),
|
||||
new Vector3(-10f, 0f, -9f),
|
||||
new Vector3(-15f, 0f, -9f)
|
||||
},
|
||||
player);
|
||||
|
||||
CreateEnemy(
|
||||
context,
|
||||
enemiesParent,
|
||||
patrolParent,
|
||||
"Enemy_CenterCorridor",
|
||||
new Vector3(0f, 0f, -4f),
|
||||
new[]
|
||||
{
|
||||
new Vector3(-1f, 0f, -14f),
|
||||
new Vector3(-1f, 0f, -2f),
|
||||
new Vector3(1f, 0f, 6f),
|
||||
new Vector3(1f, 0f, 14f)
|
||||
},
|
||||
player);
|
||||
|
||||
CreateEnemy(
|
||||
context,
|
||||
enemiesParent,
|
||||
patrolParent,
|
||||
"Enemy_RightWing",
|
||||
new Vector3(12f, 0f, 12f),
|
||||
new[]
|
||||
{
|
||||
new Vector3(10f, 0f, 10f),
|
||||
new Vector3(15f, 0f, 10f),
|
||||
new Vector3(15f, 0f, 16f),
|
||||
new Vector3(10f, 0f, 16f)
|
||||
},
|
||||
player);
|
||||
}
|
||||
|
||||
private static EnemyStateMachine CreateEnemy(
|
||||
BuildContext context,
|
||||
Transform enemiesParent,
|
||||
Transform patrolParent,
|
||||
string enemyName,
|
||||
Vector3 position,
|
||||
Vector3[] waypointPositions,
|
||||
GameObject player)
|
||||
{
|
||||
GameObject enemyRoot = new GameObject(enemyName);
|
||||
enemyRoot.transform.SetParent(enemiesParent);
|
||||
enemyRoot.transform.position = position;
|
||||
enemyRoot.layer = LayerMask.NameToLayer("Default");
|
||||
|
||||
CapsuleCollider capsuleCollider = enemyRoot.AddComponent<CapsuleCollider>();
|
||||
capsuleCollider.center = new Vector3(0f, 1f, 0f);
|
||||
capsuleCollider.height = 2f;
|
||||
capsuleCollider.radius = 0.4f;
|
||||
|
||||
GameObject body = GameObject.CreatePrimitive(PrimitiveType.Capsule);
|
||||
body.name = "Body";
|
||||
body.transform.SetParent(enemyRoot.transform);
|
||||
body.transform.localPosition = new Vector3(0f, 1f, 0f);
|
||||
body.transform.localRotation = Quaternion.identity;
|
||||
body.GetComponent<Renderer>().sharedMaterial = context.enemyMaterial;
|
||||
UnityEngine.Object.DestroyImmediate(body.GetComponent<Collider>());
|
||||
|
||||
NavMeshAgent agent = enemyRoot.AddComponent<NavMeshAgent>();
|
||||
agent.radius = 0.35f;
|
||||
agent.height = 2f;
|
||||
agent.baseOffset = 0f;
|
||||
agent.speed = 2.2f;
|
||||
agent.angularSpeed = 360f;
|
||||
agent.acceleration = 12f;
|
||||
agent.stoppingDistance = 0.1f;
|
||||
agent.autoBraking = true;
|
||||
|
||||
EnemyStateMachine stateMachine = enemyRoot.AddComponent<EnemyStateMachine>();
|
||||
stateMachine.agent = agent;
|
||||
stateMachine.patrolSpeed = 2.2f;
|
||||
stateMachine.suspicionSpeed = 2.9f;
|
||||
stateMachine.alertSpeed = 4.1f;
|
||||
stateMachine.hearingRange = 14f;
|
||||
stateMachine.suspicionWaitDuration = 2.5f;
|
||||
stateMachine.captureDistance = 1.7f;
|
||||
|
||||
EnemyVision vision = enemyRoot.AddComponent<EnemyVision>();
|
||||
vision.stateMachine = stateMachine;
|
||||
vision.player = player.transform;
|
||||
vision.viewRadius = 13.5f;
|
||||
vision.viewAngle = 70f;
|
||||
vision.eyeHeight = 1.4f;
|
||||
vision.obstacleMask = context.obstacleMask;
|
||||
vision.targetMask = context.targetMask;
|
||||
|
||||
EnemyVisionVisualizer visualizer = enemyRoot.AddComponent<EnemyVisionVisualizer>();
|
||||
visualizer.vision = vision;
|
||||
visualizer.stateMachine = stateMachine;
|
||||
visualizer.visionMaterialTemplate = context.visionMaterial;
|
||||
|
||||
stateMachine.vision = vision;
|
||||
stateMachine.patrolPoints = CreateWaypoints(enemyName + "_Route", patrolParent, waypointPositions);
|
||||
|
||||
return stateMachine;
|
||||
}
|
||||
|
||||
private static Transform[] CreateWaypoints(string routeName, Transform patrolParent, Vector3[] positions)
|
||||
{
|
||||
GameObject routeRoot = new GameObject(routeName);
|
||||
routeRoot.transform.SetParent(patrolParent);
|
||||
|
||||
Transform[] waypoints = new Transform[positions.Length];
|
||||
for (int i = 0; i < positions.Length; i++)
|
||||
{
|
||||
GameObject waypoint = new GameObject("Waypoint_" + i);
|
||||
waypoint.transform.SetParent(routeRoot.transform);
|
||||
waypoint.transform.position = positions[i];
|
||||
waypoints[i] = waypoint.transform;
|
||||
}
|
||||
|
||||
return waypoints;
|
||||
}
|
||||
|
||||
private static GameObject CreateWall(BuildContext context, Transform parent, string name, Vector3 position, Vector3 scale)
|
||||
{
|
||||
GameObject wall = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
wall.name = name;
|
||||
wall.transform.SetParent(parent);
|
||||
wall.transform.position = position;
|
||||
wall.transform.localScale = scale;
|
||||
wall.GetComponent<Renderer>().sharedMaterial = context.wallMaterial;
|
||||
wall.layer = context.obstacleLayer;
|
||||
SetNavigationStatic(wall);
|
||||
return wall;
|
||||
}
|
||||
|
||||
private static GameObject CreateCover(BuildContext context, Transform parent, string name, Vector3 position, Vector3 scale)
|
||||
{
|
||||
GameObject cover = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
cover.name = name;
|
||||
cover.transform.SetParent(parent);
|
||||
cover.transform.position = position;
|
||||
cover.transform.localScale = scale;
|
||||
cover.GetComponent<Renderer>().sharedMaterial = context.coverMaterial;
|
||||
cover.layer = context.coverLayer;
|
||||
cover.AddComponent<CoverChecker>();
|
||||
SetNavigationStatic(cover);
|
||||
return cover;
|
||||
}
|
||||
|
||||
private static GameObject CreateUIObject(string name, Transform parent, Vector2 anchoredPosition, Vector2 sizeDelta, Vector2 anchorMin, Vector2 anchorMax)
|
||||
{
|
||||
GameObject gameObject = new GameObject(name, typeof(RectTransform));
|
||||
gameObject.transform.SetParent(parent, false);
|
||||
RectTransform rectTransform = gameObject.GetComponent<RectTransform>();
|
||||
rectTransform.anchorMin = anchorMin;
|
||||
rectTransform.anchorMax = anchorMax;
|
||||
rectTransform.pivot = new Vector2(anchorMin.x, anchorMax.y);
|
||||
rectTransform.anchoredPosition = anchoredPosition;
|
||||
rectTransform.sizeDelta = sizeDelta;
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
private static Text CreateText(
|
||||
BuildContext context,
|
||||
Transform parent,
|
||||
string name,
|
||||
string text,
|
||||
int fontSize,
|
||||
FontStyle fontStyle,
|
||||
Vector2 anchoredPosition,
|
||||
Vector2 sizeDelta)
|
||||
{
|
||||
GameObject textObject = CreateUIObject(name, parent, anchoredPosition, sizeDelta, new Vector2(0f, 1f), new Vector2(0f, 1f));
|
||||
Text uiText = textObject.AddComponent<Text>();
|
||||
uiText.font = context.font;
|
||||
uiText.text = text;
|
||||
uiText.fontSize = fontSize;
|
||||
uiText.fontStyle = fontStyle;
|
||||
uiText.alignment = TextAnchor.UpperLeft;
|
||||
uiText.horizontalOverflow = HorizontalWrapMode.Wrap;
|
||||
uiText.verticalOverflow = VerticalWrapMode.Overflow;
|
||||
uiText.color = Color.white;
|
||||
return uiText;
|
||||
}
|
||||
|
||||
private static Text CreateCenteredText(
|
||||
BuildContext context,
|
||||
Transform parent,
|
||||
string name,
|
||||
string text,
|
||||
int fontSize,
|
||||
FontStyle fontStyle,
|
||||
Vector2 sizeDelta)
|
||||
{
|
||||
GameObject textObject = new GameObject(name, typeof(RectTransform));
|
||||
textObject.transform.SetParent(parent, false);
|
||||
RectTransform rectTransform = textObject.GetComponent<RectTransform>();
|
||||
rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
|
||||
rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
|
||||
rectTransform.pivot = new Vector2(0.5f, 0.5f);
|
||||
rectTransform.anchoredPosition = Vector2.zero;
|
||||
rectTransform.sizeDelta = sizeDelta;
|
||||
|
||||
Text uiText = textObject.AddComponent<Text>();
|
||||
uiText.font = context.font;
|
||||
uiText.text = text;
|
||||
uiText.fontSize = fontSize;
|
||||
uiText.fontStyle = fontStyle;
|
||||
uiText.alignment = TextAnchor.MiddleCenter;
|
||||
uiText.horizontalOverflow = HorizontalWrapMode.Wrap;
|
||||
uiText.verticalOverflow = VerticalWrapMode.Overflow;
|
||||
uiText.color = Color.white;
|
||||
return uiText;
|
||||
}
|
||||
|
||||
private static Material GetOrCreateOpaqueMaterial(string path, Color color)
|
||||
{
|
||||
Material material = AssetDatabase.LoadAssetAtPath<Material>(path);
|
||||
if (material == null)
|
||||
{
|
||||
material = new Material(Shader.Find("Standard"));
|
||||
AssetDatabase.CreateAsset(material, path);
|
||||
}
|
||||
|
||||
material.shader = Shader.Find("Standard");
|
||||
material.color = color;
|
||||
EditorUtility.SetDirty(material);
|
||||
return material;
|
||||
}
|
||||
|
||||
private static Font LoadBuiltinFont()
|
||||
{
|
||||
Font font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
|
||||
if (font != null)
|
||||
{
|
||||
return font;
|
||||
}
|
||||
|
||||
font = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
||||
if (font != null)
|
||||
{
|
||||
return font;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Не удалось загрузить встроенный шрифт Unity.");
|
||||
}
|
||||
|
||||
private static Material GetOrCreateTransparentMaterial(string path, Color color)
|
||||
{
|
||||
Material material = AssetDatabase.LoadAssetAtPath<Material>(path);
|
||||
if (material == null)
|
||||
{
|
||||
material = new Material(Shader.Find("Standard"));
|
||||
AssetDatabase.CreateAsset(material, path);
|
||||
}
|
||||
|
||||
material.shader = Shader.Find("Standard");
|
||||
material.SetFloat("_Mode", 3f);
|
||||
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
|
||||
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
||||
material.SetInt("_ZWrite", 0);
|
||||
material.DisableKeyword("_ALPHATEST_ON");
|
||||
material.EnableKeyword("_ALPHABLEND_ON");
|
||||
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
|
||||
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
|
||||
material.color = color;
|
||||
EditorUtility.SetDirty(material);
|
||||
return material;
|
||||
}
|
||||
|
||||
private static void EnsureFolders()
|
||||
{
|
||||
Directory.CreateDirectory(SceneDirectory);
|
||||
Directory.CreateDirectory("Assets/Scripts");
|
||||
Directory.CreateDirectory("Assets/Editor");
|
||||
Directory.CreateDirectory("Assets/Materials");
|
||||
Directory.CreateDirectory(MaterialDirectory);
|
||||
}
|
||||
|
||||
private static void EnsureTag(string tagName)
|
||||
{
|
||||
SerializedObject tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
|
||||
SerializedProperty tagsProperty = tagManager.FindProperty("tags");
|
||||
|
||||
for (int i = 0; i < tagsProperty.arraySize; i++)
|
||||
{
|
||||
SerializedProperty existingTag = tagsProperty.GetArrayElementAtIndex(i);
|
||||
if (existingTag.stringValue == tagName)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tagsProperty.InsertArrayElementAtIndex(tagsProperty.arraySize);
|
||||
tagsProperty.GetArrayElementAtIndex(tagsProperty.arraySize - 1).stringValue = tagName;
|
||||
tagManager.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private static int EnsureLayer(string layerName, int preferredIndex)
|
||||
{
|
||||
int existingLayer = LayerMask.NameToLayer(layerName);
|
||||
if (existingLayer >= 0)
|
||||
{
|
||||
return existingLayer;
|
||||
}
|
||||
|
||||
SerializedObject tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
|
||||
SerializedProperty layersProperty = tagManager.FindProperty("layers");
|
||||
|
||||
if (preferredIndex >= 8 && preferredIndex < layersProperty.arraySize)
|
||||
{
|
||||
SerializedProperty preferredLayer = layersProperty.GetArrayElementAtIndex(preferredIndex);
|
||||
if (string.IsNullOrEmpty(preferredLayer.stringValue) || preferredLayer.stringValue == layerName)
|
||||
{
|
||||
preferredLayer.stringValue = layerName;
|
||||
tagManager.ApplyModifiedProperties();
|
||||
return preferredIndex;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 8; i < layersProperty.arraySize; i++)
|
||||
{
|
||||
SerializedProperty layerProperty = layersProperty.GetArrayElementAtIndex(i);
|
||||
if (string.IsNullOrEmpty(layerProperty.stringValue))
|
||||
{
|
||||
layerProperty.stringValue = layerName;
|
||||
tagManager.ApplyModifiedProperties();
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogWarning("Не удалось добавить слой " + layerName + ". Будет использован Default.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void SetNavigationStatic(GameObject gameObject)
|
||||
{
|
||||
GameObjectUtility.SetStaticEditorFlags(
|
||||
gameObject,
|
||||
StaticEditorFlags.BatchingStatic |
|
||||
StaticEditorFlags.ContributeGI |
|
||||
StaticEditorFlags.NavigationStatic |
|
||||
StaticEditorFlags.OccludeeStatic |
|
||||
StaticEditorFlags.OccluderStatic);
|
||||
}
|
||||
|
||||
private static bool TryBakeNavMesh()
|
||||
{
|
||||
try
|
||||
{
|
||||
Type navMeshBuilderType = FindType("UnityEditor.AI.NavMeshBuilder");
|
||||
if (navMeshBuilderType == null)
|
||||
{
|
||||
Debug.LogWarning("UnityEditor.AI.NavMeshBuilder не найден. Враги смогут использовать fallback-движение без NavMesh.");
|
||||
return false;
|
||||
}
|
||||
|
||||
MethodInfo clearMethod = navMeshBuilderType.GetMethod("ClearAllNavMeshes", BindingFlags.Public | BindingFlags.Static);
|
||||
MethodInfo buildMethod = navMeshBuilderType.GetMethod("BuildNavMesh", BindingFlags.Public | BindingFlags.Static);
|
||||
if (buildMethod == null)
|
||||
{
|
||||
Debug.LogWarning("Метод BuildNavMesh не найден. Используйте Window -> AI -> Navigation -> Bake.");
|
||||
return false;
|
||||
}
|
||||
|
||||
clearMethod?.Invoke(null, null);
|
||||
buildMethod.Invoke(null, null);
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Debug.LogWarning("Автоматическая запечка NavMesh не удалась: " + exception.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static Type FindType(string fullName)
|
||||
{
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
for (int i = 0; i < assemblies.Length; i++)
|
||||
{
|
||||
Type type = assemblies[i].GetType(fullName);
|
||||
if (type != null)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff1a9bdc0531d36dab57be60f02aaed9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42218de20335e4957af01d9f40aec68b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f168bc65528873d739e18ec0009eb03d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,83 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Lab5_Cover
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.48, g: 0.31, b: 0.2, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b5fdb5e6d80f16858a1aa028f4feb38
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,83 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Lab5_Enemy
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.78, g: 0.2, b: 0.18, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74828097caed400189494e271903a597
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,83 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Lab5_Floor
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.21, g: 0.24, b: 0.28, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0540e5a109e41e85adba7ef31b13602
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,83 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Lab5_Player
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.15, g: 0.46, b: 0.9, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a281e4550a8624c4bb12c0c3a70774c
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Lab5_Vision
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _ALPHABLEND_ON
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 3000
|
||||
stringTagMap:
|
||||
RenderType: Transparent
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 10
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 3
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 5
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _Color: {r: 0.2, g: 0.95, b: 0.35, a: 0.22}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf4ad84858ddbbcaba30f5fbb75591a8
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,83 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Lab5_Wall
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.63, g: 0.65, b: 0.69, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ed1db8b66d46074983f534e86e0f6dd
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Lab5_Zone
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _ALPHABLEND_ON
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 3000
|
||||
stringTagMap:
|
||||
RenderType: Transparent
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 10
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 3
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 5
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _Color: {r: 0.15, g: 0.95, b: 0.95, a: 0.3}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f921b85304e44cc67bc8319d4ef52e93
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9e46986aaf4df183950a49c2ef697f0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9930d1a4f44e01237998f5d0a604b9a0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9be5facad7366ed16be183a4d61a5ddb
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 905297707969a254489ea8b8d1937a9c
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 23800000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,267 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 705507994}
|
||||
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 12
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 2
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_LightingSettings: {fileID: 0}
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &705507993
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 705507995}
|
||||
- component: {fileID: 705507994}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &705507994
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 705507993}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 8
|
||||
m_Type: 1
|
||||
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_Lightmapping: 1
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &705507995
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 705507993}
|
||||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
|
||||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
--- !u!1 &963194225
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 963194228}
|
||||
- component: {fileID: 963194227}
|
||||
- component: {fileID: 963194226}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &963194226
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 963194225}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &963194227
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 963194225}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_GateFitMode: 2
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &963194228
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 963194225}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fc0d4010bbf28b4594072e72b8655ab
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41e5c5d9c7975c3ab9888def5d7bae63
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
public class CoverChecker : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Если объект находится между врагом и игроком, он должен блокировать линию видимости.")]
|
||||
public bool blocksVision = true;
|
||||
|
||||
[Tooltip("Небольшая метка для будущих расширений механики укрытий.")]
|
||||
public float concealmentStrength = 1f;
|
||||
|
||||
public static bool IsVisionBlocked(Vector3 origin, Vector3 target, LayerMask obstacleMask)
|
||||
{
|
||||
Vector3 direction = target - origin;
|
||||
float distance = direction.magnitude;
|
||||
|
||||
if (distance <= Mathf.Epsilon)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Physics.Raycast(origin, direction.normalized, distance, obstacleMask, QueryTriggerInteraction.Ignore);
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = blocksVision ? new Color(0.2f, 0.7f, 1f, 0.5f) : new Color(1f, 0.4f, 0.2f, 0.3f);
|
||||
Collider objectCollider = GetComponent<Collider>();
|
||||
|
||||
if (objectCollider != null)
|
||||
{
|
||||
Gizmos.matrix = transform.localToWorldMatrix;
|
||||
Gizmos.DrawWireCube(objectCollider.bounds.center - transform.position, objectCollider.bounds.size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e3e939402d7fb1cc9bab1bf53ffc289
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,296 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
[RequireComponent(typeof(CapsuleCollider))]
|
||||
public class EnemyStateMachine : MonoBehaviour
|
||||
{
|
||||
public enum State
|
||||
{
|
||||
Patrol,
|
||||
Suspicion,
|
||||
Alert
|
||||
}
|
||||
|
||||
[Header("References")]
|
||||
public Transform[] patrolPoints;
|
||||
public NavMeshAgent agent;
|
||||
public EnemyVision vision;
|
||||
|
||||
[Header("Movement")]
|
||||
public float patrolSpeed = 2.2f;
|
||||
public float suspicionSpeed = 2.8f;
|
||||
public float alertSpeed = 3.8f;
|
||||
public float manualRotationSpeed = 8f;
|
||||
public float waypointTolerance = 0.7f;
|
||||
|
||||
[Header("Awareness")]
|
||||
public float hearingRange = 12f;
|
||||
public float suspicionWaitDuration = 2.5f;
|
||||
public float loseSightDelay = 1.3f;
|
||||
public float captureDistance = 1.6f;
|
||||
public int captureDamage = 10;
|
||||
public float captureCooldown = 1f;
|
||||
|
||||
public State CurrentState { get; private set; } = State.Patrol;
|
||||
public static IReadOnlyList<EnemyStateMachine> ActiveEnemies => activeEnemies;
|
||||
|
||||
private static readonly List<EnemyStateMachine> activeEnemies = new List<EnemyStateMachine>();
|
||||
|
||||
private Transform player;
|
||||
private PlayerHealth playerHealth;
|
||||
private int patrolIndex;
|
||||
private Vector3 investigationTarget;
|
||||
private Vector3 lastKnownPlayerPosition;
|
||||
private float suspicionTimer;
|
||||
private float lastSeenTime = -999f;
|
||||
private float lastCaptureTime = -999f;
|
||||
private float lastHandledNoiseTimestamp = -999f;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!activeEnemies.Contains(this))
|
||||
{
|
||||
activeEnemies.Add(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
activeEnemies.Remove(this);
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
agent = agent != null ? agent : GetComponent<NavMeshAgent>();
|
||||
vision = vision != null ? vision : GetComponent<EnemyVision>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
AcquirePlayer();
|
||||
ApplySpeedForState(CurrentState);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
AcquirePlayer();
|
||||
ListenForNoise();
|
||||
|
||||
switch (CurrentState)
|
||||
{
|
||||
case State.Patrol:
|
||||
UpdatePatrol();
|
||||
break;
|
||||
case State.Suspicion:
|
||||
UpdateSuspicion();
|
||||
break;
|
||||
case State.Alert:
|
||||
UpdateAlert();
|
||||
break;
|
||||
}
|
||||
|
||||
if (CurrentState == State.Alert && Time.time - lastSeenTime > loseSightDelay)
|
||||
{
|
||||
investigationTarget = lastKnownPlayerPosition;
|
||||
EnterState(State.Suspicion);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPlayerDetected(Vector3 playerPos)
|
||||
{
|
||||
lastKnownPlayerPosition = playerPos;
|
||||
lastSeenTime = Time.time;
|
||||
|
||||
if (CurrentState != State.Alert)
|
||||
{
|
||||
EnterState(State.Alert);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPlayerLost()
|
||||
{
|
||||
if (CurrentState == State.Alert)
|
||||
{
|
||||
investigationTarget = lastKnownPlayerPosition;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnNoiseHeard(Vector3 noisePosition)
|
||||
{
|
||||
if (CurrentState == State.Alert)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
investigationTarget = noisePosition;
|
||||
suspicionTimer = 0f;
|
||||
EnterState(State.Suspicion);
|
||||
}
|
||||
|
||||
private void UpdatePatrol()
|
||||
{
|
||||
if (patrolPoints == null || patrolPoints.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Transform targetPoint = patrolPoints[patrolIndex];
|
||||
MoveTowards(targetPoint.position, patrolSpeed);
|
||||
|
||||
if (HasReached(targetPoint.position))
|
||||
{
|
||||
patrolIndex = (patrolIndex + 1) % patrolPoints.Length;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSuspicion()
|
||||
{
|
||||
MoveTowards(investigationTarget, suspicionSpeed);
|
||||
|
||||
if (HasReached(investigationTarget))
|
||||
{
|
||||
suspicionTimer += Time.deltaTime;
|
||||
if (suspicionTimer >= suspicionWaitDuration)
|
||||
{
|
||||
suspicionTimer = 0f;
|
||||
EnterState(State.Patrol);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
suspicionTimer = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAlert()
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lastKnownPlayerPosition = player.position;
|
||||
MoveTowards(lastKnownPlayerPosition, alertSpeed);
|
||||
|
||||
if (Vector3.Distance(transform.position, player.position) <= captureDistance && Time.time >= lastCaptureTime + captureCooldown)
|
||||
{
|
||||
lastCaptureTime = Time.time;
|
||||
if (playerHealth != null)
|
||||
{
|
||||
playerHealth.TakeDamage(captureDamage);
|
||||
}
|
||||
Debug.Log("Игрок обнаружен!");
|
||||
}
|
||||
}
|
||||
|
||||
private void ListenForNoise()
|
||||
{
|
||||
NoiseManager.NoiseEvent noise = NoiseManager.GetClosestNoise(transform.position, hearingRange);
|
||||
if (noise == null || noise.timestamp <= lastHandledNoiseTimestamp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lastHandledNoiseTimestamp = noise.timestamp;
|
||||
OnNoiseHeard(noise.position);
|
||||
}
|
||||
|
||||
private void EnterState(State newState)
|
||||
{
|
||||
CurrentState = newState;
|
||||
ApplySpeedForState(newState);
|
||||
|
||||
switch (newState)
|
||||
{
|
||||
case State.Patrol:
|
||||
suspicionTimer = 0f;
|
||||
break;
|
||||
case State.Suspicion:
|
||||
suspicionTimer = 0f;
|
||||
break;
|
||||
case State.Alert:
|
||||
lastSeenTime = Time.time;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplySpeedForState(State state)
|
||||
{
|
||||
if (agent == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case State.Patrol:
|
||||
agent.speed = patrolSpeed;
|
||||
break;
|
||||
case State.Suspicion:
|
||||
agent.speed = suspicionSpeed;
|
||||
break;
|
||||
case State.Alert:
|
||||
agent.speed = alertSpeed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveTowards(Vector3 destination, float manualSpeed)
|
||||
{
|
||||
if (agent != null && agent.isActiveAndEnabled && agent.isOnNavMesh)
|
||||
{
|
||||
agent.SetDestination(destination);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback нужен на случай, если NavMesh ещё не запечён или агент не смог встать на него.
|
||||
Vector3 flatDestination = new Vector3(destination.x, transform.position.y, destination.z);
|
||||
Vector3 direction = flatDestination - transform.position;
|
||||
direction.y = 0f;
|
||||
|
||||
if (direction.sqrMagnitude <= 0.001f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 step = direction.normalized * manualSpeed * Time.deltaTime;
|
||||
transform.position += step.sqrMagnitude > direction.sqrMagnitude ? direction : step;
|
||||
|
||||
Quaternion targetRotation = Quaternion.LookRotation(direction.normalized, Vector3.up);
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * manualRotationSpeed);
|
||||
}
|
||||
|
||||
private bool HasReached(Vector3 destination)
|
||||
{
|
||||
if (agent != null && agent.isActiveAndEnabled && agent.isOnNavMesh)
|
||||
{
|
||||
if (agent.pathPending)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return agent.remainingDistance <= Mathf.Max(agent.stoppingDistance, waypointTolerance);
|
||||
}
|
||||
|
||||
Vector3 flatDestination = new Vector3(destination.x, transform.position.y, destination.z);
|
||||
return Vector3.Distance(transform.position, flatDestination) <= waypointTolerance;
|
||||
}
|
||||
|
||||
private void AcquirePlayer()
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject playerObject = GameObject.FindGameObjectWithTag("Player");
|
||||
if (playerObject == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player = playerObject.transform;
|
||||
playerHealth = playerObject.GetComponent<PlayerHealth>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1293c8e1da110e426a9118204db9badf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class EnemyVision : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
public EnemyStateMachine stateMachine;
|
||||
public Transform player;
|
||||
|
||||
[Header("Vision")]
|
||||
public float viewRadius = 14f;
|
||||
[Range(1f, 180f)]
|
||||
public float viewAngle = 65f;
|
||||
public LayerMask obstacleMask;
|
||||
public LayerMask targetMask;
|
||||
public float eyeHeight = 1.4f;
|
||||
public float standingDetectionDelay = 0.12f;
|
||||
public float crouchDetectionDelay = 0.35f;
|
||||
|
||||
private bool hadLineOfSight;
|
||||
private float visibleTimer;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
stateMachine = stateMachine != null ? stateMachine : GetComponent<EnemyStateMachine>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
AcquirePlayer();
|
||||
if (player == null || stateMachine == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool canSeePlayer = CanSeePlayer(out Vector3 eyePosition, out Vector3 targetPosition, out Color debugColor);
|
||||
Debug.DrawRay(eyePosition, targetPosition - eyePosition, debugColor);
|
||||
|
||||
if (canSeePlayer)
|
||||
{
|
||||
PlayerStealth stealth = player.GetComponent<PlayerStealth>();
|
||||
float requiredTime = stealth != null && stealth.IsCrouching ? crouchDetectionDelay : standingDetectionDelay;
|
||||
visibleTimer += Time.deltaTime;
|
||||
|
||||
if (visibleTimer >= requiredTime)
|
||||
{
|
||||
hadLineOfSight = true;
|
||||
stateMachine.OnPlayerDetected(player.position);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
visibleTimer = 0f;
|
||||
if (hadLineOfSight)
|
||||
{
|
||||
hadLineOfSight = false;
|
||||
stateMachine.OnPlayerLost();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float GetViewRadiusForCurrentTarget()
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
return viewRadius;
|
||||
}
|
||||
|
||||
PlayerStealth stealth = player.GetComponent<PlayerStealth>();
|
||||
return viewRadius * (stealth != null ? stealth.VisibilityMultiplier : 1f);
|
||||
}
|
||||
|
||||
private bool CanSeePlayer(out Vector3 eyePosition, out Vector3 targetPosition, out Color debugColor)
|
||||
{
|
||||
eyePosition = transform.position + Vector3.up * eyeHeight;
|
||||
targetPosition = player.position + Vector3.up * 0.9f;
|
||||
debugColor = Color.gray;
|
||||
|
||||
float effectiveRadius = GetViewRadiusForCurrentTarget();
|
||||
Vector3 directionToPlayer = targetPosition - eyePosition;
|
||||
float distanceToPlayer = directionToPlayer.magnitude;
|
||||
|
||||
if (distanceToPlayer > effectiveRadius)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
float angleToPlayer = Vector3.Angle(transform.forward, directionToPlayer);
|
||||
if (angleToPlayer > viewAngle * 0.5f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int combinedMask = obstacleMask | targetMask;
|
||||
if (Physics.Raycast(eyePosition, directionToPlayer.normalized, out RaycastHit hit, distanceToPlayer, combinedMask, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
// Если первым попался не игрок, значит между врагом и игроком есть укрытие или стена.
|
||||
bool isPlayerHit = hit.transform == player || hit.transform.IsChildOf(player);
|
||||
debugColor = isPlayerHit ? Color.green : Color.red;
|
||||
return isPlayerHit;
|
||||
}
|
||||
|
||||
debugColor = Color.red;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void AcquirePlayer()
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject playerObject = GameObject.FindGameObjectWithTag("Player");
|
||||
if (playerObject != null)
|
||||
{
|
||||
player = playerObject.transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 170f19287f4f8d6a3a78c9caf9cd84d0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,214 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public class EnemyVisionVisualizer : MonoBehaviour
|
||||
{
|
||||
public EnemyVision vision;
|
||||
public EnemyStateMachine stateMachine;
|
||||
public Material visionMaterialTemplate;
|
||||
public int segmentCount = 28;
|
||||
public float groundOffset = 0.05f;
|
||||
|
||||
private Transform meshRoot;
|
||||
private MeshFilter meshFilter;
|
||||
private MeshRenderer meshRenderer;
|
||||
private Mesh visionMesh;
|
||||
private Material runtimeMaterial;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
vision = vision != null ? vision : GetComponent<EnemyVision>();
|
||||
stateMachine = stateMachine != null ? stateMachine : GetComponent<EnemyStateMachine>();
|
||||
EnsureMeshObjects();
|
||||
RebuildMesh();
|
||||
UpdateVisualState();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
EnsureMeshObjects();
|
||||
UpdateVisualState();
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
segmentCount = Mathf.Max(6, segmentCount);
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
EnsureMeshObjects();
|
||||
RebuildMesh();
|
||||
UpdateVisualState();
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureMeshObjects()
|
||||
{
|
||||
int visualizationLayer = LayerMask.NameToLayer("Vision");
|
||||
if (visualizationLayer < 0)
|
||||
{
|
||||
visualizationLayer = LayerMask.NameToLayer("Ignore Raycast");
|
||||
}
|
||||
|
||||
if (meshRoot == null)
|
||||
{
|
||||
Transform existing = transform.Find("VisionCone");
|
||||
if (existing != null)
|
||||
{
|
||||
meshRoot = existing;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject root = new GameObject("VisionCone");
|
||||
root.transform.SetParent(transform, false);
|
||||
root.transform.localPosition = new Vector3(0f, groundOffset, 0f);
|
||||
root.transform.localRotation = Quaternion.identity;
|
||||
root.layer = visualizationLayer;
|
||||
meshRoot = root.transform;
|
||||
}
|
||||
}
|
||||
|
||||
meshRoot.localPosition = new Vector3(0f, groundOffset, 0f);
|
||||
meshRoot.gameObject.layer = visualizationLayer;
|
||||
|
||||
if (meshFilter == null)
|
||||
{
|
||||
meshFilter = meshRoot.GetComponent<MeshFilter>();
|
||||
if (meshFilter == null)
|
||||
{
|
||||
meshFilter = meshRoot.gameObject.AddComponent<MeshFilter>();
|
||||
}
|
||||
}
|
||||
|
||||
if (meshRenderer == null)
|
||||
{
|
||||
meshRenderer = meshRoot.GetComponent<MeshRenderer>();
|
||||
if (meshRenderer == null)
|
||||
{
|
||||
meshRenderer = meshRoot.gameObject.AddComponent<MeshRenderer>();
|
||||
meshRenderer.shadowCastingMode = ShadowCastingMode.Off;
|
||||
meshRenderer.receiveShadows = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (visionMesh == null)
|
||||
{
|
||||
visionMesh = new Mesh { name = "EnemyVisionCone" };
|
||||
meshFilter.sharedMesh = visionMesh;
|
||||
}
|
||||
|
||||
if (runtimeMaterial == null)
|
||||
{
|
||||
runtimeMaterial = visionMaterialTemplate != null ? new Material(visionMaterialTemplate) : BuildTransparentMaterial();
|
||||
runtimeMaterial.name = "EnemyVisionRuntimeMaterial";
|
||||
meshRenderer.sharedMaterial = runtimeMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
private void RebuildMesh()
|
||||
{
|
||||
if (vision == null || visionMesh == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float radius = vision.viewRadius;
|
||||
float halfAngle = vision.viewAngle * 0.5f;
|
||||
|
||||
Vector3[] vertices = new Vector3[segmentCount + 2];
|
||||
int[] triangles = new int[segmentCount * 3];
|
||||
Vector2[] uv = new Vector2[vertices.Length];
|
||||
|
||||
vertices[0] = Vector3.zero;
|
||||
uv[0] = new Vector2(0.5f, 0f);
|
||||
|
||||
for (int i = 0; i <= segmentCount; i++)
|
||||
{
|
||||
float progress = i / (float)segmentCount;
|
||||
float angle = -halfAngle + progress * vision.viewAngle;
|
||||
float radians = Mathf.Deg2Rad * angle;
|
||||
Vector3 direction = new Vector3(Mathf.Sin(radians), 0f, Mathf.Cos(radians));
|
||||
vertices[i + 1] = direction * radius;
|
||||
uv[i + 1] = new Vector2(progress, 1f);
|
||||
|
||||
if (i == segmentCount)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int triangleIndex = i * 3;
|
||||
triangles[triangleIndex] = 0;
|
||||
triangles[triangleIndex + 1] = i + 2;
|
||||
triangles[triangleIndex + 2] = i + 1;
|
||||
}
|
||||
|
||||
visionMesh.Clear();
|
||||
visionMesh.vertices = vertices;
|
||||
visionMesh.triangles = triangles;
|
||||
visionMesh.uv = uv;
|
||||
visionMesh.RecalculateNormals();
|
||||
visionMesh.RecalculateBounds();
|
||||
}
|
||||
|
||||
private void UpdateVisualState()
|
||||
{
|
||||
if (runtimeMaterial == null || stateMachine == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Color stateColor = new Color(0.2f, 0.95f, 0.35f, 0.22f);
|
||||
switch (stateMachine.CurrentState)
|
||||
{
|
||||
case EnemyStateMachine.State.Suspicion:
|
||||
stateColor = new Color(1f, 0.85f, 0.2f, 0.24f);
|
||||
break;
|
||||
case EnemyStateMachine.State.Alert:
|
||||
stateColor = new Color(1f, 0.25f, 0.2f, 0.28f);
|
||||
break;
|
||||
}
|
||||
|
||||
runtimeMaterial.color = stateColor;
|
||||
if (runtimeMaterial.HasProperty("_Color"))
|
||||
{
|
||||
runtimeMaterial.SetColor("_Color", stateColor);
|
||||
}
|
||||
}
|
||||
|
||||
private Material BuildTransparentMaterial()
|
||||
{
|
||||
Shader shader = Shader.Find("Standard");
|
||||
Material material = new Material(shader);
|
||||
material.SetFloat("_Mode", 3f);
|
||||
material.SetInt("_SrcBlend", (int)BlendMode.SrcAlpha);
|
||||
material.SetInt("_DstBlend", (int)BlendMode.OneMinusSrcAlpha);
|
||||
material.SetInt("_ZWrite", 0);
|
||||
material.DisableKeyword("_ALPHATEST_ON");
|
||||
material.EnableKeyword("_ALPHABLEND_ON");
|
||||
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
|
||||
material.renderQueue = (int)RenderQueue.Transparent;
|
||||
material.color = new Color(0.2f, 0.95f, 0.35f, 0.22f);
|
||||
return material;
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
if (vision == null)
|
||||
{
|
||||
vision = GetComponent<EnemyVision>();
|
||||
}
|
||||
|
||||
if (vision == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Gizmos.color = Color.cyan;
|
||||
Vector3 origin = transform.position + Vector3.up * 0.1f;
|
||||
Gizmos.DrawWireSphere(origin, vision.viewRadius);
|
||||
|
||||
Quaternion leftRotation = Quaternion.Euler(0f, -vision.viewAngle * 0.5f, 0f);
|
||||
Quaternion rightRotation = Quaternion.Euler(0f, vision.viewAngle * 0.5f, 0f);
|
||||
Gizmos.DrawLine(origin, origin + leftRotation * transform.forward * vision.viewRadius);
|
||||
Gizmos.DrawLine(origin, origin + rightRotation * transform.forward * vision.viewRadius);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f37b7500e8489416b94b2a9245935426
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(Collider))]
|
||||
public class LevelExit : MonoBehaviour
|
||||
{
|
||||
private bool hasTriggered;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Collider exitCollider = GetComponent<Collider>();
|
||||
exitCollider.isTrigger = true;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (hasTriggered || !other.CompareTag("Player"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerHealth playerHealth = other.GetComponent<PlayerHealth>();
|
||||
if (playerHealth == null || !playerHealth.IsAlive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hasTriggered = true;
|
||||
playerHealth.CompleteLevel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c01bde08ec6450b5f977a2b6c5629f9d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,105 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NoiseManager : MonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
public class NoiseEvent
|
||||
{
|
||||
public Vector3 position;
|
||||
public float intensity;
|
||||
public float timestamp;
|
||||
}
|
||||
|
||||
public float noiseLifetime = 1.25f;
|
||||
|
||||
public static NoiseManager Instance { get; private set; }
|
||||
public static IReadOnlyList<NoiseEvent> ActiveNoises => activeNoises;
|
||||
|
||||
private static readonly List<NoiseEvent> activeNoises = new List<NoiseEvent>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null && Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
PruneExpiredNoise();
|
||||
}
|
||||
|
||||
public static void EmitNoise(Vector3 position, float intensity)
|
||||
{
|
||||
EnsureInstance();
|
||||
PruneExpiredNoise();
|
||||
|
||||
// Шум живёт короткое время, чтобы враги реагировали на свежие события, а не на старые следы.
|
||||
activeNoises.Add(new NoiseEvent
|
||||
{
|
||||
position = position,
|
||||
intensity = intensity,
|
||||
timestamp = Time.time
|
||||
});
|
||||
}
|
||||
|
||||
public static NoiseEvent GetClosestNoise(Vector3 listenerPosition, float hearingRange)
|
||||
{
|
||||
PruneExpiredNoise();
|
||||
|
||||
NoiseEvent closest = null;
|
||||
float closestDistance = float.MaxValue;
|
||||
|
||||
for (int i = 0; i < activeNoises.Count; i++)
|
||||
{
|
||||
NoiseEvent noise = activeNoises[i];
|
||||
float effectiveRange = Mathf.Max(0.1f, hearingRange * noise.intensity);
|
||||
float distance = Vector3.Distance(listenerPosition, noise.position);
|
||||
|
||||
if (distance > effectiveRange || distance >= closestDistance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
closest = noise;
|
||||
closestDistance = distance;
|
||||
}
|
||||
|
||||
return closest;
|
||||
}
|
||||
|
||||
public static void ClearNoise()
|
||||
{
|
||||
activeNoises.Clear();
|
||||
}
|
||||
|
||||
private static void EnsureInstance()
|
||||
{
|
||||
if (Instance != null || !Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject managerObject = new GameObject("NoiseManager");
|
||||
Instance = managerObject.AddComponent<NoiseManager>();
|
||||
}
|
||||
|
||||
private static void PruneExpiredNoise()
|
||||
{
|
||||
float lifetime = Instance != null ? Instance.noiseLifetime : 1.25f;
|
||||
float minTimestamp = Time.time - lifetime;
|
||||
|
||||
for (int i = activeNoises.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (activeNoises[i].timestamp < minTimestamp)
|
||||
{
|
||||
activeNoises.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c64961fd4f61652f9806e6ec90f6aa58
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerHealth : MonoBehaviour
|
||||
{
|
||||
public int health = 100;
|
||||
|
||||
public bool IsAlive => health > 0;
|
||||
public bool HasCompletedLevel => levelCompleted;
|
||||
public event Action Died;
|
||||
public event Action LevelCompleted;
|
||||
|
||||
private bool hasTriggeredDeath;
|
||||
private bool levelCompleted;
|
||||
|
||||
public void TakeDamage(int amount)
|
||||
{
|
||||
if (!IsAlive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
health = Mathf.Max(0, health - Mathf.Abs(amount));
|
||||
|
||||
if (!IsAlive && !hasTriggeredDeath)
|
||||
{
|
||||
HandleDeath();
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
}
|
||||
|
||||
public void CompleteLevel()
|
||||
{
|
||||
if (!IsAlive || levelCompleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
levelCompleted = true;
|
||||
DisableGameplayControl();
|
||||
Debug.Log("Игрок достиг зоны выхода.");
|
||||
LevelCompleted?.Invoke();
|
||||
}
|
||||
|
||||
private void HandleDeath()
|
||||
{
|
||||
hasTriggeredDeath = true;
|
||||
DisableGameplayControl();
|
||||
|
||||
Debug.Log("Игрок обнаружен и выведен из строя.");
|
||||
Died?.Invoke();
|
||||
}
|
||||
|
||||
private void DisableGameplayControl()
|
||||
{
|
||||
enabled = false;
|
||||
|
||||
SimpleFPSController fpsController = GetComponent<SimpleFPSController>();
|
||||
if (fpsController != null)
|
||||
{
|
||||
fpsController.enabled = false;
|
||||
}
|
||||
|
||||
PlayerStealth stealth = GetComponent<PlayerStealth>();
|
||||
if (stealth != null)
|
||||
{
|
||||
stealth.enabled = false;
|
||||
}
|
||||
|
||||
CharacterController characterController = GetComponent<CharacterController>();
|
||||
if (characterController != null)
|
||||
{
|
||||
characterController.enabled = false;
|
||||
}
|
||||
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
Time.timeScale = 0f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42e347ee8a477dca39724011d10d007c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,157 @@
|
||||
using UnityEngine;
|
||||
|
||||
[DefaultExecutionOrder(-50)]
|
||||
[RequireComponent(typeof(CharacterController))]
|
||||
[RequireComponent(typeof(SimpleFPSController))]
|
||||
public class PlayerStealth : MonoBehaviour
|
||||
{
|
||||
public enum NoiseState
|
||||
{
|
||||
Silent,
|
||||
Low,
|
||||
Medium,
|
||||
High
|
||||
}
|
||||
|
||||
[Header("References")]
|
||||
public CharacterController characterController;
|
||||
public SimpleFPSController fpsController;
|
||||
public Camera playerCamera;
|
||||
|
||||
[Header("Crouch")]
|
||||
public float standingHeight = 2f;
|
||||
public float crouchingHeight = 1.2f;
|
||||
public float crouchSpeedMultiplier = 0.55f;
|
||||
public float standingCameraLocalY = 0.8f;
|
||||
public float crouchCameraLocalY = 0.35f;
|
||||
public float crouchTransitionSpeed = 8f;
|
||||
public float crouchVisibilityMultiplier = 0.72f;
|
||||
|
||||
[Header("Noise")]
|
||||
public float noiseEmitInterval = 0.35f;
|
||||
public float crouchNoiseIntensity = 0.45f;
|
||||
public float walkNoiseIntensity = 0.8f;
|
||||
public float runNoiseIntensity = 1.25f;
|
||||
public float testNoiseIntensity = 1.6f;
|
||||
|
||||
public bool IsCrouching { get; private set; }
|
||||
public NoiseState CurrentNoiseState { get; private set; } = NoiseState.Silent;
|
||||
public float CurrentNoiseIntensity { get; private set; }
|
||||
public float VisibilityMultiplier => IsCrouching ? crouchVisibilityMultiplier : 1f;
|
||||
public string CurrentNoiseLabel => CurrentNoiseState.ToString().ToLowerInvariant();
|
||||
|
||||
private float currentControllerHeight;
|
||||
private float targetCameraLocalY;
|
||||
private float lastNoiseEmitTime = -999f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
characterController = characterController != null ? characterController : GetComponent<CharacterController>();
|
||||
fpsController = fpsController != null ? fpsController : GetComponent<SimpleFPSController>();
|
||||
playerCamera = playerCamera != null ? playerCamera : GetComponentInChildren<Camera>();
|
||||
|
||||
currentControllerHeight = standingHeight;
|
||||
targetCameraLocalY = standingCameraLocalY;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
ApplyCharacterHeightImmediate(standingHeight);
|
||||
SetCameraLocalY(standingCameraLocalY);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateCrouchState();
|
||||
UpdateNoiseState();
|
||||
HandleManualNoise();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
SmoothCrouchPresentation();
|
||||
}
|
||||
|
||||
private void UpdateCrouchState()
|
||||
{
|
||||
IsCrouching = Input.GetKey(KeyCode.LeftControl);
|
||||
fpsController.AllowRunning = !IsCrouching;
|
||||
fpsController.SpeedScale = IsCrouching ? crouchSpeedMultiplier : 1f;
|
||||
targetCameraLocalY = IsCrouching ? crouchCameraLocalY : standingCameraLocalY;
|
||||
}
|
||||
|
||||
private void UpdateNoiseState()
|
||||
{
|
||||
if (!fpsController.HasMovementInput)
|
||||
{
|
||||
SetNoiseState(NoiseState.Silent, 0f);
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsCrouching)
|
||||
{
|
||||
SetNoiseState(NoiseState.Low, crouchNoiseIntensity);
|
||||
}
|
||||
else if (fpsController.IsRunning)
|
||||
{
|
||||
SetNoiseState(NoiseState.High, runNoiseIntensity);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetNoiseState(NoiseState.Medium, walkNoiseIntensity);
|
||||
}
|
||||
|
||||
if (CurrentNoiseState != NoiseState.Silent && Time.time >= lastNoiseEmitTime + noiseEmitInterval)
|
||||
{
|
||||
lastNoiseEmitTime = Time.time;
|
||||
// Периодические импульсы шума проще настраивать и удобнее для AI, чем шум каждый кадр.
|
||||
NoiseManager.EmitNoise(transform.position, CurrentNoiseIntensity);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleManualNoise()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
NoiseManager.EmitNoise(transform.position, testNoiseIntensity);
|
||||
}
|
||||
}
|
||||
|
||||
private void SmoothCrouchPresentation()
|
||||
{
|
||||
float desiredHeight = IsCrouching ? crouchingHeight : standingHeight;
|
||||
currentControllerHeight = Mathf.Lerp(currentControllerHeight, desiredHeight, Time.deltaTime * crouchTransitionSpeed);
|
||||
ApplyCharacterHeightImmediate(currentControllerHeight);
|
||||
|
||||
if (playerCamera != null)
|
||||
{
|
||||
Vector3 localPosition = playerCamera.transform.localPosition;
|
||||
localPosition.y = Mathf.Lerp(localPosition.y, targetCameraLocalY, Time.deltaTime * crouchTransitionSpeed);
|
||||
playerCamera.transform.localPosition = localPosition;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyCharacterHeightImmediate(float height)
|
||||
{
|
||||
characterController.height = height;
|
||||
characterController.center = new Vector3(0f, height * 0.5f, 0f);
|
||||
}
|
||||
|
||||
private void SetCameraLocalY(float localY)
|
||||
{
|
||||
if (playerCamera == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 localPosition = playerCamera.transform.localPosition;
|
||||
localPosition.y = localY;
|
||||
playerCamera.transform.localPosition = localPosition;
|
||||
}
|
||||
|
||||
private void SetNoiseState(NoiseState state, float intensity)
|
||||
{
|
||||
CurrentNoiseState = state;
|
||||
CurrentNoiseIntensity = intensity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c35ac882440faf9b9493afaac932ee6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,93 @@
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(CharacterController))]
|
||||
public class SimpleFPSController : MonoBehaviour
|
||||
{
|
||||
[Header("Movement")]
|
||||
public float walkSpeed = 4f;
|
||||
public float runSpeed = 7f;
|
||||
public float mouseSensitivity = 2f;
|
||||
public float gravity = -20f;
|
||||
|
||||
[Header("References")]
|
||||
public CharacterController characterController;
|
||||
public Camera playerCamera;
|
||||
|
||||
public Vector3 PlanarVelocity { get; private set; }
|
||||
public bool HasMovementInput { get; private set; }
|
||||
public bool IsRunning { get; private set; }
|
||||
public float CurrentMoveSpeed { get; private set; }
|
||||
public float SpeedScale { get; set; } = 1f;
|
||||
public bool AllowRunning { get; set; } = true;
|
||||
|
||||
private float verticalVelocity;
|
||||
private float cameraPitch;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
characterController = characterController != null ? characterController : GetComponent<CharacterController>();
|
||||
playerCamera = playerCamera != null ? playerCamera : GetComponentInChildren<Camera>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
LockCursor(true);
|
||||
}
|
||||
|
||||
private void OnApplicationFocus(bool hasFocus)
|
||||
{
|
||||
LockCursor(hasFocus);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
HandleMouseLook();
|
||||
HandleMovement();
|
||||
}
|
||||
|
||||
private void HandleMouseLook()
|
||||
{
|
||||
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity;
|
||||
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity;
|
||||
|
||||
transform.Rotate(0f, mouseX, 0f);
|
||||
|
||||
cameraPitch -= mouseY;
|
||||
cameraPitch = Mathf.Clamp(cameraPitch, -80f, 80f);
|
||||
|
||||
if (playerCamera != null)
|
||||
{
|
||||
playerCamera.transform.localRotation = Quaternion.Euler(cameraPitch, 0f, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleMovement()
|
||||
{
|
||||
Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
|
||||
input = Vector2.ClampMagnitude(input, 1f);
|
||||
HasMovementInput = input.sqrMagnitude > 0.001f;
|
||||
|
||||
IsRunning = AllowRunning && HasMovementInput && Input.GetKey(KeyCode.LeftShift);
|
||||
CurrentMoveSpeed = (IsRunning ? runSpeed : walkSpeed) * Mathf.Max(0.01f, SpeedScale);
|
||||
|
||||
Vector3 moveDirection = (transform.right * input.x + transform.forward * input.y).normalized;
|
||||
PlanarVelocity = moveDirection * (HasMovementInput ? CurrentMoveSpeed : 0f);
|
||||
|
||||
if (characterController.isGrounded && verticalVelocity < 0f)
|
||||
{
|
||||
verticalVelocity = -2f;
|
||||
}
|
||||
|
||||
verticalVelocity += gravity * Time.deltaTime;
|
||||
|
||||
Vector3 motion = PlanarVelocity;
|
||||
motion.y = verticalVelocity;
|
||||
characterController.Move(motion * Time.deltaTime);
|
||||
}
|
||||
|
||||
private static void LockCursor(bool shouldLock)
|
||||
{
|
||||
Cursor.lockState = shouldLock ? CursorLockMode.Locked : CursorLockMode.None;
|
||||
Cursor.visible = !shouldLock;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abb0c64b16486035691c6b0e3e895ef9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,239 @@
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class StealthIndicator : MonoBehaviour
|
||||
{
|
||||
[Header("UI")]
|
||||
public Image stateBar;
|
||||
public Text statusText;
|
||||
public Text controlsText;
|
||||
public Text debugText;
|
||||
public Text healthText;
|
||||
public Text gameOverText;
|
||||
|
||||
[Header("References")]
|
||||
public PlayerStealth playerStealth;
|
||||
public PlayerHealth playerHealth;
|
||||
|
||||
private readonly StringBuilder debugBuilder = new StringBuilder(256);
|
||||
private bool subscribedToPlayerHealth;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
PopulateControlsText();
|
||||
FindPlayerReferences();
|
||||
SubscribeToPlayerHealth();
|
||||
|
||||
if (gameOverText != null)
|
||||
{
|
||||
gameOverText.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
FindPlayerReferences();
|
||||
SubscribeToPlayerHealth();
|
||||
UpdateThreatState();
|
||||
UpdateDebugText();
|
||||
UpdateHealthText();
|
||||
}
|
||||
|
||||
private void PopulateControlsText()
|
||||
{
|
||||
if (controlsText == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
controlsText.text =
|
||||
"WASD - движение\n" +
|
||||
"Mouse - обзор\n" +
|
||||
"Shift - бег / больше шума\n" +
|
||||
"Ctrl - присесть / меньше шума\n" +
|
||||
"R - тестовый шум";
|
||||
}
|
||||
|
||||
private void UpdateThreatState()
|
||||
{
|
||||
int suspicionCount = 0;
|
||||
int alertCount = 0;
|
||||
|
||||
foreach (EnemyStateMachine enemy in EnemyStateMachine.ActiveEnemies)
|
||||
{
|
||||
if (enemy == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (enemy.CurrentState == EnemyStateMachine.State.Alert)
|
||||
{
|
||||
alertCount++;
|
||||
}
|
||||
else if (enemy.CurrentState == EnemyStateMachine.State.Suspicion)
|
||||
{
|
||||
suspicionCount++;
|
||||
}
|
||||
}
|
||||
|
||||
Color stateColor = new Color(0.18f, 0.85f, 0.34f, 0.95f);
|
||||
string stateLabel = "Скрытность: безопасно";
|
||||
|
||||
if (playerHealth != null && playerHealth.HasCompletedLevel)
|
||||
{
|
||||
stateColor = new Color(0.3f, 1f, 0.42f, 0.95f);
|
||||
stateLabel = "Скрытность: выход достигнут";
|
||||
}
|
||||
else if (playerHealth != null && !playerHealth.IsAlive)
|
||||
{
|
||||
stateColor = new Color(0.95f, 0.15f, 0.15f, 0.95f);
|
||||
stateLabel = "Скрытность: провал";
|
||||
}
|
||||
else if (alertCount > 0)
|
||||
{
|
||||
stateColor = new Color(0.95f, 0.25f, 0.2f, 0.95f);
|
||||
stateLabel = "Скрытность: обнаружен";
|
||||
}
|
||||
else if (suspicionCount > 0)
|
||||
{
|
||||
stateColor = new Color(1f, 0.8f, 0.15f, 0.95f);
|
||||
stateLabel = "Скрытность: подозрение";
|
||||
}
|
||||
|
||||
if (stateBar != null)
|
||||
{
|
||||
stateBar.color = stateColor;
|
||||
}
|
||||
|
||||
if (statusText != null)
|
||||
{
|
||||
statusText.text = stateLabel;
|
||||
statusText.color = stateColor;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDebugText()
|
||||
{
|
||||
if (debugText == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int suspicionCount = 0;
|
||||
int alertCount = 0;
|
||||
foreach (EnemyStateMachine enemy in EnemyStateMachine.ActiveEnemies)
|
||||
{
|
||||
if (enemy == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (enemy.CurrentState == EnemyStateMachine.State.Suspicion)
|
||||
{
|
||||
suspicionCount++;
|
||||
}
|
||||
|
||||
if (enemy.CurrentState == EnemyStateMachine.State.Alert)
|
||||
{
|
||||
alertCount++;
|
||||
}
|
||||
}
|
||||
|
||||
debugBuilder.Length = 0;
|
||||
if (playerStealth != null)
|
||||
{
|
||||
debugBuilder.Append("Поза: ");
|
||||
debugBuilder.Append(playerStealth.IsCrouching ? "присел" : "стоит");
|
||||
debugBuilder.Append('\n');
|
||||
debugBuilder.Append("Шум: ");
|
||||
debugBuilder.Append(playerStealth.CurrentNoiseLabel);
|
||||
debugBuilder.Append('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
debugBuilder.Append("Поза: нет данных\n");
|
||||
debugBuilder.Append("Шум: нет данных\n");
|
||||
}
|
||||
|
||||
debugBuilder.Append("Враги в Suspicion: ");
|
||||
debugBuilder.Append(suspicionCount);
|
||||
debugBuilder.Append('\n');
|
||||
debugBuilder.Append("Враги в Alert: ");
|
||||
debugBuilder.Append(alertCount);
|
||||
|
||||
debugText.text = debugBuilder.ToString();
|
||||
}
|
||||
|
||||
private void UpdateHealthText()
|
||||
{
|
||||
if (healthText == null || playerHealth == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
healthText.text = "Здоровье: " + playerHealth.health;
|
||||
healthText.color = playerHealth.IsAlive ? Color.white : Color.red;
|
||||
}
|
||||
|
||||
private void FindPlayerReferences()
|
||||
{
|
||||
if (playerStealth != null && playerHealth != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject playerObject = GameObject.FindGameObjectWithTag("Player");
|
||||
if (playerObject == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerStealth == null)
|
||||
{
|
||||
playerStealth = playerObject.GetComponent<PlayerStealth>();
|
||||
}
|
||||
|
||||
if (playerHealth == null)
|
||||
{
|
||||
playerHealth = playerObject.GetComponent<PlayerHealth>();
|
||||
}
|
||||
}
|
||||
|
||||
private void SubscribeToPlayerHealth()
|
||||
{
|
||||
if (playerHealth == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (subscribedToPlayerHealth)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
playerHealth.Died += HandlePlayerDeath;
|
||||
playerHealth.LevelCompleted += HandleLevelCompleted;
|
||||
subscribedToPlayerHealth = true;
|
||||
}
|
||||
|
||||
private void HandlePlayerDeath()
|
||||
{
|
||||
if (gameOverText != null)
|
||||
{
|
||||
gameOverText.gameObject.SetActive(true);
|
||||
gameOverText.text = "Игрок устранен";
|
||||
gameOverText.color = new Color(1f, 0.2f, 0.2f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleLevelCompleted()
|
||||
{
|
||||
if (gameOverText != null)
|
||||
{
|
||||
gameOverText.gameObject.SetActive(true);
|
||||
gameOverText.text = "Миссия выполнена";
|
||||
gameOverText.color = new Color(0.35f, 1f, 0.45f, 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e71600b43f1c24c2c9908aa7a64a939c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17ab44046a2b5f7dca1a972c2a105ddb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5fbd48ef955cf21199b79dc03612c979
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 23800000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user