mirror of
https://github.com/ConjureETS/PillowFight.git
synced 2026-03-24 00:50:59 +00:00
Add the door open mechanic when the mom comes in
This commit is contained in:
parent
9bf9b5aaef
commit
1c42b584c2
BIN
Assets/Art/Materials/T_commode_1_D.mat
Normal file
BIN
Assets/Art/Materials/T_commode_1_D.mat
Normal file
Binary file not shown.
8
Assets/Art/Materials/T_commode_1_D.mat.meta
Normal file
8
Assets/Art/Materials/T_commode_1_D.mat.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1894dbc07d32ec040af40e55380a9d5f
|
||||
timeCreated: 1440297631
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Art/Materials/T_commode_D.mat
Normal file
BIN
Assets/Art/Materials/T_commode_D.mat
Normal file
Binary file not shown.
8
Assets/Art/Materials/T_commode_D.mat.meta
Normal file
8
Assets/Art/Materials/T_commode_D.mat.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 507be854a4d610b4c9227d57afdcb6d3
|
||||
timeCreated: 1440297625
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Art/SM_commode_1_.FBX
Normal file
BIN
Assets/Art/SM_commode_1_.FBX
Normal file
Binary file not shown.
74
Assets/Art/SM_commode_1_.FBX.meta
Normal file
74
Assets/Art/SM_commode_1_.FBX.meta
Normal file
@ -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:
|
||||
9
Assets/Art/SM_commode_1_.fbm.meta
Normal file
9
Assets/Art/SM_commode_1_.fbm.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e24261dccdd4ec142959624f87ea6140
|
||||
folderAsset: yes
|
||||
timeCreated: 1440297624
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Art/SM_commode_1_.fbm/T_commode_D.tga
Normal file
BIN
Assets/Art/SM_commode_1_.fbm/T_commode_D.tga
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 MiB |
55
Assets/Art/SM_commode_1_.fbm/T_commode_D.tga.meta
Normal file
55
Assets/Art/SM_commode_1_.fbm/T_commode_D.tga.meta
Normal file
@ -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:
|
||||
BIN
Assets/Art/SM_commode_2_.FBX
Normal file
BIN
Assets/Art/SM_commode_2_.FBX
Normal file
Binary file not shown.
74
Assets/Art/SM_commode_2_.FBX.meta
Normal file
74
Assets/Art/SM_commode_2_.FBX.meta
Normal file
@ -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:
|
||||
9
Assets/Art/SM_commode_2_.fbm.meta
Normal file
9
Assets/Art/SM_commode_2_.fbm.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36f98f419991a654d81ade73afcee8fa
|
||||
folderAsset: yes
|
||||
timeCreated: 1440297631
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Art/SM_commode_2_.fbm/T_commode_1_D.tga
Normal file
BIN
Assets/Art/SM_commode_2_.fbm/T_commode_1_D.tga
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 768 KiB |
55
Assets/Art/SM_commode_2_.fbm/T_commode_1_D.tga.meta
Normal file
55
Assets/Art/SM_commode_2_.fbm/T_commode_1_D.tga.meta
Normal file
@ -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:
|
||||
Binary file not shown.
@ -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<Child> safeChildren = new List<Child>();
|
||||
|
||||
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<Child> safeChildren = new List<Child>();
|
||||
|
||||
_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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,41 +1,70 @@
|
||||
using UnityEngine;
|
||||
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;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
public class Door : MonoBehaviour
|
||||
{
|
||||
public float MaxAngle = 135f;
|
||||
public float OpenDuration = 5f;
|
||||
public float CloseDuration = 1f;
|
||||
|
||||
/*
|
||||
// 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)();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user