Commit 76367c20 authored by 16이진형's avatar 16이진형

상호작용 가능할때 문자 뜨기

parent f55c4315
......@@ -652,6 +652,7 @@ MonoBehaviour:
playercamera: {fileID: 1661408489}
velocityslider: {fileID: 260633610}
accelslider: {fileID: 1086622590}
interactText: {fileID: 527034809}
canvas: {fileID: 1193230064}
mytime: {fileID: 1678224219}
wintext: {fileID: 512200287}
......@@ -983,6 +984,87 @@ MonoBehaviour:
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Level Clear!
--- !u!1 &527034807
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 527034808}
- component: {fileID: 527034810}
- component: {fileID: 527034809}
m_Layer: 5
m_Name: Interact Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &527034808
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 527034807}
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_Children: []
m_Father: {fileID: 1193230061}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -117, y: -81}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &527034809
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 527034807}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 1
m_MinSize: 10
m_MaxSize: 200
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: '
'
--- !u!222 &527034810
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 527034807}
m_CullTransparentMesh: 0
--- !u!1 &535323107
GameObject:
m_ObjectHideFlags: 0
......@@ -1341,6 +1423,7 @@ MonoBehaviour:
time: 0
theobject: {fileID: 1320474661}
background: {fileID: 1713675711}
uiManager: {fileID: 394305455}
--- !u!4 &739347347
Transform:
m_ObjectHideFlags: 0
......@@ -2884,6 +2967,7 @@ RectTransform:
- {fileID: 1496132465}
- {fileID: 512200285}
- {fileID: 1086622586}
- {fileID: 527034808}
m_Father: {fileID: 0}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......
......@@ -175,4 +175,20 @@ public class ExtrudedMesh : MonoBehaviour
transform.parent.GetComponent<FlatlandMovement>().OnCollisionStaychild(collision);
}
public void OnCollisionEnter(Collision collision)
{
if (transform.parent.GetComponent(typeof(FlatlandMovement)) == null)
return;
else
transform.parent.GetComponent<FlatlandMovement>().OnCollisionEnterchild(collision);
}
public void OnCollisionExit(Collision collision)
{
if (transform.parent.GetComponent(typeof(FlatlandMovement)) == null)
return;
else
transform.parent.GetComponent<FlatlandMovement>().OnCollisionExitchild(collision);
}
}
......@@ -253,8 +253,28 @@ public class FlatlandMovement : MonoBehaviour
}
}
/// <summary>
/// 겹쳐지면 모든 프레임 호출
/// </summary>
/// <param name="collision"></param>
public virtual void OnCollisionStaychild(Collision collision)
{
}
/// <summary>
/// 들어왔을때 호출
/// </summary>
/// <param name="collision"></param>
public virtual void OnCollisionEnterchild(Collision collision)
{
}
/// <summary>
/// 나갔을때 호출
/// </summary>
/// <param name="collision"></param>
public virtual void OnCollisionExitchild(Collision collision)
{
}
}
......@@ -11,6 +11,10 @@ public class PlayerMovement : FlatlandMovement,IInteractor
public GameObject background;
public UIManager uiManager;
private List<InteractiveObject> interactiveObjects;
// Start is called before the first frame update
void Start()
{
......@@ -21,11 +25,26 @@ public class PlayerMovement : FlatlandMovement,IInteractor
time = 0.0f;
isinertial = true;
alpha = new Vector3(0.0f, 0.0f, 0.0f);
interactiveObjects = new List<InteractiveObject>();
}
void Update()
{
base.Update();
InteractiveObject obj = TryFindClosestInterativeObject();
if (obj)
{
uiManager.InteractText = obj.InteractType;
}
else
{
uiManager.InteractText = "";
}
}
// Update is called once per frame
......@@ -145,18 +164,56 @@ public class PlayerMovement : FlatlandMovement,IInteractor
return;
}
public override void OnCollisionStaychild(Collision collision)
public override void OnCollisionEnterchild(Collision collision)
{
if (collision.transform.parent != null)
{
Debug.Log("Collision");
var x = collision.transform.parent.gameObject.GetComponent<InteractiveObject>();
InteractiveObject x = collision.transform.parent.gameObject.GetComponent<InteractiveObject>();
if (x)
{
//상호작용가능한 물건일때
Debug.Log(x.InteractType);
interactiveObjects.Add(x);
//uiManager.InteractText = x.InteractType;
}
}
}
public override void OnCollisionExitchild(Collision collision)
{
if (collision.transform.parent != null)
{
Debug.Log("Collision");
InteractiveObject x = collision.transform.parent.gameObject.GetComponent<InteractiveObject>();
if (x)
{
//상호작용가능한 물건일때
Debug.Log(x.InteractType);
interactiveObjects.Remove(x);
//uiManager.InteractText = x.InteractType;
}
}
}
private InteractiveObject TryFindClosestInterativeObject()
{
if(interactiveObjects.Count == 0)
{
return null;
}
InteractiveObject result = interactiveObjects[0];
foreach(var obj in interactiveObjects)
{
if(SpaceLength(result.transform.position,transform.position) >= SpaceLength(obj.transform.position, transform.position))
{
result = obj;
}
}
return result;
}
}
......@@ -17,6 +17,8 @@ public class UIManager : MonoBehaviour
[SerializeField]
LogScaleSlider accelslider;
[SerializeField]
private Text interactText;
public Canvas canvas;
public Text mytime;
......@@ -29,7 +31,7 @@ public class UIManager : MonoBehaviour
public LevelManager levelManager;
public PathRenderer pathRenderer;
private int prevSelectPathNum = -1;
private Text pathName;
private Text pathVelocity;
......@@ -259,4 +261,12 @@ public class UIManager : MonoBehaviour
Debug.Log(e);
}
}
public string InteractText
{
set
{
interactText.text = value;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment