- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg) - LoginPanel: InputField placeholder本地化、字体颜色保持 - HistoryPanel: 用时数据本地化、placeholder本地化 - RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建) - AppraiseWindowBase: 评价等级本地化、操作消息重建 - EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized - StudentOperateRecorder: 新增InjectOperateMsgLocalized方法 - LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选 - 字体切换时保留颜色和verticalOverflow
102 lines
2.7 KiB
C#
102 lines
2.7 KiB
C#
namespace VRTK.Examples.Archery
|
|
{
|
|
using UnityEngine;
|
|
|
|
public class Arrow : MonoBehaviour
|
|
{
|
|
public float maxArrowLife = 10f;
|
|
[HideInInspector]
|
|
public bool inFlight = false;
|
|
|
|
private bool collided = false;
|
|
private Rigidbody rigidBody;
|
|
private GameObject arrowHolder;
|
|
private Vector3 originalPosition;
|
|
private Quaternion originalRotation;
|
|
private Vector3 originalScale;
|
|
|
|
public void SetArrowHolder(GameObject holder)
|
|
{
|
|
arrowHolder = holder;
|
|
arrowHolder.SetActive(false);
|
|
}
|
|
|
|
public void OnNock()
|
|
{
|
|
collided = false;
|
|
inFlight = false;
|
|
}
|
|
|
|
public void Fired()
|
|
{
|
|
DestroyArrow(maxArrowLife);
|
|
}
|
|
|
|
public void ResetArrow()
|
|
{
|
|
collided = true;
|
|
inFlight = false;
|
|
RecreateNotch();
|
|
ResetTransform();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
rigidBody = GetComponent<Rigidbody>();
|
|
SetOrigns();
|
|
}
|
|
|
|
private void SetOrigns()
|
|
{
|
|
originalPosition = transform.localPosition;
|
|
originalRotation = transform.localRotation;
|
|
originalScale = transform.localScale;
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
if (!collided)
|
|
{
|
|
transform.LookAt(transform.position + rigidBody.velocity);
|
|
}
|
|
}
|
|
|
|
private void OnCollisionEnter(Collision collision)
|
|
{
|
|
if (inFlight)
|
|
{
|
|
ResetArrow();
|
|
}
|
|
}
|
|
|
|
private void RecreateNotch()
|
|
{
|
|
//swap the arrow holder to be the parent again
|
|
arrowHolder.transform.SetParent(null);
|
|
arrowHolder.SetActive(true);
|
|
|
|
//make the arrow a child of the holder again
|
|
transform.SetParent(arrowHolder.transform);
|
|
|
|
//reset the state of the rigidbodies and colliders
|
|
GetComponent<Rigidbody>().isKinematic = true;
|
|
GetComponent<Collider>().enabled = false;
|
|
arrowHolder.GetComponent<Rigidbody>().isKinematic = false;
|
|
}
|
|
|
|
private void ResetTransform()
|
|
{
|
|
arrowHolder.transform.position = transform.position;
|
|
arrowHolder.transform.rotation = transform.rotation;
|
|
transform.localPosition = originalPosition;
|
|
transform.localRotation = originalRotation;
|
|
transform.localScale = originalScale;
|
|
}
|
|
|
|
private void DestroyArrow(float time)
|
|
{
|
|
Destroy(arrowHolder, time);
|
|
Destroy(gameObject, time);
|
|
}
|
|
}
|
|
} |