Added spring
This commit is contained in:
@@ -12,14 +12,14 @@ namespace Fruitomation.Game
|
||||
|
||||
private void Start()
|
||||
{
|
||||
TriggerDetector.SetAction((other) =>
|
||||
TriggerDetector.SetAction(other =>
|
||||
{
|
||||
if (other.transform.parent.TryGetComponent(out Rigidbody2D body))
|
||||
{
|
||||
Vector3 force = new(-transform.localScale.x, 0f, 0f);
|
||||
body?.AddForce(force * Mathf.PI, ForceMode2D.Impulse);
|
||||
}
|
||||
});
|
||||
}, TriggerType.Stay);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
||||
7
Assets/Scripts/Game/Buildings/SlicerBuilding.cs
Normal file
7
Assets/Scripts/Game/Buildings/SlicerBuilding.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Fruitomation.Game
|
||||
{
|
||||
public class SlicerBuilding : Building
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Game/Buildings/SlicerBuilding.cs.meta
Normal file
3
Assets/Scripts/Game/Buildings/SlicerBuilding.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2a0d2e92ab8436a8854e59ee269188a
|
||||
timeCreated: 1776341863
|
||||
35
Assets/Scripts/Game/Buildings/SpringBuilding.cs
Normal file
35
Assets/Scripts/Game/Buildings/SpringBuilding.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Fruitomation.Game
|
||||
{
|
||||
public class SpringBuilding : Building
|
||||
{
|
||||
[SerializeField] private TriggerDetector Trigger;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Trigger.SetAction(other =>
|
||||
{
|
||||
if (other.transform.parent.TryGetComponent(out Rigidbody2D body))
|
||||
{
|
||||
Vector2 v0 = body.linearVelocity;
|
||||
float magnitude = Math.Max(v0.magnitude * 0.8f, 20f);
|
||||
|
||||
Vector2 v1 = new Vector2(v0.x * 1.2f, Math.Abs(v0.y)).normalized * magnitude;
|
||||
body.linearVelocity = v1;
|
||||
}
|
||||
}, TriggerType.Enter);
|
||||
|
||||
Trigger.SetAction(other =>
|
||||
{
|
||||
if (other.transform.parent.TryGetComponent(out Rigidbody2D body))
|
||||
{
|
||||
Vector2 v0 = body.linearVelocity;
|
||||
v0.y = Math.Max(1f, v0.y);
|
||||
body.linearVelocity = v0;
|
||||
}
|
||||
}, TriggerType.Stay);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Game/Buildings/SpringBuilding.cs.meta
Normal file
2
Assets/Scripts/Game/Buildings/SpringBuilding.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d85c1768ca4c6594dbdb161463af59dc
|
||||
Reference in New Issue
Block a user