summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-03-14 11:43:40 +0800
committerchai <215380520@qq.com>2024-03-14 11:43:40 +0800
commitcc55520a19043a7b4870858e962fa3e20c46bc39 (patch)
treeb437f788e506a48ec16a215c6965b8170f15d5f6
parent54c872fa42b1ba0fdbcfe812b80bb8eb0cfe108f (diff)
*misc
-rw-r--r--CreepyRobots.csproj3
-rw-r--r--CreepyRobots.sln25
-rw-r--r--GameMode.cs8
-rw-r--r--_ActiveRagdoll/AvaragePosition.cs (renamed from AvaragePosition.cs)0
-rw-r--r--_Camera/CameraMovement.cs (renamed from CameraMovement.cs)0
-rw-r--r--_Camera/CameraRecoil.cs (renamed from CameraRecoil.cs)0
-rw-r--r--_Camera/CameraWobble.cs (renamed from CameraWobble.cs)0
-rw-r--r--_Camera/WobbleShake.cs (renamed from WobbleShake.cs)0
-rw-r--r--_Debug/DebugRigidBody.cs140
-rw-r--r--_Debug/REPL.cs124
-rw-r--r--_Debug/SimpleMoveCamera.cs139
11 files changed, 439 insertions, 0 deletions
diff --git a/CreepyRobots.csproj b/CreepyRobots.csproj
index 9d5de2a..4b2362c 100644
--- a/CreepyRobots.csproj
+++ b/CreepyRobots.csproj
@@ -180,4 +180,7 @@
<HintPath>..\CreepyRobots_Data\Managed\UnityEngine.WindModule.dll</HintPath>
</Reference>
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="_ActiveRagdoll\Actions\" />
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/CreepyRobots.sln b/CreepyRobots.sln
new file mode 100644
index 0000000..7069481
--- /dev/null
+++ b/CreepyRobots.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.4.33213.308
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreepyRobots", "CreepyRobots.csproj", "{7A54260D-D4B7-4D9C-A7B2-A32A0DC2C3B1}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7A54260D-D4B7-4D9C-A7B2-A32A0DC2C3B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7A54260D-D4B7-4D9C-A7B2-A32A0DC2C3B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7A54260D-D4B7-4D9C-A7B2-A32A0DC2C3B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7A54260D-D4B7-4D9C-A7B2-A32A0DC2C3B1}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {536450D1-037F-4BED-BE36-22A677EAB581}
+ EndGlobalSection
+EndGlobal
diff --git a/GameMode.cs b/GameMode.cs
index 2d717aa..5b03929 100644
--- a/GameMode.cs
+++ b/GameMode.cs
@@ -30,6 +30,8 @@ public class GameMode : MonoBehaviour
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
+ Invoke("DebugGame", 3);
+
Init();
while (true)
{
@@ -39,6 +41,12 @@ public class GameMode : MonoBehaviour
}
}
+ // ²âÊÔ
+ private void DebugGame()
+ {
+ REPL.StartREPL();
+ }
+
private IEnumerator WaitForWaveToEnd()
{
while (enemies.Count > 0)
diff --git a/AvaragePosition.cs b/_ActiveRagdoll/AvaragePosition.cs
index cea74d6..cea74d6 100644
--- a/AvaragePosition.cs
+++ b/_ActiveRagdoll/AvaragePosition.cs
diff --git a/CameraMovement.cs b/_Camera/CameraMovement.cs
index a94012a..a94012a 100644
--- a/CameraMovement.cs
+++ b/_Camera/CameraMovement.cs
diff --git a/CameraRecoil.cs b/_Camera/CameraRecoil.cs
index e82532a..e82532a 100644
--- a/CameraRecoil.cs
+++ b/_Camera/CameraRecoil.cs
diff --git a/CameraWobble.cs b/_Camera/CameraWobble.cs
index 2bd1236..2bd1236 100644
--- a/CameraWobble.cs
+++ b/_Camera/CameraWobble.cs
diff --git a/WobbleShake.cs b/_Camera/WobbleShake.cs
index 4da2d38..4da2d38 100644
--- a/WobbleShake.cs
+++ b/_Camera/WobbleShake.cs
diff --git a/_Debug/DebugRigidBody.cs b/_Debug/DebugRigidBody.cs
new file mode 100644
index 0000000..8267f50
--- /dev/null
+++ b/_Debug/DebugRigidBody.cs
@@ -0,0 +1,140 @@
+
+using UnityEngine;
+
+public class DebugRigidBody : MonoBehaviour
+{
+
+ public enum EMode
+ {
+ Axis,
+ Cube,
+ Axis_Cube,
+ }
+ public EMode mode = EMode.Axis;
+
+ public Color color = Color.white;
+
+ // When added to an object, draws colored rays from the
+ // transform position.
+ public int lineCount = 100;
+ public float radius = 3.0f;
+
+ public float cubeLen = 0.05f;
+
+ static Material lineMaterial;
+ static void CreateLineMaterial()
+ {
+ if (!lineMaterial)
+ {
+ // Unity has a built-in shader that is useful for drawing
+ // simple colored things.
+ Shader shader = Shader.Find("Hidden/Internal-Colored");
+ lineMaterial = new Material(shader);
+ lineMaterial.hideFlags = HideFlags.HideAndDontSave;
+ // Turn on alpha blending
+ lineMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
+ lineMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
+ // Turn backface culling off
+ lineMaterial.SetInt("_Cull", (int)UnityEngine.Rendering.CullMode.Off);
+ // Turn off depth writes
+ lineMaterial.SetInt("_ZWrite", 0);
+ }
+ }
+
+ private void PutVertex(Vector3 vert)
+ {
+ GL.Vertex3(vert.x, vert.y, vert.z);
+ }
+
+ // Will be called after all regular rendering is done
+ public void OnRenderObject()
+ {
+ CreateLineMaterial();
+ // Apply the line material
+ lineMaterial.SetPass(0);
+
+ if (mode == EMode.Axis || mode == EMode.Axis_Cube)
+ {
+ GL.PushMatrix();
+ // Set transformation matrix for drawing to
+ // match our transform
+ GL.MultMatrix(transform.localToWorldMatrix);
+
+ // Draw lines
+ GL.Begin(GL.LINES);
+
+ float len = 0.3f;
+
+ GL.Color(Color.red);
+ PutVertex(Vector3.zero);
+ PutVertex(Vector3.right * len);
+
+ GL.Color(Color.green);
+ PutVertex(Vector3.zero);
+ PutVertex(Vector3.up * len);
+
+ GL.Color(Color.blue);
+ PutVertex(Vector3.zero);
+ PutVertex(Vector3.forward * len);
+
+ GL.End();
+ GL.PopMatrix();
+ }
+ if (mode == EMode.Cube || mode == EMode.Axis_Cube)
+ {
+ GL.PushMatrix();
+ // Set transformation matrix for drawing to
+ // match our transform
+ GL.MultMatrix(transform.localToWorldMatrix);
+
+ float len = cubeLen;
+
+ GL.wireframe = true;
+
+ GL.Begin(GL.QUADS);
+
+ GL.Color(color);
+
+ GL.Vertex3(len, len, -len);
+ GL.Vertex3(-len, len, -len);
+ GL.Vertex3(-len, len, len);
+ GL.Vertex3(len, len, len);
+
+ // Bottom face (y = -len)
+ GL.Vertex3(len, -len, len);
+ GL.Vertex3(-len, -len, len);
+ GL.Vertex3(-len, -len, -len);
+ GL.Vertex3(len, -len, -len);
+
+ // Front face (z = len)
+ GL.Vertex3(len, len, len);
+ GL.Vertex3(-len, len, len);
+ GL.Vertex3(-len, -len, len);
+ GL.Vertex3(len, -len, len);
+
+ // Back face (z = -len)
+ GL.Vertex3(len, -len, -len);
+ GL.Vertex3(-len, -len, -len);
+ GL.Vertex3(-len, len, -len);
+ GL.Vertex3(len, len, -len);
+
+ // Left face (x = -len)
+ GL.Vertex3(-len, len, len);
+ GL.Vertex3(-len, len, -len);
+ GL.Vertex3(-len, -len, -len);
+ GL.Vertex3(-len, -len, len);
+
+ // Right face (x = len)
+ GL.Vertex3(len, len, -len);
+ GL.Vertex3(len, len, len);
+ GL.Vertex3(len, -len, len);
+ GL.Vertex3(len, -len, -len);
+ GL.End(); // End of drawing color-cube
+
+ GL.wireframe = false;
+
+ GL.PopMatrix();
+ }
+ }
+
+}
diff --git a/_Debug/REPL.cs b/_Debug/REPL.cs
new file mode 100644
index 0000000..29209ef
--- /dev/null
+++ b/_Debug/REPL.cs
@@ -0,0 +1,124 @@
+using System.Collections.Generic;
+using System.Drawing;
+using UnityEngine;
+
+class REPL
+{
+ public static void StartREPL()
+ {
+ AddCamera();
+ AddRigidbodyDebug();
+ AddCubes();
+ }
+
+ public static void AddCamera()
+ {
+ GameObject camera = GameObject.Find("WanderCamera");
+ if (camera != null)
+ {
+ GameObject.DestroyImmediate(camera);
+ }
+
+ camera = new GameObject();
+ camera.name = "WanderCamera";
+ camera.AddComponent<Camera>();
+ camera.AddComponent<SimpleMoveCamera>();
+
+ GameObject wanderCam = GameObject.Find("WanderCamera");
+
+ GameObject player = GameObject.Find("Player");
+ if (player != null)
+ {
+ wanderCam.transform.position = player.transform.position;
+ }
+
+ wanderCam.transform.position = new Vector3(1.21f, 33.92f, -10.4f);
+ wanderCam.transform.rotation = Quaternion.Euler(25.95f, 75, 0);
+ }
+
+ public static void AddRigidbodyDebug()
+ {
+ string[] targets = {
+ "Head",
+ "Neck",
+ "Torso",
+ "Arm_Right",
+ "Arm_Left",
+ "Hand_Right",
+ "Hand_Left",
+ "Hip",
+ "Leg_Left",
+ "Leg_Right",
+ "Foot_Left",
+ "Foot_Right",
+ "Knee_Left",
+ "Knee_Right",
+ };
+
+ for(int i = 0; i < targets.Length; ++i)
+ {
+ string target = targets[i];
+ GameObject go = GameObject.Find(target);
+ if(go != null)
+ {
+ var comps = go.gameObject.GetComponents<MonoBehaviour>();
+ if (comps != null)
+ {
+ for (int j = 0; j < comps.Length; j++)
+ {
+ if (comps[j].GetType().Name == "DebugRigidBody" || comps[j].GetType().Name == "DebugRigidBody2")
+ {
+ UnityEngine.Object.DestroyImmediate(comps[j]);
+ }
+ }
+ }
+ Debug.Log(go.name);
+ var drb = go.AddComponent<DebugRigidBody>();
+ //drb.mode = DebugRigidBody.EMode.Cube;
+ //drb.color = Color.green;
+ }
+ }
+ }
+
+ public struct CubeParams
+ {
+ public UnityEngine.Color color;
+ public float size;
+ public DebugRigidBody.EMode mode;
+ }
+
+ public static void AddCubes()
+ {
+ Dictionary<string, CubeParams> targets = new Dictionary<string, CubeParams>{
+ {"CameraPos", new CubeParams(){ color = UnityEngine.Color.red, size = 0.2f, mode = DebugRigidBody.EMode.Cube } },
+ {"Main Camera", new CubeParams(){ color = UnityEngine.Color.white, size = 0.05f, mode = DebugRigidBody.EMode.Axis_Cube } },
+ {"RotationTarget", new CubeParams(){ color = UnityEngine.Color.green, size = 0.05f, mode = DebugRigidBody.EMode.Axis_Cube } },
+ //{"AvaragePosition", new CubeParams(){ color = UnityEngine.Color.blue, size = 0.2f, mode = DebugRigidBody.EMode.Axis_Cube } },
+ };
+
+ foreach(var target in targets)
+ {
+ string name = target.Key;
+ GameObject go = GameObject.Find(name);
+ if (go != null)
+ {
+ var comps = go.gameObject.GetComponents<MonoBehaviour>();
+ if (comps != null)
+ {
+ for (int j = 0; j < comps.Length; j++)
+ {
+ if (comps[j].GetType().Name == "DebugRigidBody" || comps[j].GetType().Name == "DebugRigidBody2")
+ {
+ UnityEngine.Object.DestroyImmediate(comps[j]);
+ }
+ }
+ }
+ Debug.Log(go.name);
+ var drb = go.AddComponent<DebugRigidBody>();
+ drb.mode = target.Value.mode;
+ drb.color = target.Value.color;
+ drb.cubeLen = target.Value.size;
+ }
+ }
+ }
+}
diff --git a/_Debug/SimpleMoveCamera.cs b/_Debug/SimpleMoveCamera.cs
new file mode 100644
index 0000000..35a7360
--- /dev/null
+++ b/_Debug/SimpleMoveCamera.cs
@@ -0,0 +1,139 @@
+
+using UnityEngine;
+/// <summary>
+/// A simple free camera to be added to a Unity game object.
+///
+/// Keys:
+/// wasd / arrows - movement
+/// q/e - up/down (local space)
+/// r/f - up/down (world space)
+/// pageup/pagedown - up/down (world space)
+/// hold shift - enable fast movement mode
+/// right mouse - enable free look
+/// mouse - free look / rotation
+///
+/// </summary>
+public class SimpleMoveCamera : MonoBehaviour
+{
+ /// <summary>
+ /// Normal speed of camera movement.
+ /// </summary>
+ public float movementSpeed = 10f;
+
+ /// <summary>
+ /// Speed of camera movement when shift is held down,
+ /// </summary>
+ public float fastMovementSpeed = 100f;
+
+ /// <summary>
+ /// Sensitivity for free look.
+ /// </summary>
+ public float freeLookSensitivity = 3f;
+
+ /// <summary>
+ /// Amount to zoom the camera when using the mouse wheel.
+ /// </summary>
+ public float zoomSensitivity = 10f;
+
+ /// <summary>
+ /// Amount to zoom the camera when using the mouse wheel (fast mode).
+ /// </summary>
+ public float fastZoomSensitivity = 50f;
+
+ /// <summary>
+ /// Set to true when free looking (on right mouse button).
+ /// </summary>
+ private bool looking = false;
+
+ void Update()
+ {
+ var fastMode = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
+ var movementSpeed = fastMode ? this.fastMovementSpeed : this.movementSpeed;
+
+ if (Input.GetKey(KeyCode.H) || Input.GetKey(KeyCode.LeftArrow))
+ {
+ transform.position = transform.position + (-transform.right * movementSpeed * Time.deltaTime);
+ }
+
+ if (Input.GetKey(KeyCode.K) || Input.GetKey(KeyCode.RightArrow))
+ {
+ transform.position = transform.position + (transform.right * movementSpeed * Time.deltaTime);
+ }
+
+ if (Input.GetKey(KeyCode.U) || Input.GetKey(KeyCode.UpArrow))
+ {
+ transform.position = transform.position + (transform.forward * movementSpeed * Time.deltaTime);
+ }
+
+ if (Input.GetKey(KeyCode.J) || Input.GetKey(KeyCode.DownArrow))
+ {
+ transform.position = transform.position + (-transform.forward * movementSpeed * Time.deltaTime);
+ }
+ if (Input.GetKey(KeyCode.Q))
+ {
+ transform.position = transform.position + (transform.up * movementSpeed * Time.deltaTime);
+ }
+ if (Input.GetKey(KeyCode.E))
+ {
+ transform.position = transform.position + (-transform.up * movementSpeed * Time.deltaTime);
+ }
+
+ if (Input.GetKey(KeyCode.R) || Input.GetKey(KeyCode.PageUp))
+ {
+ transform.position = transform.position + (Vector3.up * movementSpeed * Time.deltaTime);
+ }
+
+ if (Input.GetKey(KeyCode.F) || Input.GetKey(KeyCode.PageDown))
+ {
+ transform.position = transform.position + (-Vector3.up * movementSpeed * Time.deltaTime);
+ }
+
+ if (looking)
+ {
+ float newRotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * freeLookSensitivity;
+ float newRotationY = transform.localEulerAngles.x - Input.GetAxis("Mouse Y") * freeLookSensitivity;
+ transform.localEulerAngles = new Vector3(newRotationY, newRotationX, 0f);
+ }
+
+ float axis = Input.GetAxis("Mouse ScrollWheel");
+ if (axis != 0)
+ {
+ var zoomSensitivity = fastMode ? this.fastZoomSensitivity : this.zoomSensitivity;
+ transform.position = transform.position + transform.forward * axis * zoomSensitivity;
+ }
+
+ if (Input.GetKeyDown(KeyCode.Mouse1))
+ {
+ StartLooking();
+ }
+ else if (Input.GetKeyUp(KeyCode.Mouse1))
+ {
+ StopLooking();
+ }
+ }
+
+ void OnDisable()
+ {
+ StopLooking();
+ }
+
+ /// <summary>
+ /// Enable free looking.
+ /// </summary>
+ public void StartLooking()
+ {
+ looking = true;
+ Cursor.visible = false;
+ Cursor.lockState = CursorLockMode.Locked;
+ }
+
+ /// <summary>
+ /// Disable free looking.
+ /// </summary>
+ public void StopLooking()
+ {
+ looking = false;
+ Cursor.visible = true;
+ Cursor.lockState = CursorLockMode.None;
+ }
+} \ No newline at end of file