uc-hoba 8 years ago
commit b0f46d1ff3
  1. 941
      Unity_2018_Frozen/Assets/Frozen/FrozenTwo.unity
  2. 101
      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]
private bool standby = true;
[Range(3, 15)]
public float DisAppearTime = 5;
public Material mat;
public Area area;
public Vector2 WallROI;
public float wallDistance = 0;
public float bottomHeight = 0.1f;
public float minHeight = 0;
public float MaxHeight = 0.5f;
[SerializeField]
private RectTransform m_recttrans;
@ -24,6 +29,9 @@ public class CharacterBehaviour : MonoBehaviour {
private MeshRenderer m_meshRender;
public Color color;
private bool isSleep;
public float VideoStopTime = 1.5f;
private void Awake()
{
m_meshRender = GetComponent<MeshRenderer>();
@ -79,7 +87,7 @@ public class CharacterBehaviour : MonoBehaviour {
mat.mainTextureOffset = new Vector2(0,-1);
StartCoroutine(PlayOnStart());
InitialTouchButton();
RandomAppearWall();
StartCoroutine(RandomPosNoTriggerOther());
}
IEnumerator PlayOnStart()
@ -89,6 +97,7 @@ public class CharacterBehaviour : MonoBehaviour {
while (!player.IsPlaying)
{
player.Play();
mat.mainTexture = player.Texture;
yield return null;
}
}
@ -97,9 +106,14 @@ public class CharacterBehaviour : MonoBehaviour {
void Update () {
if (Input.GetKeyDown(KeyCode.R))
RandomAppearWall();
{
if(!isTriggerCollider)
StartCoroutine(RandomPosNoTriggerOther());
}
if(!isSleep)
UpdateMaterial();
if (!isSleep)
{
if (!standby)
CheckPlayFinished();
@ -127,17 +141,17 @@ public class CharacterBehaviour : MonoBehaviour {
Quaternion q = new Quaternion();
if (area == Area.LeftWall)
{
newPos.x = -FrozenScreenToWorldSpace.Instance.length / 2 + wallDistance;
newPos.x = -FrozenScreenToWorldSpace.Instance.length / 2;
q.SetLookRotation(Vector3.left);
}
if (area == Area.RightWall)
{
newPos.x = FrozenScreenToWorldSpace.Instance.length / 2 - wallDistance;
newPos.x = FrozenScreenToWorldSpace.Instance.length / 2;
q.SetLookRotation(Vector3.right);
}
if (area == Area.TopWall)
{
newPos.z = FrozenScreenToWorldSpace.Instance.width / 2 - wallDistance;
newPos.z = FrozenScreenToWorldSpace.Instance.width / 2;
q.SetLookRotation(Vector3.forward);
}
transform.rotation = q;
@ -168,7 +182,7 @@ public class CharacterBehaviour : MonoBehaviour {
else
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();
SetButtonPos();
}
@ -199,17 +213,10 @@ public class CharacterBehaviour : MonoBehaviour {
IEnumerator Sleep()
{
isSleep = true;
currentPlayer.Pause();
currentPlayer.Frame = 0;
yield return StartCoroutine(Fade(0));
m_meshRender.enabled = false;
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));
yield return StartCoroutine(WaitVideoStopTimeFadeOut());
yield return new WaitForSeconds(GetDisAppear());
yield return StartCoroutine(RandomPosNoTriggerOther());
yield return StartCoroutine(WaitVideoStandbyFadeIn());
isSleep = false;
Idle();
}
@ -224,6 +231,60 @@ public class CharacterBehaviour : MonoBehaviour {
color.a = Mathf.Lerp(origin, targetA, value);
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; } }
private static FrozenCharacterController instance;
[Range(3,15)]
public float DisAppearTime;
public float Maxheight = 0.65f;
private void Awake()
{
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;
float4 _MainTex_ST;
float4 _Color;
v2f vert (appdata_t v)
{
v2f o;
@ -57,6 +58,7 @@ SubShader {
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.texcoord) * _Color;
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}

Loading…
Cancel
Save