Sync
This commit is contained in:
parent
dce16ef235
commit
f927a71fab
|
@ -1183,6 +1183,9 @@ PrefabInstance:
|
||||||
- targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
|
- targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
|
||||||
insertIndex: -1
|
insertIndex: -1
|
||||||
addedObject: {fileID: 1579580572}
|
addedObject: {fileID: 1579580572}
|
||||||
|
- targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
|
||||||
|
insertIndex: -1
|
||||||
|
addedObject: {fileID: 1579580579}
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
|
||||||
--- !u!114 &869964774 stripped
|
--- !u!114 &869964774 stripped
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
@ -1492,6 +1495,9 @@ PrefabInstance:
|
||||||
- targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
|
- targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
|
||||||
insertIndex: -1
|
insertIndex: -1
|
||||||
addedObject: {fileID: 1254139637}
|
addedObject: {fileID: 1254139637}
|
||||||
|
- targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
|
||||||
|
insertIndex: -1
|
||||||
|
addedObject: {fileID: 1254139644}
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
|
||||||
--- !u!114 &1232208433 stripped
|
--- !u!114 &1232208433 stripped
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
@ -1551,7 +1557,21 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
StepInterval: 0.8
|
StepInterval: 0.8
|
||||||
Volume: 1
|
Volume: 0.25
|
||||||
|
--- !u!114 &1254139644
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1254139629}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 20d294d88e5bc8a42afb1f72751fb61f, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
RopeRubleTolerance: 0.5
|
||||||
|
rope: {fileID: 1920006248}
|
||||||
--- !u!1 &1377274208
|
--- !u!1 &1377274208
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -3225,7 +3245,21 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
StepInterval: 0.8
|
StepInterval: 0.8
|
||||||
Volume: 1
|
Volume: 0.25
|
||||||
|
--- !u!114 &1579580579
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1579580564}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 20d294d88e5bc8a42afb1f72751fb61f, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
RopeRubleTolerance: 0.5
|
||||||
|
rope: {fileID: 1920006248}
|
||||||
--- !u!1 &1600052931
|
--- !u!1 &1600052931
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -3893,7 +3927,7 @@ MonoBehaviour:
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 4910321061857220296}
|
m_GameObject: {fileID: 4910321061857220296}
|
||||||
m_Enabled: 1
|
m_Enabled: 0
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 8766ad5393174fa488ef4a58b62181b4, type: 3}
|
m_Script: {fileID: 11500000, guid: 8766ad5393174fa488ef4a58b62181b4, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Unity.Mathematics;
|
||||||
|
|
||||||
|
public static class FloatExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Refrence link: https://forum.unity.com/attachments/upload_2021-1-14_13-8-33-png.773578/
|
||||||
|
/// </summary>
|
||||||
|
public static float Remap(this float from, float fromMin, float fromMax, float toMin, float toMax)
|
||||||
|
{
|
||||||
|
var fromAbs = from - fromMin;
|
||||||
|
var fromMaxAbs = fromMax - fromMin;
|
||||||
|
|
||||||
|
var normal = fromAbs / fromMaxAbs;
|
||||||
|
|
||||||
|
var toMaxAbs = toMax - toMin;
|
||||||
|
var toAbs = toMaxAbs * normal;
|
||||||
|
|
||||||
|
var to = toAbs + toMin;
|
||||||
|
|
||||||
|
return to;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Just clamps the value between two numbers (Easier to write)
|
||||||
|
/// </summary>
|
||||||
|
public static float Clamp(this float input, float min, float max) => math.clamp(input, min, max);
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f285fcef3bcd16648a7d1bc02576bad3
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using UnityEngine.Windows;
|
||||||
|
using UnityEngine.InputSystem.DualShock;
|
||||||
|
|
||||||
[RequireComponent(typeof(PlayerInput))]
|
[RequireComponent(typeof(PlayerInput))]
|
||||||
public class PlayerMovement : MonoBehaviour
|
public class PlayerMovement : MonoBehaviour
|
||||||
|
@ -13,11 +15,6 @@ public class PlayerMovement : MonoBehaviour
|
||||||
|
|
||||||
private bool right = false;
|
private bool right = false;
|
||||||
|
|
||||||
private bool vibrate = false;
|
|
||||||
[SerializeField] private float stepCooldown = 0.05f;
|
|
||||||
[SerializeField] private float stepVibrationTime = 0.05f;
|
|
||||||
|
|
||||||
[SerializeField] private GameObject rumble;
|
|
||||||
|
|
||||||
[Header("Whipping")]
|
[Header("Whipping")]
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
|
@ -44,19 +41,21 @@ public class PlayerMovement : MonoBehaviour
|
||||||
playerInput.useArrowKeys = true;
|
playerInput.useArrowKeys = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
StartCoroutine(ToggleWithDelay());
|
if (playerInput.controller != null)
|
||||||
|
{
|
||||||
|
var pad = (DualShockGamepad)Gamepad.all.ElementAtOrDefault(playerInput.PlayerNum);
|
||||||
|
if (pad == null) return;
|
||||||
|
|
||||||
|
if (playerInput.PlayerNum == 1)
|
||||||
|
pad.SetLightBarColor(Color.red);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (playerInput.movement != Vector2.zero)
|
if (playerInput.movement != Vector2.zero)
|
||||||
{
|
{
|
||||||
RumbleWalk();
|
animationHandler.Run();
|
||||||
animationHandler.Run(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
animationHandler.Run(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void FixedUpdate()
|
private void FixedUpdate()
|
||||||
|
@ -81,37 +80,4 @@ public class PlayerMovement : MonoBehaviour
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void RumbleWalk()
|
|
||||||
{
|
|
||||||
if (vibrate && playerInput.controller != null)
|
|
||||||
{
|
|
||||||
if (right)
|
|
||||||
{
|
|
||||||
rumble.GetComponent<RumbleManager>().RumblePulse(0.0f, 0.004f, stepVibrationTime, playerInput.PlayerNum);
|
|
||||||
right = false;
|
|
||||||
}
|
|
||||||
else if (!right)
|
|
||||||
{
|
|
||||||
rumble.GetComponent<RumbleManager>().RumblePulse(0.004f, 0.0f, stepVibrationTime, playerInput.PlayerNum);
|
|
||||||
right = true;
|
|
||||||
}
|
|
||||||
vibrate = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private IEnumerator ToggleWithDelay()
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
vibrate = !vibrate;
|
|
||||||
yield return new WaitForSeconds(stepCooldown);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnCollisionStay2D(Collision2D collision)
|
|
||||||
{
|
|
||||||
if (collision.otherCollider.gameObject.CompareTag("Enemy"))
|
|
||||||
{ // Other object is an enemy
|
|
||||||
hp.TakeDamage(1f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class RopeSimulator : MonoBehaviour
|
||||||
|
|
||||||
if (prevSubDivision - (int) subDivision >= 0) return;
|
if (prevSubDivision - (int) subDivision >= 0) return;
|
||||||
|
|
||||||
// Extend from start
|
// Max from start
|
||||||
rope.points.Insert(1, new Point(rope.points[1].position));
|
rope.points.Insert(1, new Point(rope.points[1].position));
|
||||||
rope.sticks.Clear();
|
rope.sticks.Clear();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4469770a8125fda4ea033ad0c3ba459b
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,84 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
public class PlayerRumbling : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private float RopeRubleTolerance = 0.5f;
|
||||||
|
|
||||||
|
private PlayerInput pInput;
|
||||||
|
private Gamepad pad;
|
||||||
|
|
||||||
|
// Rope
|
||||||
|
[SerializeField] private RopeSimulator rope;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
Invoke("LateStart", 0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LateStart()
|
||||||
|
{
|
||||||
|
pInput = GetComponent<PlayerInput>();
|
||||||
|
pad = Gamepad.all.ElementAtOrDefault(pInput.PlayerNum);
|
||||||
|
if (pad == null)
|
||||||
|
{
|
||||||
|
this.enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
hasInit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasInit = false;
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (!hasInit) return;
|
||||||
|
|
||||||
|
var rumble = new RumbleData();
|
||||||
|
|
||||||
|
float ropeClamed = Mathf.Max(0, rope.Overshoot);
|
||||||
|
if (ropeClamed > RopeRubleTolerance)
|
||||||
|
{
|
||||||
|
float mapped = ropeClamed.Remap(0.5f, 1f, 0f, 1f);
|
||||||
|
rumble.Max(mapped, mapped);
|
||||||
|
}
|
||||||
|
|
||||||
|
rumble.Commit(pad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RumbleData
|
||||||
|
{
|
||||||
|
private bool modified = false;
|
||||||
|
private float lowFreq = 0;
|
||||||
|
private float highFreq = 0;
|
||||||
|
|
||||||
|
public void Max(float low, float high)
|
||||||
|
{
|
||||||
|
modified = true;
|
||||||
|
lowFreq = Mathf.Max(lowFreq, low);
|
||||||
|
highFreq = Mathf.Max(highFreq, high);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Min(float low, float high)
|
||||||
|
{
|
||||||
|
modified = true;
|
||||||
|
lowFreq = Mathf.Min(lowFreq, low);
|
||||||
|
highFreq = Mathf.Min(highFreq, high);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(float low, float high)
|
||||||
|
{
|
||||||
|
modified = true;
|
||||||
|
lowFreq += low;
|
||||||
|
highFreq += high;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Commit(Gamepad target)
|
||||||
|
{
|
||||||
|
modified = false;
|
||||||
|
target.SetMotorSpeeds(lowFreq, highFreq);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 20d294d88e5bc8a42afb1f72751fb61f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue