Prepared a function that grants random camera movement (drunk effect)
This commit is contained in:
parent
f9085d0165
commit
2acc73213c
@ -26674,6 +26674,11 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 7b852f4c11744f74d93a7c35435bb4eb, type: 3}
|
m_Script: {fileID: 11500000, guid: 7b852f4c11744f74d93a7c35435bb4eb, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
drunk: 0
|
||||||
|
max: 0
|
||||||
|
duration: 0
|
||||||
|
speed: 2
|
||||||
|
temp: {x: 0, y: 0, z: 0}
|
||||||
--- !u!20 &519420031
|
--- !u!20 &519420031
|
||||||
Camera:
|
Camera:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -40598,9 +40603,9 @@ MonoBehaviour:
|
|||||||
m_OnClick:
|
m_OnClick:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls:
|
m_Calls:
|
||||||
- m_Target: {fileID: 1177353681}
|
- m_Target: {fileID: 519420030}
|
||||||
m_TargetAssemblyTypeName: Player, Assembly-CSharp
|
m_TargetAssemblyTypeName: CamerFollow, Assembly-CSharp
|
||||||
m_MethodName: AddDefensePoint
|
m_MethodName: Drink
|
||||||
m_Mode: 1
|
m_Mode: 1
|
||||||
m_Arguments:
|
m_Arguments:
|
||||||
m_ObjectArgument: {fileID: 0}
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
@ -6,6 +6,13 @@ public class CamerFollow : MonoBehaviour
|
|||||||
{
|
{
|
||||||
|
|
||||||
private Transform playerTransform;
|
private Transform playerTransform;
|
||||||
|
private float xx;
|
||||||
|
private float yy;
|
||||||
|
public int drunk;
|
||||||
|
public float max;
|
||||||
|
public float duration;
|
||||||
|
public float speed = 10.0f;
|
||||||
|
public Vector3 temp;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
@ -14,12 +21,65 @@ public class CamerFollow : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LateUpdate()
|
void LateUpdate()
|
||||||
|
{
|
||||||
|
speed = 3f;
|
||||||
|
max = 0.8f;
|
||||||
|
duration += Time.deltaTime;
|
||||||
|
drunk = PlayerPrefs.GetInt("drunk");
|
||||||
|
if(drunk == 1)
|
||||||
|
{
|
||||||
|
if(duration >= max)
|
||||||
|
{
|
||||||
|
temp = transform.position;
|
||||||
|
xx = Random.Range(-3.0f, 3.0f);
|
||||||
|
yy = Random.Range(-3.0f, 3.0f);
|
||||||
|
temp.x = playerTransform.position.x + xx;
|
||||||
|
temp.y = playerTransform.position.y + yy;
|
||||||
|
duration = 0f;
|
||||||
|
}
|
||||||
|
transform.position = Vector3.MoveTowards(transform.position, temp, speed * Time.deltaTime);
|
||||||
|
if(transform.position.x == temp.x && transform.position.y == temp.y)
|
||||||
|
{
|
||||||
|
xx = Random.Range(-4.0f, 4.0f);
|
||||||
|
yy = Random.Range(-4.0f, 4.0f);
|
||||||
|
temp.x = playerTransform.position.x + xx;
|
||||||
|
temp.y = playerTransform.position.y + yy;
|
||||||
|
transform.position = Vector3.MoveTowards(transform.position, temp, speed * Time.deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(drunk == 2)
|
||||||
|
{
|
||||||
|
temp.x = playerTransform.position.x;
|
||||||
|
temp.y = playerTransform.position.y;
|
||||||
|
transform.position = Vector3.MoveTowards(transform.position, temp, speed * Time.deltaTime);
|
||||||
|
if(playerTransform.position.x == transform.position.x && playerTransform.position.y == transform.position.y)
|
||||||
|
{
|
||||||
|
PlayerPrefs.SetInt("drunk", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// we store current camera's position here
|
// we store current camera's position here
|
||||||
Vector3 temp = transform.position;
|
Vector3 temp = transform.position;
|
||||||
temp.x = playerTransform.position.x;
|
temp.x = playerTransform.position.x;
|
||||||
temp.y = playerTransform.position.y;
|
temp.y = playerTransform.position.y;
|
||||||
transform.position = temp;
|
transform.position = temp;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Drink()
|
||||||
|
{
|
||||||
|
PlayerPrefs.SetInt("drunk", 1);
|
||||||
|
StartCoroutine(SoberUp());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public IEnumerator SoberUp()
|
||||||
|
{
|
||||||
|
yield return new WaitForSecondsRealtime(10);
|
||||||
|
PlayerPrefs.SetInt("drunk", 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,32 +9,32 @@ EditorUserSettings:
|
|||||||
value: 22424703114646680e0b0227036c72111f19352f223d667d6d0a1532f0e1372ce7f518e8ea3f7129370bfb25
|
value: 22424703114646680e0b0227036c72111f19352f223d667d6d0a1532f0e1372ce7f518e8ea3f7129370bfb25
|
||||||
flags: 0
|
flags: 0
|
||||||
RecentlyUsedScenePath-1:
|
RecentlyUsedScenePath-1:
|
||||||
value: 22424703114646680e0b0227036c761e1821112620292135633c133af6f9
|
|
||||||
flags: 0
|
|
||||||
RecentlyUsedScenePath-2:
|
|
||||||
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb
|
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb
|
||||||
flags: 0
|
flags: 0
|
||||||
RecentlyUsedScenePath-3:
|
RecentlyUsedScenePath-2:
|
||||||
value: 22424703114646680e0b0227036c7b0518101d252266333e243d04
|
value: 22424703114646680e0b0227036c7b0518101d252266333e243d04
|
||||||
flags: 0
|
flags: 0
|
||||||
RecentlyUsedScenePath-4:
|
RecentlyUsedScenePath-3:
|
||||||
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
|
|
||||||
flags: 0
|
|
||||||
RecentlyUsedScenePath-5:
|
|
||||||
value: 22424703114646680e0b0227036c68190c160a2e042733232867083debf42d
|
value: 22424703114646680e0b0227036c68190c160a2e042733232867083debf42d
|
||||||
flags: 0
|
flags: 0
|
||||||
RecentlyUsedScenePath-6:
|
RecentlyUsedScenePath-4:
|
||||||
value: 22424703114646680e0b0227036c7c1100123d24383a273e2e2c5326ece92021
|
value: 22424703114646680e0b0227036c7c1100123d24383a273e2e2c5326ece92021
|
||||||
flags: 0
|
flags: 0
|
||||||
RecentlyUsedScenePath-7:
|
RecentlyUsedScenePath-5:
|
||||||
value: 22424703114646680e0b0227036c70050204112e291f2f2a2c3b1920caef212be7a923e7ee2e26
|
value: 22424703114646680e0b0227036c70050204112e291f2f2a2c3b1920caef212be7a923e7ee2e26
|
||||||
flags: 0
|
flags: 0
|
||||||
RecentlyUsedScenePath-8:
|
RecentlyUsedScenePath-6:
|
||||||
value: 22424703114646680e0b0227036c791904040c1c25242a312a2c5326ece92021
|
value: 22424703114646680e0b0227036c791904040c1c25242a312a2c5326ece92021
|
||||||
flags: 0
|
flags: 0
|
||||||
RecentlyUsedScenePath-9:
|
RecentlyUsedScenePath-7:
|
||||||
value: 22424703114646680e0b0227036c7c151b12163e2d3a3f7e38271427fb
|
value: 22424703114646680e0b0227036c7c151b12163e2d3a3f7e38271427fb
|
||||||
flags: 0
|
flags: 0
|
||||||
|
RecentlyUsedScenePath-8:
|
||||||
|
value: 22424703114646680e0b0227036c761e1821112620292135633c133af6f9
|
||||||
|
flags: 0
|
||||||
|
RecentlyUsedScenePath-9:
|
||||||
|
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
|
||||||
|
flags: 0
|
||||||
vcSharedLogLevel:
|
vcSharedLogLevel:
|
||||||
value: 0d5e400f0650
|
value: 0d5e400f0650
|
||||||
flags: 0
|
flags: 0
|
||||||
|
Loading…
Reference in New Issue
Block a user