diff --git a/Assets/Art/Materials/T_commode_1_D.mat b/Assets/Art/Materials/T_commode_1_D.mat new file mode 100644 index 0000000..e2bbab1 Binary files /dev/null and b/Assets/Art/Materials/T_commode_1_D.mat differ diff --git a/Assets/Art/Materials/T_commode_1_D.mat.meta b/Assets/Art/Materials/T_commode_1_D.mat.meta new file mode 100644 index 0000000..0f391b5 --- /dev/null +++ b/Assets/Art/Materials/T_commode_1_D.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1894dbc07d32ec040af40e55380a9d5f +timeCreated: 1440297631 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art/Materials/T_commode_D.mat b/Assets/Art/Materials/T_commode_D.mat new file mode 100644 index 0000000..46b5a04 Binary files /dev/null and b/Assets/Art/Materials/T_commode_D.mat differ diff --git a/Assets/Art/Materials/T_commode_D.mat.meta b/Assets/Art/Materials/T_commode_D.mat.meta new file mode 100644 index 0000000..9cb6471 --- /dev/null +++ b/Assets/Art/Materials/T_commode_D.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 507be854a4d610b4c9227d57afdcb6d3 +timeCreated: 1440297625 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art/SM_commode_1_.FBX b/Assets/Art/SM_commode_1_.FBX new file mode 100644 index 0000000..a98c830 Binary files /dev/null and b/Assets/Art/SM_commode_1_.FBX differ diff --git a/Assets/Art/SM_commode_1_.FBX.meta b/Assets/Art/SM_commode_1_.FBX.meta new file mode 100644 index 0000000..c86c2af --- /dev/null +++ b/Assets/Art/SM_commode_1_.FBX.meta @@ -0,0 +1,74 @@ +fileFormatVersion: 2 +guid: 5db9b9991e715344a89919be8ce49389 +timeCreated: 1440297625 +licenseType: Free +ModelImporter: + serializedVersion: 18 + fileIDToRecycleName: + 100000: //RootNode + 400000: //RootNode + 2300000: //RootNode + 3300000: //RootNode + 4300000: Box054 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + optimizeGameObjects: 0 + motionNodeName: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: .5 + animationPositionError: .5 + animationScaleError: .5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + splitTangentsAcrossUV: 1 + normalImportMode: 0 + tangentImportMode: 1 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + human: [] + skeleton: [] + armTwist: .5 + foreArmTwist: .5 + upperLegTwist: .5 + legTwist: .5 + armStretch: .0500000007 + legStretch: .0500000007 + feetSpacing: 0 + rootMotionBoneName: + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art/SM_commode_1_.fbm.meta b/Assets/Art/SM_commode_1_.fbm.meta new file mode 100644 index 0000000..03fce9a --- /dev/null +++ b/Assets/Art/SM_commode_1_.fbm.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e24261dccdd4ec142959624f87ea6140 +folderAsset: yes +timeCreated: 1440297624 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art/SM_commode_1_.fbm/T_commode_D.tga b/Assets/Art/SM_commode_1_.fbm/T_commode_D.tga new file mode 100644 index 0000000..8fefe03 Binary files /dev/null and b/Assets/Art/SM_commode_1_.fbm/T_commode_D.tga differ diff --git a/Assets/Art/SM_commode_1_.fbm/T_commode_D.tga.meta b/Assets/Art/SM_commode_1_.fbm/T_commode_D.tga.meta new file mode 100644 index 0000000..def9349 --- /dev/null +++ b/Assets/Art/SM_commode_1_.fbm/T_commode_D.tga.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: f7e9071f7a47fb947858f8dabffd3bbf +timeCreated: 1440297625 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art/SM_commode_2_.FBX b/Assets/Art/SM_commode_2_.FBX new file mode 100644 index 0000000..722435f Binary files /dev/null and b/Assets/Art/SM_commode_2_.FBX differ diff --git a/Assets/Art/SM_commode_2_.FBX.meta b/Assets/Art/SM_commode_2_.FBX.meta new file mode 100644 index 0000000..e363248 --- /dev/null +++ b/Assets/Art/SM_commode_2_.FBX.meta @@ -0,0 +1,74 @@ +fileFormatVersion: 2 +guid: ef8771875030cca4b8ae59900904752a +timeCreated: 1440297631 +licenseType: Free +ModelImporter: + serializedVersion: 18 + fileIDToRecycleName: + 100000: //RootNode + 400000: //RootNode + 2300000: //RootNode + 3300000: //RootNode + 4300000: Box065 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + optimizeGameObjects: 0 + motionNodeName: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: .5 + animationPositionError: .5 + animationScaleError: .5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + splitTangentsAcrossUV: 1 + normalImportMode: 0 + tangentImportMode: 1 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + human: [] + skeleton: [] + armTwist: .5 + foreArmTwist: .5 + upperLegTwist: .5 + legTwist: .5 + armStretch: .0500000007 + legStretch: .0500000007 + feetSpacing: 0 + rootMotionBoneName: + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art/SM_commode_2_.fbm.meta b/Assets/Art/SM_commode_2_.fbm.meta new file mode 100644 index 0000000..7173300 --- /dev/null +++ b/Assets/Art/SM_commode_2_.fbm.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 36f98f419991a654d81ade73afcee8fa +folderAsset: yes +timeCreated: 1440297631 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art/SM_commode_2_.fbm/T_commode_1_D.tga b/Assets/Art/SM_commode_2_.fbm/T_commode_1_D.tga new file mode 100644 index 0000000..38bcfe9 Binary files /dev/null and b/Assets/Art/SM_commode_2_.fbm/T_commode_1_D.tga differ diff --git a/Assets/Art/SM_commode_2_.fbm/T_commode_1_D.tga.meta b/Assets/Art/SM_commode_2_.fbm/T_commode_1_D.tga.meta new file mode 100644 index 0000000..77990c5 --- /dev/null +++ b/Assets/Art/SM_commode_2_.fbm/T_commode_1_D.tga.meta @@ -0,0 +1,55 @@ +fileFormatVersion: 2 +guid: d75d0130f08061a43a0aec68715549dd +timeCreated: 1440297631 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/PatScene.unity b/Assets/Scenes/PatScene.unity index b0f867e..b4ec123 100644 Binary files a/Assets/Scenes/PatScene.unity and b/Assets/Scenes/PatScene.unity differ diff --git a/Assets/Scripts/MomBehavior.cs b/Assets/Scripts/MomBehavior.cs index c5615cd..5b70763 100644 --- a/Assets/Scripts/MomBehavior.cs +++ b/Assets/Scripts/MomBehavior.cs @@ -8,7 +8,6 @@ using InputHandler; public class MomBehavior : MonoBehaviour { - public Action OnWarning; public Action OnEnterRoom; public Action OnLeaveRoom; @@ -17,20 +16,23 @@ public class MomBehavior : MonoBehaviour public float MaxTriggerTime = 90f; public float WarningHeadsupTime = 5f; public float MotherStayTime = 2f; + public Door RoomDoor; public Child[] Children; + private enum State { Away, Warning, InRoom } + + private State _currentState; + private float _elapsedTime = 0f; private float _nextTriggerTime; - private bool _isInRoom; - private bool _gameOver = false; public bool IsInRoom { - get { return _isInRoom; } + get { return _currentState == State.InRoom; } } void Awake() @@ -46,83 +48,100 @@ public class MomBehavior : MonoBehaviour _elapsedTime += Time.deltaTime; - if (_elapsedTime >= _nextTriggerTime - WarningHeadsupTime && _elapsedTime < _nextTriggerTime) + switch (_currentState) { - WarningText.gameObject.SetActive(true); - - if (OnWarning != null) - { - OnWarning(); - } - } - else if (_elapsedTime >= _nextTriggerTime) - { - WarningText.gameObject.SetActive(false); - _nextTriggerTime = GetNextTriggerTime(); - - _elapsedTime = 0f; - - StartCoroutine(StayInRoom()); - } - - if (_isInRoom) - { - List safeChildren = new List(); - - foreach (Child child in Children) - { - if (child == null) continue; - - if (child.IsSleeping) + case State.Away: + if (_elapsedTime >= _nextTriggerTime - WarningHeadsupTime && _elapsedTime < _nextTriggerTime) { - safeChildren.Add(child); + SetState(State.Warning); } - else + break; + case State.Warning: + if (_elapsedTime >= _nextTriggerTime) { - Debug.Log("Player " + child.Index + " has been spotted by mom."); - - // TODO: Visual animation that the player lost (lasso?) - - Destroy(child.gameObject); + SetState(State.InRoom); + } + break; + case State.InRoom: + if (_elapsedTime >= 2f) + { + SetState(State.Away); } - } - if (safeChildren.Count == 0) - { - Debug.Log("Mom wins!"); - - MenusManager.Instance.ShowMenu("MomWinsMenu"); - - _gameOver = true; - } - else if (safeChildren.Count == 1) - { - Debug.Log("Player " + safeChildren[0].Index + " wins!"); - - PlayerWinsMenu menu = (PlayerWinsMenu)MenusManager.Instance.ShowMenu("PlayerWinsMenu"); - menu.SetPlayerIndex(safeChildren[0].Index); - - _gameOver = true; - } + CheckIfSleeping(); + break; } } - private IEnumerator StayInRoom() + private void SetState(State newState) { - if (OnEnterRoom != null) + switch (newState) { - OnEnterRoom(); + case State.Away: + RoomDoor.Close(OnLeaveRoom); + _elapsedTime = 0f; + break; + case State.Warning: + // Temporary + WarningText.gameObject.SetActive(true); + + RoomDoor.Open(); + break; + case State.InRoom: + // Temporary + WarningText.gameObject.SetActive(false); + _nextTriggerTime = GetNextTriggerTime(); + + _elapsedTime = 0f; + + if (OnEnterRoom != null) + { + OnEnterRoom(); + } + break; } - _isInRoom = true; + _currentState = newState; + } - yield return new WaitForSeconds(MotherStayTime); + private void CheckIfSleeping() + { + List safeChildren = new List(); - _isInRoom = false; - - if (OnLeaveRoom != null) + foreach (Child child in Children) { - OnLeaveRoom(); + if (child == null) continue; + + if (child.IsSleeping) + { + safeChildren.Add(child); + } + else + { + Debug.Log("Player " + child.Index + " has been spotted by mom."); + + // TODO: Visual animation that the player lost (lasso?) + + Destroy(child.gameObject); + } + } + + if (safeChildren.Count == 0) + { + Debug.Log("Mom wins!"); + + MenusManager.Instance.ShowMenu("MomWinsMenu"); + + _gameOver = true; + } + else if (safeChildren.Count == 1) + { + Debug.Log("Player " + safeChildren[0].Index + " wins!"); + + PlayerWinsMenu menu = (PlayerWinsMenu)MenusManager.Instance.ShowMenu("PlayerWinsMenu"); + menu.SetPlayerIndex(safeChildren[0].Index); + + _gameOver = true; } } diff --git a/Assets/Test/Door.cs b/Assets/Test/Door.cs index 8ef7f11..658a567 100644 --- a/Assets/Test/Door.cs +++ b/Assets/Test/Door.cs @@ -1,41 +1,70 @@ using UnityEngine; -using System.Collections; +using System.Collections; +using System; -public class Door : MonoBehaviour { - - private float state = 0f; //From 0 to 1 (closed to open) - private float goal = -1f; //-1 or 1 - public float angles; - public float openingSpeed; - public AnimationCurve curvature; +public class Door : MonoBehaviour +{ + public float MaxAngle = 135f; + public float OpenDuration = 5f; + public float CloseDuration = 1f; - // Use this for initialization - void Start () { - - } - + /* // Update is called once per frame - void Update () { - - if (Input.GetKeyDown(KeyCode.A)) - { - goal *= -1; - } - + void Update () + { state = Mathf.Clamp(state + goal * openingSpeed * Time.deltaTime, 0f, 1f); //transform.rotation = Quaternion.identity; //transform.Rotate(Vector3.up * state * angles); transform.rotation = Quaternion.Euler(Vector3.up * curvature.Evaluate(state) * -angles); - } + }*/ public void Open() { - + StartCoroutine(OpenDoor()); } - public void Close() - { + private IEnumerator OpenDoor() + { + Vector3 initialRot = transform.localEulerAngles; + Vector3 finalRot = new Vector3(initialRot.x, initialRot.y - MaxAngle, initialRot.z); - } + float ratio = 0f; + + while (ratio < 1f) + { + ratio += Time.deltaTime / OpenDuration; + + transform.localEulerAngles = Vector3.Lerp(initialRot, finalRot, ratio); + + yield return null; + } + } + + public void Close(Action callback) + { + StartCoroutine("CloseDoor", callback); + } + + private IEnumerator CloseDoor(object callback) + { + Vector3 initialRot = transform.localEulerAngles; + Vector3 finalRot = new Vector3(initialRot.x, initialRot.y + MaxAngle, initialRot.z); + + float ratio = 0f; + + while (ratio < 1f) + { + ratio += Time.deltaTime / CloseDuration; + + transform.localEulerAngles = Vector3.Lerp(initialRot, finalRot, Mathf.Pow(ratio, 4)); + + yield return null; + } + + if (callback != null) + { + ((Action)callback)(); + } + } } diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 6e63725..52c12ea 100644 Binary files a/ProjectSettings/ProjectSettings.asset and b/ProjectSettings/ProjectSettings.asset differ