|
|
|
@ -8,12 +8,17 @@ public class CharacterBehaviour : MonoBehaviour { |
|
|
|
[SerializeField] |
|
|
|
[SerializeField] |
|
|
|
private bool standby = true; |
|
|
|
private bool standby = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Range(3, 15)] |
|
|
|
|
|
|
|
public float DisAppearTime = 5; |
|
|
|
|
|
|
|
|
|
|
|
public Material mat; |
|
|
|
public Material mat; |
|
|
|
|
|
|
|
|
|
|
|
public Area area; |
|
|
|
public Area area; |
|
|
|
public Vector2 WallROI; |
|
|
|
public Vector2 WallROI; |
|
|
|
public float wallDistance = 0; |
|
|
|
public float bottomHeight = 0.1f; |
|
|
|
|
|
|
|
public float minHeight = 0; |
|
|
|
|
|
|
|
public float MaxHeight = 0.5f; |
|
|
|
[SerializeField] |
|
|
|
[SerializeField] |
|
|
|
private RectTransform m_recttrans; |
|
|
|
private RectTransform m_recttrans; |
|
|
|
|
|
|
|
|
|
|
|
@ -24,6 +29,9 @@ public class CharacterBehaviour : MonoBehaviour { |
|
|
|
private MeshRenderer m_meshRender; |
|
|
|
private MeshRenderer m_meshRender; |
|
|
|
public Color color; |
|
|
|
public Color color; |
|
|
|
private bool isSleep; |
|
|
|
private bool isSleep; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public float VideoStopTime = 1.5f; |
|
|
|
|
|
|
|
|
|
|
|
private void Awake() |
|
|
|
private void Awake() |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_meshRender = GetComponent<MeshRenderer>(); |
|
|
|
m_meshRender = GetComponent<MeshRenderer>(); |
|
|
|
@ -79,7 +87,7 @@ public class CharacterBehaviour : MonoBehaviour { |
|
|
|
mat.mainTextureOffset = new Vector2(0,-1); |
|
|
|
mat.mainTextureOffset = new Vector2(0,-1); |
|
|
|
StartCoroutine(PlayOnStart()); |
|
|
|
StartCoroutine(PlayOnStart()); |
|
|
|
InitialTouchButton(); |
|
|
|
InitialTouchButton(); |
|
|
|
RandomAppearWall(); |
|
|
|
StartCoroutine(RandomPosNoTriggerOther()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
IEnumerator PlayOnStart() |
|
|
|
IEnumerator PlayOnStart() |
|
|
|
@ -89,6 +97,7 @@ public class CharacterBehaviour : MonoBehaviour { |
|
|
|
while (!player.IsPlaying) |
|
|
|
while (!player.IsPlaying) |
|
|
|
{ |
|
|
|
{ |
|
|
|
player.Play(); |
|
|
|
player.Play(); |
|
|
|
|
|
|
|
mat.mainTexture = player.Texture; |
|
|
|
yield return null; |
|
|
|
yield return null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -97,9 +106,14 @@ public class CharacterBehaviour : MonoBehaviour { |
|
|
|
void Update () { |
|
|
|
void Update () { |
|
|
|
|
|
|
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.R)) |
|
|
|
if (Input.GetKeyDown(KeyCode.R)) |
|
|
|
RandomAppearWall(); |
|
|
|
{ |
|
|
|
|
|
|
|
if(!isTriggerCollider) |
|
|
|
|
|
|
|
StartCoroutine(RandomPosNoTriggerOther()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!isSleep) |
|
|
|
UpdateMaterial(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isSleep) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!standby) |
|
|
|
if (!standby) |
|
|
|
CheckPlayFinished(); |
|
|
|
CheckPlayFinished(); |
|
|
|
@ -127,17 +141,17 @@ public class CharacterBehaviour : MonoBehaviour { |
|
|
|
Quaternion q = new Quaternion(); |
|
|
|
Quaternion q = new Quaternion(); |
|
|
|
if (area == Area.LeftWall) |
|
|
|
if (area == Area.LeftWall) |
|
|
|
{ |
|
|
|
{ |
|
|
|
newPos.x = -FrozenScreenToWorldSpace.Instance.length / 2 + wallDistance; |
|
|
|
newPos.x = -FrozenScreenToWorldSpace.Instance.length / 2; |
|
|
|
q.SetLookRotation(Vector3.left); |
|
|
|
q.SetLookRotation(Vector3.left); |
|
|
|
} |
|
|
|
} |
|
|
|
if (area == Area.RightWall) |
|
|
|
if (area == Area.RightWall) |
|
|
|
{ |
|
|
|
{ |
|
|
|
newPos.x = FrozenScreenToWorldSpace.Instance.length / 2 - wallDistance; |
|
|
|
newPos.x = FrozenScreenToWorldSpace.Instance.length / 2; |
|
|
|
q.SetLookRotation(Vector3.right); |
|
|
|
q.SetLookRotation(Vector3.right); |
|
|
|
} |
|
|
|
} |
|
|
|
if (area == Area.TopWall) |
|
|
|
if (area == Area.TopWall) |
|
|
|
{ |
|
|
|
{ |
|
|
|
newPos.z = FrozenScreenToWorldSpace.Instance.width / 2 - wallDistance; |
|
|
|
newPos.z = FrozenScreenToWorldSpace.Instance.width / 2; |
|
|
|
q.SetLookRotation(Vector3.forward); |
|
|
|
q.SetLookRotation(Vector3.forward); |
|
|
|
} |
|
|
|
} |
|
|
|
transform.rotation = q; |
|
|
|
transform.rotation = q; |
|
|
|
@ -168,7 +182,7 @@ public class CharacterBehaviour : MonoBehaviour { |
|
|
|
else |
|
|
|
else |
|
|
|
WallROI.x = Random.Range(minX, FrozenScreenToWorldSpace.Instance.width - minX) / FrozenScreenToWorldSpace.Instance.width; |
|
|
|
WallROI.x = Random.Range(minX, FrozenScreenToWorldSpace.Instance.width - minX) / FrozenScreenToWorldSpace.Instance.width; |
|
|
|
|
|
|
|
|
|
|
|
WallROI.y = Random.Range(0.5f, FrozenCharacterController.Instance.Maxheight) / (float)FrozenScreenToWorldSpace.Instance.height; |
|
|
|
WallROI.y = Random.Range((transform.localScale.y/2) - transform.localScale.y * bottomHeight + minHeight, MaxHeight) / (float)FrozenScreenToWorldSpace.Instance.height; |
|
|
|
UpdatePos(); |
|
|
|
UpdatePos(); |
|
|
|
SetButtonPos(); |
|
|
|
SetButtonPos(); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -199,17 +213,10 @@ public class CharacterBehaviour : MonoBehaviour { |
|
|
|
IEnumerator Sleep() |
|
|
|
IEnumerator Sleep() |
|
|
|
{ |
|
|
|
{ |
|
|
|
isSleep = true; |
|
|
|
isSleep = true; |
|
|
|
currentPlayer.Pause(); |
|
|
|
yield return StartCoroutine(WaitVideoStopTimeFadeOut()); |
|
|
|
currentPlayer.Frame = 0; |
|
|
|
yield return new WaitForSeconds(GetDisAppear()); |
|
|
|
yield return StartCoroutine(Fade(0)); |
|
|
|
yield return StartCoroutine(RandomPosNoTriggerOther()); |
|
|
|
m_meshRender.enabled = false; |
|
|
|
yield return StartCoroutine(WaitVideoStandbyFadeIn()); |
|
|
|
yield return new WaitForSeconds(FrozenCharacterController.Instance.GetDisAppear()); |
|
|
|
|
|
|
|
RandomAppearWall(); |
|
|
|
|
|
|
|
standby = true; |
|
|
|
|
|
|
|
currentPlayer.Play(); |
|
|
|
|
|
|
|
mat.mainTexture = currentPlayer.Texture; |
|
|
|
|
|
|
|
m_meshRender.enabled = true; |
|
|
|
|
|
|
|
yield return StartCoroutine(Fade(1)); |
|
|
|
|
|
|
|
isSleep = false; |
|
|
|
isSleep = false; |
|
|
|
Idle(); |
|
|
|
Idle(); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -224,6 +231,60 @@ public class CharacterBehaviour : MonoBehaviour { |
|
|
|
color.a = Mathf.Lerp(origin, targetA, value); |
|
|
|
color.a = Mathf.Lerp(origin, targetA, value); |
|
|
|
yield return null; |
|
|
|
yield return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
color.a = targetA; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerator WaitVideoStandbyFadeIn() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
standby = true; |
|
|
|
|
|
|
|
currentPlayer.Play(); |
|
|
|
|
|
|
|
mat.mainTexture = currentPlayer.Texture; |
|
|
|
|
|
|
|
yield return StartCoroutine(Fade(1)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerator WaitVideoStopTimeFadeOut() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
yield return new WaitForSeconds(VideoStopTime); |
|
|
|
|
|
|
|
yield return StartCoroutine(Fade(0)); |
|
|
|
|
|
|
|
currentPlayer.Pause(); |
|
|
|
|
|
|
|
currentPlayer.Frame = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool isTriggerCollider; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnTriggerExit(Collider other) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
isTriggerCollider = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OnTriggerStay(Collider other) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
isTriggerCollider = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnTriggerEnter(Collider other) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
isTriggerCollider = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public float GetDisAppear() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
float distime = DisAppearTime - Random.Range(0, DisAppearTime / 2); |
|
|
|
|
|
|
|
distime = DisAppearTime * distime - distime * distime + 0.5f * distime; |
|
|
|
|
|
|
|
return distime; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerator RandomPosNoTriggerOther() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
RandomAppearWall(); |
|
|
|
|
|
|
|
yield return null; |
|
|
|
|
|
|
|
yield return new WaitForSeconds(0.1f); |
|
|
|
|
|
|
|
while (isTriggerCollider) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
RandomAppearWall(); |
|
|
|
|
|
|
|
yield return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|