uc-hoba 8 years ago
commit b0f46d1ff3
  1. 941
      Unity_2018_Frozen/Assets/Frozen/FrozenTwo.unity
  2. 99
      Unity_2018_Frozen/Assets/Frozen/Script/CharacterBehaviour.cs
  3. 20
      Unity_2018_Frozen/Assets/Frozen/Script/FrozenCharacterController.cs
  4. 2
      Unity_2018_Frozen/Assets/Frozen/Shader/UnlitColorAlpha.shader

File diff suppressed because it is too large Load Diff

@ -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,7 +106,12 @@ public class CharacterBehaviour : MonoBehaviour {
void Update () { void Update () {
if (Input.GetKeyDown(KeyCode.R)) if (Input.GetKeyDown(KeyCode.R))
RandomAppearWall(); {
if(!isTriggerCollider)
StartCoroutine(RandomPosNoTriggerOther());
}
UpdateMaterial();
if (!isSleep) if (!isSleep)
{ {
@ -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;
}
}
} }

@ -8,32 +8,12 @@ public class FrozenCharacterController : MonoBehaviour {
public static FrozenCharacterController Instance { get { return instance; } } public static FrozenCharacterController Instance { get { return instance; } }
private static FrozenCharacterController instance; private static FrozenCharacterController instance;
[Range(3,15)]
public float DisAppearTime;
public float Maxheight = 0.65f;
private void Awake() private void Awake()
{ {
instance = this; instance = this;
} }
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public float GetDisAppear()
{
float distime = DisAppearTime - Random.Range(0, DisAppearTime / 2);
distime = DisAppearTime * distime - distime * distime + 0.5f * distime;
return distime;
}
} }

@ -43,6 +43,7 @@ SubShader {
sampler2D _MainTex; sampler2D _MainTex;
float4 _MainTex_ST; float4 _MainTex_ST;
float4 _Color; float4 _Color;
v2f vert (appdata_t v) v2f vert (appdata_t v)
{ {
v2f o; v2f o;
@ -57,6 +58,7 @@ SubShader {
fixed4 frag (v2f i) : SV_Target fixed4 frag (v2f i) : SV_Target
{ {
fixed4 col = tex2D(_MainTex, i.texcoord) * _Color; fixed4 col = tex2D(_MainTex, i.texcoord) * _Color;
UNITY_APPLY_FOG(i.fogCoord, col); UNITY_APPLY_FOG(i.fogCoord, col);
return col; return col;
} }

Loading…
Cancel
Save