Commit f3bc76e6 authored by abpo11's avatar abpo11

아이템 및 생명석 하이라이트, e키를 누르면 상호작용으로 먹어짐

parent 40cfe404
......@@ -1020,6 +1020,11 @@ Prefab:
propertyPath: inventoryManager
value:
objectReference: {fileID: 1908917313}
- target: {fileID: 114294925164316638, guid: 3d077a5f727dd1e4780e9265ed26e036,
type: 2}
propertyPath: itemLayer.m_Bits
value: 8192
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3d077a5f727dd1e4780e9265ed26e036, type: 2}
m_IsPrefabAsset: 0
......
......@@ -53,13 +53,18 @@ public class PlayerController : MonoBehaviour
[SerializeField]
private LayerMask outerwallLayer;
[SerializeField]
private LayerMask itemLayer;
[SerializeField]
private float ropeDistance = 0.3f;
[SerializeField]
private float rayDistance;
[SerializeField]
private float ropeUp, ropeDown;
[SerializeField]
private DroppedItem lastDropItem;
private DroppedLifeStone lastLifeStone;
private float interaction;
private bool interactionCoolDown=true;
public PlayerState playerState, previousState;
void Start()
......@@ -73,7 +78,7 @@ public class PlayerController : MonoBehaviour
horizontal = Input.GetAxis("Horizontal");
horizontalRaw = Input.GetAxisRaw("Horizontal");
verticalRaw = Input.GetAxisRaw("Vertical");
interaction = Input.GetAxisRaw("interaction");
if (Input.GetButtonDown("Jump"))
{
jump = true;
......@@ -91,7 +96,24 @@ public class PlayerController : MonoBehaviour
rb.gravityScale = rbAttackGravityScale;
return;
}
if (GetItemRay() == false && lastDropItem!=null)
{
lastDropItem.HighlightSwitch(false);
lastDropItem = null;
}
if (interaction != 1f) interactionCoolDown = true;
if (lastDropItem!=null && interaction == 1f &&interactionCoolDown)
{
interactionCoolDown = false;
print(lastDropItem.PushItem()+"냠냠");
}
if(lastLifeStone!=null && interaction == 1f && interactionCoolDown)
{
interactionCoolDown = false;
lastLifeStone.ApplyLifeStone();
print("생명석 냠냠");
}
if (isGrounded)
isJumpable = true;
if (playerState != PlayerState.Attack)
......@@ -248,6 +270,76 @@ public class PlayerController : MonoBehaviour
return (hit1.collider != null || hit2.collider != null || hit3.collider != null||
hit4.collider != null || hit5.collider != null || hit6.collider != null) && rb.velocity.y == 0;//플랫폼 점프 버그 방지
}
bool GetItemRay()
{
RaycastHit2D hit1 = Physics2D.Raycast(transform.position + new Vector3(Player.X / 2f *0f, 0, 0), Vector2.down, rayDistance, itemLayer);
// RaycastHit2D hit2 = Physics2D.Raycast(transform.position - new Vector3(Player.X / 2f, 0, 0), Vector2.down, rayDistance, itemLayer);
Debug.DrawRay(transform.position + new Vector3(Player.X / 2f*0f, 0, 0), rayDistance * Vector2.down, Color.white);
if (hit1.collider != null)
{
DroppedItem temp = hit1.collider.GetComponent<DroppedItem>();
DroppedLifeStone stoneTemp;
if (temp == null)
{
stoneTemp = hit1.collider.GetComponent<DroppedLifeStone>();
if (lastLifeStone!= stoneTemp)
{
if (lastLifeStone != null)
{
lastLifeStone.HighlightSwitch(false);
}
lastLifeStone = stoneTemp;
stoneTemp.HighlightSwitch(true);
}
}
else if (lastDropItem != temp)
{
if (lastDropItem != null)
{
lastDropItem.HighlightSwitch(false);
}
lastDropItem = temp;
temp.HighlightSwitch(true);
}
}
/*else if(hit2.collider != null)
{
DroppedItem temp = hit2.collider.GetComponent<DroppedItem>();
DroppedLifeStone stoneTemp;
if (temp == null)
{
stoneTemp = hit2.collider.GetComponent<DroppedLifeStone>();
if (lastLifeStone != stoneTemp)
{
if (lastLifeStone != null)
{
lastLifeStone.HighlightSwitch(false);
}
lastLifeStone = stoneTemp;
stoneTemp.HighlightSwitch(true);
}
}
else if (lastDropItem != temp)
{
if (lastDropItem != null)
{
lastDropItem.HighlightSwitch(false);
}
lastDropItem = temp;
temp.HighlightSwitch(true);
}
}*/
return hit1.collider != null ;
}
bool IsInRope() // Is player in rope?
{
RaycastHit2D hit1 = Physics2D.Raycast(transform.position + ropeUp * Vector3.up, Vector2.right, ropeDistance, ropeLayer);
......
......@@ -278,13 +278,29 @@ InputManager:
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Submit
m_Name: interaction
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: e
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Cancel
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: enter
positiveButton: escape
altNegativeButton:
altPositiveButton: space
altPositiveButton: joystick button 1
gravity: 1000
dead: 0.001
sensitivity: 1000
......
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