hasicak
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
<<<<<<< HEAD
|
||||
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(CapsuleCollider))]
|
||||
=======
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
>>>>>>> origin/main
|
||||
public class Hole : MonoBehaviour
|
||||
{
|
||||
[Header("Nastavení")]
|
||||
@@ -17,19 +13,9 @@ public class Hole : MonoBehaviour
|
||||
[Tooltip("Síla vtahování itemu k díře")]
|
||||
public float pullForce = 4f;
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
[Header("Vizuál")]
|
||||
public Renderer glowRenderer;
|
||||
=======
|
||||
[Header("Pohyb díry (volitelné)")]
|
||||
public bool hasMovement = false;
|
||||
public float moveSpeed = 2f;
|
||||
public Vector2 moveRange = new Vector2(1.5f, 0f);
|
||||
|
||||
[Header("Vizuál")]
|
||||
public SpriteRenderer glowRenderer;
|
||||
>>>>>>> origin/main
|
||||
|
||||
private Vector3 startPosition;
|
||||
private bool isGlowing = false;
|
||||
@@ -48,7 +34,6 @@ public class Hole : MonoBehaviour
|
||||
|
||||
void Update()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
|
||||
}
|
||||
|
||||
@@ -67,29 +52,6 @@ public class Hole : MonoBehaviour
|
||||
Debug.Log($"Rigidbody detected: {other.gameObject.name}, distance: {dist}");
|
||||
Vector3 dir = (transform.position - rb.position).normalized;
|
||||
rb.AddForce(dir * pullForce * Time.fixedDeltaTime, ForceMode.Impulse);
|
||||
=======
|
||||
if (hasMovement)
|
||||
{
|
||||
float x = startPosition.x + Mathf.Sin(Time.time * moveSpeed) * moveRange.x;
|
||||
float y = startPosition.y + Mathf.Cos(Time.time * moveSpeed * 0.7f) * moveRange.y;
|
||||
transform.position = new Vector3(x, y, transform.position.z);
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerStay2D(Collider2D other)
|
||||
{
|
||||
DraggableObject draggable = other.GetComponent<DraggableObject>();
|
||||
if (draggable == null) return;
|
||||
|
||||
float dist = Vector2.Distance(transform.position, other.transform.position);
|
||||
|
||||
|
||||
Rigidbody2D rb = other.GetComponent<Rigidbody2D>();
|
||||
if (rb != null)
|
||||
{
|
||||
Vector2 dir = ((Vector2)transform.position - rb.position).normalized;
|
||||
rb.AddForce(dir * pullForce * Time.fixedDeltaTime, ForceMode2D.Impulse);
|
||||
>>>>>>> origin/main
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +62,7 @@ public class Hole : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
Debug.Log($"Collider entered: {other.gameObject.name}");
|
||||
@@ -110,24 +72,14 @@ public class Hole : MonoBehaviour
|
||||
void OnTriggerExit(Collider other)
|
||||
{
|
||||
Debug.Log($"Collider exited: {other.gameObject.name}");
|
||||
=======
|
||||
void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (other.GetComponent<DraggableObject>() != null) SetGlow(true);
|
||||
}
|
||||
|
||||
void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
>>>>>>> origin/main
|
||||
if (other.GetComponent<DraggableObject>() != null) SetGlow(false);
|
||||
}
|
||||
|
||||
void SetGlow(bool active)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
|
||||
Debug.Log($"SetGlow: {active}");
|
||||
=======
|
||||
>>>>>>> origin/main
|
||||
|
||||
isGlowing = active;
|
||||
if (glowRenderer == null) return;
|
||||
glowRenderer.enabled = active;
|
||||
@@ -139,13 +91,9 @@ public class Hole : MonoBehaviour
|
||||
while (isGlowing && glowRenderer != null)
|
||||
{
|
||||
float t = Mathf.PingPong(Time.time * 3f, 1f);
|
||||
<<<<<<< HEAD
|
||||
Color c = glowRenderer.sharedMaterial.color;
|
||||
glowRenderer.sharedMaterial.color = new Color(c.r, c.g, c.b, Mathf.Lerp(0.3f, 0.9f, t));
|
||||
=======
|
||||
Color c = glowRenderer.color;
|
||||
glowRenderer.color = new Color(c.r, c.g, c.b, Mathf.Lerp(0.3f, 0.9f, t));
|
||||
>>>>>>> origin/main
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user