132 lines
2.4 KiB
Plaintext
132 lines
2.4 KiB
Plaintext
using Sirenix.OdinInspector;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PHomePushCart : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private PHomePush m_push;
|
|
[SerializeField]
|
|
private bool m_havePlayerInside;
|
|
|
|
[SerializeField]
|
|
private float m_speedBase;
|
|
public float SpeedBase
|
|
{
|
|
get
|
|
{
|
|
return m_speedBase;
|
|
}
|
|
|
|
set
|
|
{
|
|
m_speedBase = value;
|
|
}
|
|
}
|
|
|
|
[SerializeField]
|
|
private float m_speedRatio;
|
|
public float SpeedRatio
|
|
{
|
|
get
|
|
{
|
|
return m_speedRatio;
|
|
}
|
|
|
|
set
|
|
{
|
|
m_speedRatio = value;
|
|
}
|
|
}
|
|
|
|
[SerializeField]
|
|
private float m_returnSpeed;
|
|
[SerializeField]
|
|
private SpriteRenderer m_sprite;
|
|
|
|
[SerializeField]
|
|
private PHomeInventoryDisplayer m_inventoryDisplayer;
|
|
|
|
public float Speed
|
|
{
|
|
get
|
|
{
|
|
return m_speedBase * (1 + SpeedRatio);
|
|
}
|
|
}
|
|
|
|
public float ReturnSpeed
|
|
{
|
|
get
|
|
{
|
|
return m_returnSpeed;
|
|
}
|
|
}
|
|
|
|
public bool HavePlayerInside
|
|
{
|
|
get
|
|
{
|
|
return m_havePlayerInside;
|
|
}
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
m_push = transform.parent.GetComponent<PHomePush>();
|
|
}
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
if (collision.attachedRigidbody == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
PHomePlayer player = collision.attachedRigidbody.GetComponent<PHomePlayer>();
|
|
if (player == null)
|
|
{
|
|
return;
|
|
}
|
|
//m_push.ChoseItemWithPlayer(player.transform.position);
|
|
m_havePlayerInside = true;
|
|
}
|
|
|
|
public void StartPush()
|
|
{
|
|
m_sprite.sprite = m_push.SelectedWorldBall.Body;
|
|
}
|
|
|
|
private void OnTriggerExit2D(Collider2D collision)
|
|
{
|
|
if (collision.attachedRigidbody == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
PHomePlayer player = collision.attachedRigidbody.GetComponent<PHomePlayer>();
|
|
if (player == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
m_havePlayerInside = false;
|
|
}
|
|
|
|
public void OpenInventorySelect()
|
|
{
|
|
if (PHomeGameMode.main.IsInPreStage)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (m_push.IsPushingStarted || m_push.IsFinished)
|
|
{
|
|
return;
|
|
}
|
|
|
|
m_inventoryDisplayer.Init(this, true);
|
|
}
|
|
}
|