87 lines
3.7 KiB
C#
87 lines
3.7 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
/*******************************************************************************
|
|
*Create By CG
|
|
*Function µã»÷ºó½ûïÀ¿¨¿Û
|
|
*******************************************************************************/
|
|
namespace ZXK.GYJQR
|
|
{
|
|
public class JinGuKaKouCtrl : Step_0
|
|
{
|
|
public JinGuKaKouCtrl(AZBS itemAttr) : base(itemAttr) { }
|
|
public void BindInitTwo(GameObject geo1, Vector3 pos1, Vector3 rot1, GameObject geo2, Vector3 pos2, Vector3 rot2, System.Action jumpStepEvent)
|
|
{
|
|
Rigidbody part_qddlrg1;
|
|
if (!geo1.TryGetComponent<Rigidbody>(out part_qddlrg1))
|
|
{
|
|
part_qddlrg1 = geo1.AddComponent<Rigidbody>();
|
|
}
|
|
part_qddlrg1.isKinematic = true;
|
|
part_qddlrg1.useGravity = false;
|
|
Rigidbody part_qddlrg2;
|
|
if (!geo2.TryGetComponent<Rigidbody>(out part_qddlrg2))
|
|
{
|
|
part_qddlrg2 = geo2.AddComponent<Rigidbody>();
|
|
}
|
|
part_qddlrg2.isKinematic = true;
|
|
part_qddlrg2.useGravity = false;
|
|
PathManager pm_kakou_1 = geo1.GetComponent<PathManager>() ? geo1.GetComponent<PathManager>() : geo1.AddComponent<PathManager>();
|
|
PathManager pm_kakou_2 = geo2.GetComponent<PathManager>() ? geo2.GetComponent<PathManager>() : geo2.AddComponent<PathManager>();
|
|
pm_kakou_1.onMouseDown = new UnityEngine.Events.UnityEvent();
|
|
pm_kakou_2.onMouseDown = new UnityEngine.Events.UnityEvent();
|
|
pm_kakou_1.onMouseDown.AddListener(() =>
|
|
{
|
|
if (!CG.UTility.PopUpMng._TriAble) return;
|
|
geo1.transform.DOLocalMove(pos1, 2.0f);
|
|
geo1.transform.DOLocalRotate(rot1, 2.0f).onComplete += () =>
|
|
{
|
|
OutLineState(geo1, false);
|
|
geo1.transform.DOKill();
|
|
};
|
|
geo2.transform.DOLocalMove(pos2, 2.0f);
|
|
geo2.transform.DOLocalRotate(rot2, 2.0f).onComplete += () =>
|
|
{
|
|
OutLineState(geo2, false);
|
|
geo2.transform.DOKill();
|
|
};
|
|
OnDelayCort = CG.UTility.MonoManager.Instance.StartCoroutine(OnDelay(2.0f, jumpStepEvent));
|
|
});
|
|
pm_kakou_2.onMouseDown.AddListener(() =>
|
|
{
|
|
|
|
});
|
|
}
|
|
public Coroutine OnDelayCort;
|
|
public IEnumerator OnDelay(float t, System.Action action)
|
|
{
|
|
yield return new WaitForSeconds(t);
|
|
action?.Invoke();
|
|
}
|
|
public void BindInit(GameObject geo, Vector3 pos, Vector3 rot, System.Action jumpStepEvent)
|
|
{
|
|
Rigidbody part_qddlrg;
|
|
if (!geo.TryGetComponent<Rigidbody>(out part_qddlrg))
|
|
{
|
|
part_qddlrg = geo.AddComponent<Rigidbody>();
|
|
}
|
|
part_qddlrg.isKinematic = true;
|
|
part_qddlrg.useGravity = false;
|
|
PathManager pm_kakou_1 = geo.GetComponent<PathManager>() ? geo.GetComponent<PathManager>() : geo.AddComponent<PathManager>();
|
|
pm_kakou_1.onMouseDown = new UnityEngine.Events.UnityEvent();
|
|
pm_kakou_1.onMouseDown.AddListener(() =>
|
|
{
|
|
OnExcuteRotateStep(pm_kakou_1, pos, rot, 2.0f, jumpStepEvent);
|
|
});
|
|
}
|
|
/// <summary>
|
|
/// Ö´ÐÐÐýת½Ç¶È·¾¶¶¯»²½Öè
|
|
/// </summary>
|
|
private void OnExcuteRotateStep(PathManager pm, Vector3 pos, Vector3 rot, float t, System.Action jumpStepEvent)
|
|
{
|
|
pm.transform.DOLocalMove(pos, t);
|
|
OnDelayCort = CG.UTility.MonoManager.Instance.StartCoroutine(OnDelay(t, jumpStepEvent));
|
|
}
|
|
}
|
|
} |