saving progress

This commit is contained in:
allylikesfrogs 2023-05-04 16:09:55 -07:00
parent 5d7ef08d32
commit 5ca3e74167
7 changed files with 100 additions and 54 deletions

View File

@ -10,9 +10,11 @@ GameObject:
m_Component:
- component: {fileID: 8574288191223281125}
- component: {fileID: 8004311008239541573}
- component: {fileID: 1200350290249857739}
- component: {fileID: 3074979239951328625}
m_Layer: 0
m_Name: water
m_TagString: Untagged
m_TagString: water
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@ -85,6 +87,64 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &1200350290249857739
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1476043796409163884}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f11c011d93f67a140b0991fa94ea41c3, type: 3}
m_Name:
m_EditorClassIdentifier:
bounceForce: 2
--- !u!61 &3074979239951328625
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1476043796409163884}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 1, y: 1}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!1 &2587898580844709860
GameObject:
m_ObjectHideFlags: 0
@ -97,7 +157,6 @@ GameObject:
- component: {fileID: 3190295003044267436}
- component: {fileID: 3996260041246843173}
- component: {fileID: 2327441879067933148}
- component: {fileID: 3359596523382966936}
m_Layer: 0
m_Name: bounce
m_TagString: bouncy
@ -244,17 +303,3 @@ BoxCollider2D:
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!114 &3359596523382966936
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2587898580844709860}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f11c011d93f67a140b0991fa94ea41c3, type: 3}
m_Name:
m_EditorClassIdentifier:
RB: {fileID: 3996260041246843173}
bounceForce: 2

View File

@ -32074,7 +32074,8 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedComponents:
- {fileID: 1200350290249857739, guid: b7611ec9c156a6d40ae4a76a0def99dd, type: 3}
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []

View File

@ -1,23 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// MIGHT NOT NEED THIS LOL
public class WaterBehavior : MonoBehaviour
{
public Rigidbody2D RB;
[SerializeField] private float bounceForce = 2;
void OnCollisionEnter2D(Collision2D col)
{
Bounce();
}
private void Bounce()
{
/*RB.velocity = new Vector2(RB.velocity.x, -(RB.velocity.y));
RB.AddForce(RB.velocity * bounceForce, ForceMode2D.Impulse);*/
}
}

View File

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

View File

@ -25,6 +25,9 @@ public class PlayerBehavior : MonoBehaviour
public float dashDistance = 0.1f;
private float currentDashTime;
public bool isDash = false;
public float bonk = 2f;
private Vector2 saveVelocity;
public bool isInWater = false;
[Header("Grappling:")]
[SerializeField] public Tutorial_GrapplingGun grapplingGun;
@ -112,7 +115,6 @@ public class PlayerBehavior : MonoBehaviour
}
transform.position = transform.position + moveDirection;
currentDashTime += dashStopSpeed;
print("cdt " + currentDashTime);
}
else
{
@ -224,9 +226,28 @@ public class PlayerBehavior : MonoBehaviour
void Bounce()
{
Vector2 reflect = new Vector2(-(saveVelocity.x),-(saveVelocity.y) * bonk);
print("x vel: " + saveVelocity.x);
print("y vel: " + saveVelocity.y);
_rb.AddForce(reflect, ForceMode2D.Impulse);
print("boing");
}
void Water()
{
if(_rb.velocity.y < 0.2f)
{
saveVelocity = Vector2.zero;
isInWater = true;
print("buoy");
}
else
{
saveVelocity = _rb.velocity;
//_rb.AddForce(saveVelocity, ForceMode2D.Force);
}
}
void OnTriggerEnter2D(Collider2D col)
{
if (col.tag == "grappleSurface")
@ -248,9 +269,9 @@ public class PlayerBehavior : MonoBehaviour
this.playerController.in_range = true;
this.playerController.enemy = col.transform.parent.gameObject;
}
else if (col.tag == "bouncy")
else if (col.tag == "water")
{
Bounce();
Water();
}
}
@ -265,6 +286,10 @@ public class PlayerBehavior : MonoBehaviour
this.playerController.in_range = false;
this.playerController.enemy = null;
}
else if (col.tag == "water")
{
isInWater = false;
}
}
void OnCollisionEnter2D(Collision2D collision)
@ -296,6 +321,10 @@ public class PlayerBehavior : MonoBehaviour
{
StateController.Instance.RespawnPlayer();
}
else if (collision.gameObject.tag == "bouncy")
{
Bounce();
}
}
IEnumerator DestroyPlayer()

View File

@ -310,6 +310,10 @@ public class PlayerMovement : MonoBehaviour
//Caps maximum fall speed, so when falling over large distances we don't accelerate to insanely high speeds
RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFallSpeed));
}
else if (playerBehavior.isInWater)
{
SetGravityScale(0);
}
else
{
//Default gravity if standing on a platform or moving upwards

View File

@ -22,6 +22,7 @@ TagManager:
- ProjectileEnemy
- GameUICanvas
- bouncy
- water
layers:
- Default
- TransparentFX