This commit is contained in:
BOT Alex 2024-02-03 17:33:51 +01:00
commit a43b040676
16 changed files with 428 additions and 251 deletions

View File

@ -47,7 +47,7 @@ AnimatorStateTransition:
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
@ -85,7 +85,7 @@ AnimatorStateMachine:
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 280, y: 90, z: 0}
m_AnyStatePosition: {x: 300, y: 70, z: 0}
m_EntryPosition: {x: 20, y: 160, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
@ -111,7 +111,7 @@ AnimatorStateTransition:
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
@ -136,7 +136,7 @@ AnimatorStateTransition:
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
@ -265,7 +265,7 @@ AnimatorStateTransition:
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
@ -290,7 +290,7 @@ AnimatorStateTransition:
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1

View File

@ -129,31 +129,31 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Run
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Mop
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Swing
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: RunMop
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer

View File

@ -188,6 +188,7 @@ GameObject:
- component: {fileID: 5467488512035376674}
- component: {fileID: 3878447480781341932}
- component: {fileID: 1749848915408613053}
- component: {fileID: 1949941092232239315}
m_Layer: 7
m_Name: Player1
m_TagString: Player
@ -224,7 +225,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 3dbdb849a2f5df14d9e109a7776c5ac0, type: 3}
m_Name:
m_EditorClassIdentifier:
player: 0
moveSpeed: 70
stepCooldown: 0.2
stepVibrationTime: 0.05
@ -295,6 +295,7 @@ MonoBehaviour:
anchor: {fileID: 1170758327458850867}
body: {fileID: 1508323898269695585}
locked: 0
playerInput: {fileID: 1949941092232239315}
--- !u!114 &3878447480781341932
MonoBehaviour:
m_ObjectHideFlags: 0
@ -319,7 +320,25 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b69b92d72c7244443854899c4b700d9c, type: 3}
m_Name:
m_EditorClassIdentifier:
playerInput: {fileID: 1949941092232239315}
otherPlayerAttack: {fileID: 0}
playerMovement: {fileID: 651446758998956252}
joint: {fileID: 5467488512035376674}
initialDrag: 0
--- !u!114 &1949941092232239315
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3120938410244321186}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: de340bb967770a7499e140a52a287f84, type: 3}
m_Name:
m_EditorClassIdentifier:
playerNumber: 0
movement: {x: 0, y: 0}
whipAttack: 0
ropeLengthShrinken: 0
ropeLengthExtend: 0

View File

@ -187,6 +187,7 @@ GameObject:
- component: {fileID: 1508323898269695585}
- component: {fileID: 5467488512035376674}
- component: {fileID: 3878447480781341932}
- component: {fileID: 7071433868121438663}
m_Layer: 7
m_Name: Player2
m_TagString: Player
@ -223,10 +224,14 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 3dbdb849a2f5df14d9e109a7776c5ac0, type: 3}
m_Name:
m_EditorClassIdentifier:
moveSpeed: 5
player: 1
moveSpeed: 65
stepCooldown: 0.2
stepVibrationTime: 0.05
rumble: {fileID: 0}
whipAttack: {fileID: 7071433868121438663}
whipMoveSpeed: 25
maxWhipMoveSpeed: 30
--- !u!114 &3086165646112058191
MonoBehaviour:
m_ObjectHideFlags: 0
@ -261,7 +266,7 @@ Rigidbody2D:
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_LinearDrag: 10
m_AngularDrag: 0.05
m_GravityScale: 0
m_Material: {fileID: 6200000, guid: 7c680ffb793a1f2478e6682c957e4868, type: 2}
@ -302,3 +307,19 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9c2ddf673a65d3d49bc9470e1a4572e4, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &7071433868121438663
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3120938410244321186}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b69b92d72c7244443854899c4b700d9c, type: 3}
m_Name:
m_EditorClassIdentifier:
otherPlayerAttack: {fileID: 0}
playerMovement: {fileID: 651446758998956252}
joint: {fileID: 5467488512035376674}
initialDrag: 0

View File

@ -868,6 +868,7 @@ MonoBehaviour:
anchor: {fileID: 625885769}
body: {fileID: 0}
locked: 0
playerInput: {fileID: 0}
--- !u!1 &646449334
GameObject:
m_ObjectHideFlags: 0
@ -2080,6 +2081,9 @@ MonoBehaviour:
m_Bits: 1
pullForce: 65
xyGravityDampScalor: 1
ropeExtendSpeed: 15
ropeShrinkSpeed: 15
ropeMaxLength: 0
lineRenderer: {fileID: 1647138191}
--- !u!4 &1647138193
Transform:
@ -2334,6 +2338,10 @@ PrefabInstance:
propertyPath: otherPlayerAttack
value:
objectReference: {fileID: 465041015}
- target: {fileID: 1949941092232239315, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
propertyPath: playerNumber
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
propertyPath: m_Name
value: Player 2

View File

@ -362,105 +362,6 @@ MonoBehaviour:
m_Area: 1
m_IgnoreFromBuild: 0
m_AffectedAgents: ffffffff
--- !u!1 &107616016
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 107616020}
- component: {fileID: 107616021}
- component: {fileID: 107616018}
- component: {fileID: 107616017}
m_Layer: 0
m_Name: Player 2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!50 &107616017
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 107616016}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 0
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 1
m_Constraints: 0
--- !u!114 &107616018
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 107616016}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3}
m_Name:
m_EditorClassIdentifier:
maxHealth: 100
OnHealthZero:
m_PersistentCalls:
m_Calls: []
OnHealthChange:
m_PersistentCalls:
m_Calls: []
minThreshold: 1
squezeDamageScalor: 1
--- !u!4 &107616020
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 107616016}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3.51, y: 1.14, z: -0.09089095}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1682789264}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &107616021
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 107616016}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e891644cda7544948af35b0d2f2c3be2, type: 3}
m_Name:
m_EditorClassIdentifier:
moveSpeed: 5
stepCooldown: 0.2
stepVibrationTime: 0.05
rumble: {fileID: 1744797149}
--- !u!1 &220016280
GameObject:
m_ObjectHideFlags: 0
@ -480,7 +381,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!114 &220016281
MonoBehaviour:
m_ObjectHideFlags: 0
@ -493,7 +394,13 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6a3ffc4a3af9e0243ac9ee0c995bb82f, type: 3}
m_Name:
m_EditorClassIdentifier:
target: {fileID: 2026065165}
targets:
- {fileID: 2026065165}
- {fileID: 780144035302788033}
ropeDistCheck: 1
ropeCheckMask:
serializedVersion: 2
m_Bits: 64
--- !u!195 &220016282
NavMeshAgent:
m_ObjectHideFlags: 0
@ -1781,90 +1688,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1666646756}
m_CullTransparentMesh: 1
--- !u!1 &1682789263
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1682789264}
- component: {fileID: 1682789265}
m_Layer: 0
m_Name: Renderer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1682789264
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1682789263}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.7082175, y: 0.44170734, z: 0.09089095}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 107616020}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &1682789265
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1682789263}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: -2413806693520163455, guid: a86470a33a6bf42c4b3595704624658b, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &1744797149
GameObject:
m_ObjectHideFlags: 0
@ -1914,6 +1737,94 @@ Transform:
m_CorrespondingSourceObject: {fileID: 320690117028550720, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
m_PrefabInstance: {fileID: 6593404997020511677}
m_PrefabAsset: {fileID: 0}
--- !u!114 &2026065166 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 1749848915408613053, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
m_PrefabInstance: {fileID: 6593404997020511677}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b69b92d72c7244443854899c4b700d9c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &780144035302788026
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
propertyPath: m_LocalPosition.x
value: -15.740316
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
propertyPath: m_LocalPosition.y
value: -3.0342276
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
propertyPath: m_LocalPosition.z
value: -0.09089095
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
propertyPath: m_Name
value: Player2
objectReference: {fileID: 0}
- target: {fileID: 7071433868121438663, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
propertyPath: otherPlayerAttack
value:
objectReference: {fileID: 2026065166}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
--- !u!114 &780144035302788027 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 7071433868121438663, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
m_PrefabInstance: {fileID: 780144035302788026}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b69b92d72c7244443854899c4b700d9c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &780144035302788033 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
m_PrefabInstance: {fileID: 780144035302788026}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &6593404997020511677
PrefabInstance:
m_ObjectHideFlags: 0
@ -1966,14 +1877,14 @@ PrefabInstance:
propertyPath: rumble
value:
objectReference: {fileID: 1744797149}
- target: {fileID: 1749848915408613053, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
propertyPath: otherPlayerAttack
value:
objectReference: {fileID: 780144035302788027}
- target: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
propertyPath: m_Name
value: Player
objectReference: {fileID: 0}
- target: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
@ -1985,7 +1896,6 @@ SceneRoots:
m_Roots:
- {fileID: 63829549}
- {fileID: 6593404997020511677}
- {fileID: 107616020}
- {fileID: 646449338}
- {fileID: 1420709241}
- {fileID: 1602984459}
@ -1993,3 +1903,4 @@ SceneRoots:
- {fileID: 1365819705}
- {fileID: 220016284}
- {fileID: 1180110923}
- {fileID: 780144035302788026}

View File

@ -5,30 +5,19 @@ using UnityEngine.InputSystem;
public class RumbleManager : MonoBehaviour
{
private Gamepad pad1;
private Gamepad pad2;
private Gamepad pad;
private Coroutine stopRumbleAfterTimeCorutine;
public void RumblePulse1(float lowFrequency, float highFrequency, float duration)
public void RumblePulse(float lowFrequency, float highFrequency, float duration, int player)
{
pad1 = Gamepad.all[0];
if (pad1 != null)
pad = Gamepad.all[player];
if (pad != null)
{
pad1.SetMotorSpeeds(lowFrequency, highFrequency);
pad.SetMotorSpeeds(lowFrequency, highFrequency);
stopRumbleAfterTimeCorutine = StartCoroutine(stopRumble(duration, pad1));
}
}
public void RumblePulse2(float lowFrequency, float highFrequency, float duration)
{
pad2 = Gamepad.all[1];
if (pad2 != null)
{
pad2.SetMotorSpeeds(lowFrequency, highFrequency);
stopRumbleAfterTimeCorutine = StartCoroutine(stopRumble(duration, pad2));
stopRumbleAfterTimeCorutine = StartCoroutine(stopRumble(duration, pad));
}
}

View File

@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerInput : MonoBehaviour
{
[SerializeField] private int playerNumber;
public Vector2 movement;
public Vector2 look;
public Gamepad controller { get; private set; }
public bool whipAttack;
public event Action<int> ropeLengthShrinken;
public event Action<int> ropeLengthExtend;
public int PlayerNum => playerNumber;
private void Awake()
{
controller = Gamepad.all.ElementAtOrDefault(playerNumber);
if (controller == null)
{
Debug.LogWarning($"No Gamepad found for player {playerNumber + 1}");
}
}
private void Update()
{
if (controller != null)
{
movement.x = controller.leftStick.x.ReadValue();
movement.y = controller.leftStick.y.ReadValue();
look.x = controller.rightStick.x.ReadValue();
look.y = controller.rightStick.y.ReadValue();
whipAttack = controller.buttonWest.IsPressed();
if (controller.rightShoulder.IsPressed()) ropeLengthShrinken?.Invoke(playerNumber);
if (controller.leftShoulder.IsPressed()) ropeLengthExtend?.Invoke(playerNumber);
}
else
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
whipAttack = Input.GetKey(KeyCode.B);
}
//Debug.Log($"player {playerNumber}: move {movement}");
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: de340bb967770a7499e140a52a287f84
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -2,14 +2,13 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using System.Linq;
[RequireComponent(typeof(PlayerInput))]
public class PlayerMovement : MonoBehaviour
{
public int player = 0;
public float moveSpeed = 5f;
private Rigidbody2D rb;
private Vector2 movement;
private Gamepad playerController;
private bool right = false;
@ -29,64 +28,58 @@ public class PlayerMovement : MonoBehaviour
[SerializeField]
private float maxWhipMoveSpeed = 30f;
private PlayerInput playerInput;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
playerController = Gamepad.all[player];
playerInput = GetComponent<PlayerInput>();
StartCoroutine(ToggleWithDelay());
}
void Update()
{
if (playerController != null)
if (playerInput.movement != Vector2.zero)
{
movement.x = playerController.leftStick.x.ReadValue();
movement.y = playerController.leftStick.y.ReadValue();
}
else
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical"); ;
}
if (movement.x != 0 || movement.y != 0)
RumbleWalk();
GetComponent<PlayerAnimationHandler>().Run();
}
}
private void FixedUpdate()
{
if (whipAttack.IsBeingWhipped)
{
float sign = movement.x > 0 ? 1 : -1;
if (movement.x == 0)
sign = 0;
//float sign = Vector2.Dot((whipAttack.joint.position - whipAttack.otherPlayerAttack.joint.position).normalized, movement.normalized);
Vector2 ropeDir = whipAttack.otherPlayerAttack.joint.position - whipAttack.joint.position;
Vector2 tangent = new Vector2(-ropeDir.y, ropeDir.x).normalized;
rb.AddForce(tangent * whipMoveSpeed * sign);
rb.AddForce(Vector2.Dot(playerInput.movement, tangent) * tangent * whipMoveSpeed);
rb.velocity = Vector2.ClampMagnitude(rb.velocity, maxWhipMoveSpeed);
}
else if (whipAttack.IsWhippingOtherPlayer)
{
movement = Vector2.zero;
playerInput.movement = Vector2.zero;
}
else
{
rb.AddForce(movement * moveSpeed);
rb.AddForce(playerInput.movement * moveSpeed);
}
}
private void RumbleWalk()
{
if (vibrate && playerController != null)
if (vibrate && playerInput.controller != null)
{
if (right)
{
rumble.GetComponent<RumbleManager>().RumblePulse1(0.0f, 0.004f, stepVibrationTime);
rumble.GetComponent<RumbleManager>().RumblePulse(0.0f, 0.004f, stepVibrationTime, playerInput.PlayerNum);
right = false;
}
else if (!right)
{
rumble.GetComponent<RumbleManager>().RumblePulse1(0.004f, 0.0f, stepVibrationTime);
rumble.GetComponent<RumbleManager>().RumblePulse(0.004f, 0.0f, stepVibrationTime, playerInput.PlayerNum);
right = true;
}
vibrate = false;

View File

@ -2,13 +2,15 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using System.Linq;
public class RopeWhipAttack : MonoBehaviour
{
[SerializeField] PlayerInput playerInput;
public RopeWhipAttack otherPlayerAttack;
public PlayerMovement playerMovement;
public RopeJoint joint;
public bool IsWhippingOtherPlayer => joint.locked;
public bool IsBeingWhipped => otherPlayerAttack.joint.locked;
@ -24,7 +26,7 @@ public class RopeWhipAttack : MonoBehaviour
// Other player is whip attacking
if (otherPlayerAttack.joint.locked) return;
if (Gamepad.all[playerMovement.player].rightShoulder.IsPressed())
if (playerInput.whipAttack)
{
joint.locked = true;
otherPlayerAttack.joint.body.drag = 0f;

View File

@ -7,6 +7,13 @@ public class RopeBuilder
List<Point> points = new();
List<Stick> sticks = new();
public RopeBuilder() { }
public RopeBuilder(List<Point> points, List<Stick> sticks)
{
this.points = points;
this.sticks = sticks;
}
public RopeBuilder AddPoint(Point point)
{
points.Add(point);

View File

@ -7,6 +7,7 @@ public class RopeJoint : MonoBehaviour
public Transform anchor;
public Rigidbody2D body;
public bool locked = false;
public PlayerInput playerInput;
public Vector3 position => anchor.position;
}

View File

@ -24,7 +24,7 @@ public class RopeSimulator : MonoBehaviour
RopeJoint start, end;
[SerializeField]
int subDivision = 50;
float subDivision = 50f;
[SerializeField]
float collisionCheckDist = 0.5f;
@ -50,6 +50,12 @@ public class RopeSimulator : MonoBehaviour
[SerializeField]
float xyGravityDampScalor = 1f;
[SerializeField, Range(0f, 20f)]
public float ropeExtendSpeed, ropeShrinkSpeed;
[SerializeField]
public float ropeMaxLength, ropeMinLength;
[Header("Rendering")]
[SerializeField] LineRenderer lineRenderer;
@ -72,11 +78,86 @@ public class RopeSimulator : MonoBehaviour
// .ConnectPoints(2, 3)
// .ConnectPoints(3, 4)
// .Build();
Rebuild();
start.playerInput.ropeLengthShrinken += ShrinkenRope;
end.playerInput.ropeLengthShrinken += ShrinkenRope;
start.playerInput.ropeLengthExtend += ExtendRope;
end.playerInput.ropeLengthExtend += ExtendRope;
}
void ShrinkenRope(int playerNumber)
{
int prevSubDivision = (int) subDivision;
subDivision -= ropeShrinkSpeed * Time.deltaTime;
if (subDivision < ropeMinLength)
subDivision = ropeMinLength;
if (prevSubDivision - (int)subDivision > 0) return;
// Shrink from start
if (playerNumber == start.playerInput.PlayerNum)
{
rope.sticks.Clear();
rope.points.RemoveAt(0);
var builder = new RopeBuilder(rope.points, new List<Stick>());
// Re-gen sticks
for (int i = 0; i < (int) subDivision; i++)
{
builder.ConnectPoints(i, i + 1);
}
rope = builder.Build();
}
// Shrink from end
else if (playerNumber == end.playerInput.PlayerNum)
{
rope.points.RemoveAt(rope.points.Count - 2);
rope.sticks.Clear();
var builder = new RopeBuilder(rope.points, new List<Stick>());
// Re-gen sticks
for (int i = 0; i < (int)subDivision; i++)
{
builder.ConnectPoints(i, i + 1);
}
rope = builder.Build();
}
CreateOrderArray();
}
void ExtendRope(int playerNumber)
{
subDivision += ropeExtendSpeed * Time.deltaTime;
if (subDivision > ropeMaxLength)
subDivision = ropeMaxLength;
Rebuild();
}
private void OnDestroy()
{
start.playerInput.ropeLengthShrinken -= ShrinkenRope;
end.playerInput.ropeLengthShrinken -= ShrinkenRope;
start.playerInput.ropeLengthExtend -= ExtendRope;
end.playerInput.ropeLengthExtend -= ExtendRope;
}
private void Rebuild()
{
Debug.Log("rebuild");
ropeCollidersParent.DestroyChildren();
RopeBuilder builder = new RopeBuilder();
builder.AddPoint(new Point(start.position, locked: true));
for (int i = 1; i < subDivision; i++)
for (int i = 1; i < (int) subDivision; i++)
{
Vector3 pointPos = Vector3.Lerp(start.position, end.position, (float)i / (float)subDivision);
Vector3 pointPos = Vector3.Lerp(start.position, end.position, (float)i / (float)(int)subDivision);
//Debug.Log($"pos: {pointPos}, t={i / subDivision}");
Debug.DrawRay(pointPos, (end.position - start.position).normalized);
builder.AddPoint(new Point(pointPos));
@ -84,7 +165,7 @@ public class RopeSimulator : MonoBehaviour
builder.AddPoint(new Point(end.position, locked: true));
for (int i = 0; i < subDivision; i++)
for (int i = 0; i < (int) subDivision; i++)
{
builder.ConnectPointsWithDesiredLength(i, i + 1, desiredLength: distBetweenRopePoints);
}
@ -108,6 +189,7 @@ public class RopeSimulator : MonoBehaviour
private void Update()
{
ShrinkenRope(1);
colliderToSquezeForce.Clear();
rope.points.First().position = start.position;

View File

@ -0,0 +1,67 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Upgrade
{
public string name = "MT";
public int amount = 0;
public Upgrade(string n)
{
name = n;
}
}
public class Upgrades
{
public Upgrade mopUpgrade = new Upgrade("Mop Radius");
public Upgrade speedUpgrade = new Upgrade("Move speed");
public Upgrade ropeUpgrade = new Upgrade("Longer Rope");
public Upgrade healthUpgrade = new Upgrade("More health");
public Upgrade damageUpgrade = new Upgrade("More rope damage");
public Upgrade bloodUpgrade = new Upgrade("MORE BLOOD!");
public Upgrade reelUpgrade = new Upgrade("Faster rope reel speed");
}
public class Upgrader : MonoBehaviour
{
public GameObject player1;
public GameObject player2;
public BloodComputeShader bloodManager;
public RopeSimulator rope;
public Upgrades upgrades { get; private set; }
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
/// Increases mop radius by 10%
public void UpgradeMopSize()
{
bloodManager.CleanRadius *= 1.1f;
}
/// Increases move speed by 10%
public void UpgradeSpeed()
{
player1.GetComponent<PlayerMovement>().moveSpeed *= 1.1f;
player2.GetComponent<PlayerMovement>().moveSpeed *= 1.1f;
}
public void RopeUpgrade() {
// todo: public methods
}
// public void
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 723cbd9d3229f69d79e38cebc5eabf45
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: