SwapLines
parent
ce47f7515b
commit
9bd2cdefc6
@ -0,0 +1,186 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &7889671876836792639
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 2190496012411949397}
|
||||||
|
- component: {fileID: 9057376229307534297}
|
||||||
|
- component: {fileID: 7429976590137184792}
|
||||||
|
- component: {fileID: 2673016220022461625}
|
||||||
|
- component: {fileID: 3158508003152714365}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: SwapLineRenderer
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &2190496012411949397
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7889671876836792639}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!120 &9057376229307534297
|
||||||
|
LineRenderer:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7889671876836792639}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
|
m_MotionVectors: 0
|
||||||
|
m_LightProbeUsage: 0
|
||||||
|
m_ReflectionProbeUsage: 0
|
||||||
|
m_RayTracingMode: 0
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: 77e5ea3a019674146a9f2b3ed629b386, type: 2}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_Positions:
|
||||||
|
- {x: 0, y: 0, z: 0}
|
||||||
|
- {x: 0, y: 0, z: 1}
|
||||||
|
m_Parameters:
|
||||||
|
serializedVersion: 3
|
||||||
|
widthMultiplier: 1
|
||||||
|
widthCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
colorGradient:
|
||||||
|
serializedVersion: 2
|
||||||
|
key0: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
key1: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
ctime0: 0
|
||||||
|
ctime1: 65535
|
||||||
|
ctime2: 0
|
||||||
|
ctime3: 0
|
||||||
|
ctime4: 0
|
||||||
|
ctime5: 0
|
||||||
|
ctime6: 0
|
||||||
|
ctime7: 0
|
||||||
|
atime0: 0
|
||||||
|
atime1: 65535
|
||||||
|
atime2: 0
|
||||||
|
atime3: 0
|
||||||
|
atime4: 0
|
||||||
|
atime5: 0
|
||||||
|
atime6: 0
|
||||||
|
atime7: 0
|
||||||
|
m_Mode: 0
|
||||||
|
m_ColorSpace: -1
|
||||||
|
m_NumColorKeys: 2
|
||||||
|
m_NumAlphaKeys: 2
|
||||||
|
numCornerVertices: 0
|
||||||
|
numCapVertices: 0
|
||||||
|
alignment: 0
|
||||||
|
textureMode: 1
|
||||||
|
textureScale: {x: 1, y: 1}
|
||||||
|
shadowBias: 0.5
|
||||||
|
generateLightingData: 0
|
||||||
|
m_MaskInteraction: 0
|
||||||
|
m_UseWorldSpace: 1
|
||||||
|
m_Loop: 0
|
||||||
|
m_ApplyActiveColorSpace: 1
|
||||||
|
--- !u!114 &7429976590137184792
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7889671876836792639}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 1e6412647fb95594eb08353a0c8edd79, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
lineRenderer: {fileID: 9057376229307534297}
|
||||||
|
scrollingMaterial: {fileID: 2100000, guid: 77e5ea3a019674146a9f2b3ed629b386, type: 2}
|
||||||
|
speed: 1
|
||||||
|
tiling: 0.5
|
||||||
|
serverCharacter: {fileID: 0}
|
||||||
|
--- !u!114 &2673016220022461625
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7889671876836792639}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 275c684c245283442a60cb83984b7474, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
lineRenderer: {fileID: 9057376229307534297}
|
||||||
|
colliderRadius: 0.1
|
||||||
|
--- !u!114 &3158508003152714365
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7889671876836792639}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: ae3b814bce97b534eb12f8d764c2be7e, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
lineRenderer: {fileID: 9057376229307534297}
|
||||||
|
touchRadius: 1
|
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: de92a155449a1dc4aa295b73aae3b557
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,62 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public class LineColliderCapsules : MonoBehaviour
|
||||||
|
{
|
||||||
|
public LineRenderer lineRenderer;
|
||||||
|
public float colliderRadius = 0.1f; // Adjust based on line width
|
||||||
|
|
||||||
|
private List<GameObject> colliders = new List<GameObject>();
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
GenerateColliders();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
UpdateColliders();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GenerateColliders()
|
||||||
|
{
|
||||||
|
// Destroy old colliders
|
||||||
|
foreach (var col in colliders)
|
||||||
|
{
|
||||||
|
Destroy(col);
|
||||||
|
}
|
||||||
|
colliders.Clear();
|
||||||
|
|
||||||
|
if (lineRenderer.positionCount < 2) return;
|
||||||
|
|
||||||
|
for (int i = 0; i < lineRenderer.positionCount - 1; i++)
|
||||||
|
{
|
||||||
|
GameObject colObj = new GameObject("LineSegmentCollider");
|
||||||
|
colObj.transform.parent = transform;
|
||||||
|
|
||||||
|
CapsuleCollider capsule = colObj.AddComponent<CapsuleCollider>();
|
||||||
|
capsule.radius = colliderRadius;
|
||||||
|
capsule.height = Vector3.Distance(lineRenderer.GetPosition(i), lineRenderer.GetPosition(i + 1));
|
||||||
|
capsule.direction = 2; // Z-axis
|
||||||
|
|
||||||
|
colliders.Add(colObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateColliders();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateColliders()
|
||||||
|
{
|
||||||
|
if (lineRenderer.positionCount < 2) return;
|
||||||
|
|
||||||
|
for (int i = 0; i < colliders.Count; i++)
|
||||||
|
{
|
||||||
|
Vector3 start = lineRenderer.GetPosition(i);
|
||||||
|
Vector3 end = lineRenderer.GetPosition(i + 1);
|
||||||
|
Vector3 midPoint = (start + end) / 2;
|
||||||
|
|
||||||
|
colliders[i].transform.position = midPoint;
|
||||||
|
colliders[i].transform.LookAt(end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 275c684c245283442a60cb83984b7474
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,89 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class LineTouchDetector : MonoBehaviour
|
||||||
|
{
|
||||||
|
public LineRenderer lineRenderer;
|
||||||
|
public float touchRadius = 0.5f; // Max distance to detect a touch
|
||||||
|
|
||||||
|
private ScrollingLineRenderer scrollingLineRenderer;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
scrollingLineRenderer = GetComponentInParent<ScrollingLineRenderer>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
DetectTouchOrClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DetectTouchOrClick()
|
||||||
|
{
|
||||||
|
Vector3 touchPos;
|
||||||
|
bool touched = false;
|
||||||
|
|
||||||
|
// Detect touch on mobile
|
||||||
|
if (Input.touchCount > 0)
|
||||||
|
{
|
||||||
|
Touch touch = Input.GetTouch(0);
|
||||||
|
touchPos = touch.position;
|
||||||
|
touched = true;
|
||||||
|
}
|
||||||
|
// Detect mouse click on PC
|
||||||
|
else if (Input.GetMouseButtonDown(0))
|
||||||
|
{
|
||||||
|
touchPos = Input.mousePosition;
|
||||||
|
touched = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return; // No input detected
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert screen position to world position
|
||||||
|
Ray ray = Camera.main.ScreenPointToRay(touchPos);
|
||||||
|
if (Physics.Raycast(ray, out RaycastHit hit, 100f))
|
||||||
|
{
|
||||||
|
// Check if the touch is close to the LineRenderer
|
||||||
|
if (IsTouchNearLine(hit.point))
|
||||||
|
{
|
||||||
|
Debug.Log("[LineTouchDetector] Line touched! Sending decision to server...");
|
||||||
|
scrollingLineRenderer.SendDecisionToServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsTouchNearLine(Vector3 touchPoint)
|
||||||
|
{
|
||||||
|
float minDistance = float.MaxValue;
|
||||||
|
Vector3[] positions = new Vector3[lineRenderer.positionCount];
|
||||||
|
lineRenderer.GetPositions(positions);
|
||||||
|
|
||||||
|
for (int i = 0; i < positions.Length - 1; i++)
|
||||||
|
{
|
||||||
|
float dist = DistanceFromPointToLineSegment(touchPoint, positions[i], positions[i + 1]);
|
||||||
|
if (dist < minDistance)
|
||||||
|
{
|
||||||
|
minDistance = dist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return minDistance <= touchRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float DistanceFromPointToLineSegment(Vector3 point, Vector3 lineStart, Vector3 lineEnd)
|
||||||
|
{
|
||||||
|
Vector3 closestPoint = ClosestPointOnLineSegment(point, lineStart, lineEnd);
|
||||||
|
return Vector3.Distance(point, closestPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector3 ClosestPointOnLineSegment(Vector3 point, Vector3 a, Vector3 b)
|
||||||
|
{
|
||||||
|
Vector3 ap = point - a;
|
||||||
|
Vector3 ab = b - a;
|
||||||
|
float ab2 = ab.sqrMagnitude;
|
||||||
|
float ap_ab = Vector3.Dot(ap, ab);
|
||||||
|
float t = Mathf.Clamp01(ap_ab / ab2);
|
||||||
|
return a + ab * t;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ae3b814bce97b534eb12f8d764c2be7e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,31 @@
|
|||||||
|
using Unity.BossRoom.Gameplay.GameplayObjects.Character;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ScrollingLineRenderer : MonoBehaviour
|
||||||
|
{
|
||||||
|
public LineRenderer lineRenderer;
|
||||||
|
public Material scrollingMaterial;
|
||||||
|
public float speed = 1.0f; // Adjust speed in Inspector
|
||||||
|
public float tiling = 1.0f; // Controls how many arrows fit in the line
|
||||||
|
public ServerCharacter serverCharacter;
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
lineRenderer.material = scrollingMaterial;
|
||||||
|
}
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (scrollingMaterial == null) return;
|
||||||
|
|
||||||
|
// Scroll texture over time
|
||||||
|
float offset = Time.time * speed;
|
||||||
|
scrollingMaterial.SetFloat("_Speed", speed);
|
||||||
|
scrollingMaterial.SetFloat("_Tiling", -tiling);
|
||||||
|
}
|
||||||
|
public void SendDecisionToServer()
|
||||||
|
{
|
||||||
|
if (serverCharacter != null)
|
||||||
|
{
|
||||||
|
serverCharacter.NotifySwapDecisionRpc(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1e6412647fb95594eb08353a0c8edd79
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue